Split UI thread shutdown into before and after stages (see #3609)

Existing UI thread shutdown tasks need to be executed before the UI
thread RunLoop is terminated. Those tasks have now been moved to
CefMainRunner::StartShutdownOnUIThread and FinishShutdownOnUIThread is
now called after the RunLoop is terminated.

This fixes a shutdown crash in ChromeProcessSingleton::DeleteInstance.
DeleteInstance needs to be called on the UI thread near the end of the
shutdown process (after ChromeProcessSingleton::Cleanup is called via
PostMainMessageLoopRun).
This commit is contained in:
Marshall Greenblatt
2023-12-11 15:36:56 -05:00
parent 80c65f25a3
commit 262a93b2f7
7 changed files with 77 additions and 60 deletions

View File

@ -71,13 +71,13 @@ class CefMainRunner : public CefMainRunnerHandler {
// Called on the UI thread after the context is initialized.
void OnContextInitialized(base::OnceClosure context_initialized);
// Performs shutdown actions that need to occur on the UI thread before any
// threads are destroyed.
void FinishShutdownOnUIThread(base::OnceClosure shutdown_on_ui_thread,
base::WaitableEvent* uithread_shutdown_event);
// Performs shutdown actions that need to occur on the UI thread before the
// thread RunLoop has stopped.
void StartShutdownOnUIThread(base::OnceClosure shutdown_on_ui_thread);
// Destroys the runtime and related objects.
void FinalizeShutdown(base::OnceClosure finalize_shutdown);
// Performs shutdown actions that need to occur on the UI thread after the
// thread RunLoop has stopped and before running exit callbacks.
void FinishShutdownOnUIThread();
const bool multi_threaded_message_loop_;
const bool external_message_pump_;