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

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

Issue 2752603002: Propagate server response error and interrupt the download. (Closed)
Patch Set: Merge recent changes in the tree. Created 3 years, 9 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
« no previous file with comments | « content/browser/download/download_worker.h ('k') | content/browser/download/parallel_download_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_worker.cc
diff --git a/content/browser/download/download_worker.cc b/content/browser/download/download_worker.cc
index 6cea949a7355ee52e6f0b7627d84fbb414bf54fc..5f65d9eb82c2e9882b905e5f284fbdd41d8f667d 100644
--- a/content/browser/download/download_worker.cc
+++ b/content/browser/download/download_worker.cc
@@ -38,7 +38,9 @@ DownloadWorker::DownloadWorker(DownloadWorker::Delegate* delegate,
: delegate_(delegate),
offset_(offset),
length_(length),
- weak_factory_(this) {}
+ weak_factory_(this) {
+ DCHECK(delegate_);
+}
DownloadWorker::~DownloadWorker() = default;
@@ -54,15 +56,18 @@ void DownloadWorker::SendRequest(
}
void DownloadWorker::Pause() {
- request_handle_->PauseRequest();
+ if (request_handle_)
+ request_handle_->PauseRequest();
}
void DownloadWorker::Resume() {
- request_handle_->ResumeRequest();
+ if (request_handle_)
+ request_handle_->ResumeRequest();
}
void DownloadWorker::Cancel() {
- request_handle_->CancelRequest();
+ if (request_handle_)
+ request_handle_->CancelRequest();
}
void DownloadWorker::OnUrlDownloaderStarted(
@@ -72,13 +77,15 @@ void DownloadWorker::OnUrlDownloaderStarted(
// |callback| is not used in subsequent requests.
DCHECK(callback.is_null());
- // TODO(xingliu): Pass the |stream_reader| to parallel job and handle failed
- // request.
+ // TODO(xingliu): Add the interrupt reason and metric data for precondition
+ // failure. Make DownloadRequestCore know if it should return error if the
+ // the server gives a different part of the content, e.g. "If-Match" return
+ // http 200.
if (create_info->result !=
DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE) {
- VLOG(kVerboseLevel) << "Parallel download sub request failed. reason = "
+ VLOG(kVerboseLevel) << "Parallel download sub-request failed. reason = "
<< create_info->result;
- NOTIMPLEMENTED();
+ delegate_->OnServerResponseError(this, create_info->result);
return;
}
« no previous file with comments | « content/browser/download/download_worker.h ('k') | content/browser/download/parallel_download_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698