diff options
author | andrewhayden@chromium.org <andrewhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-03 10:55:43 +0000 |
---|---|---|
committer | andrewhayden@chromium.org <andrewhayden@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-03 10:55:43 +0000 |
commit | aa328c73297697e1d4846c0cb8ef7be7f8d80608 (patch) | |
tree | c855d573c138ce94c7d18ffff92b95780da543df | |
parent | b623b5f07d8e167f2cc2b79b5f7087b382dc2d2f (diff) | |
download | chromium_src-aa328c73297697e1d4846c0cb8ef7be7f8d80608.zip chromium_src-aa328c73297697e1d4846c0cb8ef7be7f8d80608.tar.gz chromium_src-aa328c73297697e1d4846c0cb8ef7be7f8d80608.tar.bz2 |
[Chromium] Add tracing to startup process, particularly for Android
BUG=222350
Review URL: https://chromiumcodereview.appspot.com/13820011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198078 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | android_webview/native/android_webview_jni_registrar.cc | 2 | ||||
-rw-r--r-- | base/android/base_jni_registrar.cc | 2 | ||||
-rw-r--r-- | base/android/jni_registrar.cc | 2 | ||||
-rw-r--r-- | chrome/app/android/chrome_main_delegate_android.cc | 2 | ||||
-rw-r--r-- | chrome/browser/android/chrome_jni_registrar.cc | 2 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main.cc | 60 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main_android.cc | 21 | ||||
-rw-r--r-- | content/app/android/content_main.cc | 2 | ||||
-rw-r--r-- | content/app/content_main_runner.cc | 20 | ||||
-rw-r--r-- | content/browser/browser_main_loop.cc | 66 | ||||
-rw-r--r-- | content/browser/browser_main_runner.cc | 1 | ||||
-rw-r--r-- | content/browser/gpu/gpu_data_manager_impl.cc | 8 | ||||
-rw-r--r-- | content/gpu/gpu_info_collector.cc | 2 |
13 files changed, 171 insertions, 19 deletions
diff --git a/android_webview/native/android_webview_jni_registrar.cc b/android_webview/native/android_webview_jni_registrar.cc index cc503e3..993ca7d 100644 --- a/android_webview/native/android_webview_jni_registrar.cc +++ b/android_webview/native/android_webview_jni_registrar.cc @@ -19,6 +19,7 @@ #include "android_webview/native/java_browser_view_renderer_helper.h" #include "base/android/jni_android.h" #include "base/android/jni_registrar.h" +#include "base/debug/trace_event.h" namespace android_webview { @@ -40,6 +41,7 @@ static base::android::RegistrationMethod kWebViewRegisteredMethods[] = { }; bool RegisterJni(JNIEnv* env) { + TRACE_EVENT0("startup", "android_webview::RegisterJni"); return RegisterNativeMethods(env, kWebViewRegisteredMethods, arraysize(kWebViewRegisteredMethods)); } diff --git a/base/android/base_jni_registrar.cc b/base/android/base_jni_registrar.cc index 1f0bc69..882938b 100644 --- a/base/android/base_jni_registrar.cc +++ b/base/android/base_jni_registrar.cc @@ -13,6 +13,7 @@ #include "base/android/path_service_android.h" #include "base/android/path_utils.h" #include "base/android/thread_utils.h" +#include "base/debug/trace_event.h" #include "base/message_pump_android.h" #include "base/power_monitor/power_monitor_android.h" @@ -32,6 +33,7 @@ static RegistrationMethod kBaseRegisteredMethods[] = { }; bool RegisterJni(JNIEnv* env) { + TRACE_EVENT0("startup", "base_android::RegisterJni"); return RegisterNativeMethods(env, kBaseRegisteredMethods, arraysize(kBaseRegisteredMethods)); } diff --git a/base/android/jni_registrar.cc b/base/android/jni_registrar.cc index fb39946..0f32089 100644 --- a/base/android/jni_registrar.cc +++ b/base/android/jni_registrar.cc @@ -4,6 +4,7 @@ #include "base/android/jni_registrar.h" +#include "base/debug/trace_event.h" #include "base/logging.h" #include "base/android/jni_android.h" @@ -13,6 +14,7 @@ namespace android { bool RegisterNativeMethods(JNIEnv* env, const RegistrationMethod* method, size_t count) { + TRACE_EVENT0("startup", "base_android::RegisterNativeMethods") const RegistrationMethod* end = method + count; while (method != end) { if (!method->func(env)) { diff --git a/chrome/app/android/chrome_main_delegate_android.cc b/chrome/app/android/chrome_main_delegate_android.cc index 8f6ffe2..81f4029 100644 --- a/chrome/app/android/chrome_main_delegate_android.cc +++ b/chrome/app/android/chrome_main_delegate_android.cc @@ -5,6 +5,7 @@ #include "chrome/app/android/chrome_main_delegate_android.h" #include "base/android/jni_android.h" +#include "base/debug/trace_event.h" #include "chrome/browser/android/chrome_jni_registrar.h" #include "chrome/browser/android/chrome_startup_flags.h" #include "content/public/browser/browser_main_runner.h" @@ -26,6 +27,7 @@ void ChromeMainDelegateAndroid::SandboxInitialized( int ChromeMainDelegateAndroid::RunProcess( const std::string& process_type, const content::MainFunctionParams& main_function_params) { + TRACE_EVENT0("startup", "ChromeMainDelegateAndroid::RunProcess") if (process_type.empty()) { JNIEnv* env = base::android::AttachCurrentThread(); RegisterApplicationNativeMethods(env); diff --git a/chrome/browser/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc index 50a2105..ff67496 100644 --- a/chrome/browser/android/chrome_jni_registrar.cc +++ b/chrome/browser/android/chrome_jni_registrar.cc @@ -6,6 +6,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_registrar.h" +#include "base/debug/trace_event.h" #include "chrome/browser/android/chrome_web_contents_delegate_android.h" #include "chrome/browser/android/content_view_util.h" #include "chrome/browser/android/dev_tools_server.h" @@ -74,6 +75,7 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = { }; bool RegisterJni(JNIEnv* env) { + TRACE_EVENT0("startup", "chrome_android::RegisterJni"); return RegisterNativeMethods(env, kChromeRegisteredMethods, arraysize(kChromeRegisteredMethods)); } diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 38c42ab7..f89afc8 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -239,6 +239,7 @@ PrefService* InitializeLocalState( base::SequencedTaskRunner* local_state_task_runner, const CommandLine& parsed_command_line, bool is_first_run) { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::InitializeLocalState") base::FilePath local_state_path; PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); bool local_state_file_exists = file_util::PathExists(local_state_path); @@ -334,6 +335,7 @@ base::FilePath GetStartupProfilePath(const base::FilePath& user_data_dir, Profile* CreateProfile(const content::MainFunctionParams& parameters, const base::FilePath& user_data_dir, const CommandLine& parsed_command_line) { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::CreateProfile") if (ProfileManager::IsMultipleProfilesEnabled() && parsed_command_line.HasSwitch(switches::kProfileDirectory)) { g_browser_process->local_state()->SetString(prefs::kProfileLastUsed, @@ -571,6 +573,7 @@ ChromeBrowserMainParts::~ChromeBrowserMainParts() { // This will be called after the command-line has been mutated by about:flags void ChromeBrowserMainParts::SetupMetricsAndFieldTrials() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::SetupMetricsAndFieldTrials"); // Must initialize metrics after labs have been converted into switches, // but before field trials are set up (so that client ID is available for // one-time randomized field trials). @@ -625,6 +628,7 @@ void ChromeBrowserMainParts::SetupMetricsAndFieldTrials() { // ChromeBrowserMainParts: |SetupMetricsAndFieldTrials()| related -------------- void ChromeBrowserMainParts::StartMetricsRecording() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::StartMetricsRecording"); MetricsService* metrics = g_browser_process->metrics_service(); // TODO(miu): Metrics reporting is disabled in DEBUG builds until ill-fired @@ -695,31 +699,37 @@ DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { // content::BrowserMainParts implementation ------------------------------------ void ChromeBrowserMainParts::PreEarlyInitialization() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreEarlyInitialization"); for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PreEarlyInitialization(); } void ChromeBrowserMainParts::PostEarlyInitialization() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostEarlyInitialization"); for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PostEarlyInitialization(); } void ChromeBrowserMainParts::ToolkitInitialized() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::ToolkitInitialized"); for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->ToolkitInitialized(); } void ChromeBrowserMainParts::PreMainMessageLoopStart() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopStart"); for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PreMainMessageLoopStart(); } void ChromeBrowserMainParts::PostMainMessageLoopStart() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopStart"); for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PostMainMessageLoopStart(); } int ChromeBrowserMainParts::PreCreateThreads() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreads"); result_code_ = PreCreateThreadsImpl(); // These members must be initialized before returning from this function. DCHECK(master_prefs_.get()); @@ -736,8 +746,13 @@ int ChromeBrowserMainParts::PreCreateThreads() { } int ChromeBrowserMainParts::PreCreateThreadsImpl() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreCreateThreadsImpl") run_message_loop_ = false; - user_data_dir_ = chrome::GetUserDataDir(parameters()); + { + TRACE_EVENT0("startup", + "ChromeBrowserMainParts::PreCreateThreadsImpl:GetUserDataDir"); + user_data_dir_ = chrome::GetUserDataDir(parameters()); + } // Whether this is First Run. |do_first_run_tasks_| should be prefered to this // unless the desire is actually to know whether this is really First Run @@ -763,10 +778,17 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { JsonPrefStore::GetTaskRunnerForFile( base::FilePath(chrome::kLocalStorePoolName), BrowserThread::GetBlockingPool()); - browser_process_.reset(new BrowserProcessImpl(local_state_task_runner, - parsed_command_line())); + + { + TRACE_EVENT0("startup", + "ChromeBrowserMainParts::PreCreateThreadsImpl:InitBrowswerProcessImpl"); + browser_process_.reset(new BrowserProcessImpl(local_state_task_runner, + parsed_command_line())); + } if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { + TRACE_EVENT0("startup", + "ChromeBrowserMainParts::PreCreateThreadsImpl:InitProfiling"); // User wants to override default tracking status. std::string flag = parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); @@ -804,8 +826,13 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { // ResourceBundle::InitSharedInstanceWithLocale as some loaded resources are // affected by experiment flags (--touch-optimized-ui in particular). Not // needed on Android as there aren't experimental flags. - about_flags::ConvertFlagsToSwitches(local_state_, - CommandLine::ForCurrentProcess()); + { + TRACE_EVENT0("startup", + "ChromeBrowserMainParts::PreCreateThreadsImpl:ConvertFlags"); + about_flags::ConvertFlagsToSwitches(local_state_, + CommandLine::ForCurrentProcess()); + } + local_state_->UpdateCommandLinePrefStore( new CommandLinePrefStore(CommandLine::ForCurrentProcess())); @@ -827,10 +854,17 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { #else const std::string locale = local_state_->GetString(prefs::kApplicationLocale); + // On a POSIX OS other than ChromeOS, the parameter that is passed to the // method InitSharedInstance is ignored. + + TRACE_EVENT_BEGIN0("startup", + "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); const std::string loaded_locale = ResourceBundle::InitSharedInstanceWithLocale(locale, NULL); + TRACE_EVENT_END0("startup", + "ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle"); + if (loaded_locale.empty() && !parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) { ShowMissingLocaleMessageBox(); @@ -841,8 +875,12 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { base::FilePath resources_pack_path; PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path); - ResourceBundle::GetSharedInstance().AddDataPackFromPath( - resources_pack_path, ui::SCALE_FACTOR_NONE); + { + TRACE_EVENT0("startup", + "ChromeBrowserMainParts::PreCreateThreadsImpl:AddDataPack"); + ResourceBundle::GetSharedInstance().AddDataPackFromPath( + resources_pack_path, ui::SCALE_FACTOR_NONE); + } #endif // defined(OS_MACOSX) } @@ -960,6 +998,7 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { } void ChromeBrowserMainParts::PreMainMessageLoopRun() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRun"); result_code_ = PreMainMessageLoopRunImpl(); for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) @@ -978,17 +1017,20 @@ void ChromeBrowserMainParts::PreMainMessageLoopRun() { // PostBrowserStart() void ChromeBrowserMainParts::PreProfileInit() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreProfileInit"); for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PreProfileInit(); } void ChromeBrowserMainParts::PostProfileInit() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostProfileInit"); LaunchDevToolsHandlerIfNeeded(profile(), parsed_command_line()); for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PostProfileInit(); } void ChromeBrowserMainParts::PreBrowserStart() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreBrowserStart"); for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PreBrowserStart(); @@ -996,6 +1038,7 @@ void ChromeBrowserMainParts::PreBrowserStart() { } void ChromeBrowserMainParts::PostBrowserStart() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostBrowserStart"); #if !defined(OS_ANDROID) if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kVisitURLs)) RunPageCycler(); @@ -1036,6 +1079,7 @@ void ChromeBrowserMainParts::SetupPlatformFieldTrials() { } int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreMainMessageLoopRunImpl"); #if !defined(OS_ANDROID) if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kTrackActiveVisitTime)) { @@ -1564,6 +1608,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { } bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::MainMessageLoopRun"); #if defined(OS_ANDROID) // Chrome on Android does not use default MessageLoop. It has its own // Android specific MessageLoop @@ -1602,6 +1647,7 @@ bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { } void ChromeBrowserMainParts::PostMainMessageLoopRun() { + TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopRun"); #if defined(OS_ANDROID) // Chrome on Android does not use default MessageLoop. It has its own // Android specific MessageLoop diff --git a/chrome/browser/chrome_browser_main_android.cc b/chrome/browser/chrome_browser_main_android.cc index 51cf9f2..ea68eb3 100644 --- a/chrome/browser/chrome_browser_main_android.cc +++ b/chrome/browser/chrome_browser_main_android.cc @@ -5,6 +5,7 @@ #include "chrome/browser/chrome_browser_main_android.h" #include "base/command_line.h" +#include "base/debug/trace_event.h" #include "base/path_service.h" #include "cc/base/switches.h" #include "chrome/app/breakpad_linux.h" @@ -26,6 +27,7 @@ ChromeBrowserMainPartsAndroid::~ChromeBrowserMainPartsAndroid() { } void ChromeBrowserMainPartsAndroid::PreProfileInit() { + TRACE_EVENT0("startup", "ChromeBrowserMainPartsAndroid::PreProfileInit") #if defined(USE_LINUX_BREAKPAD) #if defined(GOOGLE_CHROME_BUILD) // TODO(jcivelli): we should not initialize the crash-reporter when it was not @@ -51,6 +53,8 @@ void ChromeBrowserMainPartsAndroid::PreProfileInit() { } void ChromeBrowserMainPartsAndroid::PreEarlyInitialization() { + TRACE_EVENT0("startup", + "ChromeBrowserMainPartsAndroid::PreEarlyInitialization") net::NetworkChangeNotifier::SetFactory( new net::NetworkChangeNotifierFactoryAndroid()); @@ -59,8 +63,20 @@ void ChromeBrowserMainPartsAndroid::PreEarlyInitialization() { // Chrome on Android does not use default MessageLoop. It has its own // Android specific MessageLoop. DCHECK(!main_message_loop_.get()); - main_message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI)); - MessageLoopForUI::current()->Start(); + + // Create and start the MessageLoop. + // This is a critical point in the startup process. + { + TRACE_EVENT0("startup", + "ChromeBrowserMainPartsAndroid::PreEarlyInitialization:CreateUiMsgLoop"); + main_message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI)); + } + + { + TRACE_EVENT0("startup", + "ChromeBrowserMainPartsAndroid::PreEarlyInitialization:StartUiMsgLoop"); + MessageLoopForUI::current()->Start(); + } CommandLine::ForCurrentProcess()->AppendSwitch( cc::switches::kCompositeToMailbox); @@ -69,6 +85,7 @@ void ChromeBrowserMainPartsAndroid::PreEarlyInitialization() { } int ChromeBrowserMainPartsAndroid::PreCreateThreads() { + TRACE_EVENT0("startup", "ChromeBrowserMainPartsAndroid::PreCreateThreads") // PreCreateThreads initializes ResourceBundle instance. const int result = ChromeBrowserMainParts::PreCreateThreads(); diff --git a/content/app/android/content_main.cc b/content/app/android/content_main.cc index 4059de4..e9cd1fd 100644 --- a/content/app/android/content_main.cc +++ b/content/app/android/content_main.cc @@ -7,6 +7,7 @@ #include "base/at_exit.h" #include "base/base_switches.h" #include "base/command_line.h" +#include "base/debug/trace_event.h" #include "base/lazy_instance.h" #include "content/public/app/content_main.h" #include "content/public/app/content_main_delegate.h" @@ -35,6 +36,7 @@ static void InitApplicationContext(JNIEnv* env, jclass clazz, jobject context) { } static jint Start(JNIEnv* env, jclass clazz) { + TRACE_EVENT0("startup", "content::Start"); const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); // This is only for browser process. We want to start waiting as early as diff --git a/content/app/content_main_runner.cc b/content/app/content_main_runner.cc index 0c054fb..9f1947a 100644 --- a/content/app/content_main_runner.cc +++ b/content/app/content_main_runner.cc @@ -507,6 +507,13 @@ class ContentMainRunnerImpl : public ContentMainRunner { const char** argv, ContentMainDelegate* delegate) OVERRIDE { +#if defined(OS_ANDROID) + // See note at the initialization of ExitManager, below; basically, + // only Android builds have the ctor/dtor handlers set up to use + // TRACE_EVENT right away. + TRACE_EVENT0("startup", "ContentMainRunnerImpl::Initialize"); +#endif // OS_ANDROID + // NOTE(willchan): One might ask why these TCMalloc-related calls are done // here rather than in process_util_linux.cc with the definition of // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a @@ -576,6 +583,8 @@ class ContentMainRunnerImpl : public ContentMainRunner { // The exit manager is in charge of calling the dtors of singleton objects. // On Android, AtExitManager is set up when library is loaded. // On iOS, it's set up in main(), which can't call directly through to here. + // A consequence of this is that you can't use the ctor/dtor-based + // TRACE_EVENT methods on Linux or iOS builds till after we set this up. #if !defined(OS_ANDROID) && !defined(OS_IOS) exit_manager_.reset(new base::AtExitManager); #endif // !OS_ANDROID && !OS_IOS @@ -588,10 +597,11 @@ class ContentMainRunnerImpl : public ContentMainRunner { autorelease_pool_.reset(new base::mac::ScopedNSAutoreleasePool()); #endif - // On Android, the command line is initialized when library is loaded. + // On Android, the command line is initialized when library is loaded and + // we have already started our TRACE_EVENT0. #if !defined(OS_ANDROID) CommandLine::Init(argc, argv); -#endif +#endif // !OS_ANDROID int exit_code; if (delegate && delegate->BasicStartupComplete(&exit_code)) @@ -622,6 +632,12 @@ class ContentMainRunnerImpl : public ContentMainRunner { category_filter, base::debug::TraceLog::RECORD_UNTIL_FULL); } +#if !defined(OS_ANDROID) + // Android tracing started at the beginning of the method. + // Other OSes have to wait till we get here in order for all the memory + // management setup to be completed. + TRACE_EVENT0("startup", "ContentMainRunnerImpl::Initialize"); +#endif // !OS_ANDROID #if defined(OS_MACOSX) && !defined(OS_IOS) // We need to allocate the IO Ports before the Sandbox is initialized or diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index e92a698..bc6e7f2 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc @@ -293,6 +293,7 @@ BrowserMainLoop::~BrowserMainLoop() { } void BrowserMainLoop::Init() { + TRACE_EVENT0("startup", "BrowserMainLoop::Init") parts_.reset( GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); } @@ -300,6 +301,7 @@ void BrowserMainLoop::Init() { // BrowserMainLoop stages ================================================== void BrowserMainLoop::EarlyInitialization() { + TRACE_EVENT0("startup", "BrowserMainLoop::EarlyInitialization") #if defined(USE_X11) if (parsed_command_line_.HasSwitch(switches::kSingleProcess) || parsed_command_line_.HasSwitch(switches::kInProcessGPU)) { @@ -344,8 +346,12 @@ void BrowserMainLoop::EarlyInitialization() { } void BrowserMainLoop::MainMessageLoopStart() { - if (parts_) + TRACE_EVENT0("startup", "BrowserMainLoop::MainMessageLoopStart") + if (parts_) { + TRACE_EVENT0("startup", + "BrowserMainLoop::MainMessageLoopStart:PreMainMessageLoopStart"); parts_->PreMainMessageLoopStart(); + } #if defined(OS_WIN) // If we're running tests (ui_task is non-null), then the ResourceBundle @@ -410,8 +416,13 @@ void BrowserMainLoop::MainMessageLoopStart() { } void BrowserMainLoop::CreateThreads() { - if (parts_) + TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads") + + if (parts_) { + TRACE_EVENT0("startup", + "BrowserMainLoop::MainMessageLoopStart:PreCreateThreads"); result_code_ = parts_->PreCreateThreads(); + } #if !defined(OS_IOS) && (!defined(GOOGLE_CHROME_BUILD) || defined(OS_ANDROID)) // Single-process is an unsupported and not fully tested mode, so @@ -442,16 +453,28 @@ void BrowserMainLoop::CreateThreads() { switch (thread_id) { case BrowserThread::DB: + TRACE_EVENT_BEGIN1("startup", + "BrowserMainLoop::CreateThreads:start", + "Thread", "BrowserThread::DB"); thread_to_start = &db_thread_; break; case BrowserThread::WEBKIT_DEPRECATED: // Special case as WebKitThread is a separate // type. |thread_to_start| is not used in this case. + TRACE_EVENT_BEGIN1("startup", + "BrowserMainLoop::CreateThreads:start", + "Thread", "BrowserThread::WEBKIT_DEPRECATED"); break; case BrowserThread::FILE_USER_BLOCKING: + TRACE_EVENT_BEGIN1("startup", + "BrowserMainLoop::CreateThreads:start", + "Thread", "BrowserThread::FILE_USER_BLOCKING"); thread_to_start = &file_user_blocking_thread_; break; case BrowserThread::FILE: + TRACE_EVENT_BEGIN1("startup", + "BrowserMainLoop::CreateThreads:start", + "Thread", "BrowserThread::FILE"); thread_to_start = &file_thread_; #if defined(OS_WIN) // On Windows, the FILE thread needs to be have a UI message loop @@ -463,13 +486,22 @@ void BrowserMainLoop::CreateThreads() { #endif break; case BrowserThread::PROCESS_LAUNCHER: + TRACE_EVENT_BEGIN1("startup", + "BrowserMainLoop::CreateThreads:start", + "Thread", "BrowserThread::PROCESS_LAUNCHER"); thread_to_start = &process_launcher_thread_; break; case BrowserThread::CACHE: + TRACE_EVENT_BEGIN1("startup", + "BrowserMainLoop::CreateThreads:start", + "Thread", "BrowserThread::CACHE"); thread_to_start = &cache_thread_; options = &io_message_loop_options; break; case BrowserThread::IO: + TRACE_EVENT_BEGIN1("startup", + "BrowserMainLoop::CreateThreads:start", + "Thread", "BrowserThread::IO"); thread_to_start = &io_thread_; options = &io_message_loop_options; break; @@ -493,12 +525,18 @@ void BrowserMainLoop::CreateThreads() { } else { NOTREACHED(); } + + TRACE_EVENT_END0("startup", "BrowserMainLoop::CreateThreads:start"); + } BrowserThreadsStarted(); - if (parts_) + if (parts_) { + TRACE_EVENT0("startup", + "BrowserMainLoop::CreateThreads:PreMainMessageLoopRun"); parts_->PreMainMessageLoopRun(); + } // If the UI thread blocks, the whole UI is unresponsive. // Do not allow disk IO from the UI thread. @@ -686,6 +724,7 @@ void SetHighThreadPriority() { #endif void BrowserMainLoop::BrowserThreadsStarted() { + TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted") #if defined(OS_ANDROID) // TODO(epenner): Move thread priorities to base. (crbug.com/170549) BrowserThread::PostTask(BrowserThread::UI, @@ -710,11 +749,19 @@ void BrowserMainLoop::BrowserThreadsStarted() { device_monitor_mac_.reset(new DeviceMonitorMac()); #endif - // RDH needs the IO thread to be created. - resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); + // RDH needs the IO thread to be created + { + TRACE_EVENT0("startup", + "BrowserMainLoop::BrowserThreadsStarted:InitResourceDispatcherHost"); + resource_dispatcher_host_.reset(new ResourceDispatcherHostImpl()); + } // MediaStreamManager needs the IO thread to be created. - media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); + { + TRACE_EVENT0("startup", + "BrowserMainLoop::BrowserThreadsStarted:InitMediaStreamManager"); + media_stream_manager_.reset(new MediaStreamManager(audio_manager_.get())); + } // Initialize the GpuDataManager before we set up the MessageLoops because // otherwise we'll trigger the assertion about doing IO on the UI thread. @@ -722,7 +769,11 @@ void BrowserMainLoop::BrowserThreadsStarted() { #endif // !OS_IOS #if defined(ENABLE_INPUT_SPEECH) - speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl()); + { + TRACE_EVENT0("startup", + "BrowserMainLoop::BrowserThreadsStarted:InitSpeechRecognition"); + speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl()); + } #endif #if !defined(OS_IOS) @@ -758,6 +809,7 @@ void BrowserMainLoop::BrowserThreadsStarted() { } void BrowserMainLoop::InitializeToolkit() { + TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit") // TODO(evan): this function is rather subtle, due to the variety // of intersecting ifdefs we have. To keep it easy to follow, there // are no #else branches on any #ifs. diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc index c283db9..175b62f 100644 --- a/content/browser/browser_main_runner.cc +++ b/content/browser/browser_main_runner.cc @@ -43,6 +43,7 @@ class BrowserMainRunnerImpl : public BrowserMainRunner { virtual int Initialize(const MainFunctionParams& parameters) OVERRIDE { + TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize") is_initialized_ = true; #if !defined(OS_IOS) diff --git a/content/browser/gpu/gpu_data_manager_impl.cc b/content/browser/gpu/gpu_data_manager_impl.cc index 5863e22..1ac0c17 100644 --- a/content/browser/gpu/gpu_data_manager_impl.cc +++ b/content/browser/gpu/gpu_data_manager_impl.cc @@ -11,6 +11,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" +#include "base/debug/trace_event.h" #include "base/file_util.h" #include "base/metrics/field_trial.h" #include "base/metrics/histogram.h" @@ -311,12 +312,17 @@ void GpuDataManagerImpl::GetGLStrings(std::string* gl_vendor, void GpuDataManagerImpl::Initialize() { + TRACE_EVENT0("startup", "GpuDataManagerImpl::Initialize"); CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kSkipGpuDataLoading)) return; GPUInfo gpu_info; - gpu_info_collector::CollectBasicGraphicsInfo(&gpu_info); + { + TRACE_EVENT0("startup", + "GpuDataManagerImpl::Initialize:CollectBasicGraphicsInfo"); + gpu_info_collector::CollectBasicGraphicsInfo(&gpu_info); + } #if defined(ARCH_CPU_X86_FAMILY) if (!gpu_info.gpu.vendor_id || !gpu_info.gpu.device_id) gpu_info.finalized = true; diff --git a/content/gpu/gpu_info_collector.cc b/content/gpu/gpu_info_collector.cc index 1197812..0d51b69 100644 --- a/content/gpu/gpu_info_collector.cc +++ b/content/gpu/gpu_info_collector.cc @@ -7,6 +7,7 @@ #include <string> #include <vector> +#include "base/debug/trace_event.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/string_number_conversions.h" @@ -79,6 +80,7 @@ std::string GetVersionFromString(const std::string& version_string) { namespace gpu_info_collector { bool CollectGraphicsInfoGL(content::GPUInfo* gpu_info) { + TRACE_EVENT0("startup", "gpu_info_collector::CollectGraphicsInfoGL"); if (!gfx::GLSurface::InitializeOneOff()) { LOG(ERROR) << "gfx::GLSurface::InitializeOneOff() failed"; return false; |