diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-01 17:30:18 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-01 17:30:18 +0000 |
commit | 47dbcd4e357f14f23ff42ffdd17a1711ee3d97f7 (patch) | |
tree | 4d13f330b293ea6a9a3e2659cb5547d97331c3b9 /chrome/browser/download/download_file_manager.h | |
parent | c8c34a1ec4df1022d6a23ce190f2504f7da3a159 (diff) | |
download | chromium_src-47dbcd4e357f14f23ff42ffdd17a1711ee3d97f7.zip chromium_src-47dbcd4e357f14f23ff42ffdd17a1711ee3d97f7.tar.gz chromium_src-47dbcd4e357f14f23ff42ffdd17a1711ee3d97f7.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.
TEST=unit_tests, browser_tests, ui_tests
BUG=48913
Review URL: http://codereview.chromium.org/3245005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58196 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/download_file_manager.h')
-rw-r--r-- | chrome/browser/download/download_file_manager.h | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/chrome/browser/download/download_file_manager.h b/chrome/browser/download/download_file_manager.h index 15e7d21..d51d35f 100644 --- a/chrome/browser/download/download_file_manager.h +++ b/chrome/browser/download/download_file_manager.h @@ -44,7 +44,6 @@ #include "base/basictypes.h" #include "base/hash_tables.h" -#include "base/lock.h" #include "base/ref_counted.h" #include "base/timer.h" #include "gfx/native_widget_types.h" @@ -75,16 +74,17 @@ class DownloadFileManager // Called on the IO thread int GetNextId(); + // Called on UI thread to make DownloadFileManager start the download. + void StartDownload(DownloadCreateInfo* info); + // Handlers for notifications sent from the IO thread and run on the // download thread. - void StartDownload(DownloadCreateInfo* info); void UpdateDownload(int id, DownloadBuffer* buffer); void CancelDownload(int id); void DownloadFinished(int id, DownloadBuffer* buffer); - // Called on the UI thread to remove a download item or manager. - void RemoveDownloadManager(DownloadManager* manager); - void RemoveDownload(int id, DownloadManager* manager); + // Called on FILE thread by DownloadManager at the beginning of its shutdown. + void OnDownloadManagerShutdown(DownloadManager* manager); #if !defined(OS_MACOSX) // The open and show methods run on the file thread, which does not work on @@ -125,22 +125,14 @@ class DownloadFileManager // Clean up helper that runs on the download thread. void OnShutdown(); - // Handlers for notifications sent from the download thread and run on - // the UI thread. - void OnStartDownload(DownloadCreateInfo* info); - void OnDownloadFinished(int id, int64 bytes_so_far); - - // Called only on UI thread to get the DownloadManager for a tab's profile. - static DownloadManager* DownloadManagerFromRenderIds(int render_process_id, - int review_view_id); - DownloadManager* GetDownloadManager(int download_id); + // Creates DownloadFile on FILE thread and continues starting the download + // process. + void CreateDownloadFile(DownloadCreateInfo* info, + DownloadManager* download_manager); // Called only on the download thread. DownloadFile* GetDownloadFile(int id); - // Called on the UI thread to remove a download from the UI progress table. - void RemoveDownloadFromUIProgress(int id); - // Called only from OnFinalDownloadName or OnIntermediateDownloadName // on the FILE thread. void CancelDownloadOnRename(int id); @@ -152,28 +144,12 @@ class DownloadFileManager typedef base::hash_map<int, DownloadFile*> DownloadFileMap; DownloadFileMap downloads_; - // Throttle updates to the UI thread. + // Schedule periodic updates of the download progress. This timer + // is controlled from the FILE thread, and posts updates to the UI thread. base::RepeatingTimer<DownloadFileManager> update_timer_; ResourceDispatcherHost* resource_dispatcher_host_; - // Tracking which DownloadManager to send data to, called only on UI thread. - // DownloadManagerMap maps download IDs to their DownloadManager. - typedef base::hash_map<int, DownloadManager*> DownloadManagerMap; - DownloadManagerMap managers_; - - // RequestMap maps a DownloadManager to all in-progress download IDs. - // Called only on the UI thread. - typedef base::hash_set<int> DownloadRequests; - typedef std::map<DownloadManager*, DownloadRequests> RequestMap; - RequestMap requests_; - - // Used for progress updates on the UI thread, mapping download->id() to bytes - // received so far. Written to by the file thread and read by the UI thread. - typedef base::hash_map<int, int64> ProgressMap; - ProgressMap ui_progress_; - Lock progress_lock_; - DISALLOW_COPY_AND_ASSIGN(DownloadFileManager); }; |