diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 20:21:13 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-10 20:21:13 +0000 |
commit | 326a6a9153ad69dc7b62db8e218df7c9d0440a00 (patch) | |
tree | d418b49b4832b0b8dfb200ff90e349714b0aeebf /chrome/browser/download/download_manager.cc | |
parent | 670e362c28e8a92dda5dd537cca662d283ffc2a8 (diff) | |
download | chromium_src-326a6a9153ad69dc7b62db8e218df7c9d0440a00.zip chromium_src-326a6a9153ad69dc7b62db8e218df7c9d0440a00.tar.gz chromium_src-326a6a9153ad69dc7b62db8e218df7c9d0440a00.tar.bz2 |
GTTF: Clean up DownloadFileManager
This removes a lot of duplication, locking, and thread jumping.
Most of the operations run on the FILE thread, and we do not duplicate
so much information. Each DownloadFile keeps track of its DownloadManager
(each Profile has its own DownloadManager). This allows us to remove
many maps from DownloadFileManager that were duplicating that information.
There is still SaveFileManager, but hopefully I will be able
to merge those two in small steps.
Hopefully, this is http://codereview.chromium.org/3245005 done right.
TEST=unit_tests, browser_tests, ui_tests
BUG=48913
Review URL: http://codereview.chromium.org/3347018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59139 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/download_manager.cc')
-rw-r--r-- | chrome/browser/download/download_manager.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index ad9b604..5d503dd 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( |