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

Unified Diff: chrome/browser/download/download_file_manager.h

Issue 3348010: Revert 58196 - GTTF: Clean up DownloadFileManager... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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_file.cc ('k') | chrome/browser/download/download_file_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_file_manager.h
===================================================================
--- chrome/browser/download/download_file_manager.h (revision 58717)
+++ chrome/browser/download/download_file_manager.h (working copy)
@@ -44,6 +44,7 @@
#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"
@@ -74,17 +75,16 @@
// 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 FILE thread by DownloadManager at the beginning of its shutdown.
- void OnDownloadManagerShutdown(DownloadManager* manager);
+ // Called on the UI thread to remove a download item or manager.
+ void RemoveDownloadManager(DownloadManager* manager);
+ void RemoveDownload(int id, DownloadManager* manager);
#if !defined(OS_MACOSX)
// The open and show methods run on the file thread, which does not work on
@@ -125,14 +125,22 @@
// Clean up helper that runs on the download thread.
void OnShutdown();
- // Creates DownloadFile on FILE thread and continues starting the download
- // process.
- void CreateDownloadFile(DownloadCreateInfo* info,
- DownloadManager* download_manager);
+ // 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);
+
// 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);
@@ -144,12 +152,28 @@
typedef base::hash_map<int, DownloadFile*> DownloadFileMap;
DownloadFileMap downloads_;
- // Schedule periodic updates of the download progress. This timer
- // is controlled from the FILE thread, and posts updates to the UI thread.
+ // Throttle 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);
};
« no previous file with comments | « chrome/browser/download/download_file.cc ('k') | chrome/browser/download/download_file_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698