| Index: content/browser/download/download_item.cc
|
| diff --git a/content/browser/download/download_item.cc b/content/browser/download/download_item.cc
|
| index 3318a0769a6f2459d9971b7e6377d0a55e04db13..e9c90d4b1278fda87fb1b0ae74528f157805ab96 100644
|
| --- a/content/browser/download/download_item.cc
|
| +++ b/content/browser/download/download_item.cc
|
| @@ -137,6 +137,10 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| referrer_url_(info.referrer_url),
|
| total_bytes_(info.total_bytes),
|
| received_bytes_(info.received_bytes),
|
| + hash_state_(info.hash_state),
|
| + last_modified_time_(info.last_modified_time),
|
| + etag_(info.etag),
|
| + last_reason_(info.last_reason),
|
| start_tick_(base::TimeTicks()),
|
| state_(static_cast<DownloadState>(info.state)),
|
| start_time_(info.start_time),
|
| @@ -182,6 +186,9 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| referrer_charset_(info.referrer_charset),
|
| total_bytes_(info.total_bytes),
|
| received_bytes_(0),
|
| + hash_(DownloadItem::kEmptyFileHash),
|
| + last_modified_time_(info.last_modified),
|
| + etag_(info.etag),
|
| last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE),
|
| start_tick_(base::TimeTicks::Now()),
|
| state_(IN_PROGRESS),
|
| @@ -215,6 +222,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| referrer_url_(GURL()),
|
| total_bytes_(0),
|
| received_bytes_(0),
|
| + hash_(DownloadItem::kEmptyFileHash),
|
| last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE),
|
| start_tick_(base::TimeTicks::Now()),
|
| state_(IN_PROGRESS),
|
| @@ -340,10 +348,17 @@ void DownloadItem::UpdateSize(int64 bytes_so_far) {
|
| total_bytes_ = 0;
|
| }
|
|
|
| +void DownloadItem::UpdateSizeAndHashState(int64 bytes_so_far,
|
| + const Pickle& hash_state) {
|
| + hash_state_ = hash_state;
|
| +
|
| + UpdateSize(bytes_so_far);
|
| +}
|
| +
|
| // Updates from the download thread may have been posted while this download
|
| // was being cancelled in the UI thread, so we'll accept them unless we're
|
| // complete.
|
| -void DownloadItem::Update(int64 bytes_so_far) {
|
| +void DownloadItem::Update(int64 bytes_so_far, const Pickle& hash_state) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -351,7 +366,7 @@ void DownloadItem::Update(int64 bytes_so_far) {
|
| NOTREACHED();
|
| return;
|
| }
|
| - UpdateSize(bytes_so_far);
|
| + UpdateSizeAndHashState(bytes_so_far, hash_state);
|
| UpdateObservers();
|
| }
|
|
|
| @@ -398,8 +413,8 @@ void DownloadItem::OnAllDataSaved(int64 size, const std::string& final_hash) {
|
|
|
| DCHECK(!all_data_saved_);
|
| all_data_saved_ = true;
|
| - UpdateSize(size);
|
| hash_ = final_hash;
|
| + UpdateSize(size);
|
| }
|
|
|
| void DownloadItem::OnDownloadedFileRemoved() {
|
| @@ -460,7 +475,9 @@ void DownloadItem::UpdateTarget() {
|
| state_info_.target_name = full_path_.BaseName();
|
| }
|
|
|
| -void DownloadItem::Interrupted(int64 size, InterruptReason reason) {
|
| +void DownloadItem::Interrupted(int64 size,
|
| + const Pickle& hash_state,
|
| + InterruptReason reason) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -468,7 +485,7 @@ void DownloadItem::Interrupted(int64 size, InterruptReason reason) {
|
| return;
|
|
|
| last_reason_ = reason;
|
| - UpdateSize(size);
|
| + UpdateSizeAndHashState(size, hash_state);
|
| download_stats::RecordDownloadInterrupted(reason,
|
| received_bytes_,
|
| total_bytes_);
|
| @@ -693,7 +710,11 @@ DownloadPersistentStoreInfo DownloadItem::GetPersistentStoreInfo() const {
|
| total_bytes(),
|
| state(),
|
| db_handle(),
|
| - opened());
|
| + opened(),
|
| + hash_state_,
|
| + last_modified_time_,
|
| + etag_,
|
| + last_reason_);
|
| }
|
|
|
| TabContents* DownloadItem::GetTabContents() const {
|
| @@ -738,9 +759,8 @@ void DownloadItem::Init(bool active) {
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| UpdateTarget();
|
| - if (active) {
|
| + if (active)
|
| download_stats::RecordDownloadCount(download_stats::START_COUNT);
|
| - }
|
| VLOG(20) << __FUNCTION__ << "() " << DebugString(true);
|
| }
|
|
|
| @@ -801,6 +821,8 @@ std::string DownloadItem::DebugString(bool verbose) const {
|
| " is_paused = %c"
|
| " is_otr = %c"
|
| " safety_state = %s"
|
| + " last_modified = '%s'"
|
| + " etag = '%s'"
|
| " url_chain = \n\t\"%s\"\n\t"
|
| " target_name = \"%" PRFilePath "\""
|
| " full_path = \"%" PRFilePath "\"",
|
| @@ -810,6 +832,8 @@ std::string DownloadItem::DebugString(bool verbose) const {
|
| is_paused() ? 'T' : 'F',
|
| is_otr() ? 'T' : 'F',
|
| DebugSafetyStateString(safety_state()),
|
| + last_modified_time_.c_str(),
|
| + etag_.c_str(),
|
| url_list.c_str(),
|
| state_info_.target_name.value().c_str(),
|
| full_path().value().c_str());
|
|
|