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

Unified Diff: content/browser/download/parallel_download_utils.cc

Issue 2750853004: Add a delay to send the parallel requests. (Closed)
Patch Set: Work on nits. 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 5bd4413c9628aaa6cb4e5ed3f6428919ae1613fd..5b719c3646f9a31198a0357f33c04dbba4b5ff0e 100644
--- a/content/browser/download/parallel_download_utils.cc
+++ b/content/browser/download/parallel_download_utils.cc
@@ -6,6 +6,7 @@
#include "base/metrics/field_trial_params.h"
#include "base/strings/string_number_conversions.h"
+#include "base/time/time.h"
#include "content/public/browser/download_save_info.h"
#include "content/public/common/content_features.h"
@@ -28,6 +29,10 @@ const char kParallelRequestCountFinchKey[] = "request_count";
// specified.
const int kParallelRequestCount = 2;
+// Finch parameter key value for the delay time in milliseconds to send
+// parallel requests after response of the original request is handled.
+const char kParallelRequestDelayFinchKey[] = "parallel_request_delay";
+
// TODO(qinmin): replace this with a comparator operator in
// DownloadItem::ReceivedSlice.
bool compareReceivedSlices(const DownloadItem::ReceivedSlice& lhs,
@@ -90,7 +95,7 @@ int64_t GetMinSliceSizeConfig() {
std::string finch_value = base::GetFieldTrialParamValueByFeature(
features::kParallelDownloading, kMinSliceSizeFinchKey);
int64_t result;
- return !finch_value.empty() && base::StringToInt64(finch_value, &result)
+ return base::StringToInt64(finch_value, &result)
? result
: kMinSliceSizeParallelDownload;
}
@@ -99,9 +104,17 @@ int GetParallelRequestCountConfig() {
std::string finch_value = base::GetFieldTrialParamValueByFeature(
features::kParallelDownloading, kParallelRequestCountFinchKey);
int result;
- return !finch_value.empty() && base::StringToInt(finch_value, &result)
- ? result
- : kParallelRequestCount;
+ return base::StringToInt(finch_value, &result) ? result
+ : kParallelRequestCount;
+}
+
+base::TimeDelta GetParallelRequestDelayConfig() {
+ std::string finch_value = base::GetFieldTrialParamValueByFeature(
+ features::kParallelDownloading, kParallelRequestDelayFinchKey);
+ int64_t time_ms = 0;
+ return base::StringToInt64(finch_value, &time_ms)
+ ? base::TimeDelta::FromMilliseconds(time_ms)
+ : base::TimeDelta::FromMilliseconds(0);
}
} // 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