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

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

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DownloadSaveInfo::offset is now int64. Created 9 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
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 e19080170e19f46e57e3fc72682bda4bbf667565..57c20d82dacd3235db4b773d21197c5dc85c4d34 100644
--- a/content/browser/download/download_item_impl.h
+++ b/content/browser/download/download_item_impl.h
@@ -64,14 +64,17 @@ class CONTENT_EXPORT DownloadItemImpl : public DownloadItem {
virtual void OpenDownload() OVERRIDE;
virtual void ShowDownloadInShell() OVERRIDE;
virtual void DangerousDownloadValidated() OVERRIDE;
- virtual void Update(int64 bytes_so_far) OVERRIDE;
+ virtual void Update(int64 bytes_so_far,
+ const std::string& hash_state) OVERRIDE;
virtual void Cancel(bool user_cancel) OVERRIDE;
virtual void MarkAsComplete() OVERRIDE;
virtual void DelayedDownloadOpened() OVERRIDE;
virtual void OnAllDataSaved(
int64 size, const std::string& final_hash) OVERRIDE;
virtual void OnDownloadedFileRemoved() OVERRIDE;
- virtual void Interrupted(int64 size, InterruptReason reason) OVERRIDE;
+ virtual void Interrupted(int64 size,
+ const std::string& hash_state,
+ InterruptReason reason) OVERRIDE;
virtual void Delete(DeleteReason reason) OVERRIDE;
virtual void Remove() OVERRIDE;
virtual bool TimeRemaining(base::TimeDelta* remaining) const OVERRIDE;
@@ -106,6 +109,7 @@ class CONTENT_EXPORT DownloadItemImpl : public DownloadItem {
virtual void SetTotalBytes(int64 total_bytes) OVERRIDE;
virtual const std::string& GetHash() const OVERRIDE;
virtual int64 GetReceivedBytes() const OVERRIDE;
+ virtual const std::string& GetHashState() const OVERRIDE;
virtual int32 GetId() const OVERRIDE;
virtual DownloadId GetGlobalId() const OVERRIDE;
virtual base::Time GetStartTime() const OVERRIDE;
@@ -131,6 +135,8 @@ class CONTENT_EXPORT DownloadItemImpl : public DownloadItem {
virtual bool IsTemporary() const OVERRIDE;
virtual void SetOpened(bool opened) OVERRIDE;
virtual bool GetOpened() const OVERRIDE;
+ virtual const std::string& GetLastModifiedTime() const OVERRIDE;
+ virtual const std::string& GetETag() const OVERRIDE;
virtual InterruptReason GetLastReason() const OVERRIDE;
virtual DownloadPersistentStoreInfo GetPersistentStoreInfo() const OVERRIDE;
virtual DownloadStateInfo GetStateInfo() const OVERRIDE;
@@ -148,8 +154,14 @@ class CONTENT_EXPORT DownloadItemImpl : public DownloadItem {
// downloads and false for downloads from the history.
void Init(bool active);
+ // Internal helper for maintaining consistent received and total sizes, and
+ // hash state.
+ void UpdateProgress(int64 bytes_so_far, const std::string& hash_state);
+
// Internal helper for maintaining consistent received and total sizes.
Randy Smith (Not in Mondays) 2011/11/23 19:25:13 nit: Also hash state (conceptually, though you mig
ahendrickson 2011/12/20 00:04:14 Done.
- void UpdateSize(int64 size);
+ // Should only be called from |OnAllDataSaved|.
+ void ProgressComplete(int64 bytes_so_far,
+ const std::string& final_hash);
// Called when the entire download operation (including renaming etc)
// is completed.
@@ -210,10 +222,10 @@ class CONTENT_EXPORT DownloadItemImpl : public DownloadItem {
// It's used to construct a suggested filename.
std::string referrer_charset_;
- // Total bytes expected
+ // Total bytes expected.
int64 total_bytes_;
- // Current received bytes
+ // Current received bytes.
int64 received_bytes_;
// Sha256 hash of the content. This might be empty either because
@@ -221,31 +233,41 @@ class CONTENT_EXPORT DownloadItemImpl : public DownloadItem {
// (ChromeDownloadManagerDelegate::GenerateFileHash() returned false).
std::string hash_;
+ // A blob containing the state of the hash algorithm. Only valid while the
+ // download is in progress.
+ std::string hash_state_;
+
+ // Server's time stamp for the file.
+ std::string last_modified_time_;
+
+ // Server's ETAG for the file.
+ std::string etag_;
+
// Last reason.
InterruptReason last_reason_;
- // Start time for calculating remaining time
+ // Start time for calculating remaining time.
base::TimeTicks start_tick_;
- // The current state of this download
+ // The current state of this download.
DownloadState state_;
- // The views of this item in the download shelf and download tab
+ // The views of this item in the download shelf and download tab.
ObserverList<Observer> observers_;
- // Time the download was started
+ // Time the download was started.
base::Time start_time_;
- // Time the download completed
+ // Time the download completed.
base::Time end_time_;
- // Our persistent store handle
+ // Our persistent store handle.
int64 db_handle_;
- // Our owning object
+ // Our owning object.
DownloadManager* download_manager_;
- // In progress downloads may be paused by the user, we note it here
+ // In progress downloads may be paused by the user, we note it here.
bool is_paused_;
// A flag for indicating if the download should be opened at completion.

Powered by Google App Engine
This is Rietveld 408576698