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

Unified Diff: content/browser/download/download_file_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
« no previous file with comments | « content/browser/download/download_file_factory.cc ('k') | content/browser/download/download_file_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_file_impl.h
diff --git a/content/browser/download/download_file_impl.h b/content/browser/download/download_file_impl.h
index 47289f8083eba966cd48c3408c5decb43ca8ccc1..11424aff2e36f44fc28b1c446d829750be0b3b66 100644
--- a/content/browser/download/download_file_impl.h
+++ b/content/browser/download/download_file_impl.h
@@ -14,13 +14,14 @@
#include "base/timer.h"
#include "content/browser/download/base_file.h"
#include "content/browser/download/byte_stream.h"
-#include "content/browser/download/download_request_handle.h"
+#include "content/public/browser/download_save_info.h"
#include "net/base/net_log.h"
struct DownloadCreateInfo;
namespace content {
class ByteStreamReader;
+class DownloadDestinationObserver;
class DownloadManager;
class PowerSaveBlocker;
}
@@ -29,17 +30,28 @@ class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile {
public:
// Takes ownership of the object pointed to by |request_handle|.
// |bound_net_log| will be used for logging the download file's events.
- DownloadFileImpl(scoped_ptr<DownloadCreateInfo> info,
- scoped_ptr<content::ByteStreamReader> stream,
- scoped_ptr<DownloadRequestHandleInterface> request_handle,
- scoped_refptr<content::DownloadManager> download_manager,
- bool calculate_hash,
- scoped_ptr<content::PowerSaveBlocker> power_save_blocker,
- const net::BoundNetLog& bound_net_log);
+ // May be constructed on any thread. All methods besides the constructor
+ // (including destruction) must occur on the FILE thread.
+ //
+ // Note that the DownloadFileImpl automatically reads from the passed in
+ // stream, and sends updates and status of those reads to the
+ // DownloadDestinationObserver.
+ DownloadFileImpl(
+ scoped_ptr<content::DownloadSaveInfo> save_info,
+ const FilePath& default_downloads_directory,
+ const GURL& url,
+ const GURL& referrer_url,
+ int64 received_bytes,
+ bool calculate_hash,
+ scoped_ptr<content::ByteStreamReader> stream,
+ const net::BoundNetLog& bound_net_log,
+ scoped_ptr<content::PowerSaveBlocker> power_save_blocker,
+ base::WeakPtr<content::DownloadDestinationObserver> observer);
+
virtual ~DownloadFileImpl();
// DownloadFile functions.
- virtual content::DownloadInterruptReason Initialize() OVERRIDE;
+ virtual void Initialize(const InitializeCallback& callback) OVERRIDE;
virtual void Rename(const FilePath& full_path,
bool overwrite_existing_file,
const RenameCompletionCallback& callback) OVERRIDE;
@@ -52,11 +64,6 @@ class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile {
virtual int64 CurrentSpeed() const OVERRIDE;
virtual bool GetHash(std::string* hash) OVERRIDE;
virtual std::string GetHashState() OVERRIDE;
- virtual void CancelDownloadRequest() OVERRIDE;
- virtual int Id() const OVERRIDE;
- virtual content::DownloadManager* GetDownloadManager() OVERRIDE;
- virtual const content::DownloadId& GlobalId() const OVERRIDE;
- virtual std::string DebugString() const OVERRIDE;
protected:
// For test class overrides.
@@ -74,29 +81,18 @@ class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile {
// The base file instance.
BaseFile file_;
+ // The default directory for creating the download file.
+ FilePath default_download_directory_;
+
// The stream through which data comes.
// TODO(rdsmith): Move this into BaseFile; requires using the same
// stream semantics in SavePackage. Alternatively, replace SaveFile
// with DownloadFile and get rid of BaseFile.
scoped_ptr<content::ByteStreamReader> stream_reader_;
- // The unique identifier for this download, assigned at creation by
- // the DownloadFileManager for its internal record keeping.
- content::DownloadId id_;
-
- // The default directory for creating the download file.
- FilePath default_download_directory_;
-
// Used to trigger progress updates.
scoped_ptr<base::RepeatingTimer<DownloadFileImpl> > update_timer_;
- // The handle to the request information. Used for operations outside the
- // download system, specifically canceling a download.
- scoped_ptr<DownloadRequestHandleInterface> request_handle_;
-
- // DownloadManager this download belongs to.
- scoped_refptr<content::DownloadManager> download_manager_;
-
// Statistics
size_t bytes_seen_;
base::TimeDelta disk_writes_time_;
@@ -104,6 +100,8 @@ class CONTENT_EXPORT DownloadFileImpl : virtual public content::DownloadFile {
net::BoundNetLog bound_net_log_;
+ base::WeakPtr<content::DownloadDestinationObserver> observer_;
+
base::WeakPtrFactory<DownloadFileImpl> weak_factory_;
// RAII handle to keep the system from sleeping while we're downloading.
« no previous file with comments | « content/browser/download/download_file_factory.cc ('k') | content/browser/download/download_file_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698