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

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

Issue 393753002: mac: Add a profiler for startup time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from jeremy. 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 #include "chrome/browser/chrome_browser_main_mac.h" 5 #include "chrome/browser/chrome_browser_main_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <sys/sysctl.h> 8 #include <sys/sysctl.h>
9 9
10 #include "apps/app_shim/app_shim_host_manager_mac.h" 10 #include "apps/app_shim/app_shim_host_manager_mac.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/mac/bundle_locations.h" 13 #include "base/mac/bundle_locations.h"
14 #include "base/mac/mac_util.h" 14 #include "base/mac/mac_util.h"
15 #include "base/mac/scoped_nsobject.h" 15 #include "base/mac/scoped_nsobject.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #import "chrome/browser/app_controller_mac.h" 18 #import "chrome/browser/app_controller_mac.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #import "chrome/browser/chrome_browser_application_mac.h" 20 #import "chrome/browser/chrome_browser_application_mac.h"
21 #include "chrome/browser/mac/install_from_dmg.h" 21 #include "chrome/browser/mac/install_from_dmg.h"
22 #import "chrome/browser/mac/keystone_glue.h" 22 #import "chrome/browser/mac/keystone_glue.h"
23 #include "chrome/browser/mac/mac_startup_profiler.h"
23 #include "chrome/browser/ui/app_list/app_list_service.h" 24 #include "chrome/browser/ui/app_list/app_list_service.h"
24 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
26 #include "components/breakpad/app/breakpad_mac.h" 27 #include "components/breakpad/app/breakpad_mac.h"
27 #include "components/metrics/metrics_service.h" 28 #include "components/metrics/metrics_service.h"
28 #include "content/public/common/main_function_params.h" 29 #include "content/public/common/main_function_params.h"
29 #include "content/public/common/result_codes.h" 30 #include "content/public/common/result_codes.h"
30 #include "ui/base/l10n/l10n_util_mac.h" 31 #include "ui/base/l10n/l10n_util_mac.h"
31 #include "ui/base/resource/resource_bundle.h" 32 #include "ui/base/resource/resource_bundle.h"
32 #include "ui/base/resource/resource_handle.h" 33 #include "ui/base/resource/resource_handle.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 singleton_command_line->AppendSwitch(switches::kRestoreLastSession); 169 singleton_command_line->AppendSwitch(switches::kRestoreLastSession);
169 } else if (base::mac::WasLaunchedAsHiddenLoginItem()) { 170 } else if (base::mac::WasLaunchedAsHiddenLoginItem()) {
170 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); 171 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess();
171 singleton_command_line->AppendSwitch(switches::kNoStartupWindow); 172 singleton_command_line->AppendSwitch(switches::kNoStartupWindow);
172 } 173 }
173 174
174 RecordCatSixtyFour(); 175 RecordCatSixtyFour();
175 } 176 }
176 177
177 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() { 178 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() {
179 MacStartupProfiler::GetInstance()->Profile(
180 MacStartupProfiler::PRE_MAIN_MESSAGE_LOOP_START);
178 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart(); 181 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart();
179 182
180 // Tell Cocoa to finish its initialization, which we want to do manually 183 // Tell Cocoa to finish its initialization, which we want to do manually
181 // instead of calling NSApplicationMain(). The primary reason is that NSAM() 184 // instead of calling NSApplicationMain(). The primary reason is that NSAM()
182 // never returns, which would leave all the objects currently on the stack 185 // never returns, which would leave all the objects currently on the stack
183 // in scoped_ptrs hanging and never cleaned up. We then load the main nib 186 // in scoped_ptrs hanging and never cleaned up. We then load the main nib
184 // directly. The main event loop is run from common code using the 187 // directly. The main event loop is run from common code using the
185 // MessageLoop API, which works out ok for us because it's a wrapper around 188 // MessageLoop API, which works out ok for us because it's a wrapper around
186 // CFRunLoop. 189 // CFRunLoop.
187 190
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 @"NSTreatUnknownArgumentsAsOpen": @"NO", 253 @"NSTreatUnknownArgumentsAsOpen": @"NO",
251 // CoreAnimation has poor performance and CoreAnimation and 254 // CoreAnimation has poor performance and CoreAnimation and
252 // non-CoreAnimation exhibit window flickering when layers are not hosted 255 // non-CoreAnimation exhibit window flickering when layers are not hosted
253 // in the window server, which is the default when not not using the 256 // in the window server, which is the default when not not using the
254 // 10.9 SDK. 257 // 10.9 SDK.
255 // TODO: Remove this when we build with the 10.9 SDK. 258 // TODO: Remove this when we build with the 10.9 SDK.
256 @"NSWindowHostsLayersInWindowServer": @(base::mac::IsOSMavericksOrLater()) 259 @"NSWindowHostsLayersInWindowServer": @(base::mac::IsOSMavericksOrLater())
257 }]; 260 }];
258 } 261 }
259 262
263 void ChromeBrowserMainPartsMac::PostMainMessageLoopStart() {
264 MacStartupProfiler::GetInstance()->Profile(
265 MacStartupProfiler::POST_MAIN_MESSAGE_LOOP_START);
266 }
267
260 void ChromeBrowserMainPartsMac::PreProfileInit() { 268 void ChromeBrowserMainPartsMac::PreProfileInit() {
269 MacStartupProfiler::GetInstance()->Profile(
270 MacStartupProfiler::PRE_PROFILE_INIT);
261 ChromeBrowserMainPartsPosix::PreProfileInit(); 271 ChromeBrowserMainPartsPosix::PreProfileInit();
262 // This is called here so that the app shim socket is only created after 272 // This is called here so that the app shim socket is only created after
263 // taking the singleton lock. 273 // taking the singleton lock.
264 g_browser_process->platform_part()->app_shim_host_manager()->Init(); 274 g_browser_process->platform_part()->app_shim_host_manager()->Init();
265 AppListService::InitAll(NULL); 275 AppListService::InitAll(NULL);
266 } 276 }
267 277
268 void ChromeBrowserMainPartsMac::PostProfileInit() { 278 void ChromeBrowserMainPartsMac::PostProfileInit() {
279 MacStartupProfiler::GetInstance()->Profile(
280 MacStartupProfiler::POST_PROFILE_INIT);
269 ChromeBrowserMainPartsPosix::PostProfileInit(); 281 ChromeBrowserMainPartsPosix::PostProfileInit();
270 g_browser_process->metrics_service()->RecordBreakpadRegistration( 282 g_browser_process->metrics_service()->RecordBreakpadRegistration(
271 breakpad::IsCrashReporterEnabled()); 283 breakpad::IsCrashReporterEnabled());
272 } 284 }
273 285
274 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { 286 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() {
275 AppController* appController = [NSApp delegate]; 287 AppController* appController = [NSApp delegate];
276 [appController didEndMainMessageLoop]; 288 [appController didEndMainMessageLoop];
277 } 289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698