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

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: Merged with trunk 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 0e53e8d35d9e5522621760ae13708013d09e1548..0e1e811c1fefa978fa8b412139c1f84f49a1673c 100644
--- a/content/browser/download/download_item.h
+++ b/content/browser/download/download_item.h
@@ -24,6 +24,7 @@
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
+#include "base/pickle.h"
#include "base/time.h"
#include "content/browser/download/download_id.h"
#include "content/browser/download/download_request_handle.h"
@@ -146,8 +147,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 Pickle& hash_state);
Randy Smith (Not in Mondays) 2011/11/21 02:10:17 So this makes me concerned, as pickling and unpick
ahendrickson 2011/11/21 20:34:47 FWIW, the size of the pickle payload is around 300
Randy Smith (Not in Mondays) 2011/11/22 17:37:49 That sounds ok. Could you figure out about how of
ahendrickson 2011/11/22 23:46:44 Operations are in bytes SHA256ContextStr has 3 fi
Randy Smith (Not in Mondays) 2011/11/23 19:25:13 I'm not too worried about the space costs; more ab
ahendrickson 2011/12/20 00:04:13 I downloaded a 50MB file, which took about 10-15 s
Randy Smith (Not in Mondays) 2011/12/20 17:05:40 Cool. What's the comparison? (I.e. what that wou
ahendrickson 2011/12/20 22:06:54 Without the hash state being passed around: DRH:
Randy Smith (Not in Mondays) 2011/12/21 19:14:49 Agreed. Thanks for the due diligence.
// Cancel the download operation. We need to distinguish between cancels at
// exit (DownloadManager destructor) from user interface initiated cancels
@@ -176,8 +179,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 Pickle& 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
@@ -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,13 @@ 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 Pickle& 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);
// Called when the entire download operation (including renaming etc)
// is completed.
@@ -401,42 +415,50 @@ 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_;
+ Pickle 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