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

Side by Side 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: Polish on the comment. 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/download/download_stats.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/download/download_job_factory.h" 5 #include "content/browser/download/download_job_factory.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/browser/download/download_item_impl.h" 10 #include "content/browser/download/download_item_impl.h"
11 #include "content/browser/download/download_job.h" 11 #include "content/browser/download/download_job.h"
12 #include "content/browser/download/download_job_impl.h" 12 #include "content/browser/download/download_job_impl.h"
13 #include "content/browser/download/download_stats.h"
13 #include "content/browser/download/parallel_download_job.h" 14 #include "content/browser/download/parallel_download_job.h"
14 #include "content/browser/download/parallel_download_utils.h" 15 #include "content/browser/download/parallel_download_utils.h"
15 #include "content/public/common/content_features.h" 16 #include "content/public/common/content_features.h"
16 17
17 namespace content { 18 namespace content {
18 19
20 namespace {
21
22 // Returns if the download should be a parallel download.
23 bool ShouldUseParallelDownload(const DownloadCreateInfo& create_info) {
24 // To enable parallel download, following conditions need to be satisfied.
25 // 1. Feature |kParallelDownloading| enabled.
26 // 2. Strong validators response headers. i.e. ETag and Last-Modified.
27 // 3. Accept-Ranges header.
28 // 4. Content-Length header.
29 // 5. Content-Length is no less than the minimum slice size configuration.
30 // 6. HTTP/1.1 protocol, not QUIC nor HTTP/1.0.
31 if (!base::FeatureList::IsEnabled(features::kParallelDownloading))
32 return false;
33
34 // Etag and last modified are stored into DownloadCreateInfo in
35 // DownloadRequestCore only if the response header complies to the strong
36 // validator rule.
37 bool has_strong_validator =
38 !create_info.etag.empty() || !create_info.last_modified.empty();
39 bool has_content_length = create_info.total_bytes > 0;
40 bool satisfy_min_file_size =
41 create_info.total_bytes >= GetMinSliceSizeConfig();
42 bool satisfy_connection_type = create_info.connection_info ==
43 net::HttpResponseInfo::CONNECTION_INFO_HTTP1_1;
44
45 bool should_use_parallel_download =
46 has_strong_validator && create_info.accept_range && has_content_length &&
47 satisfy_min_file_size && satisfy_connection_type;
48
49 RecordParallelDownloadCreationEvent(
50 should_use_parallel_download
51 ? ParallelDownloadCreationEvent::STARTED_PARALLEL_DOWNLOAD
52 : ParallelDownloadCreationEvent::FELL_BACK_TO_NORMAL_DOWNLOAD);
53
54 if (!has_strong_validator) {
55 RecordParallelDownloadCreationEvent(
56 ParallelDownloadCreationEvent::FALLBACK_REASON_STRONG_VALIDATORS);
57 }
58 if (!create_info.accept_range) {
59 RecordParallelDownloadCreationEvent(
60 ParallelDownloadCreationEvent::FALLBACK_REASON_ACCEPT_RANGE_HEADER);
61 }
62 if (!has_content_length) {
63 RecordParallelDownloadCreationEvent(
64 ParallelDownloadCreationEvent::FALLBACK_REASON_CONTENT_LENGTH_HEADER);
65 }
66 if (!satisfy_min_file_size) {
67 RecordParallelDownloadCreationEvent(
68 ParallelDownloadCreationEvent::FALLBACK_REASON_FILE_SIZE);
69 }
70 if (!satisfy_connection_type) {
71 RecordParallelDownloadCreationEvent(
72 ParallelDownloadCreationEvent::FALLBACK_REASON_CONNECTION_TYPE);
73 }
74
75 return should_use_parallel_download;
76 }
77
78 } // namespace
79
19 std::unique_ptr<DownloadJob> DownloadJobFactory::CreateJob( 80 std::unique_ptr<DownloadJob> DownloadJobFactory::CreateJob(
20 DownloadItemImpl* download_item, 81 DownloadItemImpl* download_item,
21 std::unique_ptr<DownloadRequestHandleInterface> req_handle, 82 std::unique_ptr<DownloadRequestHandleInterface> req_handle,
22 const DownloadCreateInfo& create_info) { 83 const DownloadCreateInfo& create_info) {
23 // Build parallel download job. 84 // Build parallel download job.
24 if (ShouldUseParallelDownload(create_info)) { 85 if (ShouldUseParallelDownload(create_info)) {
25 return base::MakeUnique<ParallelDownloadJob>(download_item, 86 return base::MakeUnique<ParallelDownloadJob>(download_item,
26 std::move(req_handle), 87 std::move(req_handle),
27 create_info); 88 create_info);
28 } 89 }
29 90
30 // An ordinary download job. 91 // An ordinary download job.
31 return base::MakeUnique<DownloadJobImpl>(download_item, 92 return base::MakeUnique<DownloadJobImpl>(download_item,
32 std::move(req_handle)); 93 std::move(req_handle));
33 } 94 }
34 95
35 } // namespace 96 } // namespace
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_stats.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698