Chromium Code Reviews| 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()); |