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

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

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated Randy's comments. 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.h
diff --git a/content/browser/download/download_item.h b/content/browser/download/download_item.h
index 3d3b0e7ace3a8b7454f1f7cc31088b3a2c5cc6e7..ab911d3253f92e0261f4eb491900836c7faab61f 100644
--- a/content/browser/download/download_item.h
+++ b/content/browser/download/download_item.h
@@ -163,8 +163,11 @@ class CONTENT_EXPORT DownloadItem {
// Called when the user has validated the download of a dangerous file.
void DangerousDownloadValidated();
- // Received a new chunk of data
- void Update(int64 bytes_so_far);
+ // Received a new chunk of data.
+ // |bytes_so_far| is the number of bytes received so far.
+ // |partial_hash| is the hash up to this point. It will be an empty string
+ // if we are not calculating hashes.
+ void Update(int64 bytes_so_far, const std::string& partial_hash);
// Cancel the download operation. We need to distinguish between cancels at
// exit (DownloadManager destructor) from user interface initiated cancels
@@ -193,8 +196,11 @@ class CONTENT_EXPORT DownloadItem {
// Download operation had an error.
// |size| is the amount of data received at interruption.
+ // |partial_hash| is the current hash value at interruption.
// |reason| is the download interrupt reason code that the operation received.
- void Interrupted(int64 size, InterruptReason reason);
+ void Interrupted(int64 size,
+ const std::string partial_hash,
+ InterruptReason reason);
// Deletes the file from disk and removes the download from the views and
// history. |user| should be true if this is the result of the user clicking
@@ -313,6 +319,9 @@ class CONTENT_EXPORT DownloadItem {
void set_opened(bool opened) { opened_ = opened; }
bool opened() const { return opened_; }
+ const std::string& last_modified_time() const { return last_modified_time_; }
+ const std::string& etag() const { return etag_; }
+
InterruptReason last_reason() const { return last_reason_; }
DownloadPersistentStoreInfo GetPersistentStoreInfo() const;
@@ -354,8 +363,9 @@ class CONTENT_EXPORT DownloadItem {
// downloads and false for downloads from the history.
void Init(bool active);
- // Internal helper for maintaining consistent received and total sizes.
- void UpdateSize(int64 size);
+ // Internal helper for maintaining consistent received and total sizes, and
+ // hash.
+ void UpdateSizeAndHash(int64 size, const std::string& partial_hash);
// Called when the entire download operation (including renaming etc)
// is completed.
@@ -417,42 +427,48 @@ class CONTENT_EXPORT 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
- // the download isn't done yet or because the hash isn't needed
+ // the download hasn't started yet or because the hash isn't needed
// (ChromeDownloadManagerDelegate::GenerateFileHash() returned false).
std::string hash_;
+ // 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