OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/cronet/url_request_context_config.h" | 5 #include "components/cronet/url_request_context_config.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "components/cronet/stale_host_resolver.h" | 17 #include "components/cronet/stale_host_resolver.h" |
18 #include "net/base/address_family.h" | 18 #include "net/base/address_family.h" |
19 #include "net/cert/caching_cert_verifier.h" | 19 #include "net/cert/caching_cert_verifier.h" |
20 #include "net/cert/cert_verifier.h" | 20 #include "net/cert/cert_verifier.h" |
21 #include "net/cert/cert_verify_proc.h" | 21 #include "net/cert/cert_verify_proc.h" |
22 #include "net/cert/multi_threaded_cert_verifier.h" | 22 #include "net/cert/multi_threaded_cert_verifier.h" |
23 #include "net/dns/host_resolver.h" | 23 #include "net/dns/host_resolver.h" |
24 #include "net/dns/mapped_host_resolver.h" | 24 #include "net/dns/mapped_host_resolver.h" |
25 #include "net/http/http_server_properties.h" | 25 #include "net/http/http_server_properties.h" |
26 #include "net/nqe/network_quality_estimator_params.h" | |
26 #include "net/quic/chromium/quic_utils_chromium.h" | 27 #include "net/quic/chromium/quic_utils_chromium.h" |
27 #include "net/quic/core/quic_packets.h" | 28 #include "net/quic/core/quic_packets.h" |
28 #include "net/socket/ssl_client_socket.h" | 29 #include "net/socket/ssl_client_socket.h" |
29 #include "net/url_request/url_request_context_builder.h" | 30 #include "net/url_request/url_request_context_builder.h" |
30 | 31 |
31 namespace cronet { | 32 namespace cronet { |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 // Name of disk cache directory. | 36 // Name of disk cache directory. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 // Name of integer minimum time in milliseconds between writes to disk for DNS | 79 // Name of integer minimum time in milliseconds between writes to disk for DNS |
79 // cache persistence. Default value is one minute. Only relevant if | 80 // cache persistence. Default value is one minute. Only relevant if |
80 // "persist_to_disk" is true. | 81 // "persist_to_disk" is true. |
81 const char kStaleDnsPersistTimer[] = "persist_delay_ms"; | 82 const char kStaleDnsPersistTimer[] = "persist_delay_ms"; |
82 | 83 |
83 // Rules to override DNS resolution. Intended for testing. | 84 // Rules to override DNS resolution. Intended for testing. |
84 // See explanation of format in net/dns/mapped_host_resolver.h. | 85 // See explanation of format in net/dns/mapped_host_resolver.h. |
85 const char kHostResolverRulesFieldTrialName[] = "HostResolverRules"; | 86 const char kHostResolverRulesFieldTrialName[] = "HostResolverRules"; |
86 const char kHostResolverRules[] = "host_resolver_rules"; | 87 const char kHostResolverRules[] = "host_resolver_rules"; |
87 | 88 |
89 // NetworkQualityEstimator (NQE) experiment dictionary name. | |
90 const char kNetworkQualityEstimatorFieldTrialName[] = "NetworkQualityEstimator"; | |
91 // Name of the boolean to enable reading of the persistemnt prefs in NQE. | |
mgersh
2017/06/29 19:02:32
nit: typo in "persistent"
tbansal1
2017/06/29 22:45:05
Done.
| |
92 const char kNQEPersistentCacheReadingEnabled[] = | |
93 "persistent_cache_reading_enabled"; | |
94 | |
88 // Disable IPv6 when on WiFi. This is a workaround for a known issue on certain | 95 // Disable IPv6 when on WiFi. This is a workaround for a known issue on certain |
89 // Android phones, and should not be necessary when not on one of those devices. | 96 // Android phones, and should not be necessary when not on one of those devices. |
90 // See https://crbug.com/696569 for details. | 97 // See https://crbug.com/696569 for details. |
91 const char kDisableIPv6OnWifi[] = "disable_ipv6_on_wifi"; | 98 const char kDisableIPv6OnWifi[] = "disable_ipv6_on_wifi"; |
92 | 99 |
93 const char kSSLKeyLogFile[] = "ssl_key_log_file"; | 100 const char kSSLKeyLogFile[] = "ssl_key_log_file"; |
94 | 101 |
95 } // namespace | 102 } // namespace |
96 | 103 |
97 URLRequestContextConfig::QuicHint::QuicHint(const std::string& host, | 104 URLRequestContextConfig::QuicHint::QuicHint(const std::string& host, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 : enable_quic(enable_quic), | 136 : enable_quic(enable_quic), |
130 quic_user_agent_id(quic_user_agent_id), | 137 quic_user_agent_id(quic_user_agent_id), |
131 enable_spdy(enable_spdy), | 138 enable_spdy(enable_spdy), |
132 enable_sdch(enable_sdch), | 139 enable_sdch(enable_sdch), |
133 enable_brotli(enable_brotli), | 140 enable_brotli(enable_brotli), |
134 http_cache(http_cache), | 141 http_cache(http_cache), |
135 http_cache_max_size(http_cache_max_size), | 142 http_cache_max_size(http_cache_max_size), |
136 load_disable_cache(load_disable_cache), | 143 load_disable_cache(load_disable_cache), |
137 storage_path(storage_path), | 144 storage_path(storage_path), |
138 user_agent(user_agent), | 145 user_agent(user_agent), |
139 experimental_options(experimental_options), | |
140 mock_cert_verifier(std::move(mock_cert_verifier)), | 146 mock_cert_verifier(std::move(mock_cert_verifier)), |
141 enable_network_quality_estimator(enable_network_quality_estimator), | 147 enable_network_quality_estimator(enable_network_quality_estimator), |
142 bypass_public_key_pinning_for_local_trust_anchors( | 148 bypass_public_key_pinning_for_local_trust_anchors( |
143 bypass_public_key_pinning_for_local_trust_anchors), | 149 bypass_public_key_pinning_for_local_trust_anchors), |
144 cert_verifier_data(cert_verifier_data) {} | 150 cert_verifier_data(cert_verifier_data), |
151 nqe_persistent_caching_enabled(false), | |
152 experimental_options(experimental_options) {} | |
145 | 153 |
146 URLRequestContextConfig::~URLRequestContextConfig() {} | 154 URLRequestContextConfig::~URLRequestContextConfig() {} |
147 | 155 |
148 void URLRequestContextConfig::ParseAndSetExperimentalOptions( | 156 void URLRequestContextConfig::ParseAndSetExperimentalOptions( |
149 net::URLRequestContextBuilder* context_builder, | 157 net::URLRequestContextBuilder* context_builder, |
150 net::NetLog* net_log, | 158 net::NetLog* net_log, |
151 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) { | 159 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) { |
152 if (experimental_options.empty()) | 160 if (experimental_options.empty()) |
153 return; | 161 return; |
154 | 162 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 if (!ssl_key_log_file.empty() && file_task_runner) { | 338 if (!ssl_key_log_file.empty() && file_task_runner) { |
331 // SetSSLKeyLogFile is only safe to call before any SSLClientSockets | 339 // SetSSLKeyLogFile is only safe to call before any SSLClientSockets |
332 // are created. This should not be used if there are multiple | 340 // are created. This should not be used if there are multiple |
333 // CronetEngine. | 341 // CronetEngine. |
334 // TODO(xunjieli): Expose this as a stable API after crbug.com/458365 | 342 // TODO(xunjieli): Expose this as a stable API after crbug.com/458365 |
335 // is resolved. | 343 // is resolved. |
336 net::SSLClientSocket::SetSSLKeyLogFile(ssl_key_log_file, | 344 net::SSLClientSocket::SetSSLKeyLogFile(ssl_key_log_file, |
337 file_task_runner); | 345 file_task_runner); |
338 } | 346 } |
339 } | 347 } |
348 } else if (it.key() == kNetworkQualityEstimatorFieldTrialName) { | |
349 const base::DictionaryValue* nqe_args = nullptr; | |
350 if (!it.value().GetAsDictionary(&nqe_args)) { | |
351 LOG(ERROR) << "\"" << it.key() << "\" config params \"" << it.value() | |
352 << "\" is not a dictionary value"; | |
353 effective_experimental_options->Remove(it.key(), nullptr); | |
354 continue; | |
355 } | |
356 | |
357 bool persistent_caching_enabled; | |
358 if (nqe_args->GetBoolean(kNQEPersistentCacheReadingEnabled, | |
359 &persistent_caching_enabled)) { | |
360 nqe_persistent_caching_enabled = persistent_caching_enabled; | |
361 } | |
362 | |
363 std::string nqe_option; | |
364 if (nqe_args->GetString(net::kForceEffectiveConnectionType, | |
365 &nqe_option)) { | |
366 net::EffectiveConnectionType forced_effective_connection_type = | |
367 net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN; | |
368 bool effective_connection_type_available = | |
369 net::GetEffectiveConnectionTypeForName( | |
370 nqe_option, &forced_effective_connection_type); | |
371 if (!effective_connection_type_available) { | |
372 LOG(ERROR) << "\"" << nqe_option | |
373 << "\" is not a valid effective connection type value"; | |
374 } else { | |
375 nqe_forced_effective_connection_type = | |
376 forced_effective_connection_type; | |
377 } | |
378 } | |
379 | |
340 } else { | 380 } else { |
341 LOG(WARNING) << "Unrecognized Cronet experimental option \"" << it.key() | 381 LOG(WARNING) << "Unrecognized Cronet experimental option \"" << it.key() |
342 << "\" with params \"" << it.value(); | 382 << "\" with params \"" << it.value(); |
343 effective_experimental_options->Remove(it.key(), nullptr); | 383 effective_experimental_options->Remove(it.key(), nullptr); |
344 } | 384 } |
345 } | 385 } |
346 | 386 |
347 if (async_dns_enable || stale_dns_enable || host_resolver_rules_enable || | 387 if (async_dns_enable || stale_dns_enable || host_resolver_rules_enable || |
348 disable_ipv6_on_wifi) { | 388 disable_ipv6_on_wifi) { |
349 CHECK(net_log) << "All DNS-related experiments require NetLog."; | 389 CHECK(net_log) << "All DNS-related experiments require NetLog."; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 URLRequestContextConfigBuilder::Build() { | 462 URLRequestContextConfigBuilder::Build() { |
423 return base::MakeUnique<URLRequestContextConfig>( | 463 return base::MakeUnique<URLRequestContextConfig>( |
424 enable_quic, quic_user_agent_id, enable_spdy, enable_sdch, enable_brotli, | 464 enable_quic, quic_user_agent_id, enable_spdy, enable_sdch, enable_brotli, |
425 http_cache, http_cache_max_size, load_disable_cache, storage_path, | 465 http_cache, http_cache_max_size, load_disable_cache, storage_path, |
426 user_agent, experimental_options, std::move(mock_cert_verifier), | 466 user_agent, experimental_options, std::move(mock_cert_verifier), |
427 enable_network_quality_estimator, | 467 enable_network_quality_estimator, |
428 bypass_public_key_pinning_for_local_trust_anchors, cert_verifier_data); | 468 bypass_public_key_pinning_for_local_trust_anchors, cert_verifier_data); |
429 } | 469 } |
430 | 470 |
431 } // namespace cronet | 471 } // namespace cronet |
OLD | NEW |