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

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

Issue 3347018: GTTF: Clean up DownloadFileManager (Closed)
Patch Set: shutdowns Created 10 years, 3 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 | « chrome/browser/download/download_manager.h ('k') | chrome/browser/download/download_manager_unittest.cc » ('j') | 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 ad9b604303353c4273790daefedc4d57c4d9ac25..5d503ddfd87e75866266023d1cd1de10266b7d00 100644
--- a/chrome/browser/download/download_manager.cc
+++ b/chrome/browser/download/download_manager.cc
@@ -65,18 +65,22 @@ DownloadManager::DownloadManager()
}
DownloadManager::~DownloadManager() {
- FOR_EACH_OBSERVER(Observer, observers_, ManagerGoingDown());
-
- if (shutdown_needed_)
- Shutdown();
+ DCHECK(!shutdown_needed_);
}
void DownloadManager::Shutdown() {
- DCHECK(shutdown_needed_) << "Shutdown called when not needed.";
+ if (!shutdown_needed_)
+ return;
+ shutdown_needed_ = false;
- // Stop receiving download updates
- if (file_manager_)
- file_manager_->RemoveDownloadManager(this);
+ FOR_EACH_OBSERVER(Observer, observers_, ManagerGoingDown());
+
+ if (file_manager_) {
+ ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE,
+ NewRunnableMethod(file_manager_,
+ &DownloadFileManager::OnDownloadManagerShutdown,
+ this));
+ }
// 'in_progress_' may contain DownloadItems that have not finished the start
// complete (from the history service) and thus aren't in downloads_.
@@ -662,8 +666,6 @@ void DownloadManager::DownloadCancelledInternal(int download_id,
render_process_id,
request_id));
- // Tell the file manager to cancel the download.
- file_manager_->RemoveDownload(download_id, this); // On the UI thread
ChromeThread::PostTask(
ChromeThread::FILE, FROM_HERE,
NewRunnableMethod(
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | chrome/browser/download/download_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698