Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/public/browser/browser_main_runner.h" | 5 #include "content/public/browser/browser_main_runner.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/leak_annotations.h" | 9 #include "base/debug/leak_annotations.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/metrics/statistics_recorder.h" | 12 #include "base/metrics/statistics_recorder.h" |
| 13 #include "base/time/time.h" | |
| 13 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 14 #include "content/browser/browser_main_loop.h" | 15 #include "content/browser/browser_main_loop.h" |
| 15 #include "content/browser/browser_shutdown_profile_dumper.h" | 16 #include "content/browser/browser_shutdown_profile_dumper.h" |
| 16 #include "content/browser/notification_service_impl.h" | 17 #include "content/browser/notification_service_impl.h" |
| 17 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/common/main_function_params.h" | 19 #include "content/public/common/main_function_params.h" |
| 19 #include "ui/base/ime/input_method_initializer.h" | 20 #include "ui/base/ime/input_method_initializer.h" |
| 20 | 21 |
| 21 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 22 #include "base/win/win_util.h" | 23 #include "base/win/win_util.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 } | 105 } |
| 105 | 106 |
| 106 DWORD dummy = 0; | 107 DWORD dummy = 0; |
| 107 CHECK(::VirtualProtect(cert_verify_signature_ptr, 5, old_protect, &dummy)); | 108 CHECK(::VirtualProtect(cert_verify_signature_ptr, 5, old_protect, &dummy)); |
| 108 CHECK(::VirtualProtect(g_real_crypt_verify_signature_stub, | 109 CHECK(::VirtualProtect(g_real_crypt_verify_signature_stub, |
| 109 sidestep::kMaxPreambleStubSize, old_protect, | 110 sidestep::kMaxPreambleStubSize, old_protect, |
| 110 &old_protect)); | 111 &old_protect)); |
| 111 #endif // _WIN64 | 112 #endif // _WIN64 |
| 112 } | 113 } |
| 113 | 114 |
| 115 base::TimeTicks g_process_startup_ticks; | |
| 116 | |
| 114 } // namespace | 117 } // namespace |
| 115 | 118 |
| 116 #endif // OS_WIN | 119 #endif // OS_WIN |
| 117 | 120 |
| 118 class BrowserMainRunnerImpl : public BrowserMainRunner { | 121 class BrowserMainRunnerImpl : public BrowserMainRunner { |
| 119 public: | 122 public: |
| 120 BrowserMainRunnerImpl() | 123 BrowserMainRunnerImpl() |
| 121 : initialization_started_(false), is_shutdown_(false) {} | 124 : initialization_started_(false), is_shutdown_(false) {} |
| 122 | 125 |
| 123 ~BrowserMainRunnerImpl() override { | 126 ~BrowserMainRunnerImpl() override { |
| 124 if (initialization_started_ && !is_shutdown_) | 127 if (initialization_started_ && !is_shutdown_) |
| 125 Shutdown(); | 128 Shutdown(); |
| 126 } | 129 } |
| 127 | 130 |
| 128 int Initialize(const MainFunctionParams& parameters) override { | 131 int Initialize(const MainFunctionParams& parameters) override { |
| 129 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize"); | 132 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize"); |
| 130 // On Android we normally initialize the browser in a series of UI thread | 133 // On Android we normally initialize the browser in a series of UI thread |
| 131 // tasks. While this is happening a second request can come from the OS or | 134 // tasks. While this is happening a second request can come from the OS or |
| 132 // another application to start the browser. If this happens then we must | 135 // another application to start the browser. If this happens then we must |
| 133 // not run these parts of initialization twice. | 136 // not run these parts of initialization twice. |
| 134 if (!initialization_started_) { | 137 if (!initialization_started_) { |
| 135 initialization_started_ = true; | 138 initialization_started_ = true; |
| 136 | 139 |
| 140 g_process_startup_ticks = base::TimeTicks::Now(); | |
| 141 | |
| 137 #if !defined(OS_IOS) | 142 #if !defined(OS_IOS) |
| 138 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) | 143 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) |
| 139 base::debug::WaitForDebugger(60, true); | 144 base::debug::WaitForDebugger(60, true); |
| 140 #endif | 145 #endif |
| 141 | 146 |
| 142 #if defined(OS_WIN) | 147 #if defined(OS_WIN) |
| 143 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | 148 if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
| 144 // When "Extend support of advanced text services to all programs" | 149 // When "Extend support of advanced text services to all programs" |
| 145 // (a.k.a. Cicero Unaware Application Support; CUAS) is enabled on | 150 // (a.k.a. Cicero Unaware Application Support; CUAS) is enabled on |
| 146 // Windows XP and handwriting modules shipped with Office 2003 are | 151 // Windows XP and handwriting modules shipped with Office 2003 are |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 #endif | 281 #endif |
| 277 | 282 |
| 278 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); | 283 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); |
| 279 }; | 284 }; |
| 280 | 285 |
| 281 // static | 286 // static |
| 282 BrowserMainRunner* BrowserMainRunner::Create() { | 287 BrowserMainRunner* BrowserMainRunner::Create() { |
| 283 return new BrowserMainRunnerImpl(); | 288 return new BrowserMainRunnerImpl(); |
| 284 } | 289 } |
| 285 | 290 |
| 291 // TODO(michaeln): Where should this go and what signal should be used? | |
| 292 bool IsBrowserStartingUp() { | |
|
michaeln
2015/02/24 23:07:11
The startup metrics component tracks some stats li
| |
| 293 return base::TimeTicks::Now() - g_process_startup_ticks < | |
| 294 base::TimeDelta::FromSeconds(15); | |
| 295 } | |
| 296 | |
| 286 } // namespace content | 297 } // namespace content |
| OLD | NEW |