Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2635)

Unified Diff: chrome/browser/lifetime/application_lifetime.cc

Issue 1803143002: Replace BrowserProces::AddRefModule/RemoveModule by ScopedKeepAlive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/lifetime/application_lifetime.cc
diff --git a/chrome/browser/lifetime/application_lifetime.cc b/chrome/browser/lifetime/application_lifetime.cc
index fd55baa56573bffe932a064a291368d4aa6d8f2d..56c5f9e774a2a06a0d2a393d4e87e44b20cfd4e4 100644
--- a/chrome/browser/lifetime/application_lifetime.cc
+++ b/chrome/browser/lifetime/application_lifetime.cc
@@ -108,6 +108,24 @@ void CloseAllBrowsersAndQuit() {
CloseAllBrowsers();
}
+void ShutdownIfNoBrowsers() {
+ if (chrome::GetTotalBrowserCount() > 0)
+ return;
+
+ // Tell everyone that we are shutting down.
+ browser_shutdown::SetTryingToQuit(true);
+
+#if defined(ENABLE_SESSION_SERVICE)
+ // If ShuttingDownWithoutClosingBrowsers() returns true, the session
+ // services may not get a chance to shut down normally, so explicitly shut
+ // them down here to ensure they have a chance to persist their data.
+ ProfileManager::ShutdownSessionServices();
+#endif
+
+ chrome::NotifyAndTerminate(true);
+ chrome::OnAppExiting();
+}
+
void CloseAllBrowsers() {
// If there are no browsers and closing the last browser would quit the
// application, send the APP_TERMINATING action here. Otherwise, it will be
@@ -115,18 +133,7 @@ void CloseAllBrowsers() {
if (chrome::GetTotalBrowserCount() == 0 &&
(browser_shutdown::IsTryingToQuit() ||
!KeepAliveRegistry::GetInstance()->IsKeepingAlive())) {
- // Tell everyone that we are shutting down.
- browser_shutdown::SetTryingToQuit(true);
-
-#if defined(ENABLE_SESSION_SERVICE)
- // If ShuttingDownWithoutClosingBrowsers() returns true, the session
- // services may not get a chance to shut down normally, so explicitly shut
- // them down here to ensure they have a chance to persist their data.
- ProfileManager::ShutdownSessionServices();
-#endif
-
- chrome::NotifyAndTerminate(true);
- chrome::OnAppExiting();
+ ShutdownIfNoBrowsers();
return;
}
@@ -276,12 +283,15 @@ void SessionEnding() {
base::Process::Current().Terminate(0, false);
}
-void CloseAllBrowsersIfNeeded() {
- if (chrome::GetTotalBrowserCount() == 0 &&
- !browser_shutdown::IsTryingToQuit() && base::MessageLoop::current() &&
- !g_disable_shutdown_for_testing) {
- CloseAllBrowsers();
- }
+void ShutdownIfNeeded() {
+ if (g_disable_shutdown_for_testing)
+ return;
+
+ // We are already in the process of shutting down, no need to renotify.
+ if (browser_shutdown::IsTryingToQuit())
+ return;
+
+ ShutdownIfNoBrowsers();
dgn 2016/03/16 15:10:50 Moved the method out of CloseAllBrowsers to make w
}
#endif // !defined(OS_ANDROID)
@@ -346,9 +356,9 @@ void OnAppExiting() {
void DisableShutdownForTesting(bool disable_shutdown_for_testing) {
g_disable_shutdown_for_testing = disable_shutdown_for_testing;
- if (!g_disable_shutdown_for_testing &&
- !KeepAliveRegistry::GetInstance()->IsKeepingAlive())
- CloseAllBrowsersIfNeeded();
+
+ if (!KeepAliveRegistry::GetInstance()->IsKeepingAlive())
+ ShutdownIfNeeded();
}
#endif // !defined(OS_ANDROID)

Powered by Google App Engine
This is Rietveld 408576698