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

Unified Diff: content/browser/download/download_manager_impl.h

Issue 10861002: Revert 152213 - Replace the DownloadFileManager with direct ownership of DownloadFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
Index: content/browser/download/download_manager_impl.h
===================================================================
--- content/browser/download/download_manager_impl.h (revision 152281)
+++ content/browser/download/download_manager_impl.h (working copy)
@@ -23,24 +23,17 @@
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 |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,
+ DownloadManagerImpl(DownloadFileManager* file_manager,
+ scoped_ptr<content::DownloadItemFactory> factory,
net::NetLog* net_log);
// Implementation functions (not part of the DownloadManager interface).
@@ -68,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;
@@ -91,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;
@@ -110,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);
@@ -153,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.
@@ -171,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;
@@ -186,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
@@ -202,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
@@ -226,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_;
« no previous file with comments | « content/browser/download/download_item_impl_unittest.cc ('k') | content/browser/download/download_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698