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

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

Issue 10831302: Download resumption - Preliminary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed signed/unsigned compare issue. Created 8 years, 1 month 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 797c798bda9e7ab50833b635c7af1379a172d8cc..35ec719d7ebea75b561124ba0c931bb5859d6e62 100644
--- a/content/browser/download/download_item_impl.h
+++ b/content/browser/download/download_item_impl.h
@@ -33,6 +33,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.
@@ -56,7 +67,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:
@@ -86,6 +96,7 @@ class CONTENT_EXPORT DownloadItemImpl
virtual DownloadState GetState() const OVERRIDE;
virtual DownloadInterruptReason GetLastReason() const OVERRIDE;
virtual bool IsPaused() const OVERRIDE;
+ virtual bool CanResumeInterrupted() const OVERRIDE;
virtual bool IsTemporary() const OVERRIDE;
virtual bool IsPartialDownload() const OVERRIDE;
virtual bool IsInProgress() const OVERRIDE;
@@ -128,6 +139,7 @@ class CONTENT_EXPORT DownloadItemImpl
virtual base::Time GetEndTime() const OVERRIDE;
virtual bool CanShowInFolder() OVERRIDE;
virtual bool CanOpenDownload() OVERRIDE;
+ virtual bool CanResumeDownload() const OVERRIDE;
virtual bool ShouldOpenFileBasedOnExtension() OVERRIDE;
virtual bool GetOpenWhenComplete() const OVERRIDE;
virtual bool GetAutoOpened() OVERRIDE;
@@ -141,25 +153,32 @@ class CONTENT_EXPORT DownloadItemImpl
virtual void SetDisplayName(const FilePath& name) OVERRIDE;
virtual std::string DebugString(bool verbose) const OVERRIDE;
virtual void MockDownloadOpenForTesting() OVERRIDE;
+ virtual const net::BoundNetLog& GetBoundNetLog() const OVERRIDE;
// All remaining public interfaces virtual to allow for DownloadItemImpl
// mocks.
+ virtual bool IsResuming() const;
+ virtual ResumeMode GetResumeMode() const;
+
// Main entry points for regular downloads, in order -------------------------
// 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.
- // 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);
// If all pre-requisites have been met, complete download processing, i.e. do
// internal cleanup, file rename, and potentially auto-open. (Dangerous
// downloads still may block on user acceptance after this point.)
virtual void MaybeCompleteDownload();
- // Needed because of interwining with DownloadManagerImpl --------------------
+ // Needed because of intertwining with DownloadManagerImpl -------------------
// TODO(rdsmith): Unwind DownloadManagerImpl and DownloadItemImpl,
// removing these from the public interface.
@@ -280,6 +299,9 @@ class CONTENT_EXPORT DownloadItemImpl
// is completed.
void Completed();
+ // Initiates a resume operation on an interrupted download.
+ void ResumeInterruptedDownload();
+
// Helper routines -----------------------------------------------------------
// Indicate that an error has occurred on the download.
@@ -299,7 +321,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 +330,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 +449,12 @@ class CONTENT_EXPORT DownloadItemImpl
// In progress downloads may be paused by the user, we note it here.
bool is_paused_;
+ // A download has been resumed.
+ bool is_resuming_;
+
+ // 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