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

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: fixed jar's comments Created 7 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 // TODO(sky): nuke this when all ports support ActiveTabTracker. 1089 // TODO(sky): nuke this when all ports support ActiveTabTracker.
1090 if (!active_tab_tracker_->is_valid()) 1090 if (!active_tab_tracker_->is_valid())
1091 active_tab_tracker_.reset(); 1091 active_tab_tracker_.reset();
1092 } 1092 }
1093 #endif 1093 #endif
1094 1094
1095 // Android updates the metrics service dynamically depending on whether the 1095 // Android updates the metrics service dynamically depending on whether the
1096 // application is in the foreground or not. Do not start here. 1096 // application is in the foreground or not. Do not start here.
1097 #if !defined(OS_ANDROID) 1097 #if !defined(OS_ANDROID)
1098 // Now that the file thread has been started, start recording. 1098 // Now that the file thread has been started, start recording.
1099 MetricsService::SetExecutionPhase(MetricsService::START_METRICS_RECORDING);
1099 StartMetricsRecording(); 1100 StartMetricsRecording();
1100 #endif 1101 #endif
1101 1102
1102 // Create watchdog thread after creating all other threads because it will 1103 // Create watchdog thread after creating all other threads because it will
1103 // watch the other threads and they must be running. 1104 // watch the other threads and they must be running.
1104 browser_process_->watchdog_thread(); 1105 browser_process_->watchdog_thread();
1105 1106
1106 // Do any initializating in the browser process that requires all threads 1107 // Do any initializating in the browser process that requires all threads
1107 // running. 1108 // running.
1108 browser_process_->PreMainMessageLoopRun(); 1109 browser_process_->PreMainMessageLoopRun();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 return content::RESULT_CODE_NORMAL_EXIT; 1236 return content::RESULT_CODE_NORMAL_EXIT;
1236 #endif // defined(OS_WIN) 1237 #endif // defined(OS_WIN)
1237 } 1238 }
1238 1239
1239 // Profile creation ---------------------------------------------------------- 1240 // Profile creation ----------------------------------------------------------
1240 1241
1241 // Called before CreateProfile because creating the profile can trigger 1242 // Called before CreateProfile because creating the profile can trigger
1242 // calls to GetDefaultProfile(). 1243 // calls to GetDefaultProfile().
1243 ProfileManager::AllowGetDefaultProfile(); 1244 ProfileManager::AllowGetDefaultProfile();
1244 1245
1246 MetricsService::SetExecutionPhase(MetricsService::CREATE_PROFILE);
1245 profile_ = CreateProfile(parameters(), user_data_dir_, parsed_command_line()); 1247 profile_ = CreateProfile(parameters(), user_data_dir_, parsed_command_line());
1246 if (!profile_) 1248 if (!profile_)
1247 return content::RESULT_CODE_NORMAL_EXIT; 1249 return content::RESULT_CODE_NORMAL_EXIT;
1248 1250
1249 #if defined(ENABLE_BACKGROUND) 1251 #if defined(ENABLE_BACKGROUND)
1250 // Autoload any profiles which are running background apps. 1252 // Autoload any profiles which are running background apps.
1251 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. 1253 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075.
1252 browser_process_->profile_manager()->AutoloadProfiles(); 1254 browser_process_->profile_manager()->AutoloadProfiles();
1253 #endif 1255 #endif
1254 // Post-profile init --------------------------------------------------------- 1256 // Post-profile init ---------------------------------------------------------
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 extensions::StartupHelper extension_startup_helper; 1421 extensions::StartupHelper extension_startup_helper;
1420 if (extension_startup_helper.UninstallExtension( 1422 if (extension_startup_helper.UninstallExtension(
1421 parsed_command_line(), profile_)) 1423 parsed_command_line(), profile_))
1422 return content::RESULT_CODE_NORMAL_EXIT; 1424 return content::RESULT_CODE_NORMAL_EXIT;
1423 return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR; 1425 return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR;
1424 } 1426 }
1425 1427
1426 // Start watching for hangs during startup. We disarm this hang detector when 1428 // Start watching for hangs during startup. We disarm this hang detector when
1427 // ThreadWatcher takes over or when browser is shutdown or when 1429 // ThreadWatcher takes over or when browser is shutdown or when
1428 // startup_watcher_ is deleted. 1430 // startup_watcher_ is deleted.
1431 MetricsService::SetExecutionPhase(MetricsService::STARTUP_TIMEBOMB_ARM);
1429 startup_watcher_->Arm(base::TimeDelta::FromSeconds(300)); 1432 startup_watcher_->Arm(base::TimeDelta::FromSeconds(300));
1430 1433
1431 // On mobile, need for clean shutdown arises only when the application comes 1434 // On mobile, need for clean shutdown arises only when the application comes
1432 // to foreground (i.e. MetricsService::OnAppEnterForeground is called). 1435 // to foreground (i.e. MetricsService::OnAppEnterForeground is called).
1433 // http://crbug.com/179143 1436 // http://crbug.com/179143
1434 #if !defined(OS_ANDROID) 1437 #if !defined(OS_ANDROID)
1435 // Start watching for a hang. 1438 // Start watching for a hang.
1436 MetricsService::LogNeedForCleanShutdown(); 1439 MetricsService::LogNeedForCleanShutdown();
1437 #endif 1440 #endif
1438 1441
1439 #if defined(ENABLE_FULL_PRINTING) 1442 #if defined(ENABLE_FULL_PRINTING)
1440 // Create the instance of the cloud print proxy service so that it can launch 1443 // Create the instance of the cloud print proxy service so that it can launch
1441 // the service process if needed. This is needed because the service process 1444 // the service process if needed. This is needed because the service process
1442 // might have shutdown because an update was available. 1445 // might have shutdown because an update was available.
1443 // TODO(torne): this should maybe be done with 1446 // TODO(torne): this should maybe be done with
1444 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext() 1447 // BrowserContextKeyedServiceFactory::ServiceIsCreatedWithBrowserContext()
1445 // instead? 1448 // instead?
1446 CloudPrintProxyServiceFactory::GetForProfile(profile_); 1449 CloudPrintProxyServiceFactory::GetForProfile(profile_);
1447 #endif 1450 #endif
1448 1451
1449 // Start watching all browser threads for responsiveness. 1452 // Start watching all browser threads for responsiveness.
1453 MetricsService::SetExecutionPhase(MetricsService::THREAD_WATCHER_START);
1450 ThreadWatcherList::StartWatchingAll(parsed_command_line()); 1454 ThreadWatcherList::StartWatchingAll(parsed_command_line());
1451 1455
1452 #if !defined(DISABLE_NACL) 1456 #if !defined(DISABLE_NACL)
1453 if (parsed_command_line().HasSwitch(switches::kPnaclDir)) { 1457 if (parsed_command_line().HasSwitch(switches::kPnaclDir)) {
1454 PathService::Override(chrome::DIR_PNACL_BASE, 1458 PathService::Override(chrome::DIR_PNACL_BASE,
1455 parsed_command_line().GetSwitchValuePath( 1459 parsed_command_line().GetSwitchValuePath(
1456 switches::kPnaclDir)); 1460 switches::kPnaclDir));
1457 } 1461 }
1458 1462
1459 content::BrowserThread::PostTask( 1463 content::BrowserThread::PostTask(
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 DCHECK_EQ(base::MessageLoop::TYPE_UI, base::MessageLoop::current()->type()); 1615 DCHECK_EQ(base::MessageLoop::TYPE_UI, base::MessageLoop::current()->type());
1612 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS) 1616 #if !defined(USE_AURA) && defined(TOOLKIT_VIEWS)
1613 views::AcceleratorHandler accelerator_handler; 1617 views::AcceleratorHandler accelerator_handler;
1614 base::RunLoop run_loop(&accelerator_handler); 1618 base::RunLoop run_loop(&accelerator_handler);
1615 #else 1619 #else
1616 base::RunLoop run_loop; 1620 base::RunLoop run_loop;
1617 #endif 1621 #endif
1618 1622
1619 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle(); 1623 performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle();
1620 1624
1625 MetricsService::SetExecutionPhase(MetricsService::MAIN_MESSAGE_LOOP_RUN);
1621 run_loop.Run(); 1626 run_loop.Run();
1622 1627
1623 return true; 1628 return true;
1624 #endif 1629 #endif
1625 } 1630 }
1626 1631
1627 void ChromeBrowserMainParts::PostMainMessageLoopRun() { 1632 void ChromeBrowserMainParts::PostMainMessageLoopRun() {
1628 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun"); 1633 TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun");
1629 #if defined(OS_ANDROID) 1634 #if defined(OS_ANDROID)
1630 // Chrome on Android does not use default MessageLoop. It has its own 1635 // Chrome on Android does not use default MessageLoop. It has its own
1631 // Android specific MessageLoop 1636 // Android specific MessageLoop
1632 NOTREACHED(); 1637 NOTREACHED();
1633 #else 1638 #else
1634 1639
1635 // Start watching for jank during shutdown. It gets disarmed when 1640 // Start watching for jank during shutdown. It gets disarmed when
1636 // |shutdown_watcher_| object is destructed. 1641 // |shutdown_watcher_| object is destructed.
1642 MetricsService::SetExecutionPhase(MetricsService::SHUTDOWN_TIMEBOMB_ARM);
1637 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300)); 1643 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300));
1638 1644
1639 // Disarm the startup hang detector time bomb if it is still Arm'ed. 1645 // Disarm the startup hang detector time bomb if it is still Arm'ed.
1640 startup_watcher_->Disarm(); 1646 startup_watcher_->Disarm();
1641 1647
1642 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 1648 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
1643 chrome_extra_parts_[i]->PostMainMessageLoopRun(); 1649 chrome_extra_parts_[i]->PostMainMessageLoopRun();
1644 1650
1645 // Some tests don't set parameters.ui_task, so they started translate 1651 // Some tests don't set parameters.ui_task, so they started translate
1646 // language fetch that was never completed so we need to cleanup here 1652 // language fetch that was never completed so we need to cleanup here
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 chromeos::CrosSettings::Shutdown(); 1692 chromeos::CrosSettings::Shutdown();
1687 #endif 1693 #endif
1688 #endif 1694 #endif
1689 } 1695 }
1690 1696
1691 // Public members: 1697 // Public members:
1692 1698
1693 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 1699 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
1694 chrome_extra_parts_.push_back(parts); 1700 chrome_extra_parts_.push_back(parts);
1695 } 1701 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698