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

Unified Diff: chrome/browser/download/download_manager.cc

Issue 56096: Delete downloads after updating observers.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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/download/download_manager.cc
===================================================================
--- chrome/browser/download/download_manager.cc (revision 12799)
+++ chrome/browser/download/download_manager.cc (working copy)
@@ -1017,8 +1017,8 @@
const base::Time remove_end) {
RemoveDownloadsFromHistoryBetween(remove_begin, remove_end);
- int num_deleted = 0;
DownloadMap::iterator it = downloads_.begin();
+ std::vector<DownloadItem*> pending_deletes;
while (it != downloads_.end()) {
DownloadItem* download = it->second;
DownloadItem::DownloadState state = download->state();
@@ -1034,9 +1034,8 @@
if (dit != dangerous_finished_.end())
dangerous_finished_.erase(dit);
- delete download;
+ pending_deletes.push_back(download);
- ++num_deleted;
continue;
}
@@ -1044,9 +1043,14 @@
}
// Tell observers to refresh their views.
+ int num_deleted = static_cast<int>(pending_deletes.size());
if (num_deleted > 0)
FOR_EACH_OBSERVER(Observer, observers_, ModelChanged());
+ // Delete the download items after updating the observers.
+ STLDeleteContainerPointers(pending_deletes.begin(), pending_deletes.end());
+ pending_deletes.clear();
+
return num_deleted;
}
« 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