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

Unified Diff: chrome/browser/extensions/lazy_background_task_queue.cc

Issue 10827003: Attempt at a crash fix in LazyBackgroundTaskQueue::ProcessPendingTasks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/lazy_background_task_queue.cc
diff --git a/chrome/browser/extensions/lazy_background_task_queue.cc b/chrome/browser/extensions/lazy_background_task_queue.cc
index b98d44626be848a3a2db04c60ac4cb11ea981243..49bc2229325ce5ba975de4d76347a388a598e86d 100644
--- a/chrome/browser/extensions/lazy_background_task_queue.cc
+++ b/chrome/browser/extensions/lazy_background_task_queue.cc
@@ -115,14 +115,16 @@ void LazyBackgroundTaskQueue::ProcessPendingTasks(
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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698