Chromium Code Reviews| Index: content/browser/download/download_manager_impl.h |
| diff --git a/content/browser/download/download_manager_impl.h b/content/browser/download/download_manager_impl.h |
| index 3efb1beb823e25159cdf7a9baa0631769da93f1d..6d5a752c8c6c21dfba4b1f6f1c982714bd4e8483 100644 |
| --- a/content/browser/download/download_manager_impl.h |
| +++ b/content/browser/download/download_manager_impl.h |
| @@ -23,17 +23,24 @@ |
| class DownloadFileManager; |
| class DownloadItemImpl; |
| +namespace content { |
| +class DownloadFileFactory; |
| +} |
| + |
| +namespace net { |
| +class BoundNetLog; |
| +} |
| + |
| class CONTENT_EXPORT DownloadManagerImpl |
| : public content::DownloadManager, |
| private DownloadItemImplDelegate { |
| public: |
| - // Caller guarantees that |file_manager| and |net_log| will remain valid |
| + // Caller guarantees that |net_log| will remain valid |
| // for the lifetime of DownloadManagerImpl (until Shutdown() is called). |
| // |factory| may be a default constructed (null) scoped_ptr; if so, |
| // the DownloadManagerImpl creates and takes ownership of the |
| // default DownloadItemFactory. |
| - DownloadManagerImpl(DownloadFileManager* file_manager, |
| - scoped_ptr<content::DownloadItemFactory> factory, |
| + DownloadManagerImpl(scoped_ptr<content::DownloadItemFactory> factory, |
| net::NetLog* net_log); |
| // Implementation functions (not part of the DownloadManager interface). |
| @@ -62,16 +69,7 @@ class CONTENT_EXPORT DownloadManagerImpl |
| virtual content::DownloadId StartDownload( |
| scoped_ptr<DownloadCreateInfo> info, |
| scoped_ptr<content::ByteStreamReader> stream) OVERRIDE; |
| - virtual void UpdateDownload(int32 download_id, |
| - int64 bytes_so_far, |
| - int64 bytes_per_sec, |
| - const std::string& hash_state) OVERRIDE; |
| - virtual void OnResponseCompleted(int32 download_id, int64 size, |
| - const std::string& hash) OVERRIDE; |
| virtual void CancelDownload(int32 download_id) OVERRIDE; |
| - virtual void OnDownloadInterrupted( |
| - int32 download_id, |
| - content::DownloadInterruptReason reason) OVERRIDE; |
| virtual int RemoveDownloadsBetween(base::Time remove_begin, |
| base::Time remove_end) OVERRIDE; |
| virtual int RemoveDownloads(base::Time remove_begin) OVERRIDE; |
| @@ -99,6 +97,11 @@ class CONTENT_EXPORT DownloadManagerImpl |
| virtual content::DownloadItem* GetActiveDownloadItem(int id) OVERRIDE; |
| virtual bool GenerateFileHash() OVERRIDE; |
| + // For testing; specifically, accessed from TestFileErrorInjector. |
| + virtual void SetDownloadFileFactoryForTesting( |
| + scoped_ptr<content::DownloadFileFactory> file_factory); |
| + virtual content::DownloadFileFactory* GetDownloadFileFactory(); |
|
Randy Smith (Not in Mondays)
2012/08/02 20:41:23
Add "ForTesting" suffix and change use inside DMI
Randy Smith (Not in Mondays)
2012/08/03 17:32:44
Done.
|
| + |
| private: |
| typedef std::set<content::DownloadItem*> DownloadSet; |
| typedef base::hash_map<int32, DownloadItemImpl*> DownloadMap; |
| @@ -113,8 +116,8 @@ class CONTENT_EXPORT DownloadManagerImpl |
| virtual ~DownloadManagerImpl(); |
| // Creates the download item. Must be called on the UI thread. |
| - // Returns the |BoundNetLog| used by the |DownloadItem|. |
| - virtual net::BoundNetLog CreateDownloadItem(DownloadCreateInfo* info); |
| + virtual DownloadItemImpl* CreateDownloadItem( |
| + DownloadCreateInfo* info, const net::BoundNetLog& bound_net_log); |
| // Does nothing if |download_id| is not an active download. |
| void MaybeCompleteDownloadById(int download_id); |
| @@ -161,12 +164,6 @@ class CONTENT_EXPORT DownloadManagerImpl |
| // Remove from internal maps. |
| int RemoveDownloadItems(const DownloadItemImplVector& pending_deletes); |
| - // Called in response to our request to the DownloadFileManager to |
| - // create a DownloadFile. A |reason| of |
| - // content::DOWNLOAD_INTERRUPT_REASON_NONE indicates success. |
| - void OnDownloadFileCreated( |
| - int32 download_id, content::DownloadInterruptReason reason); |
| - |
| // Called when a download entry is committed to the persistent store. |
| void OnDownloadItemAddedToPersistentStore(DownloadItemImpl* item); |
| @@ -175,6 +172,7 @@ class CONTENT_EXPORT DownloadManagerImpl |
| // Overridden from DownloadItemImplDelegate |
| // (Note that |GetBrowserContext| are present in both interfaces.) |
| + virtual void DelegateStart(DownloadItemImpl* item) OVERRIDE; |
| virtual bool ShouldOpenDownload(DownloadItemImpl* item) OVERRIDE; |
| virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE; |
| virtual void CheckForFileRemoval(DownloadItemImpl* download_item) OVERRIDE; |
| @@ -191,6 +189,9 @@ class CONTENT_EXPORT DownloadManagerImpl |
| // Factory for creation of downloads items. |
| scoped_ptr<content::DownloadItemFactory> factory_; |
| + // Factory for the creation of download files. |
| + scoped_ptr<content::DownloadFileFactory> file_factory_; |
| + |
| // |downloads_| is the owning set for all downloads known to the |
| // DownloadManager. This includes downloads started by the user in |
| // this session, downloads initialized from the history system, and |
| @@ -202,8 +203,7 @@ class CONTENT_EXPORT DownloadManagerImpl |
| // until destruction. |
| // |
| // |active_downloads_| is a map of all downloads that are currently being |
| - // processed. The key is the ID assigned by the DownloadFileManager, |
| - // which is unique for the current session. |
| + // processed. |
| // |
| // When a download is created through a user action, the corresponding |
| // DownloadItem* is placed in |active_downloads_| and remains there until the |
| @@ -227,9 +227,6 @@ class CONTENT_EXPORT DownloadManagerImpl |
| // The current active browser context. |
| content::BrowserContext* browser_context_; |
| - // Non-owning pointer for handling file writing on the download_thread_. |
| - DownloadFileManager* file_manager_; |
| - |
| // The user's last choice for download directory. This is only used when the |
| // user wants us to prompt for a save location for each download. |
| FilePath last_download_path_; |