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

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

Issue 2823273004: Add new UMA stats for parallelizable download (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/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

Powered by Google App Engine
This is Rietveld 408576698