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

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

Issue 2752603002: Propagate server response error and interrupt the download. (Closed)
Patch Set: 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
Index: content/browser/download/parallel_download_job.cc
diff --git a/content/browser/download/parallel_download_job.cc b/content/browser/download/parallel_download_job.cc
index c8bba093fa4d9ed30d7e44329826058fa4f3727c..827d348f00c0cec7670a51da1889884f0583cca6 100644
--- a/content/browser/download/parallel_download_job.cc
+++ b/content/browser/download/parallel_download_job.cc
@@ -49,6 +49,14 @@ void ParallelDownloadJob::Resume(bool resume_request) {
worker->Resume();
}
+void ParallelDownloadJob::OnServerResponseError(
+ DownloadWorker* worker,
+ DownloadInterruptReason reason) {
+ // TODO(xingliu): Consider to let the original request to cover the full
David Trainor- moved to gerrit 2017/03/14 18:01:43 Would this ever depend on how much content we've '
xingliu 2017/03/14 21:33:21 Yes, we have the logic to limit the length of prec
+ // content if the sub-requests get invalid response.
+ DownloadJob::Interrupt(reason);
+}
+
void ParallelDownloadJob::ForkRequestsForNewDownload(int64_t bytes_received,
int64_t total_bytes,
int request_count) {
@@ -63,7 +71,6 @@ void ParallelDownloadJob::ForkRequestsForNewDownload(int64_t bytes_received,
int num_requests = bytes_left / slice_size;
int64_t current_offset = bytes_received + slice_size;
- // TODO(xingliu): Add records for slices in history db.
for (int i = 0; i < num_requests - 1; ++i) {
int64_t length = (i == (num_requests - 2))
? slice_size + (bytes_left % slice_size)
@@ -100,7 +107,8 @@ void ParallelDownloadJob::BuildParallelRequests() {
}
void ParallelDownloadJob::CreateRequest(int64_t offset, int64_t length) {
- std::unique_ptr<DownloadWorker> worker = base::MakeUnique<DownloadWorker>();
+ std::unique_ptr<DownloadWorker> worker =
+ base::MakeUnique<DownloadWorker>(this, offset, length);
DCHECK(download_item_);
StoragePartition* storage_partition =

Powered by Google App Engine
This is Rietveld 408576698