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

Side by Side Diff: content/browser/browser_main_runner.cc

Issue 949293002: Implement a poor man's PostAfterStartupTask() function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 "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"
18 #include "content/public/browser/browser_main_runner.h"
17 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
18 #include "content/public/common/main_function_params.h" 20 #include "content/public/common/main_function_params.h"
19 #include "ui/base/ime/input_method_initializer.h" 21 #include "ui/base/ime/input_method_initializer.h"
20 22
21 #if defined(OS_WIN) 23 #if defined(OS_WIN)
22 #include "base/win/win_util.h" 24 #include "base/win/win_util.h"
23 #include "base/win/windows_version.h" 25 #include "base/win/windows_version.h"
24 #include "net/cert/sha256_legacy_support_win.h" 26 #include "net/cert/sha256_legacy_support_win.h"
25 #include "sandbox/win/src/sidestep/preamble_patcher.h" 27 #include "sandbox/win/src/sidestep/preamble_patcher.h"
26 #include "ui/base/win/scoped_ole_initializer.h" 28 #include "ui/base/win/scoped_ole_initializer.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 106 }
105 107
106 DWORD dummy = 0; 108 DWORD dummy = 0;
107 CHECK(::VirtualProtect(cert_verify_signature_ptr, 5, old_protect, &dummy)); 109 CHECK(::VirtualProtect(cert_verify_signature_ptr, 5, old_protect, &dummy));
108 CHECK(::VirtualProtect(g_real_crypt_verify_signature_stub, 110 CHECK(::VirtualProtect(g_real_crypt_verify_signature_stub,
109 sidestep::kMaxPreambleStubSize, old_protect, 111 sidestep::kMaxPreambleStubSize, old_protect,
110 &old_protect)); 112 &old_protect));
111 #endif // _WIN64 113 #endif // _WIN64
112 } 114 }
113 115
116 base::TimeTicks g_process_startup_ticks;
117
114 } // namespace 118 } // namespace
115 119
116 #endif // OS_WIN 120 #endif // OS_WIN
117 121
118 class BrowserMainRunnerImpl : public BrowserMainRunner { 122 class BrowserMainRunnerImpl : public BrowserMainRunner {
119 public: 123 public:
120 BrowserMainRunnerImpl() 124 BrowserMainRunnerImpl()
121 : initialization_started_(false), is_shutdown_(false) {} 125 : initialization_started_(false), is_shutdown_(false) {}
122 126
123 ~BrowserMainRunnerImpl() override { 127 ~BrowserMainRunnerImpl() override {
124 if (initialization_started_ && !is_shutdown_) 128 if (initialization_started_ && !is_shutdown_)
125 Shutdown(); 129 Shutdown();
126 } 130 }
127 131
128 int Initialize(const MainFunctionParams& parameters) override { 132 int Initialize(const MainFunctionParams& parameters) override {
129 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize"); 133 TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize");
130 // On Android we normally initialize the browser in a series of UI thread 134 // 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 135 // 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 136 // another application to start the browser. If this happens then we must
133 // not run these parts of initialization twice. 137 // not run these parts of initialization twice.
134 if (!initialization_started_) { 138 if (!initialization_started_) {
135 initialization_started_ = true; 139 initialization_started_ = true;
136 140
141 g_process_startup_ticks = base::TimeTicks::Now();
142
137 #if !defined(OS_IOS) 143 #if !defined(OS_IOS)
138 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger)) 144 if (parameters.command_line.HasSwitch(switches::kWaitForDebugger))
139 base::debug::WaitForDebugger(60, true); 145 base::debug::WaitForDebugger(60, true);
140 #endif 146 #endif
141 147
142 #if defined(OS_WIN) 148 #if defined(OS_WIN)
143 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 149 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
144 // When "Extend support of advanced text services to all programs" 150 // When "Extend support of advanced text services to all programs"
145 // (a.k.a. Cicero Unaware Application Support; CUAS) is enabled on 151 // (a.k.a. Cicero Unaware Application Support; CUAS) is enabled on
146 // Windows XP and handwriting modules shipped with Office 2003 are 152 // Windows XP and handwriting modules shipped with Office 2003 are
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 #endif 282 #endif
277 283
278 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); 284 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl);
279 }; 285 };
280 286
281 // static 287 // static
282 BrowserMainRunner* BrowserMainRunner::Create() { 288 BrowserMainRunner* BrowserMainRunner::Create() {
283 return new BrowserMainRunnerImpl(); 289 return new BrowserMainRunnerImpl();
284 } 290 }
285 291
292 // TODO(michaeln): Where should this go and what signal should be used?
293 bool IsBrowserStartingUp() {
294 return base::TimeTicks::Now() - g_process_startup_ticks <
295 base::TimeDelta::FromSeconds(15);
cmumford 2015/02/26 23:47:45 Assuming the same 15 from above?
296 }
297
286 } // namespace content 298 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698