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

Unified Diff: content/browser/download/download_item_impl.cc

Issue 2832223004: interrupt and resume download with CONTENT_LENGTH_MISMATCH errors (Closed)
Patch Set: Created 3 years, 8 months 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_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);

Powered by Google App Engine
This is Rietveld 408576698