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

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

Issue 10912173: Replace the DownloadFileManager with direct ownership of DownloadFileImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to LKGR (r162700) Created 8 years, 2 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
diff --git a/content/browser/download/download_manager_impl.h b/content/browser/download/download_manager_impl.h
index bd52481b4e2142b8efb5f64ad698c87ebff30a51..be1a701810b4381a41ed1191cb68bee66280490b 100644
--- a/content/browser/download/download_manager_impl.h
+++ b/content/browser/download/download_manager_impl.h
@@ -15,7 +15,6 @@
#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"
@@ -23,18 +22,22 @@
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 |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,
- net::NetLog* net_log);
+ DownloadManagerImpl(net::NetLog* net_log);
// Implementation functions (not part of the DownloadManager interface).
@@ -56,16 +59,7 @@ class CONTENT_EXPORT DownloadManagerImpl
virtual content::DownloadItem* 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;
@@ -85,6 +79,13 @@ class CONTENT_EXPORT DownloadManagerImpl
virtual void SavePageDownloadFinished(
content::DownloadItem* download) OVERRIDE;
+ // For testing; specifically, accessed from TestFileErrorInjector.
+ void SetDownloadItemFactoryForTesting(
+ scoped_ptr<content::DownloadItemFactory> item_factory);
+ 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;
@@ -99,8 +100,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);
// Show the download in the browser.
void ShowDownloadInBrowser(DownloadItemImpl* download);
@@ -134,22 +135,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 the delegate has completed determining the download target.
- // Arguments following |download_id| are as per
- // content::DownloadTargetCallback.
- void OnDownloadTargetDetermined(
- int32 download_id,
- const FilePath& target_path,
- content::DownloadItem::TargetDisposition disposition,
- content::DownloadDangerType danger_type,
- const FilePath& intermediate_path);
-
// Called when a download entry is committed to the persistent store.
void OnDownloadItemAddedToPersistentStore(DownloadItemImpl* item);
@@ -158,7 +143,8 @@ class CONTENT_EXPORT DownloadManagerImpl
// Overridden from DownloadItemImplDelegate
// (Note that |GetBrowserContext| are present in both interfaces.)
- virtual DownloadFileManager* GetDownloadFileManager() OVERRIDE;
+ virtual void DetermineDownloadTarget(
+ DownloadItemImpl* item, const DownloadTargetCallback& callback) OVERRIDE;
virtual void ReadyForDownloadCompletion(
DownloadItemImpl* item, const base::Closure& complete_callback) OVERRIDE;
virtual bool ShouldOpenFileBasedOnExtension(const FilePath& path) OVERRIDE;
@@ -175,7 +161,10 @@ class CONTENT_EXPORT DownloadManagerImpl
virtual void AssertStateConsistent(DownloadItemImpl* download) const OVERRIDE;
// Factory for creation of downloads items.
- scoped_ptr<content::DownloadItemFactory> factory_;
+ scoped_ptr<content::DownloadItemFactory> item_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
@@ -188,8 +177,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
@@ -213,9 +201,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_;
-
// 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