| Index: content/browser/download/download_manager_impl.h
|
| ===================================================================
|
| --- content/browser/download/download_manager_impl.h (revision 154444)
|
| +++ content/browser/download/download_manager_impl.h (working copy)
|
| @@ -15,6 +15,7 @@
|
| #include "base/observer_list.h"
|
| #include "base/sequenced_task_runner_helpers.h"
|
| #include "base/synchronization/lock.h"
|
| +#include "content/browser/download/download_item_factory.h"
|
| #include "content/browser/download/download_item_impl_delegate.h"
|
| #include "content/common/content_export.h"
|
| #include "content/public/browser/download_manager.h"
|
| @@ -22,26 +23,17 @@
|
| class DownloadFileManager;
|
| class DownloadItemImpl;
|
|
|
| -namespace content {
|
| -class DownloadItemFactory;
|
| -class DownloadFileFactory;
|
| -}
|
| -
|
| -namespace net {
|
| -class BoundNetLog;
|
| -}
|
| -
|
| class CONTENT_EXPORT DownloadManagerImpl
|
| : public content::DownloadManager,
|
| private DownloadItemImplDelegate {
|
| public:
|
| - // Caller guarantees that |net_log| will remain valid
|
| + // Caller guarantees that |file_manager| and |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(scoped_ptr<content::DownloadItemFactory> item_factory,
|
| - scoped_ptr<content::DownloadFileFactory> file_factory,
|
| + DownloadManagerImpl(DownloadFileManager* file_manager,
|
| + scoped_ptr<content::DownloadItemFactory> factory,
|
| net::NetLog* net_log);
|
|
|
| // Implementation functions (not part of the DownloadManager interface).
|
| @@ -69,7 +61,16 @@
|
| 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;
|
| @@ -92,11 +93,6 @@
|
| 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* GetDownloadFileFactoryForTesting();
|
| -
|
| private:
|
| typedef std::set<content::DownloadItem*> DownloadSet;
|
| typedef base::hash_map<int32, DownloadItemImpl*> DownloadMap;
|
| @@ -111,8 +107,8 @@
|
| virtual ~DownloadManagerImpl();
|
|
|
| // Creates the download item. Must be called on the UI thread.
|
| - virtual DownloadItemImpl* CreateDownloadItem(
|
| - DownloadCreateInfo* info, const net::BoundNetLog& bound_net_log);
|
| + // Returns the |BoundNetLog| used by the |DownloadItem|.
|
| + virtual net::BoundNetLog CreateDownloadItem(DownloadCreateInfo* info);
|
|
|
| // Does nothing if |download_id| is not an active download.
|
| void MaybeCompleteDownloadById(int download_id);
|
| @@ -154,6 +150,12 @@
|
| // 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 the delegate has completed determining the download target.
|
| // Arguments following |download_id| are as per
|
| // content::DownloadTargetCallback.
|
| @@ -172,7 +174,7 @@
|
|
|
| // Overridden from DownloadItemImplDelegate
|
| // (Note that |GetBrowserContext| are present in both interfaces.)
|
| - virtual void DelegateStart(DownloadItemImpl* item) OVERRIDE;
|
| + virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE;
|
| virtual bool ShouldOpenDownload(DownloadItemImpl* item) OVERRIDE;
|
| virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE;
|
| virtual void CheckForFileRemoval(DownloadItemImpl* download_item) OVERRIDE;
|
| @@ -187,11 +189,8 @@
|
| virtual void AssertStateConsistent(DownloadItemImpl* download) const OVERRIDE;
|
|
|
| // Factory for creation of downloads items.
|
| - scoped_ptr<content::DownloadItemFactory> item_factory_;
|
| + 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
|
| @@ -203,7 +202,8 @@
|
| // until destruction.
|
| //
|
| // |active_downloads_| is a map of all downloads that are currently being
|
| - // processed.
|
| + // processed. The key is the ID assigned by the DownloadFileManager,
|
| + // which is unique for the current session.
|
| //
|
| // When a download is created through a user action, the corresponding
|
| // DownloadItem* is placed in |active_downloads_| and remains there until the
|
| @@ -227,6 +227,9 @@
|
| // The current active browser context.
|
| content::BrowserContext* browser_context_;
|
|
|
| + // Non-owning pointer for handling file writing on the download_thread_.
|
| + DownloadFileManager* file_manager_;
|
| +
|
| // Allows an embedder to control behavior. Guaranteed to outlive this object.
|
| content::DownloadManagerDelegate* delegate_;
|
|
|
|
|