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

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

Issue 2730363004: Parallel Download finch config parameters on Chrome client. (Closed)
Patch Set: Use a cleaner api. 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/parallel_download_utils.h ('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"
8 #include "base/strings/string_number_conversions.h"
7 #include "content/public/browser/download_save_info.h" 9 #include "content/public/browser/download_save_info.h"
10 #include "content/public/common/content_features.h"
8 11
9 namespace content { 12 namespace content {
10 13
14 namespace {
15
16 // Finch parameter key value for minimum file size in bytes to use parallel
17 // download.
18 const char kMinFileSizeFinchKey[] = "min_file_size";
qinmin 2017/03/06 22:29:08 shouldn't be file size, it could be part of a slic
xingliu 2017/03/06 23:37:05 Done. Also polished some comments. One question o
xingliu 2017/03/07 18:44:08 Got it.
19
20 // Default value for |kMinFileSizeFinchKey|, when no parameter is specified.
21 const int64_t kMinFileSizeParallelDownload = 2097152;
22
23 // Finch parameter key value for number of parallel requests in a parallel
24 // download, including the original request.
25 const char kParallelRequestCountFinchKey[] = "request_count";
26
27 // Default value for |kParallelRequestCountFinchKey|, when no parameter is
28 // specified.
29 const int kParallelRequestCount = 2;
30
31 } // namespace
32
11 DownloadItem::ReceivedSlice FindNextSliceToDownload( 33 DownloadItem::ReceivedSlice FindNextSliceToDownload(
12 const std::vector<DownloadItem::ReceivedSlice>& received_slices) { 34 const std::vector<DownloadItem::ReceivedSlice>& received_slices) {
13 if (received_slices.empty()) 35 if (received_slices.empty())
14 return DownloadItem::ReceivedSlice(0, DownloadSaveInfo::kLengthFullContent); 36 return DownloadItem::ReceivedSlice(0, DownloadSaveInfo::kLengthFullContent);
15 37
16 std::vector<DownloadItem::ReceivedSlice>::const_iterator iter = 38 std::vector<DownloadItem::ReceivedSlice>::const_iterator iter =
17 received_slices.begin(); 39 received_slices.begin();
18 DCHECK_GE(iter->offset, 0); 40 DCHECK_GE(iter->offset, 0);
19 if (iter->offset != 0) 41 if (iter->offset != 0)
20 return DownloadItem::ReceivedSlice(0, iter->offset); 42 return DownloadItem::ReceivedSlice(0, iter->offset);
(...skipping 10 matching lines...) Expand all
31 DCHECK_GE(next->offset, offset); 53 DCHECK_GE(next->offset, offset);
32 if (next->offset > offset) { 54 if (next->offset > offset) {
33 remaining_bytes = next->offset - offset; 55 remaining_bytes = next->offset - offset;
34 break; 56 break;
35 } 57 }
36 iter = next; 58 iter = next;
37 } 59 }
38 return DownloadItem::ReceivedSlice(offset, remaining_bytes); 60 return DownloadItem::ReceivedSlice(offset, remaining_bytes);
39 } 61 }
40 62
63 int64_t GetMinFileSizeConfig() {
64 std::string finch_value = base::GetFieldTrialParamValueByFeature(
65 features::kParallelDownloading, kMinFileSizeFinchKey);
66 int64_t result;
67 return !finch_value.empty() && base::StringToInt64(finch_value, &result)
68 ? result
69 : kMinFileSizeParallelDownload;
70 }
71
72 int GetParallelRequestCountConfig() {
73 std::string finch_value = base::GetFieldTrialParamValueByFeature(
74 features::kParallelDownloading, kParallelRequestCountFinchKey);
75 int result;
76 return !finch_value.empty() && base::StringToInt(finch_value, &result)
77 ? result
78 : kParallelRequestCount;
79 }
80
41 } // namespace content 81 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/parallel_download_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698