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

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

Issue 2806923002: Don't create parallel request if download is about to complete (Closed)
Patch Set: add UMA and finch Created 3 years, 8 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_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 15 matching lines...) Expand all
26 const char kParallelRequestCountFinchKey[] = "request_count"; 26 const char kParallelRequestCountFinchKey[] = "request_count";
27 27
28 // Default value for |kParallelRequestCountFinchKey|, when no parameter is 28 // Default value for |kParallelRequestCountFinchKey|, when no parameter is
29 // specified. 29 // specified.
30 const int kParallelRequestCount = 2; 30 const int kParallelRequestCount = 2;
31 31
32 // Finch parameter key value for the delay time in milliseconds to send 32 // Finch parameter key value for the delay time in milliseconds to send
33 // parallel requests after response of the original request is handled. 33 // parallel requests after response of the original request is handled.
34 const char kParallelRequestDelayFinchKey[] = "parallel_request_delay"; 34 const char kParallelRequestDelayFinchKey[] = "parallel_request_delay";
35 35
36 // Finch parameter key value for the remaining time in seconds that is required
37 // to send parallel requests.
38 const char kParallelRequestRemainingTimeFinchKey[] =
39 "parallel_request_remaining_time";
40
41 // The default remaining download time in seconds required for parallel request
42 // creation.
43 const int kDefaultRemainingTimeInSeconds = 10;
44
36 // TODO(qinmin): replace this with a comparator operator in 45 // TODO(qinmin): replace this with a comparator operator in
37 // DownloadItem::ReceivedSlice. 46 // DownloadItem::ReceivedSlice.
38 bool compareReceivedSlices(const DownloadItem::ReceivedSlice& lhs, 47 bool compareReceivedSlices(const DownloadItem::ReceivedSlice& lhs,
39 const DownloadItem::ReceivedSlice& rhs) { 48 const DownloadItem::ReceivedSlice& rhs) {
40 return lhs.offset < rhs.offset; 49 return lhs.offset < rhs.offset;
41 } 50 }
42 51
43 } // namespace 52 } // namespace
44 53
45 std::vector<DownloadItem::ReceivedSlice> FindSlicesForRemainingContent( 54 std::vector<DownloadItem::ReceivedSlice> FindSlicesForRemainingContent(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 143
135 base::TimeDelta GetParallelRequestDelayConfig() { 144 base::TimeDelta GetParallelRequestDelayConfig() {
136 std::string finch_value = base::GetFieldTrialParamValueByFeature( 145 std::string finch_value = base::GetFieldTrialParamValueByFeature(
137 features::kParallelDownloading, kParallelRequestDelayFinchKey); 146 features::kParallelDownloading, kParallelRequestDelayFinchKey);
138 int64_t time_ms = 0; 147 int64_t time_ms = 0;
139 return base::StringToInt64(finch_value, &time_ms) 148 return base::StringToInt64(finch_value, &time_ms)
140 ? base::TimeDelta::FromMilliseconds(time_ms) 149 ? base::TimeDelta::FromMilliseconds(time_ms)
141 : base::TimeDelta::FromMilliseconds(0); 150 : base::TimeDelta::FromMilliseconds(0);
142 } 151 }
143 152
153 base::TimeDelta GetParallelRequestRemainingTimeConfig() {
154 std::string finch_value = base::GetFieldTrialParamValueByFeature(
155 features::kParallelDownloading, kParallelRequestRemainingTimeFinchKey);
156 int time_in_seconds = 0;
157 return base::StringToInt(finch_value, &time_in_seconds)
158 ? base::TimeDelta::FromSeconds(time_in_seconds)
159 : base::TimeDelta::FromSeconds(kDefaultRemainingTimeInSeconds);
160 }
161
144 void DebugSlicesInfo(const DownloadItem::ReceivedSlices& slices) { 162 void DebugSlicesInfo(const DownloadItem::ReceivedSlices& slices) {
145 DVLOG(1) << "Received slices size : " << slices.size(); 163 DVLOG(1) << "Received slices size : " << slices.size();
146 for (const auto& it : slices) { 164 for (const auto& it : slices) {
147 DVLOG(1) << "Slice offset = " << it.offset 165 DVLOG(1) << "Slice offset = " << it.offset
148 << " , received_bytes = " << it.received_bytes; 166 << " , received_bytes = " << it.received_bytes;
149 } 167 }
150 } 168 }
151 169
152 } // namespace content 170 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/parallel_download_utils.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698