Update shutdown documentation for DestroyProfileOnBrowserClose
Bug: 1053445 Change-Id: If30916182adb2b9933fbd5a9bf64a8d3b6ef7ed7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3553316 Reviewed-by: David Roger <droger@chromium.org> Reviewed-by: Francois Pierre Doray <fdoray@chromium.org> Commit-Queue: Nicolas Ouellet-Payeur <nicolaso@chromium.org> Cr-Commit-Position: refs/heads/main@{#986608}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
02f5f24a04
commit
a918fb9d03
@ -9,6 +9,52 @@ any shutdown step.
|
||||
|
||||
See below for how the process differs on ChromeOS.
|
||||
|
||||
## Step 0: Profile destruction
|
||||
|
||||
Since M98, Chrome can destroy `Profile` objects separately from shutdown; on
|
||||
Windows and Linux, this happens in multi-profile scenarios. On macOS, it can
|
||||
also happen in single-profile scenarios, because Chrome lifetime is separate
|
||||
from browser windows.
|
||||
|
||||
Typically, this logic triggers when all browser windows are closed, but other
|
||||
things can [keep a `Profile`
|
||||
alive](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/profiles/keep_alive/profile_keep_alive_types.h).
|
||||
|
||||
`~ScopedProfileKeepAlive` posts a task to run `RemoveKeepAliveOnUIThread`. This
|
||||
decrements the refcount in `ProfileManager`, and if it hits zero then
|
||||
`DestroyProfileWhenAppropriate` is called.
|
||||
|
||||
```
|
||||
ProfileDestroyer::DestroyProfileWhenAppropriate
|
||||
...
|
||||
ProfileManager::RemoveProfile
|
||||
ProfileManager::RemoveKeepAlive
|
||||
ScopedProfileKeepAlive::RemoveKeepAliveOnUIThread
|
||||
```
|
||||
|
||||
Unlike regular profiles, OTR profiles are **not** refcounted. Instead,
|
||||
`~Browser` checks the profile's browser count after removing itself. If it's
|
||||
zero, it calls `DestroyProfileWhenAppropriate` directly.
|
||||
|
||||
```
|
||||
ProfileDestroyer::DestroyProfileWhenAppropriate
|
||||
Browser::~Browser
|
||||
```
|
||||
|
||||
You can use `ProfileManager` logging to inspect a profile's keepalive state:
|
||||
|
||||
```
|
||||
$ ./out/Default/chrome --enable-logging=stderr --v=0 --vmodule=profile_manager=1
|
||||
[71002:259:0328/133310.430142:VERBOSE1:profile_manager.cc(1489)] AddKeepAlive(Default, kBrowserWindow). keep_alives=[kWaitingForFirstBrowserWindow (1), kBrowserWindow (1)]
|
||||
[71002:259:0328/133310.430177:VERBOSE1:profile_manager.cc(1543)] ClearFirstBrowserWindowKeepAlive(Default). keep_alives=[kBrowserWindow (1)]
|
||||
[71002:259:0328/133314.468135:VERBOSE1:profile_manager.cc(1489)] AddKeepAlive(Default, kExtensionUpdater). keep_alives=[kBrowserWindow (1), kExtensionUpdater (1)]
|
||||
[71002:259:0328/133314.469444:VERBOSE1:profile_manager.cc(1522)] RemoveKeepAlive(Default, kExtensionUpdater). keep_alives=[kBrowserWindow (1)]
|
||||
[71002:259:0328/133315.396614:VERBOSE1:profile_manager.cc(1489)] AddKeepAlive(Default, kOffTheRecordProfile). keep_alives=[kBrowserWindow (1), kOffTheRecordProfile (1)]
|
||||
[71002:259:0328/133417.078148:VERBOSE1:profile_manager.cc(1522)] RemoveKeepAlive(Default, kBrowserWindow). keep_alives=[kOffTheRecordProfile (1)]
|
||||
[71002:259:0328/133442.705250:VERBOSE1:profile_manager.cc(1522)] RemoveKeepAlive(Default, kOffTheRecordProfile). keep_alives=[]
|
||||
[71002:259:0328/133442.705296:VERBOSE1:profile_manager.cc(1567)] Deleting profile Default
|
||||
```
|
||||
|
||||
## Step 1: Exiting the main loop
|
||||
|
||||
Shutdown starts when nothing keeps Chrome alive. Typically, this happens when
|
||||
|
Reference in New Issue
Block a user