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

Unified Diff: content/browser/browser_main_runner.cc

Issue 22691002: Allow overlapping sync and async startup requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow multiple overlapping startup requests - update to merge with nyquist@'s patch Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_main_runner.cc
diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc
index 1a349a2e7cccb56176162951b77ffcc909e0ae06..fa9e59a8d5fd4c53da35f1d165558e899f62c5bd 100644
--- a/content/browser/browser_main_runner.cc
+++ b/content/browser/browser_main_runner.cc
@@ -30,75 +30,82 @@ namespace content {
class BrowserMainRunnerImpl : public BrowserMainRunner {
public:
- BrowserMainRunnerImpl() : is_initialized_(false), is_shutdown_(false) {}
+ BrowserMainRunnerImpl()
+ : initialization_started_(false), is_shutdown_(false) {}
virtual ~BrowserMainRunnerImpl() {
- if (is_initialized_ && !is_shutdown_)
+ if (initialization_started_ && !is_shutdown_)
Shutdown();
}
- virtual int Initialize(const MainFunctionParams& parameters)
- OVERRIDE {
- TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize")
- is_initialized_ = true;
+ virtual int Initialize(const MainFunctionParams& parameters) OVERRIDE {
+ TRACE_EVENT0("startup", "BrowserMainRunnerImpl::Initialize");
+ // On Android we normally initialize the browser in a series of UI thread
+ // tasks. While this is happening a second request can come from the OS or
+ // another application to start the browser. If this happens then we must
+ // not run these parts of initialization twice.
+ if (!initialization_started_) {
+ initialization_started_ = true;
#if !defined(OS_IOS)
- if (parameters.command_line.HasSwitch(switches::kWaitForDebugger))
- base::debug::WaitForDebugger(60, true);
+ if (parameters.command_line.HasSwitch(switches::kWaitForDebugger))
+ base::debug::WaitForDebugger(60, true);
#endif
#if defined(OS_WIN)
- if (parameters.command_line.HasSwitch(
- switches::kEnableTextServicesFramework)) {
- base::win::SetForceToUseTSF();
- } else if (base::win::GetVersion() < base::win::VERSION_VISTA) {
- // When "Extend support of advanced text services to all programs"
- // (a.k.a. Cicero Unaware Application Support; CUAS) is enabled on
- // Windows XP and handwriting modules shipped with Office 2003 are
- // installed, "penjpn.dll" and "skchui.dll" will be loaded and then crash
- // unless a user installs Office 2003 SP3. To prevent these modules from
- // being loaded, disable TSF entirely. crbug/160914.
- // TODO(yukawa): Add a high-level wrapper for this instead of calling
- // Win32 API here directly.
- ImmDisableTextFrameService(static_cast<DWORD>(-1));
- }
+ if (parameters.command_line.HasSwitch(
+ switches::kEnableTextServicesFramework)) {
+ base::win::SetForceToUseTSF();
+ } else if (base::win::GetVersion() < base::win::VERSION_VISTA) {
+ // When "Extend support of advanced text services to all programs"
+ // (a.k.a. Cicero Unaware Application Support; CUAS) is enabled on
+ // Windows XP and handwriting modules shipped with Office 2003 are
+ // installed, "penjpn.dll" and "skchui.dll" will be loaded and then
+ // crash
+ // unless a user installs Office 2003 SP3. To prevent these modules from
+ // being loaded, disable TSF entirely. crbug/160914.
+ // TODO(yukawa): Add a high-level wrapper for this instead of calling
+ // Win32 API here directly.
+ ImmDisableTextFrameService(static_cast<DWORD>(-1));
+ }
#endif // OS_WIN
- base::StatisticsRecorder::Initialize();
+ base::StatisticsRecorder::Initialize();
- notification_service_.reset(new NotificationServiceImpl);
+ notification_service_.reset(new NotificationServiceImpl);
#if defined(OS_WIN)
- // Ole must be initialized before starting message pump, so that TSF
- // (Text Services Framework) module can interact with the message pump
- // on Windows 8 Metro mode.
- ole_initializer_.reset(new ui::ScopedOleInitializer);
+ // Ole must be initialized before starting message pump, so that TSF
+ // (Text Services Framework) module can interact with the message pump
+ // on Windows 8 Metro mode.
+ ole_initializer_.reset(new ui::ScopedOleInitializer);
#endif // OS_WIN
- main_loop_.reset(new BrowserMainLoop(parameters));
+ main_loop_.reset(new BrowserMainLoop(parameters));
- main_loop_->Init();
+ main_loop_->Init();
- main_loop_->EarlyInitialization();
+ main_loop_->EarlyInitialization();
- // Must happen before we try to use a message loop or display any UI.
- main_loop_->InitializeToolkit();
+ // Must happen before we try to use a message loop or display any UI.
+ main_loop_->InitializeToolkit();
- main_loop_->MainMessageLoopStart();
+ main_loop_->MainMessageLoopStart();
- // WARNING: If we get a WM_ENDSESSION, objects created on the stack here
- // are NOT deleted. If you need something to run during WM_ENDSESSION add it
- // to browser_shutdown::Shutdown or BrowserProcess::EndSession.
+// WARNING: If we get a WM_ENDSESSION, objects created on the stack here
+// are NOT deleted. If you need something to run during WM_ENDSESSION add it
+// to browser_shutdown::Shutdown or BrowserProcess::EndSession.
#if defined(OS_WIN) && !defined(NO_TCMALLOC)
- // When linking shared libraries, NO_TCMALLOC is defined, and dynamic
- // allocator selection is not supported.
+ // When linking shared libraries, NO_TCMALLOC is defined, and dynamic
+ // allocator selection is not supported.
- // Make this call before going multithreaded, or spawning any subprocesses.
- base::allocator::SetupSubprocessAllocator();
+ // Make this call before going multithreaded, or spawning any
+ // subprocesses.
+ base::allocator::SetupSubprocessAllocator();
#endif
- ui::InitializeInputMethod();
-
+ ui::InitializeInputMethod();
+ }
main_loop_->CreateStartupTasks();
int result_code = main_loop_->GetResultCode();
if (result_code > 0)
@@ -116,14 +123,14 @@ class BrowserMainRunnerImpl : public BrowserMainRunner {
}
virtual int Run() OVERRIDE {
- DCHECK(is_initialized_);
+ DCHECK(initialization_started_);
DCHECK(!is_shutdown_);
main_loop_->RunMainMessageLoopParts();
return main_loop_->GetResultCode();
}
virtual void Shutdown() OVERRIDE {
- DCHECK(is_initialized_);
+ DCHECK(initialization_started_);
DCHECK(!is_shutdown_);
g_exited_main_message_loop = true;
@@ -147,7 +154,7 @@ class BrowserMainRunnerImpl : public BrowserMainRunner {
protected:
// True if the runner has been initialized.
Yaron 2013/08/22 06:00:26 Nit: update
aberent 2013/08/23 11:40:21 Done.
- bool is_initialized_;
+ bool initialization_started_;
// True if the runner has been shut down.
bool is_shutdown_;

Powered by Google App Engine
This is Rietveld 408576698