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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/download/parallel_download_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/parallel_download_utils.cc
diff --git a/content/browser/download/parallel_download_utils.cc b/content/browser/download/parallel_download_utils.cc
index 5846e1eb8ee58005c561380ed9f0721364a483e1..38fcccb1d2e103e7e336cb1cf3f8e0b2ed3a8864 100644
--- a/content/browser/download/parallel_download_utils.cc
+++ b/content/browser/download/parallel_download_utils.cc
@@ -4,10 +4,32 @@
#include "content/browser/download/parallel_download_utils.h"
+#include "base/metrics/field_trial_params.h"
+#include "base/strings/string_number_conversions.h"
#include "content/public/browser/download_save_info.h"
+#include "content/public/common/content_features.h"
namespace content {
+namespace {
+
+// Finch parameter key value for minimum file size in bytes to use parallel
+// download.
+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.
+
+// Default value for |kMinFileSizeFinchKey|, when no parameter is specified.
+const int64_t kMinFileSizeParallelDownload = 2097152;
+
+// Finch parameter key value for number of parallel requests in a parallel
+// download, including the original request.
+const char kParallelRequestCountFinchKey[] = "request_count";
+
+// Default value for |kParallelRequestCountFinchKey|, when no parameter is
+// specified.
+const int kParallelRequestCount = 2;
+
+} // namespace
+
DownloadItem::ReceivedSlice FindNextSliceToDownload(
const std::vector<DownloadItem::ReceivedSlice>& received_slices) {
if (received_slices.empty())
@@ -38,4 +60,22 @@ DownloadItem::ReceivedSlice FindNextSliceToDownload(
return DownloadItem::ReceivedSlice(offset, remaining_bytes);
}
+int64_t GetMinFileSizeConfig() {
+ std::string finch_value = base::GetFieldTrialParamValueByFeature(
+ features::kParallelDownloading, kMinFileSizeFinchKey);
+ int64_t result;
+ return !finch_value.empty() && base::StringToInt64(finch_value, &result)
+ ? result
+ : kMinFileSizeParallelDownload;
+}
+
+int GetParallelRequestCountConfig() {
+ std::string finch_value = base::GetFieldTrialParamValueByFeature(
+ features::kParallelDownloading, kParallelRequestCountFinchKey);
+ int result;
+ return !finch_value.empty() && base::StringToInt(finch_value, &result)
+ ? result
+ : kParallelRequestCount;
+}
+
} // namespace content
« 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