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

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

Issue 393753002: mac: Add a profiler for startup time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Send histogram to UMA. Created 6 years, 5 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 "apps/app_shim/extension_app_shim_handler_mac.h" 7 #include "apps/app_shim/extension_app_shim_handler_mac.h"
8 #include "apps/app_window_registry.h" 8 #include "apps/app_window_registry.h"
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 12 matching lines...) Expand all
23 #include "chrome/browser/background/background_mode_manager.h" 23 #include "chrome/browser/background/background_mode_manager.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/browser_shutdown.h" 25 #include "chrome/browser/browser_shutdown.h"
26 #include "chrome/browser/chrome_notification_types.h" 26 #include "chrome/browser/chrome_notification_types.h"
27 #include "chrome/browser/command_updater.h" 27 #include "chrome/browser/command_updater.h"
28 #include "chrome/browser/download/download_service.h" 28 #include "chrome/browser/download/download_service.h"
29 #include "chrome/browser/download/download_service_factory.h" 29 #include "chrome/browser/download/download_service_factory.h"
30 #include "chrome/browser/extensions/extension_service.h" 30 #include "chrome/browser/extensions/extension_service.h"
31 #include "chrome/browser/first_run/first_run.h" 31 #include "chrome/browser/first_run/first_run.h"
32 #include "chrome/browser/lifetime/application_lifetime.h" 32 #include "chrome/browser/lifetime/application_lifetime.h"
33 #include "chrome/browser/mac/mac_startup_profiler.h"
33 #include "chrome/browser/profiles/profile_info_cache_observer.h" 34 #include "chrome/browser/profiles/profile_info_cache_observer.h"
34 #include "chrome/browser/profiles/profile_manager.h" 35 #include "chrome/browser/profiles/profile_manager.h"
35 #include "chrome/browser/profiles/profiles_state.h" 36 #include "chrome/browser/profiles/profiles_state.h"
36 #include "chrome/browser/sessions/session_restore.h" 37 #include "chrome/browser/sessions/session_restore.h"
37 #include "chrome/browser/sessions/session_service.h" 38 #include "chrome/browser/sessions/session_service.h"
38 #include "chrome/browser/sessions/session_service_factory.h" 39 #include "chrome/browser/sessions/session_service_factory.h"
39 #include "chrome/browser/sessions/tab_restore_service.h" 40 #include "chrome/browser/sessions/tab_restore_service.h"
40 #include "chrome/browser/sessions/tab_restore_service_factory.h" 41 #include "chrome/browser/sessions/tab_restore_service_factory.h"
41 #include "chrome/browser/signin/signin_manager_factory.h" 42 #include "chrome/browser/signin/signin_manager_factory.h"
42 #include "chrome/browser/signin/signin_promo.h" 43 #include "chrome/browser/signin/signin_promo.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 }; 275 };
275 276
276 @implementation AppController 277 @implementation AppController
277 278
278 @synthesize startupComplete = startupComplete_; 279 @synthesize startupComplete = startupComplete_;
279 280
280 // This method is called very early in application startup (ie, before 281 // This method is called very early in application startup (ie, before
281 // the profile is loaded or any preferences have been registered). Defer any 282 // the profile is loaded or any preferences have been registered). Defer any
282 // user-data initialization until -applicationDidFinishLaunching:. 283 // user-data initialization until -applicationDidFinishLaunching:.
283 - (void)awakeFromNib { 284 - (void)awakeFromNib {
285 MacStartupProfiler::GetInstance()->Profile(
286 MacStartupProfiler::AWAKE_FROM_NIB);
284 // We need to register the handlers early to catch events fired on launch. 287 // We need to register the handlers early to catch events fired on launch.
285 NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager]; 288 NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager];
286 [em setEventHandler:self 289 [em setEventHandler:self
287 andSelector:@selector(getUrl:withReply:) 290 andSelector:@selector(getUrl:withReply:)
288 forEventClass:kInternetEventClass 291 forEventClass:kInternetEventClass
289 andEventID:kAEGetURL]; 292 andEventID:kAEGetURL];
290 [em setEventHandler:self 293 [em setEventHandler:self
291 andSelector:@selector(getUrl:withReply:) 294 andSelector:@selector(getUrl:withReply:)
292 forEventClass:'WWW!' // A particularly ancient AppleEvent that dates 295 forEventClass:'WWW!' // A particularly ancient AppleEvent that dates
293 andEventID:'OURL']; // back to the Spyglass days. 296 andEventID:'OURL']; // back to the Spyglass days.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 andEventID:cloud_print::kAECloudPrintClass]; 356 andEventID:cloud_print::kAECloudPrintClass];
354 [em removeEventHandlerForEventClass:'WWW!' 357 [em removeEventHandlerForEventClass:'WWW!'
355 andEventID:'OURL']; 358 andEventID:'OURL'];
356 [[NSNotificationCenter defaultCenter] removeObserver:self]; 359 [[NSNotificationCenter defaultCenter] removeObserver:self];
357 [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self]; 360 [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self];
358 } 361 }
359 362
360 // (NSApplicationDelegate protocol) This is the Apple-approved place to override 363 // (NSApplicationDelegate protocol) This is the Apple-approved place to override
361 // the default handlers. 364 // the default handlers.
362 - (void)applicationWillFinishLaunching:(NSNotification*)notification { 365 - (void)applicationWillFinishLaunching:(NSNotification*)notification {
363 // Nothing here right now. 366 MacStartupProfiler::GetInstance()->Profile(
367 MacStartupProfiler::WILL_FINISH_LAUNCHING);
364 } 368 }
365 369
366 - (BOOL)tryToTerminateApplication:(NSApplication*)app { 370 - (BOOL)tryToTerminateApplication:(NSApplication*)app {
367 // Check for in-process downloads, and prompt the user if they really want 371 // Check for in-process downloads, and prompt the user if they really want
368 // to quit (and thus cancel downloads). Only check if we're not already 372 // to quit (and thus cancel downloads). Only check if we're not already
369 // shutting down, else the user might be prompted multiple times if the 373 // shutting down, else the user might be prompted multiple times if the
370 // download isn't stopped before terminate is called again. 374 // download isn't stopped before terminate is called again.
371 if (!browser_shutdown::IsTryingToQuit() && 375 if (!browser_shutdown::IsTryingToQuit() &&
372 ![self shouldQuitWithInProgressDownloads]) 376 ![self shouldQuitWithInProgressDownloads])
373 return NO; 377 return NO;
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 if (startupIndex != TabStripModel::kNoTab && 731 if (startupIndex != TabStripModel::kNoTab &&
728 startupContent->GetVisibleURL() == GURL(chrome::kChromeUINewTabURL)) { 732 startupContent->GetVisibleURL() == GURL(chrome::kChromeUINewTabURL)) {
729 browser->tab_strip_model()->CloseWebContentsAt(startupIndex, 733 browser->tab_strip_model()->CloseWebContentsAt(startupIndex,
730 TabStripModel::CLOSE_NONE); 734 TabStripModel::CLOSE_NONE);
731 } 735 }
732 } 736 }
733 737
734 // This is called after profiles have been loaded and preferences registered. 738 // This is called after profiles have been loaded and preferences registered.
735 // It is safe to access the default profile here. 739 // It is safe to access the default profile here.
736 - (void)applicationDidFinishLaunching:(NSNotification*)notify { 740 - (void)applicationDidFinishLaunching:(NSNotification*)notify {
741 MacStartupProfiler::GetInstance()->Profile(
742 MacStartupProfiler::DID_FINISH_LAUNCHING);
743 MacStartupProfiler::GetInstance()->RecordMetrics();
744
737 // Notify BrowserList to keep the application running so it doesn't go away 745 // Notify BrowserList to keep the application running so it doesn't go away
738 // when all the browser windows get closed. 746 // when all the browser windows get closed.
739 chrome::IncrementKeepAliveCount(); 747 chrome::IncrementKeepAliveCount();
740 748
741 [self setUpdateCheckInterval]; 749 [self setUpdateCheckInterval];
742 750
743 // Start managing the menu for app windows. This needs to be done here because 751 // Start managing the menu for app windows. This needs to be done here because
744 // main menu item titles are not yet initialized in awakeFromNib. 752 // main menu item titles are not yet initialized in awakeFromNib.
745 [self initAppShimMenuController]; 753 [self initAppShimMenuController];
746 754
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 1545
1538 //--------------------------------------------------------------------------- 1546 //---------------------------------------------------------------------------
1539 1547
1540 namespace app_controller_mac { 1548 namespace app_controller_mac {
1541 1549
1542 bool IsOpeningNewWindow() { 1550 bool IsOpeningNewWindow() {
1543 return g_is_opening_new_window; 1551 return g_is_opening_new_window;
1544 } 1552 }
1545 1553
1546 } // namespace app_controller_mac 1554 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_browser_main_mac.h » ('j') | chrome/browser/mac/mac_startup_profiler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698