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

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

Issue 2752603002: Propagate server response error and interrupt the download. (Closed)
Patch Set: Work on feedbacks. 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..2a88078e9ff502b7af8f46a5f5b3ad58ee3f51fe 100644
--- a/content/browser/download/parallel_download_job.cc
+++ b/content/browser/download/parallel_download_job.cc
@@ -49,6 +49,15 @@ 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
+ // content if the sub-requests get invalid response. Consider retry on certain
+ // error.
+ DownloadJob::Interrupt(reason);
+}
+
void ParallelDownloadJob::ForkRequestsForNewDownload(int64_t bytes_received,
int64_t total_bytes,
int request_count) {
@@ -63,7 +72,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 +108,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