| OLD | NEW |
| 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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "content/browser/download/download_create_info.h" | 8 #include "content/browser/download/download_create_info.h" |
| 9 #include "content/browser/download/parallel_download_utils.h" | 9 #include "content/browser/download/parallel_download_utils.h" |
| 10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 worker->Cancel(); | 110 worker->Cancel(); |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 void ParallelDownloadJob::OnServerResponseError( | 114 void ParallelDownloadJob::OnServerResponseError( |
| 115 DownloadWorker* worker, | 115 DownloadWorker* worker, |
| 116 DownloadInterruptReason reason) { | 116 DownloadInterruptReason reason) { |
| 117 // TODO(xingliu): Consider to let the original request to cover the full | 117 // TODO(xingliu): Consider to let the original request to cover the full |
| 118 // content if the sub-requests get invalid response. Consider retry on certain | 118 // content if the sub-requests get invalid response. Consider retry on certain |
| 119 // error. | 119 // error. |
| 120 if (worker->length() == DownloadSaveInfo::kLengthFullContent && |
| 121 reason == |
| 122 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE) { |
| 123 SetPotentialFileLength(worker->offset()); |
| 124 return; |
| 125 } |
| 120 DownloadJob::Interrupt(reason); | 126 DownloadJob::Interrupt(reason); |
| 121 } | 127 } |
| 122 | 128 |
| 123 void ParallelDownloadJob::BuildParallelRequests() { | 129 void ParallelDownloadJob::BuildParallelRequests() { |
| 124 DCHECK(!requests_sent_); | 130 DCHECK(!requests_sent_); |
| 125 DCHECK(!is_paused()); | 131 DCHECK(!is_paused()); |
| 126 if (is_canceled_) | 132 if (is_canceled_) |
| 127 return; | 133 return; |
| 128 | 134 |
| 129 // TODO(qinmin): The size of |slices_to_download| should be no larger than | 135 // TODO(qinmin): The size of |slices_to_download| should be no larger than |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // download request. | 222 // download request. |
| 217 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(), | 223 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(), |
| 218 blink::WebReferrerPolicyAlways)); | 224 blink::WebReferrerPolicyAlways)); |
| 219 // Send the request. | 225 // Send the request. |
| 220 worker->SendRequest(std::move(download_params)); | 226 worker->SendRequest(std::move(download_params)); |
| 221 DCHECK(workers_.find(offset) == workers_.end()); | 227 DCHECK(workers_.find(offset) == workers_.end()); |
| 222 workers_[offset] = std::move(worker); | 228 workers_[offset] = std::move(worker); |
| 223 } | 229 } |
| 224 | 230 |
| 225 } // namespace content | 231 } // namespace content |
| OLD | NEW |