diff options
author | aberent@chromium.org <aberent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-10 21:39:15 +0000 |
---|---|---|
committer | aberent@chromium.org <aberent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-10 21:39:15 +0000 |
commit | b07c081d2c6fa85a1918fd7fbe3abcd1f6d03aec (patch) | |
tree | b840d9fb694c873be55206bd4ac4306c60f7a6e4 /content/browser/startup_task_runner.cc | |
parent | f0b95fadf5e319f0f173b872cdfa16dda7772fc2 (diff) | |
download | chromium_src-b07c081d2c6fa85a1918fd7fbe3abcd1f6d03aec.zip chromium_src-b07c081d2c6fa85a1918fd7fbe3abcd1f6d03aec.tar.gz chromium_src-b07c081d2c6fa85a1918fd7fbe3abcd1f6d03aec.tar.bz2 |
Empty startup task queue when tasks run synchronously
Also empty it when a task fails, and ensure that callback is only
called once. Extend the tests to check all this.
TEST=content_unittests --gtest_filter='StartupTaskRunner*'
BUG=304108
Review URL: https://codereview.chromium.org/25348004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228010 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/startup_task_runner.cc')
-rw-r--r-- | content/browser/startup_task_runner.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/content/browser/startup_task_runner.cc b/content/browser/startup_task_runner.cc index d1fc904..4746afe 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_.Reset(); } } 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_.Reset(); } } @@ -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_.Reset(); } } else { const base::Closure next_task = |