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

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

Issue 11571025: Initial CL for Downloads resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated Pawel's comment. Created 7 years, 11 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_item_factory.h ('k') | content/browser/download/download_item_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_item_impl.h
diff --git a/content/browser/download/download_item_impl.h b/content/browser/download/download_item_impl.h
index 572cd485e6b4fb3995a94584fdf0c63bca719202..fb91db8377b142e736e9fd61db39827299a172e5 100644
--- a/content/browser/download/download_item_impl.h
+++ b/content/browser/download/download_item_impl.h
@@ -34,6 +34,17 @@ class CONTENT_EXPORT DownloadItemImpl
: public DownloadItem,
public DownloadDestinationObserver {
public:
+ enum ResumeMode {
+ RESUME_MODE_INVALID = 0,
+ RESUME_MODE_IMMEDIATE_CONTINUE,
+ RESUME_MODE_IMMEDIATE_RESTART,
+ RESUME_MODE_USER_CONTINUE,
+ RESUME_MODE_USER_RESTART
+ };
+
+ // The maximum number of attempts we will make to resume automatically.
+ static const int kMaxAutoResumeAttempts;
+
// Note that it is the responsibility of the caller to ensure that a
// DownloadItemImplDelegate passed to a DownloadItemImpl constructor
// outlives the DownloadItemImpl.
@@ -57,7 +68,6 @@ class CONTENT_EXPORT DownloadItemImpl
// |bound_net_log| is constructed externally for our use.
DownloadItemImpl(DownloadItemImplDelegate* delegate,
const DownloadCreateInfo& info,
- scoped_ptr<DownloadRequestHandleInterface> request_handle,
const net::BoundNetLog& bound_net_log);
// Constructing for the "Save Page As..." feature:
@@ -78,6 +88,7 @@ class CONTENT_EXPORT DownloadItemImpl
virtual void DangerousDownloadValidated() OVERRIDE;
virtual void Pause() OVERRIDE;
virtual void Resume() OVERRIDE;
+ virtual void ResumeInterruptedDownload() OVERRIDE;
virtual void Cancel(bool user_cancel) OVERRIDE;
virtual void Delete(DeleteReason reason) OVERRIDE;
virtual void Remove() OVERRIDE;
@@ -147,16 +158,17 @@ class CONTENT_EXPORT DownloadItemImpl
// All remaining public interfaces virtual to allow for DownloadItemImpl
// mocks.
- // Main entry points for regular downloads, in order -------------------------
+ virtual ResumeMode GetResumeMode() const;
- // TODO(rdsmith): Fold the process that uses these fully into
- // DownloadItemImpl and pass callbacks to the delegate so that all of
- // these other than Start() can be made private.
+ // State transition operations on regular downloads --------------------------
- // Start the download
- virtual void Start(scoped_ptr<DownloadFile> download_file);
+ // Start the download.
+ // |download_file| is the associated file on the storage medium.
+ // |req_handle| is the new request handle associated with the download.
+ virtual void Start(scoped_ptr<DownloadFile> download_file,
+ scoped_ptr<DownloadRequestHandleInterface> req_handle);
- // Needed because of interwining with DownloadManagerImpl --------------------
+ // Needed because of intertwining with DownloadManagerImpl -------------------
// TODO(rdsmith): Unwind DownloadManagerImpl and DownloadItemImpl,
// removing these from the public interface.
@@ -168,9 +180,11 @@ class CONTENT_EXPORT DownloadItemImpl
// Provide a weak pointer reference to a DownloadDestinationObserver
// for use by download destinations.
- base::WeakPtr<DownloadDestinationObserver> DestinationObserverAsWeakPtr();
+ virtual base::WeakPtr<DownloadDestinationObserver>
+ DestinationObserverAsWeakPtr();
- // For dispatching on whether we're dealing with a SavePackage download.
+ // Get the download's BoundNetLog.
+ virtual const net::BoundNetLog& GetBoundNetLog() const;
// DownloadItemImpl routines only needed by SavePackage ----------------------
@@ -299,7 +313,8 @@ class CONTENT_EXPORT DownloadItemImpl
void SetFullPath(const FilePath& new_path);
- // Mapping between internal and external states.
+ void AutoResumeIfValid();
+
static DownloadState InternalToExternalState(
DownloadInternalState internal_state);
static DownloadInternalState ExternalToInternalState(
@@ -307,6 +322,7 @@ class CONTENT_EXPORT DownloadItemImpl
// Debugging routines --------------------------------------------------------
static const char* DebugDownloadStateString(DownloadInternalState state);
+ static const char* DebugResumeModeString(ResumeMode mode);
// Will be false for save package downloads retrieved from the history.
// TODO(rdsmith): Replace with a generalized enum for "download source".
@@ -425,6 +441,9 @@ class CONTENT_EXPORT DownloadItemImpl
// In progress downloads may be paused by the user, we note it here.
bool is_paused_;
+ // The number of times this download has been resumed automatically.
+ int auto_resume_count_;
+
// A flag for indicating if the download should be opened at completion.
bool open_when_complete_;
« no previous file with comments | « content/browser/download/download_item_factory.h ('k') | content/browser/download/download_item_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698