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

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

Issue 2730363004: Parallel Download finch config parameters on Chrome client. (Closed)
Patch Set: Fix for new code merged in. 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_job.cc
diff --git a/content/browser/download/parallel_download_job.cc b/content/browser/download/parallel_download_job.cc
index 1631a9e28a42068ea4e955c164238b9bb59cf2a8..c8bba093fa4d9ed30d7e44329826058fa4f3727c 100644
--- a/content/browser/download/parallel_download_job.cc
+++ b/content/browser/download/parallel_download_job.cc
@@ -12,21 +12,11 @@
namespace content {
-namespace {
-
-// TODO(xingliu): Use finch parameters to configure constants.
-// Default number of requests in a parallel download, including the original
-// request.
-const int kParallelRequestCount = 2;
-
-} // namespace
-
ParallelDownloadJob::ParallelDownloadJob(
DownloadItemImpl* download_item,
std::unique_ptr<DownloadRequestHandleInterface> request_handle,
const DownloadCreateInfo& create_info)
: DownloadJobImpl(download_item, std::move(request_handle)),
- request_num_(kParallelRequestCount),
initial_request_offset_(create_info.save_info->offset),
initial_request_length_(create_info.save_info->length) {}
@@ -60,14 +50,15 @@ void ParallelDownloadJob::Resume(bool resume_request) {
}
void ParallelDownloadJob::ForkRequestsForNewDownload(int64_t bytes_received,
- int64_t total_bytes) {
+ int64_t total_bytes,
+ int request_count) {
if (!download_item_ || total_bytes <= 0 || bytes_received >= total_bytes ||
- request_num_ <= 1) {
+ request_count <= 1) {
return;
}
int64_t bytes_left = total_bytes - bytes_received;
- int64_t slice_size = bytes_left / request_num_;
+ int64_t slice_size = bytes_left / request_count;
slice_size = slice_size > 0 ? slice_size : 1;
int num_requests = bytes_left / slice_size;
int64_t current_offset = bytes_received + slice_size;
@@ -92,7 +83,8 @@ void ParallelDownloadJob::BuildParallelRequests() {
initial_request_offset_ + initial_request_length_ >=
slices_to_download[0].offset +
slices_to_download[0].received_bytes);
- if (slices_to_download.size() >= kParallelRequestCount) {
+ if (slices_to_download.size() >=
+ static_cast<size_t>(GetParallelRequestCountConfig())) {
// The size of |slices_to_download| should be no larger than
// |kParallelRequestCount| unless |kParallelRequestCount| is changed after
// a download is interrupted. This could happen if we use finch to config
« no previous file with comments | « content/browser/download/parallel_download_job.h ('k') | content/browser/download/parallel_download_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698