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

Side by Side Diff: content/browser/download/parallel_download_job.cc

Issue 2872943003: Reduce unnecessary download interruptions due to parallel requests (Closed)
Patch Set: more restrictions on DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « content/browser/download/parallel_download_job.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/download/parallel_download_job.h" 5 #include "content/browser/download/parallel_download_job.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 RecordParallelDownloadAddStreamSuccess(success); 121 RecordParallelDownloadAddStreamSuccess(success);
122 122
123 // Destroy the request if the sink is gone. 123 // Destroy the request if the sink is gone.
124 if (!success) { 124 if (!success) {
125 VLOG(kVerboseLevel) 125 VLOG(kVerboseLevel)
126 << "Byte stream arrived after download file is released."; 126 << "Byte stream arrived after download file is released.";
127 worker->Cancel(); 127 worker->Cancel();
128 } 128 }
129 } 129 }
130 130
131 void ParallelDownloadJob::OnServerResponseError(
132 DownloadWorker* worker,
133 DownloadInterruptReason reason) {
134 // TODO(xingliu): Consider to let the original request to cover the full
135 // content if the sub-requests get invalid response. Consider retry on certain
136 // error.
137 if (worker->length() == DownloadSaveInfo::kLengthFullContent &&
138 reason ==
139 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE) {
140 SetPotentialFileLength(worker->offset());
141 return;
142 }
143 DownloadJob::Interrupt(reason);
144 }
145
146 void ParallelDownloadJob::BuildParallelRequests() { 131 void ParallelDownloadJob::BuildParallelRequests() {
147 DCHECK(!requests_sent_); 132 DCHECK(!requests_sent_);
148 DCHECK(!is_paused()); 133 DCHECK(!is_paused());
149 if (is_canceled_) 134 if (is_canceled_)
150 return; 135 return;
151 136
152 // TODO(qinmin): The size of |slices_to_download| should be no larger than 137 // TODO(qinmin): The size of |slices_to_download| should be no larger than
153 // |kParallelRequestCount| unless |kParallelRequestCount| is changed after 138 // |kParallelRequestCount| unless |kParallelRequestCount| is changed after
154 // a download is interrupted. This could happen if we use finch to config 139 // a download is interrupted. This could happen if we use finch to config
155 // the number of parallel requests. 140 // the number of parallel requests.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // download request. 228 // download request.
244 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(), 229 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(),
245 blink::kWebReferrerPolicyAlways)); 230 blink::kWebReferrerPolicyAlways));
246 // Send the request. 231 // Send the request.
247 worker->SendRequest(std::move(download_params)); 232 worker->SendRequest(std::move(download_params));
248 DCHECK(workers_.find(offset) == workers_.end()); 233 DCHECK(workers_.find(offset) == workers_.end());
249 workers_[offset] = std::move(worker); 234 workers_[offset] = std::move(worker);
250 } 235 }
251 236
252 } // namespace content 237 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/parallel_download_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698