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 7a19ea014107f293a632e8e043d9a96cf8097beb..9eceba1de61d5a8378253e2712b91e99bbc1d833 100644 |
| --- a/content/browser/download/download_item.h |
| +++ b/content/browser/download/download_item.h |
| @@ -157,8 +157,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); |
|
Randy Smith (Not in Mondays)
2011/10/31 18:46:43
Currently, Update is just used to send across size
ahendrickson
2011/11/13 21:15:20
No, Update also sets received_bytes_, which is pas
Randy Smith (Not in Mondays)
2011/11/15 18:35:25
Hmmm. I understand it, but I don't like it; I wan
|
| // Cancel the download operation. We need to distinguish between cancels at |
| // exit (DownloadManager destructor) from user interface initiated cancels |
| @@ -180,15 +183,18 @@ class CONTENT_EXPORT DownloadItem { |
| void CompleteDelayedDownload(); |
| // Called when all data has been saved. Only has display effects. |
| - void OnAllDataSaved(int64 size); |
| + void OnAllDataSaved(int64 size, const std::string final_hash); |
| // Called when the downloaded file is removed. |
| void OnDownloadedFileRemoved(); |
| // 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 |
| @@ -277,6 +283,7 @@ class CONTENT_EXPORT DownloadItem { |
| total_bytes_ = total_bytes; |
| } |
| int64 received_bytes() const { return received_bytes_; } |
| + const std::string& partial_hash() const { return partial_hash_; } |
| int32 id() const { return download_id_; } |
| DownloadId global_id() const; |
| base::Time start_time() const { return start_time_; } |
| @@ -306,6 +313,13 @@ 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_; } |
| + void set_last_modified_time(const std::string& time) { |
| + last_modified_time_ = time; |
| + } |
| + const std::string& etag() const { return etag_; } |
| + void set_etag(const std::string& tag) { etag_ = tag; } |
| + |
| InterruptReason last_reason() const { return last_reason_; } |
| DownloadPersistentStoreInfo GetPersistentStoreInfo() const; |
| @@ -351,6 +365,9 @@ class CONTENT_EXPORT DownloadItem { |
| // Internal helper for maintaining consistent received and total sizes. |
| void UpdateSize(int64 size); |
| + // Internal helper for keeping track of the hash as we receive data. |
| + void UpdateHash(const std::string& partial_hash); |
| + |
| // Called when the entire download operation (including renaming etc) |
| // is completed. |
| void Completed(); |
| @@ -414,40 +431,49 @@ 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_; |
| + // Current hash value. |
| + std::string partial_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_; |
| - // Timer for regularly updating our observers |
| + // Timer for regularly updating our observers. |
| base::RepeatingTimer<DownloadItem> update_timer_; |
| - // 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. |