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

Unified Diff: content/browser/startup_task_runner.cc

Issue 25348004: Empty startup task queue when tasks run synchronously (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 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 | « no previous file | content/browser/startup_task_runner_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/startup_task_runner.cc
diff --git a/content/browser/startup_task_runner.cc b/content/browser/startup_task_runner.cc
index d1fc904d5266b1f7dcc48a913a1827578b158c8a..6fa630bde30f604d1b7f1d809a2a5e5148a74817 100644
--- a/content/browser/startup_task_runner.cc
+++ b/content/browser/startup_task_runner.cc
@@ -27,6 +27,8 @@ void StartupTaskRunner::StartRunningTasksAsync() {
if (task_list_.empty()) {
if (!startup_complete_callback_.is_null()) {
startup_complete_callback_.Run(result);
+ // Clear the callback to prevent it being called a second time
+ startup_complete_callback_ = base::Callback<void(int)>();
jam 2013/10/07 16:17:03 nit: startup_complete_callback_.Reset();
aberent 2013/10/10 13:56:36 Done.
}
} else {
const base::Closure next_task =
@@ -43,8 +45,11 @@ void StartupTaskRunner::RunAllTasksNow() {
result = it->Run();
if (result > 0) break;
}
+ task_list_.clear();
if (!startup_complete_callback_.is_null()) {
startup_complete_callback_.Run(result);
+ // Clear the callback to prevent it being called a second time
+ startup_complete_callback_ = base::Callback<void(int)>();
jam 2013/10/07 16:17:03 ditto
aberent 2013/10/10 13:56:36 Done.
}
}
@@ -57,9 +62,15 @@ void StartupTaskRunner::WrappedTask() {
}
int result = task_list_.front().Run();
task_list_.pop_front();
- if (result > 0 || task_list_.empty()) {
+ if (result > 0) {
+ // Stop now and throw away the remaining tasks
+ task_list_.clear();
+ }
+ if (task_list_.empty()) {
if (!startup_complete_callback_.is_null()) {
startup_complete_callback_.Run(result);
+ // Clear the callback to prevent it being called a second time
+ startup_complete_callback_ = base::Callback<void(int)>();
jam 2013/10/07 16:17:03 ditto
aberent 2013/10/10 13:56:36 Done.
}
} else {
const base::Closure next_task =
« no previous file with comments | « no previous file | content/browser/startup_task_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698