Index: chrome/browser/lifetime/application_lifetime.cc |
diff --git a/chrome/browser/lifetime/application_lifetime.cc b/chrome/browser/lifetime/application_lifetime.cc |
index 06a90086966872e50350023e9c41475b19ea1ef8..5cb95639929f0f8b6565fafbf89deff07e58bab8 100644 |
--- a/chrome/browser/lifetime/application_lifetime.cc |
+++ b/chrome/browser/lifetime/application_lifetime.cc |
@@ -8,7 +8,6 @@ |
#include "base/command_line.h" |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
-#include "base/message_loop/message_loop.h" |
#include "base/prefs/pref_service.h" |
#include "base/process/process.h" |
#include "base/process/process_handle.h" |
@@ -20,6 +19,7 @@ |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/download/download_service.h" |
#include "chrome/browser/lifetime/browser_close_manager.h" |
+#include "chrome/browser/lifetime/browser_keep_alive.h" |
#include "chrome/browser/metrics/thread_watcher.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_manager.h" |
@@ -80,9 +80,6 @@ bool AreAllBrowsersCloseable() { |
} |
#endif // !defined(OS_ANDROID) |
-int g_keep_alive_count = 0; |
-bool g_disable_shutdown_for_testing = false; |
- |
#if defined(OS_CHROMEOS) |
// Whether chrome should send stop request to a session manager. |
bool g_send_stop_request_to_session_manager = false; |
@@ -121,7 +118,8 @@ void CloseAllBrowsers() { |
// application, send the APP_TERMINATING action here. Otherwise, it will be |
// sent by RemoveBrowser() when the last browser has closed. |
if (chrome::GetTotalBrowserCount() == 0 && |
- (browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive())) { |
+ (browser_shutdown::IsTryingToQuit() || |
+ !browser_lifetime::WillKeepAlive())) { |
// Tell everyone that we are shutting down. |
browser_shutdown::SetTryingToQuit(true); |
@@ -294,43 +292,6 @@ void SessionEnding() { |
base::Process::Current().Terminate(0, false); |
} |
-void IncrementKeepAliveCount() { |
- // Increment the browser process refcount as long as we're keeping the |
- // application alive. |
- if (!WillKeepAlive()) |
- g_browser_process->AddRefModule(); |
- ++g_keep_alive_count; |
-} |
- |
-void CloseAllBrowsersIfNeeded() { |
- // If there are no browsers open and we aren't already shutting down, |
- // initiate a shutdown. Also skips shutdown if this is a unit test. |
- // (MessageLoop::current() == null or explicitly disabled). |
- if (chrome::GetTotalBrowserCount() == 0 && |
- !browser_shutdown::IsTryingToQuit() && base::MessageLoop::current() && |
- !g_disable_shutdown_for_testing) { |
- CloseAllBrowsers(); |
- } |
-} |
- |
-void DecrementKeepAliveCount() { |
- DCHECK_GT(g_keep_alive_count, 0); |
- --g_keep_alive_count; |
- // Although we should have a browser process, if there is none, |
- // there is nothing to do. |
- if (!g_browser_process) return; |
- |
- // Allow the app to shutdown again. |
- if (!WillKeepAlive()) { |
- g_browser_process->ReleaseModule(); |
- CloseAllBrowsersIfNeeded(); |
- } |
-} |
- |
-bool WillKeepAlive() { |
- return g_keep_alive_count > 0; |
-} |
- |
void NotifyAppTerminating() { |
static bool notified = false; |
if (notified) |
@@ -407,10 +368,4 @@ bool ShouldStartShutdown(Browser* browser) { |
return true; |
} |
-void DisableShutdownForTesting(bool disable_shutdown_for_testing) { |
- g_disable_shutdown_for_testing = disable_shutdown_for_testing; |
- if (!g_disable_shutdown_for_testing && !WillKeepAlive()) |
- CloseAllBrowsersIfNeeded(); |
-} |
- |
} // namespace chrome |