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

Side by Side Diff: chrome/browser/lifetime/application_lifetime.cc

Issue 12212120: Replace most BrowserList::empty() and BrowserList::size() calls by multi-desktop aware calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge up to r182110 Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/lifetime/application_lifetime.h" 5 #include "chrome/browser/lifetime/application_lifetime.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/browser_shutdown.h" 14 #include "chrome/browser/browser_shutdown.h"
15 #include "chrome/browser/download/download_service.h" 15 #include "chrome/browser/download/download_service.h"
16 #include "chrome/browser/metrics/thread_watcher.h" 16 #include "chrome/browser/metrics/thread_watcher.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_finder.h"
20 #include "chrome/browser/ui/browser_iterator.h" 21 #include "chrome/browser/ui/browser_iterator.h"
21 #include "chrome/browser/ui/browser_list.h"
22 #include "chrome/browser/ui/browser_tabstrip.h" 22 #include "chrome/browser/ui/browser_tabstrip.h"
23 #include "chrome/browser/ui/browser_window.h" 23 #include "chrome/browser/ui/browser_window.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
28 #include "content/public/browser/browser_shutdown.h" 28 #include "content/public/browser/browser_shutdown.h"
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/navigation_details.h" 30 #include "content/public/browser/navigation_details.h"
31 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 #if defined(ENABLE_SESSION_SERVICE) 114 #if defined(ENABLE_SESSION_SERVICE)
115 // Before we close the browsers shutdown all session services. That way an 115 // Before we close the browsers shutdown all session services. That way an
116 // exit can restore all browsers open before exiting. 116 // exit can restore all browsers open before exiting.
117 ProfileManager::ShutdownSessionServices(); 117 ProfileManager::ShutdownSessionServices();
118 #endif 118 #endif
119 119
120 // If there are no browsers, send the APP_TERMINATING action here. Otherwise, 120 // If there are no browsers, send the APP_TERMINATING action here. Otherwise,
121 // it will be sent by RemoveBrowser() when the last browser has closed. 121 // it will be sent by RemoveBrowser() when the last browser has closed.
122 if (browser_shutdown::ShuttingDownWithoutClosingBrowsers() || 122 if (browser_shutdown::ShuttingDownWithoutClosingBrowsers() ||
123 BrowserList::empty()) { 123 chrome::GetTotalBrowserCount() == 0) {
124 chrome::NotifyAndTerminate(true); 124 chrome::NotifyAndTerminate(true);
125 chrome::OnAppExiting(); 125 chrome::OnAppExiting();
126 return; 126 return;
127 } 127 }
128 128
129 #if defined(OS_CHROMEOS) 129 #if defined(OS_CHROMEOS)
130 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker( 130 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker(
131 "StartedClosingWindows", false); 131 "StartedClosingWindows", false);
132 #endif 132 #endif
133 for (scoped_ptr<chrome::BrowserIterator> it_ptr( 133 for (scoped_ptr<chrome::BrowserIterator> it_ptr(
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // Although we should have a browser process, if there is none, 314 // Although we should have a browser process, if there is none,
315 // there is nothing to do. 315 // there is nothing to do.
316 if (!g_browser_process) return; 316 if (!g_browser_process) return;
317 317
318 // Allow the app to shutdown again. 318 // Allow the app to shutdown again.
319 if (!WillKeepAlive()) { 319 if (!WillKeepAlive()) {
320 g_browser_process->ReleaseModule(); 320 g_browser_process->ReleaseModule();
321 // If there are no browsers open and we aren't already shutting down, 321 // If there are no browsers open and we aren't already shutting down,
322 // initiate a shutdown. Also skips shutdown if this is a unit test 322 // initiate a shutdown. Also skips shutdown if this is a unit test
323 // (MessageLoop::current() == null). 323 // (MessageLoop::current() == null).
324 if (BrowserList::empty() && !browser_shutdown::IsTryingToQuit() && 324 if (chrome::GetTotalBrowserCount() == 0 &&
325 MessageLoop::current()) 325 !browser_shutdown::IsTryingToQuit() &&
326 MessageLoop::current()) {
326 browser::CloseAllBrowsers(); 327 browser::CloseAllBrowsers();
328 }
327 } 329 }
328 } 330 }
329 331
330 bool WillKeepAlive() { 332 bool WillKeepAlive() {
331 return browser::g_keep_alive_count > 0; 333 return browser::g_keep_alive_count > 0;
332 } 334 }
333 335
334 void NotifyAppTerminating() { 336 void NotifyAppTerminating() {
335 static bool notified = false; 337 static bool notified = false;
336 if (notified) 338 if (notified)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 382
381 void OnAppExiting() { 383 void OnAppExiting() {
382 static bool notified = false; 384 static bool notified = false;
383 if (notified) 385 if (notified)
384 return; 386 return;
385 notified = true; 387 notified = true;
386 HandleAppExitingForPlatform(); 388 HandleAppExitingForPlatform();
387 } 389 }
388 390
389 } // namespace chrome 391 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/fast_shutdown_browsertest.cc ('k') | chrome/browser/policy/policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698