diff options
author | rdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 16:16:51 +0000 |
---|---|---|
committer | rdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 16:16:51 +0000 |
commit | 2bddd20716a1216576e2c27ecbfa24ccf03e200b (patch) | |
tree | 4c090849a59155ea2b8bc6186e4197082b1ba026 /content/browser/download/download_file_manager.h | |
parent | 9fcf07fa6ffef170b0708b0f9ad0911e0e78dc22 (diff) | |
download | chromium_src-2bddd20716a1216576e2c27ecbfa24ccf03e200b.zip chromium_src-2bddd20716a1216576e2c27ecbfa24ccf03e200b.tar.gz chromium_src-2bddd20716a1216576e2c27ecbfa24ccf03e200b.tar.bz2 |
Simplifiy download initiation.
Now, instead of a three-way dance between DownloadResourceHandler,
DownloadFileManager, and DownloadManager, DownloadResourceHandler tells
DownloadManager to start the download, and it calls out (with return callback)
to DownloadFileManager to create the DownloadFile.
BUG=132832
TEST=Refactor; existing tests should continue to work.
R=benjhayden@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10544161
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142728 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download/download_file_manager.h')
-rw-r--r-- | content/browser/download/download_file_manager.h | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/content/browser/download/download_file_manager.h b/content/browser/download/download_file_manager.h index a769946..7a961e5 100644 --- a/content/browser/download/download_file_manager.h +++ b/content/browser/download/download_file_manager.h @@ -77,6 +77,11 @@ class BoundNetLog; class CONTENT_EXPORT DownloadFileManager : public base::RefCountedThreadSafe<DownloadFileManager> { public: + // Callback used with CreateDownloadFile(). |reason| will be + // DOWNLOAD_INTERRUPT_REASON_NONE on a successful creation. + typedef base::Callback<void(content::DownloadInterruptReason reason)> + CreateDownloadFileCallback; + // Callback used with RenameInProgressDownloadFile() and // RenameCompletingDownloadFile(). typedef base::Callback<void(const FilePath&)> RenameCompletionCallback; @@ -88,7 +93,6 @@ class CONTENT_EXPORT DownloadFileManager virtual content::DownloadFile* CreateFile( DownloadCreateInfo* info, scoped_ptr<content::ByteStreamReader> stream, - const DownloadRequestHandle& request_handle, content::DownloadManager* download_manager, bool calculate_hash, const net::BoundNetLog& bound_net_log) = 0; @@ -99,15 +103,17 @@ class CONTENT_EXPORT DownloadFileManager // |DownloadFileFactory| to be used. explicit DownloadFileManager(DownloadFileFactory* factory); - // Called on shutdown on the UI thread. - virtual void Shutdown(); - - // Called on UI thread to make DownloadFileManager start the download. Creates - // and returns the DownloadId of the download. - virtual content::DownloadId StartDownload( + // Create a download file and record it in the download file manager. + virtual void CreateDownloadFile( scoped_ptr<DownloadCreateInfo> info, scoped_ptr<content::ByteStreamReader> stream, - const DownloadRequestHandle& request_handle); + scoped_refptr<content::DownloadManager> download_manager, + bool hash_needed, + const net::BoundNetLog& bound_net_log, + const CreateDownloadFileCallback& callback); + + // Called on shutdown on the UI thread. + virtual void Shutdown(); // Handlers for notifications sent from the UI thread and run on the // FILE thread. These are both terminal actions with respect to the @@ -175,15 +181,6 @@ class CONTENT_EXPORT DownloadFileManager // Clean up helper that runs on the download thread. void OnShutdown(); - // Creates DownloadFile on FILE thread and continues starting the download - // process. - void CreateDownloadFile(scoped_ptr<DownloadCreateInfo> info, - scoped_ptr<content::ByteStreamReader> stream, - const DownloadRequestHandle& request_handle, - content::DownloadManager* download_manager, - bool hash_needed, - const net::BoundNetLog& bound_net_log); - // Called only on the download thread. content::DownloadFile* GetDownloadFile(content::DownloadId global_id); |