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

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

Issue 2730363004: Parallel Download finch config parameters on Chrome client. (Closed)
Patch Set: Polish another comment. 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 unified diff | Download patch
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 "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "content/browser/download/parallel_download_utils.h"
8 #include "content/public/browser/browser_context.h" 9 #include "content/public/browser/browser_context.h"
9 #include "content/public/browser/storage_partition.h" 10 #include "content/public/browser/storage_partition.h"
10 11
11 namespace content { 12 namespace content {
12 13
13 namespace {
14
15 // TODO(xingliu): Use finch parameters to configure constants.
16 // Default number of requests in a parallel download, including the original
17 // request.
18 const int kParallelRequestCount = 2;
19
20 } // namespace
21
22 ParallelDownloadJob::ParallelDownloadJob( 14 ParallelDownloadJob::ParallelDownloadJob(
23 DownloadItemImpl* download_item, 15 DownloadItemImpl* download_item,
24 std::unique_ptr<DownloadRequestHandleInterface> request_handle) 16 std::unique_ptr<DownloadRequestHandleInterface> request_handle)
25 : DownloadJobImpl(download_item, std::move(request_handle)), 17 : DownloadJobImpl(download_item, std::move(request_handle)),
26 request_num_(kParallelRequestCount) {} 18 request_num_(GetParallelRequestCountConfig()) {}
qinmin 2017/03/07 05:56:50 nit: this variable is no longer needed, just call
xingliu 2017/03/07 18:44:08 Done, makes sense.
27 19
28 ParallelDownloadJob::~ParallelDownloadJob() = default; 20 ParallelDownloadJob::~ParallelDownloadJob() = default;
29 21
30 void ParallelDownloadJob::Cancel(bool user_cancel) { 22 void ParallelDownloadJob::Cancel(bool user_cancel) {
31 DownloadJobImpl::Cancel(user_cancel); 23 DownloadJobImpl::Cancel(user_cancel);
32 for (auto& worker : workers_) 24 for (auto& worker : workers_)
33 worker->Cancel(); 25 worker->Cancel();
34 } 26 }
35 27
36 void ParallelDownloadJob::Pause() { 28 void ParallelDownloadJob::Pause() {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Subsequent range requests have the same referrer URL as the original 86 // Subsequent range requests have the same referrer URL as the original
95 // download request. 87 // download request.
96 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(), 88 download_params->set_referrer(Referrer(download_item_->GetReferrerUrl(),
97 blink::WebReferrerPolicyAlways)); 89 blink::WebReferrerPolicyAlways));
98 // Send the request. 90 // Send the request.
99 worker->SendRequest(std::move(download_params)); 91 worker->SendRequest(std::move(download_params));
100 workers_.push_back(std::move(worker)); 92 workers_.push_back(std::move(worker));
101 } 93 }
102 94
103 } // namespace content 95 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_job_factory.cc ('k') | content/browser/download/parallel_download_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698