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

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

Issue 2806653002: Add UMA to track why a download is non-parallel when enabled parallel (Closed)
Patch Set: Minor comment polish. 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 | « no previous file | content/browser/download/download_stats.h » ('j') | content/browser/download/download_stats.h » ('J')
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 a619b04e66559165d5bcc0f6d202fe10db66d151..aa077c73061f5acbde6a2a747cf5c029ce78a9a9 100644
--- a/content/browser/download/download_job_factory.cc
+++ b/content/browser/download/download_job_factory.cc
@@ -10,12 +10,73 @@
#include "content/browser/download/download_item_impl.h"
#include "content/browser/download/download_job.h"
#include "content/browser/download/download_job_impl.h"
+#include "content/browser/download/download_stats.h"
#include "content/browser/download/parallel_download_job.h"
#include "content/browser/download/parallel_download_utils.h"
#include "content/public/common/content_features.h"
namespace content {
+namespace {
+
+// Returns if the download should be a parallel download.
+bool ShouldUseParallelDownload(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.
+ // 3. Accept-Ranges header.
+ // 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
+ // validator rule.
+ bool has_strong_validator =
+ !create_info.etag.empty() || !create_info.last_modified.empty();
+ bool has_content_length = create_info.total_bytes > 0;
+ bool satisfy_min_file_size =
+ create_info.total_bytes >= GetMinSliceSizeConfig();
+ 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;
+
+ RecordParallelDownloadCreationEvent(
+ should_use_parallel_download
+ ? ParallelDownloadCreationEvent::PARALLEL_DOWNLOAD_COUNT
+ : ParallelDownloadCreationEvent::FALLBACK_TO_NORMAL_DOWNLOAD_COUNT);
+
+ if (!has_strong_validator) {
+ RecordParallelDownloadCreationEvent(
+ ParallelDownloadCreationEvent::FALLBACK_REASON_STRONG_VALIDATORS);
+ }
+ if (!create_info.accept_range) {
+ RecordParallelDownloadCreationEvent(
+ ParallelDownloadCreationEvent::FALLBACK_REASON_ACCEPT_RANGE_HEADER);
+ }
+ if (!has_content_length) {
+ RecordParallelDownloadCreationEvent(
+ ParallelDownloadCreationEvent::FALLBACK_REASON_CONTENT_LENGTH_HEADER);
+ }
+ if (!satisfy_min_file_size) {
+ RecordParallelDownloadCreationEvent(
+ ParallelDownloadCreationEvent::FALLBACK_REASON_FILE_SIZE);
+ }
+ if (!satisfy_connection_type) {
+ RecordParallelDownloadCreationEvent(
+ ParallelDownloadCreationEvent::FALLBACK_REASON_CONNECTION_TYPE);
+ }
+
+ return should_use_parallel_download;
+}
+
+} // namespace
+
std::unique_ptr<DownloadJob> DownloadJobFactory::CreateJob(
DownloadItemImpl* download_item,
std::unique_ptr<DownloadRequestHandleInterface> req_handle,
« no previous file with comments | « no previous file | content/browser/download/download_stats.h » ('j') | content/browser/download/download_stats.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698