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

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 1778873002: Replace Increment/DecrementKeepAliveCount by ScopedKeepAlives (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@KAObserver
Patch Set: replace the commented dcheck by a dlog 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 unified diff | Download patch
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 #import "chrome/browser/app_controller_mac.h" 5 #import "chrome/browser/app_controller_mac.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/background/background_mode_manager.h" 27 #include "chrome/browser/background/background_mode_manager.h"
28 #include "chrome/browser/browser_process.h" 28 #include "chrome/browser/browser_process.h"
29 #include "chrome/browser/browser_shutdown.h" 29 #include "chrome/browser/browser_shutdown.h"
30 #include "chrome/browser/chrome_notification_types.h" 30 #include "chrome/browser/chrome_notification_types.h"
31 #include "chrome/browser/command_updater.h" 31 #include "chrome/browser/command_updater.h"
32 #include "chrome/browser/download/download_service.h" 32 #include "chrome/browser/download/download_service.h"
33 #include "chrome/browser/download/download_service_factory.h" 33 #include "chrome/browser/download/download_service_factory.h"
34 #include "chrome/browser/extensions/extension_service.h" 34 #include "chrome/browser/extensions/extension_service.h"
35 #include "chrome/browser/first_run/first_run.h" 35 #include "chrome/browser/first_run/first_run.h"
36 #include "chrome/browser/lifetime/application_lifetime.h" 36 #include "chrome/browser/lifetime/application_lifetime.h"
37 #include "chrome/browser/lifetime/keep_alive_types.h"
38 #include "chrome/browser/lifetime/scoped_keep_alive.h"
37 #include "chrome/browser/mac/mac_startup_profiler.h" 39 #include "chrome/browser/mac/mac_startup_profiler.h"
38 #include "chrome/browser/prefs/incognito_mode_prefs.h" 40 #include "chrome/browser/prefs/incognito_mode_prefs.h"
39 #include "chrome/browser/profiles/profile_info_cache_observer.h" 41 #include "chrome/browser/profiles/profile_info_cache_observer.h"
40 #include "chrome/browser/profiles/profile_manager.h" 42 #include "chrome/browser/profiles/profile_manager.h"
41 #include "chrome/browser/profiles/profiles_state.h" 43 #include "chrome/browser/profiles/profiles_state.h"
42 #include "chrome/browser/sessions/session_restore.h" 44 #include "chrome/browser/sessions/session_restore.h"
43 #include "chrome/browser/sessions/session_service.h" 45 #include "chrome/browser/sessions/session_service.h"
44 #include "chrome/browser/sessions/session_service_factory.h" 46 #include "chrome/browser/sessions/session_service_factory.h"
45 #include "chrome/browser/sessions/tab_restore_service_factory.h" 47 #include "chrome/browser/sessions/tab_restore_service_factory.h"
46 #include "chrome/browser/signin/signin_manager_factory.h" 48 #include "chrome/browser/signin/signin_manager_factory.h"
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 runModalLoopForApplication:app]; 515 runModalLoopForApplication:app];
514 } 516 }
515 517
516 // Called when the app is shutting down. Clean-up as appropriate. 518 // Called when the app is shutting down. Clean-up as appropriate.
517 - (void)applicationWillTerminate:(NSNotification*)aNotification { 519 - (void)applicationWillTerminate:(NSNotification*)aNotification {
518 // There better be no browser windows left at this point. 520 // There better be no browser windows left at this point.
519 CHECK_EQ(0u, chrome::GetTotalBrowserCount()); 521 CHECK_EQ(0u, chrome::GetTotalBrowserCount());
520 522
521 // Tell BrowserList not to keep the browser process alive. Once all the 523 // Tell BrowserList not to keep the browser process alive. Once all the
522 // browsers get dealloc'd, it will stop the RunLoop and fall back into main(). 524 // browsers get dealloc'd, it will stop the RunLoop and fall back into main().
523 chrome::DecrementKeepAliveCount(); 525 keep_alive_.reset();
524 526
525 // Reset all pref watching, as this object outlives the prefs system. 527 // Reset all pref watching, as this object outlives the prefs system.
526 profilePrefRegistrar_.reset(); 528 profilePrefRegistrar_.reset();
527 localPrefRegistrar_.RemoveAll(); 529 localPrefRegistrar_.RemoveAll();
528 530
529 [self unregisterEventHandlers]; 531 [self unregisterEventHandlers];
530 532
531 appShimMenuController_.reset(); 533 appShimMenuController_.reset();
532 534
533 STLDeleteContainerPairSecondPointers(profileBookmarkMenuBridgeMap_.begin(), 535 STLDeleteContainerPairSecondPointers(profileBookmarkMenuBridgeMap_.begin(),
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 723
722 // This is called after profiles have been loaded and preferences registered. 724 // This is called after profiles have been loaded and preferences registered.
723 // It is safe to access the default profile here. 725 // It is safe to access the default profile here.
724 - (void)applicationDidFinishLaunching:(NSNotification*)notify { 726 - (void)applicationDidFinishLaunching:(NSNotification*)notify {
725 MacStartupProfiler::GetInstance()->Profile( 727 MacStartupProfiler::GetInstance()->Profile(
726 MacStartupProfiler::DID_FINISH_LAUNCHING); 728 MacStartupProfiler::DID_FINISH_LAUNCHING);
727 MacStartupProfiler::GetInstance()->RecordMetrics(); 729 MacStartupProfiler::GetInstance()->RecordMetrics();
728 730
729 // Notify BrowserList to keep the application running so it doesn't go away 731 // Notify BrowserList to keep the application running so it doesn't go away
730 // when all the browser windows get closed. 732 // when all the browser windows get closed.
731 chrome::IncrementKeepAliveCount(); 733 keep_alive_.reset(new ScopedKeepAlive(KeepAliveOrigin::APP_CONTROLLER,
734 KeepAliveRestartOption::DISABLED));
732 735
733 [self setUpdateCheckInterval]; 736 [self setUpdateCheckInterval];
734 737
735 // Start managing the menu for app windows. This needs to be done here because 738 // Start managing the menu for app windows. This needs to be done here because
736 // main menu item titles are not yet initialized in awakeFromNib. 739 // main menu item titles are not yet initialized in awakeFromNib.
737 [self initAppShimMenuController]; 740 [self initAppShimMenuController];
738 741
739 // If enabled, keep Chrome alive when apps are open instead of quitting all 742 // If enabled, keep Chrome alive when apps are open instead of quitting all
740 // apps. 743 // apps.
741 quitWithAppsController_ = new QuitWithAppsController(); 744 quitWithAppsController_ = new QuitWithAppsController();
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 1706
1704 //--------------------------------------------------------------------------- 1707 //---------------------------------------------------------------------------
1705 1708
1706 namespace app_controller_mac { 1709 namespace app_controller_mac {
1707 1710
1708 bool IsOpeningNewWindow() { 1711 bool IsOpeningNewWindow() {
1709 return g_is_opening_new_window; 1712 return g_is_opening_new_window;
1710 } 1713 }
1711 1714
1712 } // namespace app_controller_mac 1715 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/apps/app_window_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698