Index: content/browser/browser_main_loop.cc |
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc |
index d7553cc1012b087b98ae0f232a879be3c0c12dae..4056b8aedfb4fda7d41c3fcab2371d02b10e161e 100644 |
--- a/content/browser/browser_main_loop.cc |
+++ b/content/browser/browser_main_loop.cc |
@@ -44,6 +44,7 @@ |
#include "content/public/common/content_switches.h" |
#include "content/public/common/main_function_params.h" |
#include "content/public/common/result_codes.h" |
+#include "content/public/common/startup_task_runner.h" |
#include "crypto/nss_util.h" |
#include "media/audio/audio_manager.h" |
#include "media/base/media.h" |
@@ -471,8 +472,8 @@ void BrowserMainLoop::MainMessageLoopStart() { |
} |
} |
-void BrowserMainLoop::CreateThreads() { |
- TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads") |
+ |
+void BrowserMainLoop::PreCreateThreads() { |
if (parts_) { |
TRACE_EVENT0("startup", |
@@ -497,9 +498,35 @@ void BrowserMainLoop::CreateThreads() { |
if (parsed_command_line_.HasSwitch(switches::kSingleProcess)) |
RenderProcessHost::SetRunRendererInProcess(true); |
#endif |
+} |
+ |
+void BrowserMainLoop::CreateStartupTasks( |
+ const scoped_refptr<StartupTaskRunner>& task_runner) { |
+ TRACE_EVENT0("startup", "BrowserMainLoop::CreateStartupTasks") |
+ |
+ task_runner->SetProxy(base::MessageLoop::current()->message_loop_proxy()); |
+ |
+ base::Closure pre_create_threads = |
+ base::Bind(&BrowserMainLoop::PreCreateThreads, base::Unretained(this)); |
+ task_runner->AddTask(pre_create_threads); |
- if (result_code_ > 0) |
- return; |
+ base::Closure create_threads = |
+ base::Bind(&BrowserMainLoop::CreateThreads, base::Unretained(this)); |
+ task_runner->AddTask(create_threads); |
+ |
+ base::Closure browser_thread_started = base::Bind( |
+ &BrowserMainLoop::BrowserThreadsStarted, base::Unretained(this)); |
+ task_runner->AddTask(browser_thread_started); |
+ |
+ base::Closure pre_main_message_loop_run = base::Bind( |
+ &BrowserMainLoop::PreMainMessageLoopRun, base::Unretained(this)); |
+ task_runner->AddTask(pre_main_message_loop_run); |
+ |
+ task_runner->StartRunningTasks(); |
+} |
+ |
+void BrowserMainLoop::CreateThreads() { |
+ TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads"); |
base::Thread::Options default_options; |
base::Thread::Options io_message_loop_options; |
@@ -585,13 +612,9 @@ void BrowserMainLoop::CreateThreads() { |
} |
-#if !defined(OS_IOS) |
- indexed_db_thread_.reset(new base::Thread("IndexedDB")); |
- indexed_db_thread_->Start(); |
-#endif |
- |
- BrowserThreadsStarted(); |
+} |
+void BrowserMainLoop::PreMainMessageLoopRun() { |
if (parts_) { |
TRACE_EVENT0("startup", |
"BrowserMainLoop::CreateThreads:PreMainMessageLoopRun"); |
@@ -753,6 +776,12 @@ void BrowserMainLoop::InitializeMainThread() { |
void BrowserMainLoop::BrowserThreadsStarted() { |
TRACE_EVENT0("startup", "BrowserMainLoop::BrowserThreadsStarted") |
+ |
+#if !defined(OS_IOS) |
+ indexed_db_thread_.reset(new base::Thread("IndexedDB")); |
+ indexed_db_thread_->Start(); |
+#endif |
+ |
#if defined(OS_ANDROID) |
// Up the priority of anything that touches with display tasks |
// (this thread is UI thread, and io_thread_ is for IPCs). |