Index: content/browser/download/download_manager_impl.cc |
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc |
index ce33228f748c7f0ac84d63d8bb56d7fb38c1e1bc..094fbdf47b0c6d1ea992525fc560f587af36ea0f 100644 |
--- a/content/browser/download/download_manager_impl.cc |
+++ b/content/browser/download/download_manager_impl.cc |
@@ -322,13 +322,9 @@ void DownloadManagerImpl::Shutdown() { |
// and all in progress downloads have been cancelled. We can now delete |
// anything left. |
- // Copy downloads_ to separate container so as not to set off checks |
- // in DownloadItem destruction. |
- DownloadMap downloads_to_delete; |
- downloads_to_delete.swap(downloads_); |
- |
active_downloads_.clear(); |
- STLDeleteValues(&downloads_to_delete); |
+ STLDeleteValues(&downloads_); |
+ downloads_.clear(); |
// We'll have nothing more to report to the observers after this point. |
observers_.Clear(); |
@@ -618,13 +614,6 @@ void DownloadManagerImpl::OnResponseCompleted(int32 download_id, |
void DownloadManagerImpl::AssertStateConsistent( |
DownloadItemImpl* download) const { |
- if (download->GetState() == DownloadItem::REMOVING) { |
- DCHECK(!ContainsKey(downloads_, download->GetId())); |
- DCHECK(!ContainsKey(active_downloads_, download->GetId())); |
- return; |
- } |
- |
- // Should be in downloads_ if we're not REMOVING. |
CHECK(ContainsKey(downloads_, download->GetId())); |
int64 state = download->GetState(); |
@@ -783,20 +772,16 @@ int DownloadManagerImpl::RemoveDownloadItems( |
// Delete from internal maps. |
for (DownloadItemImplVector::const_iterator it = pending_deletes.begin(); |
- it != pending_deletes.end(); |
- ++it) { |
+ it != pending_deletes.end(); |
+ ++it) { |
DownloadItemImpl* download = *it; |
DCHECK(download); |
- downloads_.erase(download->GetId()); |
+ int32 download_id = download->GetId(); |
+ delete download; |
+ downloads_.erase(download_id); |
} |
- |
- // Tell observers to refresh their views. |
NotifyModelChanged(); |
- |
- // Delete the download items themselves. |
- const int num_deleted = static_cast<int>(pending_deletes.size()); |
- STLDeleteContainerPointers(pending_deletes.begin(), pending_deletes.end()); |
- return num_deleted; |
+ return static_cast<int>(pending_deletes.size()); |
} |
void DownloadManagerImpl::DownloadRemoved(DownloadItemImpl* download) { |
@@ -823,8 +808,6 @@ int DownloadManagerImpl::RemoveDownloadsBetween(base::Time remove_begin, |
if (delegate_) |
delegate_->RemoveItemsFromPersistentStoreBetween(remove_begin, remove_end); |
- // All downloads visible to the user will be in the history, |
- // so scan that map. |
DownloadItemImplVector pending_deletes; |
for (DownloadMap::const_iterator it = downloads_.begin(); |
it != downloads_.end(); |
@@ -835,6 +818,7 @@ int DownloadManagerImpl::RemoveDownloadsBetween(base::Time remove_begin, |
(remove_end.is_null() || download->GetStartTime() < remove_end) && |
(download->IsComplete() || download->IsCancelled())) { |
AssertStateConsistent(download); |
+ download->NotifyRemoved(); |
pending_deletes.push_back(download); |
} |
} |