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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (!requests_sent_) { | 62 if (!requests_sent_) { |
63 if (!timer_.IsRunning()) | 63 if (!timer_.IsRunning()) |
64 BuildParallelRequestAfterDelay(); | 64 BuildParallelRequestAfterDelay(); |
65 return; | 65 return; |
66 } | 66 } |
67 | 67 |
68 for (auto& worker : workers_) | 68 for (auto& worker : workers_) |
69 worker.second->Resume(); | 69 worker.second->Resume(); |
70 } | 70 } |
71 | 71 |
| 72 |
72 int ParallelDownloadJob::GetParallelRequestCount() const { | 73 int ParallelDownloadJob::GetParallelRequestCount() const { |
73 return GetParallelRequestCountConfig(); | 74 return GetParallelRequestCountConfig(); |
74 } | 75 } |
75 | 76 |
| 77 bool ParallelDownloadJob::UsesParallelRequests() const { |
| 78 return true; |
| 79 } |
| 80 |
76 void ParallelDownloadJob::BuildParallelRequestAfterDelay() { | 81 void ParallelDownloadJob::BuildParallelRequestAfterDelay() { |
77 DCHECK(workers_.empty()); | 82 DCHECK(workers_.empty()); |
78 DCHECK(!requests_sent_); | 83 DCHECK(!requests_sent_); |
79 DCHECK(!timer_.IsRunning()); | 84 DCHECK(!timer_.IsRunning()); |
80 | 85 |
81 timer_.Start(FROM_HERE, GetParallelRequestDelayConfig(), this, | 86 timer_.Start(FROM_HERE, GetParallelRequestDelayConfig(), this, |
82 &ParallelDownloadJob::BuildParallelRequests); | 87 &ParallelDownloadJob::BuildParallelRequests); |
83 } | 88 } |
84 | 89 |
85 void ParallelDownloadJob::OnByteStreamReady( | 90 void ParallelDownloadJob::OnByteStreamReady( |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // download request. | 175 // download request. |
171 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(), | 176 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(), |
172 blink::WebReferrerPolicyAlways)); | 177 blink::WebReferrerPolicyAlways)); |
173 // Send the request. | 178 // Send the request. |
174 worker->SendRequest(std::move(download_params)); | 179 worker->SendRequest(std::move(download_params)); |
175 DCHECK(workers_.find(offset) == workers_.end()); | 180 DCHECK(workers_.find(offset) == workers_.end()); |
176 workers_[offset] = std::move(worker); | 181 workers_[offset] = std::move(worker); |
177 } | 182 } |
178 | 183 |
179 } // namespace content | 184 } // namespace content |
OLD | NEW |