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

Unified Diff: chrome/browser/chrome_browser_main.cc

Issue 957353003: Add extra histogram latency tracking in PreMainMessageLoopRunImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix xml comment Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_browser_main.cc
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 3af4c611d1d4f5ae87ea353d7983a8d746302712..14b2bbe2d985dd20a398c000c866a3dc314b0b7c 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -1121,12 +1121,13 @@ void ChromeBrowserMainParts::PostBrowserStart() {
int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl");
SCOPED_UMA_HISTOGRAM_LONG_TIMER("Startup.PreMainMessageLoopRunImplLongTime");
+ const base::TimeTicks start_time_step1 = base::TimeTicks::Now();
// Android updates the metrics service dynamically depending on whether the
// application is in the foreground or not. Do not start here.
#if !defined(OS_ANDROID)
// Now that the file thread has been started, start recording.
StartMetricsRecording();
-#endif
+#endif // !defined(OS_ANDROID)
if (!base::debug::BeingDebugged()) {
// Create watchdog thread after creating all other threads because it will
@@ -1161,7 +1162,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
ui::SelectFileDialog::SetFactory(new ChromeSelectFileDialogFactory(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
-#endif
+#endif // OS_WIN
Alexei Svitkine (slow) 2015/03/02 22:11:55 defined()
Lei Zhang 2015/03/02 22:22:29 nit: Please be consistent and add defined(). Ditto
if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) {
return ShellIntegration::SetAsDefaultBrowser() ?
@@ -1172,7 +1173,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#if defined(USE_AURA)
// Make sure aura::Env has been initialized.
CHECK(aura::Env::GetInstance());
-#endif
+#endif // defined(USE_AURA)
// Android doesn't support extensions and doesn't implement ProcessSingleton.
#if !defined(OS_ANDROID)
@@ -1205,7 +1206,8 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#if defined(OS_POSIX) && !defined(OS_MACOSX)
printf("%s\n", base::SysWideToNativeMB(base::UTF16ToWide(
l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str());
-#endif
+#endif // OS_POSIX && !defined(OS_MACOSX)
Alexei Svitkine (slow) 2015/03/02 22:11:55 Nit: defined(OS_POSIX) && !defined(OS_MACOSX) #if
+
// Having a differentiated return type for testing allows for tests to
// verify proper handling of some switches. When not testing, stick to
// the standard Unix convention of returning zero when things went as
@@ -1262,7 +1264,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#else
// We don't support retention experiments on Mac or Linux.
return content::RESULT_CODE_NORMAL_EXIT;
-#endif // defined(OS_WIN)
+#endif // OS_WIN
}
#if defined(OS_WIN)
@@ -1278,12 +1280,12 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// obtained but before potentially creating the first run sentinel).
if (ChromeBrowserMainPartsWin::CheckMachineLevelInstall())
return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS;
-#endif // defined(OS_WIN)
+#endif // OS_WIN
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
if (sxs_linux::ShouldMigrateUserDataDir())
return sxs_linux::MigrateUserDataDir();
-#endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#endif // OS_LINUX && !defined(OS_CHROMEOS)
// Desktop construction occurs here, (required before profile creation).
PreProfileInit();
@@ -1293,12 +1295,20 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
metrics::MetricsService::SetExecutionPhase(
metrics::MetricsService::CREATE_PROFILE,
g_browser_process->local_state());
+
+ UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep1Time",
+ base::TimeTicks::Now() - start_time_step1);
+
+ // This step is costly and is already measured in Startup.CreateFirstProfile
+ // and more directly Profile.CreateAndInitializeProfile.
profile_ = CreatePrimaryProfile(parameters(),
user_data_dir_,
parsed_command_line());
if (!profile_)
return content::RESULT_CODE_NORMAL_EXIT;
+ const base::TimeTicks start_time_step2 = base::TimeTicks::Now();
+
#if !defined(OS_ANDROID)
// The first run sentinel must be created after the process singleton was
// grabbed and no early return paths were otherwise hit above.
@@ -1309,7 +1319,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// Autoload any profiles which are running background apps.
// TODO(rlp): Do this on a separate thread. See http://crbug.com/99075.
browser_process_->profile_manager()->AutoloadProfiles();
-#endif
+#endif // ENABLE_BACKGROUND
Alexei Svitkine (slow) 2015/03/02 22:11:55 defined()
// Post-profile init ---------------------------------------------------------
TranslateService::Initialize();
@@ -1325,7 +1335,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
NaClBrowserDelegateImpl* delegate =
new NaClBrowserDelegateImpl(browser_process_->profile_manager());
nacl::NaClBrowser::SetDelegate(delegate);
-#endif
+#endif // !defined(DISABLE_NACL)
// TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts.
// (requires supporting early exit).
@@ -1403,7 +1413,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
RLZTracker::InitRlzFromProfileDelayed(
profile_, first_run::IsChromeFirstRun(), ping_delay < 0,
base::TimeDelta::FromMilliseconds(abs(ping_delay)));
-#endif // defined(ENABLE_RLZ) && !defined(OS_CHROMEOS)
+#endif // ENABLE_RLZ && !defined(OS_CHROMEOS)
Alexei Svitkine (slow) 2015/03/02 22:11:55 Change back to defined()
// Configure modules that need access to resources.
net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider);
@@ -1446,7 +1456,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
parsed_command_line().GetSwitchValuePath(switches::kDebugPrint);
printing::PrintedDocument::set_debug_dump_path(path);
}
-#endif
+#endif // ENABLE_PRINT_PREVIEW && !defined(OFFICIAL_BUILD)
Alexei Svitkine (slow) 2015/03/02 22:11:55 Ditto.
HandleTestParameters(parsed_command_line());
browser_process_->metrics_service()->RecordBreakpadHasDebugger(
@@ -1471,7 +1481,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#if !defined(OS_ANDROID)
// Start watching for a hang.
browser_process_->metrics_service()->LogNeedForCleanShutdown();
-#endif
+#endif // !defined(OS_ANDROID)
#if defined(ENABLE_PRINT_PREVIEW)
// Create the instance of the cloud print proxy service so that it can launch
@@ -1481,7 +1491,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext()
// instead?
CloudPrintProxyServiceFactory::GetForProfile(profile_);
-#endif
+#endif // ENABLE_PRINT_PREVIEW
Alexei Svitkine (slow) 2015/03/02 22:11:54 Ditto.
// Start watching all browser threads for responsiveness.
metrics::MetricsService::SetExecutionPhase(
@@ -1491,14 +1501,14 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#if defined(OS_ANDROID)
ThreadWatcherAndroid::RegisterApplicationStatusListener();
-#endif
+#endif // OS_ANDROID
Alexei Svitkine (slow) 2015/03/02 22:11:54 Ditto.
#if !defined(DISABLE_NACL)
BrowserThread::PostTask(
BrowserThread::IO,
FROM_HERE,
base::Bind(nacl::NaClProcessHost::EarlyStartup));
-#endif
+#endif // !defined(DISABLE_NACL)
// Make sure initial prefs are recorded
PrefMetricsService::Factory::GetForProfile(profile_);
@@ -1544,17 +1554,24 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#else
std::vector<Profile*> last_opened_profiles =
g_browser_process->profile_manager()->GetLastOpenedProfiles();
-#endif
+#endif // OS_CHROMEOS
Alexei Svitkine (slow) 2015/03/02 22:11:55 Ditto.
- if (browser_creator_->Start(parsed_command_line(), base::FilePath(),
- profile_, last_opened_profiles)) {
+ UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep2Time",
+ base::TimeTicks::Now() - start_time_step2);
+
+ // This step is costly and is already measured in
+ // Startup.StartupBrowserCreator_Start.
+ bool started = browser_creator_->Start(
+ parsed_command_line(), base::FilePath(), profile_, last_opened_profiles);
+ const base::TimeTicks start_time_step3 = base::TimeTicks::Now();
+ if (started) {
#if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
// Initialize autoupdate timer. Timer callback costs basically nothing
// when browser is not in persistent mode, so it's OK to let it ride on
// the main thread. This needs to be done here because we don't want
// to start the timer when Chrome is run inside a test harness.
browser_process_->StartAutoupdateTimer();
-#endif
+#endif // OS_WIN || (OS_LINUX && !defined(OS_CHROMEOS))
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// On Linux, the running exe will be updated if an upgrade becomes
@@ -1562,7 +1579,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// modified time of the exe, so we can compare to determine if there is
// an upgrade while the browser is kept alive by a persistent extension.
upgrade_util::SaveLastModifiedTimeOfExe();
-#endif
+#endif // OS_LINUX && !defined(OS_CHROMEOS)
// Record now as the last successful chrome start.
GoogleUpdateSettings::SetLastRunTime();
@@ -1572,7 +1589,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// because Start() will add things to it while creating the main window.
if (parameters().autorelease_pool)
parameters().autorelease_pool->Recycle();
-#endif
+#endif // defined(OS_MACOSX)
base::TimeDelta delay = base::TimeTicks::Now() - browser_open_start;
UMA_HISTOGRAM_LONG_TIMES_100("Startup.BrowserOpenTabs", delay);
@@ -1589,7 +1606,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#if defined(OS_WIN)
variations_service->StartGoogleUpdateRegistrySync();
-#endif
+#endif // OS_WIN
}
translate::TranslateDownloadManager::RequestLanguageList(
@@ -1605,7 +1622,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#if !defined(OS_LINUX) || defined(OS_CHROMEOS) // http://crbug.com/426393
if (g_browser_process->metrics_service()->reporting_active())
content::StartPowerUsageMonitor();
-#endif
+#endif // !defined(OS_LINUX) || defined(OS_CHROMEOS)
process_power_collector_.reset(new ProcessPowerCollector);
process_power_collector_->Initialize();
@@ -1621,11 +1638,17 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#if defined(OS_ANDROID)
// We never run the C++ main loop on Android, since the UI thread message
// loop is controlled by the OS, so this is as close as we can get to
- // the start of the main loop
+ // the start of the main loop.
if (result_code_ <= 0) {
RecordBrowserStartupTime();
}
-#endif
+#endif // OS_ANDROID
+
+#if !defined(OS_ANDROID)
+ UMA_HISTOGRAM_TIMES("Startup.PreMainMessageLoopRunImplStep3Time",
+ base::TimeTicks::Now() - start_time_step3);
+#endif // !defined(OS_ANDROID)
+
return result_code_;
}
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698