Chromium Code Reviews| Index: content/browser/download/download_item_impl.cc |
| diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc |
| index 6c9d1f377f067a4075875c27f363f96b22f08c56..6ffbfdad316789ce0f1e076d4e8600c86f336921 100644 |
| --- a/content/browser/download/download_item_impl.cc |
| +++ b/content/browser/download/download_item_impl.cc |
| @@ -190,6 +190,7 @@ DownloadItemImpl::DownloadItemImpl( |
| etag_(etag), |
| received_slices_(received_slices), |
| net_log_(net_log), |
| + received_bytes_if_content_length_mismatch_(-1), |
| weak_ptr_factory_(this) { |
| delegate_->Attach(); |
| DCHECK(state_ == COMPLETE_INTERNAL || state_ == INTERRUPTED_INTERNAL || |
| @@ -234,6 +235,7 @@ DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate, |
| last_modified_time_(info.last_modified), |
| etag_(info.etag), |
| net_log_(net_log), |
| + received_bytes_if_content_length_mismatch_(-1), |
| weak_ptr_factory_(this) { |
| delegate_->Attach(); |
| Init(true /* actively downloading */, SRC_ACTIVE_DOWNLOAD); |
| @@ -270,6 +272,7 @@ DownloadItemImpl::DownloadItemImpl( |
| delegate_(delegate), |
| current_path_(path), |
| net_log_(net_log), |
| + received_bytes_if_content_length_mismatch_(-1), |
| weak_ptr_factory_(this) { |
| job_ = base::MakeUnique<DownloadJobImpl>(this, std::move(request_handle)); |
| delegate_->Attach(); |
| @@ -936,6 +939,7 @@ DownloadItemImpl::ResumeMode DownloadItemImpl::GetResumeMode() const { |
| switch(last_reason_) { |
| case DOWNLOAD_INTERRUPT_REASON_FILE_TRANSIENT_ERROR: |
| case DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT: |
| + case DOWNLOAD_INTERRUPT_REASON_SERVER_CONTENT_LENGTH_MISMATCH: |
| break; |
| case DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE: |
| @@ -1105,6 +1109,17 @@ void DownloadItemImpl::OnAllDataSaved( |
| // the download and don't expect to receive any more |
| // data. |
| + if (received_bytes_if_content_length_mismatch_ > 0) { |
| + if (total_bytes > received_bytes_if_content_length_mismatch_) { |
| + RecordDownloadCount( |
| + MORE_BYTES_RECEIVED_AFTER_CONTENT_LENGTH_MISMATCH_COUNT); |
| + } else if (total_bytes == received_bytes_if_content_length_mismatch_) { |
| + RecordDownloadCount( |
| + NO_BYTES_RECEIVED_AFTER_CONTENT_LENGTH_MISMATCH_COUNT); |
| + } else { |
| + // This could happen if the content changes on the server. |
| + } |
| + } |
| DVLOG(20) << __func__ << "() download=" << DebugString(true); |
| UpdateObservers(); |
| } |
| @@ -1162,7 +1177,6 @@ void DownloadItemImpl::DestinationError( |
| DVLOG(20) << __func__ |
| << "() reason:" << DownloadInterruptReasonToString(reason) |
| << " this:" << DebugString(true); |
| - |
| InterruptWithPartialState(bytes_so_far, std::move(secure_hash), reason); |
| UpdateObservers(); |
| } |
| @@ -1787,6 +1801,9 @@ void DownloadItemImpl::InterruptWithPartialState( |
| RecordDownloadInterrupted(reason, received_bytes_, total_bytes_, |
| job_ && job_->UsesParallelRequests()); |
| + if (reason == DOWNLOAD_INTERRUPT_REASON_SERVER_CONTENT_LENGTH_MISMATCH) |
|
David Trainor- moved to gerrit
2017/04/25 03:50:41
Remove extra space after ==
qinmin
2017/04/25 19:27:47
Done.
|
| + received_bytes_if_content_length_mismatch_ = received_bytes_; |
| + |
| if (!GetWebContents()) |
| RecordDownloadCount(INTERRUPTED_WITHOUT_WEBCONTENTS); |