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

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

Issue 2806923002: Don't create parallel request if download is about to complete (Closed)
Patch Set: Created 3 years, 8 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 2b4ae47d85a7f6ea39e4ca7009779c00497d2bb6..46e58ea058fc22486a086f7c611b1a1261561318 100644
--- a/content/browser/download/parallel_download_job.cc
+++ b/content/browser/download/parallel_download_job.cc
@@ -16,6 +16,10 @@ namespace {
const int kVerboseLevel = 1;
+// The minimum remaining download time for parallel request creation.
+// TODO(qinmin): make this finch configurable.
+const int kMinimumRemainingTimeInSecondsForParallelRequestCreation = 10;
+
} // namespace
ParallelDownloadJob::ParallelDownloadJob(
@@ -149,15 +153,23 @@ void ParallelDownloadJob::BuildParallelRequests() {
// Create more slices for a new download. The initial request may generate
// a received slice.
- if (slices_to_download.size() <= 1 &&
- initial_request_offset_ <= first_slice_offset) {
- // TODO(qinmin): Check the size of the last slice. If it is huge, we can
- // split it into N pieces and pass the last N-1 pieces to different workers.
- // Otherwise, just fork |slices_to_download.size()| number of workers.
- slices_to_download = FindSlicesForRemainingContent(
- first_slice_offset,
- content_length_ - first_slice_offset + initial_request_offset_,
- GetParallelRequestCount(), GetMinSliceSize());
+ if (slices_to_download.size() <= 1 && download_item_->GetTotalBytes() > 0) {
+ int64_t current_speed = download_item_->CurrentSpeed() == 0
David Trainor- moved to gerrit 2017/04/10 20:10:00 std::max(1, download_item_->CurrentSpeed())? Also
qinmin 2017/04/10 21:43:39 Done.
+ ? 1
+ : download_item_->CurrentSpeed();
+ int64_t remaining_bytes =
+ download_item_->GetTotalBytes() - download_item_->GetReceivedBytes();
+ if (remaining_bytes / current_speed >
David Trainor- moved to gerrit 2017/04/10 20:10:00 Do we want an UMA stat for when we decide/don't de
qinmin 2017/04/10 21:43:39 will add the decion about parallel download creati
+ kMinimumRemainingTimeInSecondsForParallelRequestCreation) {
+ // TODO(qinmin): Check the size of the last slice. If it is huge, we can
+ // split it into N pieces and pass the last N-1 pieces to different
+ // workers. Otherwise, just fork |slices_to_download.size()| number of
+ // workers.
+ slices_to_download = FindSlicesForRemainingContent(
+ first_slice_offset,
+ content_length_ - first_slice_offset + initial_request_offset_,
+ GetParallelRequestCount(), GetMinSliceSize());
+ }
}
DCHECK(!slices_to_download.empty());

Powered by Google App Engine
This is Rietveld 408576698