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

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

Issue 5877003: Added clearing of downloads_ set on RemoveDownloadsBetween pathway. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc
index 076bf16581484cfe086d65b6c56a744a612192f6..58fc0bb98a2f32070f5b0804e9b5db424a227efa 100644
--- a/chrome/browser/download/download_manager.cc
+++ b/chrome/browser/download/download_manager.cc
@@ -719,6 +719,8 @@ int DownloadManager::RemoveDownloadsBetween(const base::Time remove_begin,
const base::Time remove_end) {
download_history_->RemoveEntriesBetween(remove_begin, remove_end);
+ // All downloads visible to the user will be in the history,
+ // so scan that map.
DownloadMap::iterator it = history_downloads_.begin();
std::vector<DownloadItem*> pending_deletes;
while (it != history_downloads_.end()) {
@@ -740,12 +742,21 @@ int DownloadManager::RemoveDownloadsBetween(const base::Time remove_begin,
++it;
}
cbentzel 2010/12/15 21:34:20 Would this be clearer if you did if (pending_dele
- // Tell observers to refresh their views.
+ // If we aren't deleting anything, we're done.
int num_deleted = static_cast<int>(pending_deletes.size());
- if (num_deleted > 0)
- NotifyModelChanged();
+ if (num_deleted == 0)
+ return num_deleted;
+
+ // Remove the chosen downloads from the main owning container.
+ for (std::vector<DownloadItem*>::iterator it = pending_deletes.begin();
+ it != pending_deletes.end(); it++) {
+ downloads_.erase(*it);
+ }
+
+ // Tell observers to refresh their views.
+ NotifyModelChanged();
- // Delete the download items after updating the observers.
+ // Delete the download items themselves.
STLDeleteContainerPointers(pending_deletes.begin(), pending_deletes.end());
pending_deletes.clear();
« 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