| Index: content/browser/download/download_item.cc
|
| diff --git a/content/browser/download/download_item.cc b/content/browser/download/download_item.cc
|
| index 84387b667353a3727d369273445e656fed360f2b..7b42aa9ab50f1aeb4eb43aef61979253de460e49 100644
|
| --- a/content/browser/download/download_item.cc
|
| +++ b/content/browser/download/download_item.cc
|
| @@ -172,7 +172,9 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| referrer_charset_(info.referrer_charset),
|
| total_bytes_(info.total_bytes),
|
| received_bytes_(0),
|
| - last_reason_(DOWNLOAD_INTERRUPT_REASON_NONE),
|
| + last_modified_time_(info.last_modified),
|
| + etag_(info.etag),
|
| + last_reason_(info.server_interrupt_reason),
|
| start_tick_(base::TimeTicks::Now()),
|
| state_(IN_PROGRESS),
|
| start_time_(info.start_time),
|
| @@ -184,7 +186,8 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| safety_state_(SAFE),
|
| auto_opened_(false),
|
| is_otr_(is_otr),
|
| - is_temporary_(!info.save_info.file_path.empty()),
|
| + is_temporary_(!info.save_info.file_path.empty() &&
|
| + !info.continued_download),
|
| all_data_saved_(false),
|
| opened_(false),
|
| open_enabled_(true),
|
| @@ -334,6 +337,11 @@ void DownloadItem::UpdateSize(int64 bytes_so_far) {
|
| total_bytes_ = 0;
|
| }
|
|
|
| +void DownloadItem::UpdateHash(const std::string& partial_hash) {
|
| + if (!partial_hash.empty())
|
| + partial_hash_ = partial_hash;
|
| +}
|
| +
|
| void DownloadItem::StartProgressTimer() {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| @@ -353,7 +361,7 @@ void DownloadItem::StopProgressTimer() {
|
| // 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 std::string& partial_hash) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -362,6 +370,7 @@ void DownloadItem::Update(int64 bytes_so_far) {
|
| return;
|
| }
|
| UpdateSize(bytes_so_far);
|
| + UpdateHash(partial_hash);
|
| UpdateObservers();
|
| }
|
|
|
| @@ -403,13 +412,14 @@ void DownloadItem::CompleteDelayedDownload() {
|
| Completed();
|
| }
|
|
|
| -void DownloadItem::OnAllDataSaved(int64 size) {
|
| +void DownloadItem::OnAllDataSaved(int64 size, const std::string final_hash) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| DCHECK(!all_data_saved_);
|
| all_data_saved_ = true;
|
| UpdateSize(size);
|
| + UpdateHash(final_hash);
|
| StopProgressTimer();
|
| }
|
|
|
| @@ -472,7 +482,9 @@ void DownloadItem::UpdateTarget() {
|
| state_info_.target_name = full_path_.BaseName();
|
| }
|
|
|
| -void DownloadItem::Interrupted(int64 size, InterruptReason reason) {
|
| +void DownloadItem::Interrupted(int64 size,
|
| + const std::string partial_hash,
|
| + InterruptReason reason) {
|
| // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| @@ -481,6 +493,7 @@ void DownloadItem::Interrupted(int64 size, InterruptReason reason) {
|
|
|
| last_reason_ = reason;
|
| UpdateSize(size);
|
| + UpdateHash(partial_hash);
|
| StopProgressTimer();
|
| download_stats::RecordDownloadInterrupted(reason,
|
| received_bytes_,
|
| @@ -799,6 +812,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 "\"",
|
| @@ -808,6 +823,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());
|
|
|