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(); |