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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/lazy_background_task_queue.h" 5 #include "chrome/browser/extensions/lazy_background_task_queue.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/browser/extensions/extension_host.h" 9 #include "chrome/browser/extensions/extension_host.h"
10 #include "chrome/browser/extensions/extension_process_manager.h" 10 #include "chrome/browser/extensions/extension_process_manager.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 !extension->has_lazy_background_page()) 108 !extension->has_lazy_background_page())
109 return; 109 return;
110 110
111 PendingTasksKey key(profile, extension->id()); 111 PendingTasksKey key(profile, extension->id());
112 PendingTasksMap::iterator map_it = pending_tasks_.find(key); 112 PendingTasksMap::iterator map_it = pending_tasks_.find(key);
113 if (map_it == pending_tasks_.end()) { 113 if (map_it == pending_tasks_.end()) {
114 CHECK(!host); // lazy page should not load without any pending tasks 114 CHECK(!host); // lazy page should not load without any pending tasks
115 return; 115 return;
116 } 116 }
117 117
118 PendingTasksList* tasks = map_it->second.get(); 118 // Swap the pending tasks to a temporary, to avoid problems if the task
119 for (PendingTasksList::const_iterator it = tasks->begin(); 119 // list is modified during processing.
120 it != tasks->end(); ++it) { 120 PendingTasksList tasks;
121 tasks.swap(*map_it->second);
122 for (PendingTasksList::const_iterator it = tasks.begin();
123 it != tasks.end(); ++it) {
121 it->Run(host); 124 it->Run(host);
122 } 125 }
123 126
124 tasks->clear(); 127 pending_tasks_.erase(key);
125 pending_tasks_.erase(map_it);
126 128
127 // Balance the keepalive in AddPendingTask. Note we don't do this on a 129 // Balance the keepalive in AddPendingTask. Note we don't do this on a
128 // failure to load, because the keepalive count is reset in that case. 130 // failure to load, because the keepalive count is reset in that case.
129 if (host) { 131 if (host) {
130 ExtensionSystem::Get(profile)->process_manager()-> 132 ExtensionSystem::Get(profile)->process_manager()->
131 DecrementLazyKeepaliveCount(extension); 133 DecrementLazyKeepaliveCount(extension);
132 } 134 }
133 } 135 }
134 136
135 void LazyBackgroundTaskQueue::Observe( 137 void LazyBackgroundTaskQueue::Observe(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 184 }
183 break; 185 break;
184 } 186 }
185 default: 187 default:
186 NOTREACHED(); 188 NOTREACHED();
187 break; 189 break;
188 } 190 }
189 } 191 }
190 192
191 } // namespace extensions 193 } // namespace extensions
OLDNEW
« 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