Chromium Code Reviews| Index: content/browser/download/download_job_factory.cc |
| diff --git a/content/browser/download/download_job_factory.cc b/content/browser/download/download_job_factory.cc |
| index d0a7c7c9210a757facfc1ad4a0b88d82534a02c4..4edb053f2562ad83909b42167ddb6f29f5c898d6 100644 |
| --- a/content/browser/download/download_job_factory.cc |
| +++ b/content/browser/download/download_job_factory.cc |
| @@ -19,7 +19,7 @@ namespace content { |
| namespace { |
| -// Returns if the download should be a parallel download. |
| +// Returns if the download can be parallelized. |
| bool ShouldUseParallelDownload(const DownloadCreateInfo& create_info) { |
|
xingliu
2017/04/19 02:18:11
nit: Maybe also change the function name?
qinmin
2017/04/19 22:42:33
Done.
|
| // To enable parallel download, following conditions need to be satisfied. |
| // 1. Feature |kParallelDownloading| enabled. |
| @@ -28,8 +28,6 @@ bool ShouldUseParallelDownload(const DownloadCreateInfo& create_info) { |
| // 4. Content-Length header. |
| // 5. Content-Length is no less than the minimum slice size configuration. |
| // 6. HTTP/1.1 protocol, not QUIC nor HTTP/1.0. |
| - if (!base::FeatureList::IsEnabled(features::kParallelDownloading)) |
| - return false; |
| // Etag and last modified are stored into DownloadCreateInfo in |
| // DownloadRequestCore only if the response header complies to the strong |
| @@ -46,6 +44,9 @@ bool ShouldUseParallelDownload(const DownloadCreateInfo& create_info) { |
| has_strong_validator && create_info.accept_range && has_content_length && |
| satisfy_min_file_size && satisfy_connection_type; |
| + if (!base::FeatureList::IsEnabled(features::kParallelDownloading)) |
| + return should_use_parallel_download; |
| + |
| RecordParallelDownloadCreationEvent( |
| should_use_parallel_download |
| ? ParallelDownloadCreationEvent::STARTED_PARALLEL_DOWNLOAD |
| @@ -81,16 +82,18 @@ std::unique_ptr<DownloadJob> DownloadJobFactory::CreateJob( |
| DownloadItemImpl* download_item, |
| std::unique_ptr<DownloadRequestHandleInterface> req_handle, |
| const DownloadCreateInfo& create_info) { |
| + bool is_parallizable = ShouldUseParallelDownload(create_info); |
| // Build parallel download job. |
| - if (ShouldUseParallelDownload(create_info)) { |
| + if (base::FeatureList::IsEnabled(features::kParallelDownloading) && |
| + is_parallizable) { |
| return base::MakeUnique<ParallelDownloadJob>(download_item, |
| std::move(req_handle), |
| create_info); |
| } |
| // An ordinary download job. |
| - return base::MakeUnique<DownloadJobImpl>(download_item, |
| - std::move(req_handle)); |
| + return base::MakeUnique<DownloadJobImpl>(download_item, std::move(req_handle), |
| + is_parallizable); |
| } |
| } // namespace |