[Profiles] Add DestroyProfileOnBrowserClose flag

Currently, (non-OffTheRecord) Profile objects are only destroyed when
the entire browser exits.

This patch adds an DestroyProfileOnBrowserClose flag, which causes the
Profile object to be destroyed when the last window in that profile
closes. It works, but it can cause crashes or instability in some cases,
so it's off-by-default for now.

This patch does not work well with ephemeral/guest profiles, or
background mode.

Bug: 88586, 566835
Change-Id: I73e78383cd57802deaee9ec23f6fa219881b1360
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2451696
Reviewed-by: Mohamed Amir Yosef <[email protected]>
Reviewed-by: Varun Khaneja <[email protected]>
Reviewed-by: Mihai Sardarescu <[email protected]>
Reviewed-by: Marc Treib <[email protected]>
Reviewed-by: Ramin Halavati <[email protected]>
Commit-Queue: Nicolas Ouellet-Payeur <[email protected]>
Cr-Commit-Position: refs/heads/master@{#817025}
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index 624c7179..334e45c 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -1417,6 +1417,12 @@
     "Enables several profile-related features including a new signin flow, "
     "profile promo bubbles and a color picker in settings";
 
+const char kDestroyProfileOnBrowserCloseName[] =
+    "Destroy Profile on browser close";
+const char kDestroyProfileOnBrowserCloseDescription[] =
+    "Release memory and other resources when a Profile's last browser window "
+    "is closed, rather than when Chrome closes completely.";
+
 const char kNewUsbBackendName[] = "Enable new USB backend";
 const char kNewUsbBackendDescription[] =
     "Enables the new experimental USB backends for macOS and Windows";