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

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

Issue 1544603003: [Downloads] Do not store error responses during resumption. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@unify-downloader-core
Patch Set: Created 4 years, 10 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_request_core.cc
diff --git a/content/browser/download/download_request_core.cc b/content/browser/download/download_request_core.cc
index 511ebb4f36114b37e86a6d914d5e48bf7fc8a0b4..285771606cd1951582f7c18509c830639b53a0ed 100644
--- a/content/browser/download/download_request_core.cc
+++ b/content/browser/download/download_request_core.cc
@@ -199,6 +199,7 @@ DownloadRequestCore::DownloadRequestCore(net::URLRequest* request,
bytes_read_(0),
pause_count_(0),
was_deferred_(false),
+ is_partial_request_(false),
started_(false),
abort_reason_(DOWNLOAD_INTERRUPT_REASON_NONE) {
DCHECK(request_);
@@ -213,6 +214,7 @@ DownloadRequestCore::DownloadRequestCore(net::URLRequest* request,
download_id_ = request_data->download_id();
on_started_callback_ = request_data->callback();
DownloadRequestData::Detach(request_);
+ is_partial_request_ = save_info_->offset > 0;
} else {
save_info_.reset(new DownloadSaveInfo);
}
@@ -332,6 +334,18 @@ bool DownloadRequestCore::OnResponseStarted(
return true;
}
+bool DownloadRequestCore::OnRequestRedirected() {
+ DVLOG(20) << __FUNCTION__ << "() " << DebugString();
+ if (is_partial_request_) {
+ // A redirect while attempting a partial resumption indicates a potential
+ // middle box. Trigger another interruption so that the DownloadItem can
+ // retry.
+ abort_reason_ = DOWNLOAD_INTERRUPT_REASON_SERVER_UNREACHABLE;
+ return false;
+ }
+ return true;
+}
+
// Create a new buffer, which will be handed to the download thread for file
// writing and deletion.
bool DownloadRequestCore::OnWillRead(scoped_refptr<net::IOBuffer>* buf,
@@ -388,6 +402,12 @@ bool DownloadRequestCore::OnReadCompleted(int bytes_read, bool* defer) {
return true;
}
+void DownloadRequestCore::OnWillAbort(DownloadInterruptReason reason) {
+ DVLOG(20) << __FUNCTION__ << "() reason=" << reason << " " << DebugString();
+ DCHECK(!started_);
+ abort_reason_ = reason;
+}
+
void DownloadRequestCore::OnResponseCompleted(
const net::URLRequestStatus& status) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
« no previous file with comments | « content/browser/download/download_request_core.h ('k') | content/browser/download/download_resource_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698