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

Unified Diff: content/browser/download/parallel_download_utils.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 side-by-side diff with in-line comments
Download patch
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..0a49ad34ec808ced69fe87fa407fdb6e949059d5 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 slice size in bytes to use parallel
+// download.
+const char kMinSliceSizeFinchKey[] = "min_slice_size";
+
+// Default value for |kMinSliceSizeFinchKey|, when no parameter is specified.
+const int64_t kMinSliceSizeParallelDownload = 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 GetMinSliceSizeConfig() {
+ std::string finch_value = base::GetFieldTrialParamValueByFeature(
+ features::kParallelDownloading, kMinSliceSizeFinchKey);
+ int64_t result;
+ return !finch_value.empty() && base::StringToInt64(finch_value, &result)
+ ? result
+ : kMinSliceSizeParallelDownload;
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698