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

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 28283002: Track execution phase of browser process when we log if the broswer has (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Record in UMA histograms the browser execution phase Created 7 years, 2 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.h" 5 #include "chrome/browser/chrome_browser_main.h"
6 6
7 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 // TODO(sky): nuke this when all ports support ActiveTabTracker. 1078 // TODO(sky): nuke this when all ports support ActiveTabTracker.
1079 if (!active_tab_tracker_->is_valid()) 1079 if (!active_tab_tracker_->is_valid())
1080 active_tab_tracker_.reset(); 1080 active_tab_tracker_.reset();
1081 } 1081 }
1082 #endif 1082 #endif
1083 1083
1084 // Android updates the metrics service dynamically depending on whether the 1084 // Android updates the metrics service dynamically depending on whether the
1085 // application is in the foreground or not. Do not start here. 1085 // application is in the foreground or not. Do not start here.
1086 #if !defined(OS_ANDROID) 1086 #if !defined(OS_ANDROID)
1087 // Now that the file thread has been started, start recording. 1087 // Now that the file thread has been started, start recording.
1088 MetricsService::SetExecutionPhase(MetricsService::START_METRICS_RECORDING);
1088 StartMetricsRecording(); 1089 StartMetricsRecording();
1089 #endif 1090 #endif
1090 1091
1091 // Create watchdog thread after creating all other threads because it will 1092 // Create watchdog thread after creating all other threads because it will
1092 // watch the other threads and they must be running. 1093 // watch the other threads and they must be running.
1093 browser_process_->watchdog_thread(); 1094 browser_process_->watchdog_thread();
1094 1095
1095 // Do any initializating in the browser process that requires all threads 1096 // Do any initializating in the browser process that requires all threads
1096 // running. 1097 // running.
1097 browser_process_->PreMainMessageLoopRun(); 1098 browser_process_->PreMainMessageLoopRun();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 return content::RESULT_CODE_NORMAL_EXIT; 1225 return content::RESULT_CODE_NORMAL_EXIT;
1225 #endif // defined(OS_WIN) 1226 #endif // defined(OS_WIN)
1226 } 1227 }
1227 1228
1228 // Profile creation ---------------------------------------------------------- 1229 // Profile creation ----------------------------------------------------------
1229 1230
1230 // Called before CreateProfile because creating the profile can trigger 1231 // Called before CreateProfile because creating the profile can trigger
1231 // calls to GetDefaultProfile(). 1232 // calls to GetDefaultProfile().
1232 ProfileManager::AllowGetDefaultProfile(); 1233 ProfileManager::AllowGetDefaultProfile();
1233 1234
1235 MetricsService::SetExecutionPhase(MetricsService::CREATE_PROFILE);
1234 profile_ = CreateProfile(parameters(), user_data_dir_, parsed_command_line()); 1236 profile_ = CreateProfile(parameters(), user_data_dir_, parsed_command_line());
1235 if (!profile_) 1237 if (!profile_)
1236 return content::RESULT_CODE_NORMAL_EXIT; 1238 return content::RESULT_CODE_NORMAL_EXIT;
1237 1239
1238 #if defined(ENABLE_BACKGROUND) 1240 #if defined(ENABLE_BACKGROUND)
1239 // Autoload any profiles which are running background apps. 1241 // Autoload any profiles which are running background apps.
1240 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. 1242 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075.
1241 browser_process_->profile_manager()->AutoloadProfiles(); 1243 browser_process_->profile_manager()->AutoloadProfiles();
1242 #endif 1244 #endif
1243 // Post-profile init --------------------------------------------------------- 1245 // Post-profile init ---------------------------------------------------------
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 extensions::StartupHelper extension_startup_helper; 1402 extensions::StartupHelper extension_startup_helper;
1401 if (extension_startup_helper.UninstallExtension( 1403 if (extension_startup_helper.UninstallExtension(
1402 parsed_command_line(), profile_)) 1404 parsed_command_line(), profile_))
1403 return content::RESULT_CODE_NORMAL_EXIT; 1405 return content::RESULT_CODE_NORMAL_EXIT;
1404 return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR; 1406 return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR;
1405 } 1407 }
1406 1408
1407 // Start watching for hangs during startup. We disarm this hang detector when 1409 // Start watching for hangs during startup. We disarm this hang detector when
1408 // ThreadWatcher takes over or when browser is shutdown or when 1410 // ThreadWatcher takes over or when browser is shutdown or when
1409 // startup_watcher_ is deleted. 1411 // startup_watcher_ is deleted.
1412 MetricsService::SetExecutionPhase(MetricsService::STARTUP_TIMEBOMB_ARM);
1410 startup_watcher_->Arm(base::TimeDelta::FromSeconds(300)); 1413 startup_watcher_->Arm(base::TimeDelta::FromSeconds(300));
1411 1414
1412 // On mobile, need for clean shutdown arises only when the application comes 1415 // On mobile, need for clean shutdown arises only when the application comes
1413 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). 1416 // to foreground (i.e. MetricsService::OnAppEnterForeground is called).
1414 // http://crbug.com/179143 1417 // http://crbug.com/179143
1415 #if !defined(OS_ANDROID) 1418 #if !defined(OS_ANDROID)
1416 // Start watching for a hang. 1419 // Start watching for a hang.
1417 MetricsService::LogNeedForCleanShutdown(); 1420 MetricsService::LogNeedForCleanShutdown();
1418 #endif 1421 #endif
1419 1422
1420 #if defined(ENABLE_FULL_PRINTING) 1423 #if defined(ENABLE_FULL_PRINTING)
1421 // Create the instance of the cloud print proxy service so that it can launch 1424 // Create the instance of the cloud print proxy service so that it can launch
1422 // the service process if needed. This is needed because the service process 1425 // the service process if needed. This is needed because the service process
1423 // might have shutdown because an update was available. 1426 // might have shutdown because an update was available.
1424 // TODO(torne): this should maybe be done with 1427 // TODO(torne): this should maybe be done with
1425 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() 1428 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext()
1426 // instead? 1429 // instead?
1427 CloudPrintProxyServiceFactory::GetForProfile(profile_); 1430 CloudPrintProxyServiceFactory::GetForProfile(profile_);
1428 #endif 1431 #endif
1429 1432
1430 // Start watching all browser threads for responsiveness. 1433 // Start watching all browser threads for responsiveness.
1434 MetricsService::SetExecutionPhase(MetricsService::THREAD_WATCHER_START);
1431 ThreadWatcherList::StartWatchingAll(parsed_command_line()); 1435 ThreadWatcherList::StartWatchingAll(parsed_command_line());
1432 1436
1433 #if !defined(DISABLE_NACL) 1437 #if !defined(DISABLE_NACL)
1434 if (parsed_command_line().HasSwitch(switches::kPnaclDir)) { 1438 if (parsed_command_line().HasSwitch(switches::kPnaclDir)) {
1435 PathService::Override(chrome::DIR_PNACL_BASE, 1439 PathService::Override(chrome::DIR_PNACL_BASE,
1436 parsed_command_line().GetSwitchValuePath( 1440 parsed_command_line().GetSwitchValuePath(
1437 switches::kPnaclDir)); 1441 switches::kPnaclDir));
1438 } 1442 }
1439 NaClProcessHost::EarlyStartup(new NaClBrowserDelegateImpl); 1443 NaClProcessHost::EarlyStartup(new NaClBrowserDelegateImpl);
1440 #endif 1444 #endif
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 DCHECK_EQ(base::MessageLoop::TYPE_UI, base::MessageLoop::current()->type()); 1592 DCHECK_EQ(base::MessageLoop::TYPE_UI, base::MessageLoop::current()->type());
1589 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) 1593 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS)
1590 views::AcceleratorHandler accelerator_handler; 1594 views::AcceleratorHandler accelerator_handler;
1591 base::RunLoop run_loop(&accelerator_handler); 1595 base::RunLoop run_loop(&accelerator_handler);
1592 #else 1596 #else
1593 base::RunLoop run_loop; 1597 base::RunLoop run_loop;
1594 #endif 1598 #endif
1595 1599
1596 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); 1600 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle();
1597 1601
1602 MetricsService::SetExecutionPhase(MetricsService::MAIN_MESSAGE_LOOP_RUN);
1598 run_loop.Run(); 1603 run_loop.Run();
1599 1604
1600 return true; 1605 return true;
1601 #endif 1606 #endif
1602 } 1607 }
1603 1608
1604 void ChromeBrowserMainParts::PostMainMessageLoopRun() { 1609 void ChromeBrowserMainParts::PostMainMessageLoopRun() {
1605 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun"); 1610 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun");
1606 #if defined(OS_ANDROID) 1611 #if defined(OS_ANDROID)
1607 // Chrome on Android does not use default MessageLoop. It has its own 1612 // Chrome on Android does not use default MessageLoop. It has its own
1608 // Android specific MessageLoop 1613 // Android specific MessageLoop
1609 NOTREACHED(); 1614 NOTREACHED();
1610 #else 1615 #else
1611 1616
1612 // Start watching for jank during shutdown. It gets disarmed when 1617 // Start watching for jank during shutdown. It gets disarmed when
1613 // |shutdown_watcher_| object is destructed. 1618 // |shutdown_watcher_| object is destructed.
1619 MetricsService::SetExecutionPhase(MetricsService::SHUTDOWN_TIMEBOMB_ARM);
1614 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300)); 1620 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300));
1615 1621
1616 // Disarm the startup hang detector time bomb if it is still Arm'ed. 1622 // Disarm the startup hang detector time bomb if it is still Arm'ed.
1617 startup_watcher_->Disarm(); 1623 startup_watcher_->Disarm();
1618 1624
1619 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 1625 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1620 chrome_extra_parts_[i]->PostMainMessageLoopRun(); 1626 chrome_extra_parts_[i]->PostMainMessageLoopRun();
1621 1627
1622 // Some tests don't set parameters.ui_task, so they started translate 1628 // Some tests don't set parameters.ui_task, so they started translate
1623 // language fetch that was never completed so we need to cleanup here 1629 // language fetch that was never completed so we need to cleanup here
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 chromeos::CrosSettings::Shutdown(); 1669 chromeos::CrosSettings::Shutdown();
1664 #endif 1670 #endif
1665 #endif 1671 #endif
1666 } 1672 }
1667 1673
1668 // Public members: 1674 // Public members:
1669 1675
1670 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 1676 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
1671 chrome_extra_parts_.push_back(parts); 1677 chrome_extra_parts_.push_back(parts);
1672 } 1678 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_service.h » ('j') | chrome/browser/metrics/metrics_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698