Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 // Returns if the download can be parallelized. | 22 // Returns if the download can be parallelized. |
| 23 bool IsParallelizableDownload(const DownloadCreateInfo& create_info) { | 23 bool IsParallelizableDownload(const DownloadCreateInfo& create_info) { |
| 24 // To enable parallel download, following conditions need to be satisfied. | 24 // To enable parallel download, following conditions need to be satisfied. |
| 25 // 1. Feature |kParallelDownloading| enabled. | 25 // 1. Feature |kParallelDownloading| enabled. |
| 26 // 2. Strong validators response headers. i.e. ETag and Last-Modified. | 26 // 2. Strong validators response headers. i.e. ETag and Last-Modified. |
| 27 // 3. Accept-Ranges header. | 27 // 3. Accept-Ranges header. |
| 28 // 4. Content-Length header. | 28 // 4. Content-Length header. |
| 29 // 5. Content-Length is no less than the minimum slice size configuration. | 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. | 30 // 6. HTTP/1.1 protocol, not QUIC nor HTTP/1.0. |
| 31 // 7. HTTP or HTTPS scheme with GET method in the initial request. | |
| 31 | 32 |
| 32 // Etag and last modified are stored into DownloadCreateInfo in | 33 // Etag and last modified are stored into DownloadCreateInfo in |
| 33 // DownloadRequestCore only if the response header complies to the strong | 34 // DownloadRequestCore only if the response header complies to the strong |
| 34 // validator rule. | 35 // validator rule. |
| 35 bool has_strong_validator = | 36 bool has_strong_validator = |
| 36 !create_info.etag.empty() || !create_info.last_modified.empty(); | 37 !create_info.etag.empty() || !create_info.last_modified.empty(); |
| 37 bool has_content_length = create_info.total_bytes > 0; | 38 bool has_content_length = create_info.total_bytes > 0; |
| 38 bool satisfy_min_file_size = | 39 bool satisfy_min_file_size = |
| 39 create_info.total_bytes >= GetMinSliceSizeConfig(); | 40 create_info.total_bytes >= GetMinSliceSizeConfig(); |
| 40 bool satisfy_connection_type = create_info.connection_info == | 41 bool satisfy_connection_type = create_info.connection_info == |
| 41 net::HttpResponseInfo::CONNECTION_INFO_HTTP1_1; | 42 net::HttpResponseInfo::CONNECTION_INFO_HTTP1_1; |
| 43 bool http_get_method = | |
| 44 create_info.method == "GET" && create_info.url().SchemeIsHTTPOrHTTPS(); | |
| 42 | 45 |
| 43 bool is_parallelizable = has_strong_validator && create_info.accept_range && | 46 bool is_parallelizable = has_strong_validator && create_info.accept_range && |
|
qinmin
2017/05/22 21:24:50
you need to add a new UMA enum for this
xingliu
2017/05/22 22:01:49
Done.
| |
| 44 has_content_length && satisfy_min_file_size && | 47 has_content_length && satisfy_min_file_size && |
| 45 satisfy_connection_type; | 48 satisfy_connection_type && http_get_method; |
| 46 | 49 |
| 47 if (!IsParallelDownloadEnabled()) | 50 if (!IsParallelDownloadEnabled()) |
| 48 return is_parallelizable; | 51 return is_parallelizable; |
| 49 | 52 |
| 50 RecordParallelDownloadCreationEvent( | 53 RecordParallelDownloadCreationEvent( |
| 51 is_parallelizable | 54 is_parallelizable |
| 52 ? ParallelDownloadCreationEvent::STARTED_PARALLEL_DOWNLOAD | 55 ? ParallelDownloadCreationEvent::STARTED_PARALLEL_DOWNLOAD |
| 53 : ParallelDownloadCreationEvent::FELL_BACK_TO_NORMAL_DOWNLOAD); | 56 : ParallelDownloadCreationEvent::FELL_BACK_TO_NORMAL_DOWNLOAD); |
| 54 | 57 |
| 55 if (!has_strong_validator) { | 58 if (!has_strong_validator) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 std::move(req_handle), | 93 std::move(req_handle), |
| 91 create_info); | 94 create_info); |
| 92 } | 95 } |
| 93 | 96 |
| 94 // An ordinary download job. | 97 // An ordinary download job. |
| 95 return base::MakeUnique<DownloadJobImpl>(download_item, std::move(req_handle), | 98 return base::MakeUnique<DownloadJobImpl>(download_item, std::move(req_handle), |
| 96 is_parallelizable); | 99 is_parallelizable); |
| 97 } | 100 } |
| 98 | 101 |
| 99 } // namespace | 102 } // namespace |
| OLD | NEW |