Chromium Code Reviews| Index: content/browser/download/download_item.h |
| diff --git a/content/browser/download/download_item.h b/content/browser/download/download_item.h |
| index 0e53e8d35d9e5522621760ae13708013d09e1548..6bda890b0d0767e370aaf3307b0ff598d12c31e1 100644 |
| --- a/content/browser/download/download_item.h |
| +++ b/content/browser/download/download_item.h |
| @@ -146,8 +146,10 @@ 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. |
| + // |hash_state| is the current hash state. |
| + void Update(int64 bytes_so_far, const std::string& hash_state); |
| // Cancel the download operation. We need to distinguish between cancels at |
| // exit (DownloadManager destructor) from user interface initiated cancels |
| @@ -176,8 +178,11 @@ class CONTENT_EXPORT DownloadItem { |
| // Download operation had an error. |
| // |size| is the amount of data received at interruption. |
| + // |hash_state| is the current hash state 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& hash_state, |
| + 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 |
| @@ -267,6 +272,7 @@ class CONTENT_EXPORT DownloadItem { |
| } |
| int64 received_bytes() const { return received_bytes_; } |
| const std::string& hash() const { return hash_; } |
| + std::string hash_state() const { return hash_state_; } |
| int32 id() const { return download_id_.local(); } |
| DownloadId global_id() const { return download_id_; } |
| base::Time start_time() const { return start_time_; } |
| @@ -297,6 +303,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; |
| @@ -338,8 +347,14 @@ 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, and |
| + // hash state. |
| + void UpdateSizeAndHashState(int64 bytes_so_far, |
| + const std::string& hash_state); |
| + |
| // Internal helper for maintaining consistent received and total sizes. |
| - void UpdateSize(int64 size); |
| + // Should only be called from |UpdateSizeAndHashState| and |OnAllDataSaved|. |
| + void UpdateSize(int64 bytes_so_far); |
|
Randy Smith (Not in Mondays)
2011/11/22 17:37:49
Given that the reason we have UpdateSizeAndHashSta
ahendrickson
2011/11/22 23:46:44
Done.
|
| // Called when the entire download operation (including renaming etc) |
| // is completed. |
| @@ -401,10 +416,10 @@ 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 |
| @@ -412,31 +427,41 @@ class CONTENT_EXPORT DownloadItem { |
| // (ChromeDownloadManagerDelegate::GenerateFileHash() returned false). |
| std::string hash_; |
| + // A blob containing the state of the hash algorithm. Only valid while the |
| + // hash is being computed. |
|
Randy Smith (Not in Mondays)
2011/11/22 17:37:49
nit: At this level "while the hash is being comput
ahendrickson
2011/11/22 23:46:44
Done.
|
| + 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. |