| Index: chrome/browser/lifetime/application_lifetime.cc
|
| diff --git a/chrome/browser/lifetime/application_lifetime.cc b/chrome/browser/lifetime/application_lifetime.cc
|
| index 1986d1b3a5c44e9159c4943b7a1919cb8b1c3d0a..ada413f56e8a0fcd364e6e7c96a7c83f83dad846 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"
|
| @@ -81,9 +81,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;
|
| @@ -122,7 +119,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);
|
|
|
| @@ -311,43 +309,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)
|
| @@ -424,10 +385,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
|
|
|