Attempt at a crash fix in LazyBackgroundTaskQueue::ProcessPendingTasks.
According to windbg, it was crashing on this line:
it->Run(host);
My hypothesis is that one of the tasks modified the task list, corrupting
the iterator.
BUG=138790
TEST=no
Review URL: https://chromiumcodereview.appspot.com/10827003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148402 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/lazy_background_task_queue.cc b/chrome/browser/extensions/lazy_background_task_queue.cc
index b98d446..49bc222 100644
--- a/chrome/browser/extensions/lazy_background_task_queue.cc
+++ b/chrome/browser/extensions/lazy_background_task_queue.cc
@@ -115,14 +115,16 @@
return;
}
- PendingTasksList* tasks = map_it->second.get();
- for (PendingTasksList::const_iterator it = tasks->begin();
- it != tasks->end(); ++it) {
+ // Swap the pending tasks to a temporary, to avoid problems if the task
+ // list is modified during processing.
+ PendingTasksList tasks;
+ tasks.swap(*map_it->second);
+ for (PendingTasksList::const_iterator it = tasks.begin();
+ it != tasks.end(); ++it) {
it->Run(host);
}
- tasks->clear();
- pending_tasks_.erase(map_it);
+ pending_tasks_.erase(key);
// Balance the keepalive in AddPendingTask. Note we don't do this on a
// failure to load, because the keepalive count is reset in that case.