Index: content/browser/browser_main_loop.cc |
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc |
index 8bf6503759f041614a706826759a00df6844ed14..87bec3d9c1f74a5d793a1f168d73468f10070812 100644 |
--- a/content/browser/browser_main_loop.cc |
+++ b/content/browser/browser_main_loop.cc |
@@ -527,36 +527,53 @@ int BrowserMainLoop::PreCreateThreads() { |
} |
void BrowserMainLoop::CreateStartupTasks() { |
- TRACE_EVENT0("startup", "BrowserMainLoop::CreateStartupTasks") |
+ TRACE_EVENT0("startup", "BrowserMainLoop::CreateStartupTasks"); |
+ // First time through, we really want to create all the tasks |
+ if (!startup_task_runner_.get()) { |
#if defined(OS_ANDROID) |
- scoped_refptr<StartupTaskRunner> task_runner = |
- new StartupTaskRunner(BrowserMayStartAsynchronously(), |
- base::Bind(&BrowserStartupComplete), |
- base::MessageLoop::current()->message_loop_proxy()); |
+ startup_task_runner_ = make_scoped_ptr(new StartupTaskRunner( |
+ base::Bind(&BrowserStartupComplete), |
+ base::MessageLoop::current()->message_loop_proxy())); |
#else |
- scoped_refptr<StartupTaskRunner> task_runner = |
- new StartupTaskRunner(false, |
- base::Callback<void(int)>(), |
- base::MessageLoop::current()->message_loop_proxy()); |
+ startup_task_runner_ = make_scoped_ptr(new StartupTaskRunner( |
+ base::Callback<void(int)>(), |
+ base::MessageLoop::current()->message_loop_proxy())); |
#endif |
- StartupTask pre_create_threads = |
- base::Bind(&BrowserMainLoop::PreCreateThreads, base::Unretained(this)); |
- task_runner->AddTask(pre_create_threads); |
+ StartupTask pre_create_threads = |
+ base::Bind(&BrowserMainLoop::PreCreateThreads, base::Unretained(this)); |
+ startup_task_runner_->AddTask(pre_create_threads); |
- StartupTask create_threads = |
- base::Bind(&BrowserMainLoop::CreateThreads, base::Unretained(this)); |
- task_runner->AddTask(create_threads); |
+ StartupTask create_threads = |
+ base::Bind(&BrowserMainLoop::CreateThreads, base::Unretained(this)); |
+ startup_task_runner_->AddTask(create_threads); |
- StartupTask browser_thread_started = base::Bind( |
- &BrowserMainLoop::BrowserThreadsStarted, base::Unretained(this)); |
- task_runner->AddTask(browser_thread_started); |
+ StartupTask browser_thread_started = base::Bind( |
+ &BrowserMainLoop::BrowserThreadsStarted, base::Unretained(this)); |
+ startup_task_runner_->AddTask(browser_thread_started); |
- StartupTask pre_main_message_loop_run = base::Bind( |
- &BrowserMainLoop::PreMainMessageLoopRun, base::Unretained(this)); |
- task_runner->AddTask(pre_main_message_loop_run); |
+ StartupTask pre_main_message_loop_run = base::Bind( |
+ &BrowserMainLoop::PreMainMessageLoopRun, base::Unretained(this)); |
+ startup_task_runner_->AddTask(pre_main_message_loop_run); |
- task_runner->StartRunningTasks(); |
+#if defined(OS_ANDROID) |
+ if (BrowserMayStartAsynchronously()) { |
+ startup_task_runner_->StartRunningTasksAsync(); |
+ } |
+#endif |
+ } |
+#if defined(OS_ANDROID) |
+ if (!BrowserMayStartAsynchronously()) { |
+ // A second request for asynchronous startup can be ignored, so |
+ // StartupRunningTasksAsync is only called first time through. If, however, |
+ // this is a request for synchronous startup then it must override any |
+ // previous call for async startup, so we call RunAllTasksNow() |
+ // unconditionally. |
+ startup_task_runner_->RunAllTasksNow(); |
+ } |
+#else |
+ startup_task_runner_->RunAllTasksNow(); |
+#endif |
} |
int BrowserMainLoop::CreateThreads() { |