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

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

Issue 2823273004: Add new UMA stats for parallelizable download (Closed)
Patch Set: addressing comments 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
« no previous file with comments | « content/browser/download/download_job.cc ('k') | content/browser/download/download_job_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a6ac607a6341be699a854fa31238876df932c1ec 100644
--- a/content/browser/download/download_job_factory.cc
+++ b/content/browser/download/download_job_factory.cc
@@ -19,8 +19,8 @@ namespace content {
namespace {
-// Returns if the download should be a parallel download.
-bool ShouldUseParallelDownload(const DownloadCreateInfo& create_info) {
+// Returns if the download can be parallelized.
+bool IsParallelizableDownload(const DownloadCreateInfo& create_info) {
// To enable parallel download, following conditions need to be satisfied.
// 1. Feature |kParallelDownloading| enabled.
// 2. Strong validators response headers. i.e. ETag and Last-Modified.
@@ -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
@@ -42,12 +40,15 @@ bool ShouldUseParallelDownload(const DownloadCreateInfo& create_info) {
bool satisfy_connection_type = create_info.connection_info ==
net::HttpResponseInfo::CONNECTION_INFO_HTTP1_1;
- bool should_use_parallel_download =
- has_strong_validator && create_info.accept_range && has_content_length &&
- satisfy_min_file_size && satisfy_connection_type;
+ bool is_parallelizable = has_strong_validator && create_info.accept_range &&
+ has_content_length && satisfy_min_file_size &&
+ satisfy_connection_type;
+
+ if (!IsParallelDownloadEnabled())
+ return is_parallelizable;
RecordParallelDownloadCreationEvent(
- should_use_parallel_download
+ is_parallelizable
? ParallelDownloadCreationEvent::STARTED_PARALLEL_DOWNLOAD
David Trainor- moved to gerrit 2017/04/19 22:56:28 Is this still valid? We didn't technically start
qinmin 2017/04/20 17:00:28 This is fine. The if statement on line 47 ensures
: ParallelDownloadCreationEvent::FELL_BACK_TO_NORMAL_DOWNLOAD);
@@ -72,7 +73,7 @@ bool ShouldUseParallelDownload(const DownloadCreateInfo& create_info) {
ParallelDownloadCreationEvent::FALLBACK_REASON_CONNECTION_TYPE);
}
- return should_use_parallel_download;
+ return is_parallelizable;
}
} // namespace
@@ -81,16 +82,17 @@ std::unique_ptr<DownloadJob> DownloadJobFactory::CreateJob(
DownloadItemImpl* download_item,
std::unique_ptr<DownloadRequestHandleInterface> req_handle,
const DownloadCreateInfo& create_info) {
+ bool is_parallelizable = IsParallelizableDownload(create_info);
// Build parallel download job.
- if (ShouldUseParallelDownload(create_info)) {
+ if (IsParallelDownloadEnabled() && is_parallelizable) {
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_parallelizable);
}
} // namespace
« no previous file with comments | « content/browser/download/download_job.cc ('k') | content/browser/download/download_job_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698