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

Unified Diff: content/browser/browser_main_loop.cc

Issue 22691002: Allow overlapping sync and async startup requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow overlapping sync and async startup requests - fix code review Nits 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
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/browser_main_runner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/browser_main_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698