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

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 isherman, round 2. 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 kMaxCatsAndSixtyFours); 149 kMaxCatsAndSixtyFours);
149 } 150 }
150 151
151 } // namespace 152 } // namespace
152 153
153 // ChromeBrowserMainPartsMac --------------------------------------------------- 154 // ChromeBrowserMainPartsMac ---------------------------------------------------
154 155
155 ChromeBrowserMainPartsMac::ChromeBrowserMainPartsMac( 156 ChromeBrowserMainPartsMac::ChromeBrowserMainPartsMac(
156 const content::MainFunctionParams& parameters) 157 const content::MainFunctionParams& parameters)
157 : ChromeBrowserMainPartsPosix(parameters) { 158 : ChromeBrowserMainPartsPosix(parameters) {
159 MacStartupProfiler::GetInstance()->RecordLaunchTime();
jeremy 2014/07/16 08:19:23 Is this recording something different than startu
erikchen 2014/07/16 22:00:33 No. They are functionally equivalent, with the dif
158 } 160 }
159 161
160 ChromeBrowserMainPartsMac::~ChromeBrowserMainPartsMac() { 162 ChromeBrowserMainPartsMac::~ChromeBrowserMainPartsMac() {
161 } 163 }
162 164
163 void ChromeBrowserMainPartsMac::PreEarlyInitialization() { 165 void ChromeBrowserMainPartsMac::PreEarlyInitialization() {
164 ChromeBrowserMainPartsPosix::PreEarlyInitialization(); 166 ChromeBrowserMainPartsPosix::PreEarlyInitialization();
165 167
166 if (base::mac::WasLaunchedAsLoginItemRestoreState()) { 168 if (base::mac::WasLaunchedAsLoginItemRestoreState()) {
167 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); 169 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess();
168 singleton_command_line->AppendSwitch(switches::kRestoreLastSession); 170 singleton_command_line->AppendSwitch(switches::kRestoreLastSession);
169 } else if (base::mac::WasLaunchedAsHiddenLoginItem()) { 171 } else if (base::mac::WasLaunchedAsHiddenLoginItem()) {
170 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); 172 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess();
171 singleton_command_line->AppendSwitch(switches::kNoStartupWindow); 173 singleton_command_line->AppendSwitch(switches::kNoStartupWindow);
172 } 174 }
173 175
174 RecordCatSixtyFour(); 176 RecordCatSixtyFour();
175 } 177 }
176 178
177 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() { 179 void ChromeBrowserMainPartsMac::PreMainMessageLoopStart() {
180 MacStartupProfiler::GetInstance()->Profile(
181 MacStartupProfiler::PRE_MAIN_MESSAGE_LOOP_START);
178 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart(); 182 ChromeBrowserMainPartsPosix::PreMainMessageLoopStart();
179 183
180 // Tell Cocoa to finish its initialization, which we want to do manually 184 // Tell Cocoa to finish its initialization, which we want to do manually
181 // instead of calling NSApplicationMain(). The primary reason is that NSAM() 185 // instead of calling NSApplicationMain(). The primary reason is that NSAM()
182 // never returns, which would leave all the objects currently on the stack 186 // 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 187 // 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 188 // 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 189 // MessageLoop API, which works out ok for us because it's a wrapper around
186 // CFRunLoop. 190 // CFRunLoop.
187 191
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 @"NSTreatUnknownArgumentsAsOpen": @"NO", 254 @"NSTreatUnknownArgumentsAsOpen": @"NO",
251 // CoreAnimation has poor performance and CoreAnimation and 255 // CoreAnimation has poor performance and CoreAnimation and
252 // non-CoreAnimation exhibit window flickering when layers are not hosted 256 // non-CoreAnimation exhibit window flickering when layers are not hosted
253 // in the window server, which is the default when not not using the 257 // in the window server, which is the default when not not using the
254 // 10.9 SDK. 258 // 10.9 SDK.
255 // TODO: Remove this when we build with the 10.9 SDK. 259 // TODO: Remove this when we build with the 10.9 SDK.
256 @"NSWindowHostsLayersInWindowServer": @(base::mac::IsOSMavericksOrLater()) 260 @"NSWindowHostsLayersInWindowServer": @(base::mac::IsOSMavericksOrLater())
257 }]; 261 }];
258 } 262 }
259 263
264 void ChromeBrowserMainPartsMac::PostMainMessageLoopStart() {
265 MacStartupProfiler::GetInstance()->Profile(
266 MacStartupProfiler::POST_MAIN_MESSAGE_LOOP_START);
267 }
268
260 void ChromeBrowserMainPartsMac::PreProfileInit() { 269 void ChromeBrowserMainPartsMac::PreProfileInit() {
270 MacStartupProfiler::GetInstance()->Profile(
271 MacStartupProfiler::PRE_PROFILE_INIT);
261 ChromeBrowserMainPartsPosix::PreProfileInit(); 272 ChromeBrowserMainPartsPosix::PreProfileInit();
262 // This is called here so that the app shim socket is only created after 273 // This is called here so that the app shim socket is only created after
263 // taking the singleton lock. 274 // taking the singleton lock.
264 g_browser_process->platform_part()->app_shim_host_manager()->Init(); 275 g_browser_process->platform_part()->app_shim_host_manager()->Init();
265 AppListService::InitAll(NULL); 276 AppListService::InitAll(NULL);
266 } 277 }
267 278
268 void ChromeBrowserMainPartsMac::PostProfileInit() { 279 void ChromeBrowserMainPartsMac::PostProfileInit() {
280 MacStartupProfiler::GetInstance()->Profile(
281 MacStartupProfiler::POST_PROFILE_INIT);
269 ChromeBrowserMainPartsPosix::PostProfileInit(); 282 ChromeBrowserMainPartsPosix::PostProfileInit();
270 g_browser_process->metrics_service()->RecordBreakpadRegistration( 283 g_browser_process->metrics_service()->RecordBreakpadRegistration(
271 breakpad::IsCrashReporterEnabled()); 284 breakpad::IsCrashReporterEnabled());
272 } 285 }
273 286
274 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { 287 void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() {
275 AppController* appController = [NSApp delegate]; 288 AppController* appController = [NSApp delegate];
276 [appController didEndMainMessageLoop]; 289 [appController didEndMainMessageLoop];
277 } 290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698