| 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 <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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 return GetParallelRequestRemainingTimeConfig().InSeconds(); | 93 return GetParallelRequestRemainingTimeConfig().InSeconds(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void ParallelDownloadJob::CancelRequestWithOffset(int64_t offset) { | 96 void ParallelDownloadJob::CancelRequestWithOffset(int64_t offset) { |
| 97 if (initial_request_offset_ == offset) { | 97 if (initial_request_offset_ == offset) { |
| 98 DownloadJobImpl::Cancel(false); | 98 DownloadJobImpl::Cancel(false); |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 auto it = workers_.find(offset); | 102 auto it = workers_.find(offset); |
| 103 if (it != workers_.end()) | 103 DCHECK(it != workers_.end()); |
| 104 it->second->Cancel(); | 104 it->second->Cancel(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void ParallelDownloadJob::BuildParallelRequestAfterDelay() { | 107 void ParallelDownloadJob::BuildParallelRequestAfterDelay() { |
| 108 DCHECK(workers_.empty()); | 108 DCHECK(workers_.empty()); |
| 109 DCHECK(!requests_sent_); | 109 DCHECK(!requests_sent_); |
| 110 DCHECK(!timer_.IsRunning()); | 110 DCHECK(!timer_.IsRunning()); |
| 111 | 111 |
| 112 timer_.Start(FROM_HERE, GetParallelRequestDelayConfig(), this, | 112 timer_.Start(FROM_HERE, GetParallelRequestDelayConfig(), this, |
| 113 &ParallelDownloadJob::BuildParallelRequests); | 113 &ParallelDownloadJob::BuildParallelRequests); |
| 114 } | 114 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // download request. | 243 // download request. |
| 244 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(), | 244 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(), |
| 245 blink::kWebReferrerPolicyAlways)); | 245 blink::kWebReferrerPolicyAlways)); |
| 246 // Send the request. | 246 // Send the request. |
| 247 worker->SendRequest(std::move(download_params)); | 247 worker->SendRequest(std::move(download_params)); |
| 248 DCHECK(workers_.find(offset) == workers_.end()); | 248 DCHECK(workers_.find(offset) == workers_.end()); |
| 249 workers_[offset] = std::move(worker); | 249 workers_[offset] = std::move(worker); |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace content | 252 } // namespace content |
| OLD | NEW |