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

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: Address comments 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
« no previous file with comments | « chrome/browser/lifetime/application_lifetime.h ('k') | chrome/browser/lifetime/keep_alive_registry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c734162d2c165249ccac25dfe06a3408ecb0e49a 100644
--- a/chrome/browser/lifetime/application_lifetime.cc
+++ b/chrome/browser/lifetime/application_lifetime.cc
@@ -70,8 +70,6 @@ bool AreAllBrowsersCloseable() {
}
return true;
}
-
-bool g_disable_shutdown_for_testing = false;
#endif // !defined(OS_ANDROID)
#if defined(OS_CHROMEOS)
@@ -108,6 +106,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 +131,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 +281,11 @@ 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 (browser_shutdown::IsTryingToQuit())
+ return;
+
+ ShutdownIfNoBrowsers();
}
#endif // !defined(OS_ANDROID)
@@ -343,13 +347,6 @@ void OnAppExiting() {
notified = true;
HandleAppExitingForPlatform();
}
-
-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();
-}
#endif // !defined(OS_ANDROID)
} // namespace chrome
« no previous file with comments | « chrome/browser/lifetime/application_lifetime.h ('k') | chrome/browser/lifetime/keep_alive_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698