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

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

Issue 2759843002: Pump the http version to download system. (Closed)
Patch Set: Work on feedback. 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
« no previous file with comments | « content/browser/download/download_request_core.cc ('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_utils.h" 5 #include "content/browser/download/parallel_download_utils.h"
6 6
7 #include "base/metrics/field_trial_params.h" 7 #include "base/metrics/field_trial_params.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/public/browser/download_save_info.h" 10 #include "content/public/browser/download_save_info.h"
(...skipping 25 matching lines...) Expand all
36 // TODO(qinmin): replace this with a comparator operator in 36 // TODO(qinmin): replace this with a comparator operator in
37 // DownloadItem::ReceivedSlice. 37 // DownloadItem::ReceivedSlice.
38 bool compareReceivedSlices(const DownloadItem::ReceivedSlice& lhs, 38 bool compareReceivedSlices(const DownloadItem::ReceivedSlice& lhs,
39 const DownloadItem::ReceivedSlice& rhs) { 39 const DownloadItem::ReceivedSlice& rhs) {
40 return lhs.offset < rhs.offset; 40 return lhs.offset < rhs.offset;
41 } 41 }
42 42
43 } // namespace 43 } // namespace
44 44
45 bool ShouldUseParallelDownload(const DownloadCreateInfo& create_info) { 45 bool ShouldUseParallelDownload(const DownloadCreateInfo& create_info) {
46 // To enable parallel download, following conditions need to be satisfied.
46 // 1. Accept-Ranges, Content-Length and strong validators response headers. 47 // 1. Accept-Ranges, Content-Length and strong validators response headers.
47 // 2. Feature |kParallelDownloading| enabled. 48 // 2. Feature |kParallelDownloading| enabled.
48 // 3. Content-Length is no less than the minimum slice size configuration. 49 // 3. Content-Length is no less than the minimum slice size configuration.
49 // 3. TODO(xingliu) HTTP/1.1 protocol, not QUIC or HTTP/2. 50 // 3. HTTP/1.1 protocol, not QUIC nor HTTP/1.0.
50 51
51 // Etag and last modified are stored into DownloadCreateInfo in 52 // Etag and last modified are stored into DownloadCreateInfo in
52 // DownloadRequestCore only if the response header complies to the strong 53 // DownloadRequestCore only if the response header complies to the strong
53 // validator rule. 54 // validator rule.
54 bool has_strong_validator = 55 bool has_strong_validator =
55 !create_info.etag.empty() || !create_info.last_modified.empty(); 56 !create_info.etag.empty() || !create_info.last_modified.empty();
56 57
57 return has_strong_validator && create_info.accept_range && 58 return has_strong_validator && create_info.accept_range &&
58 create_info.total_bytes >= GetMinSliceSizeConfig() && 59 create_info.total_bytes >= GetMinSliceSizeConfig() &&
60 create_info.connection_info ==
61 net::HttpResponseInfo::CONNECTION_INFO_HTTP1_1 &&
59 base::FeatureList::IsEnabled(features::kParallelDownloading); 62 base::FeatureList::IsEnabled(features::kParallelDownloading);
60 } 63 }
61 64
62 std::vector<DownloadItem::ReceivedSlice> FindSlicesForRemainingContent( 65 std::vector<DownloadItem::ReceivedSlice> FindSlicesForRemainingContent(
63 int64_t bytes_received, 66 int64_t bytes_received,
64 int64_t content_length, 67 int64_t content_length,
65 int request_count) { 68 int request_count) {
66 std::vector<DownloadItem::ReceivedSlice> slices_to_download; 69 std::vector<DownloadItem::ReceivedSlice> slices_to_download;
67 if (request_count <= 0) 70 if (request_count <= 0)
68 return slices_to_download; 71 return slices_to_download;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 base::TimeDelta GetParallelRequestDelayConfig() { 156 base::TimeDelta GetParallelRequestDelayConfig() {
154 std::string finch_value = base::GetFieldTrialParamValueByFeature( 157 std::string finch_value = base::GetFieldTrialParamValueByFeature(
155 features::kParallelDownloading, kParallelRequestDelayFinchKey); 158 features::kParallelDownloading, kParallelRequestDelayFinchKey);
156 int64_t time_ms = 0; 159 int64_t time_ms = 0;
157 return base::StringToInt64(finch_value, &time_ms) 160 return base::StringToInt64(finch_value, &time_ms)
158 ? base::TimeDelta::FromMilliseconds(time_ms) 161 ? base::TimeDelta::FromMilliseconds(time_ms)
159 : base::TimeDelta::FromMilliseconds(0); 162 : base::TimeDelta::FromMilliseconds(0);
160 } 163 }
161 164
162 } // namespace content 165 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_request_core.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698