| 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" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 const char kHostResolverRulesFieldTrialName[] = "HostResolverRules"; | 82 const char kHostResolverRulesFieldTrialName[] = "HostResolverRules"; |
| 83 const char kHostResolverRules[] = "host_resolver_rules"; | 83 const char kHostResolverRules[] = "host_resolver_rules"; |
| 84 | 84 |
| 85 // Disable IPv6. This should almost never be necessary because the network stack | 85 // Disable IPv6. This should almost never be necessary because the network stack |
| 86 // has IPv6 detection logic. Please do not turn on this option without first | 86 // has IPv6 detection logic. Please do not turn on this option without first |
| 87 // reporting a bug. See http://crbug.com/696569 for the currently known issue. | 87 // reporting a bug. See http://crbug.com/696569 for the currently known issue. |
| 88 const char kDisableIPv6[] = "disable_ipv6"; | 88 const char kDisableIPv6[] = "disable_ipv6"; |
| 89 | 89 |
| 90 const char kSSLKeyLogFile[] = "ssl_key_log_file"; | 90 const char kSSLKeyLogFile[] = "ssl_key_log_file"; |
| 91 | 91 |
| 92 void ParseAndSetExperimentalOptions( | 92 // Returns the effective experimental options. |
| 93 std::unique_ptr<base::DictionaryValue> ParseAndSetExperimentalOptions( |
| 93 const std::string& experimental_options, | 94 const std::string& experimental_options, |
| 94 net::URLRequestContextBuilder* context_builder, | 95 net::URLRequestContextBuilder* context_builder, |
| 95 net::NetLog* net_log, | 96 net::NetLog* net_log, |
| 96 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) { | 97 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) { |
| 97 if (experimental_options.empty()) | 98 if (experimental_options.empty()) |
| 98 return; | 99 return nullptr; |
| 99 | 100 |
| 100 DCHECK(net_log); | 101 DCHECK(net_log); |
| 101 | 102 |
| 102 DVLOG(1) << "Experimental Options:" << experimental_options; | 103 DVLOG(1) << "Experimental Options:" << experimental_options; |
| 103 std::unique_ptr<base::Value> options = | 104 std::unique_ptr<base::Value> options = |
| 104 base::JSONReader::Read(experimental_options); | 105 base::JSONReader::Read(experimental_options); |
| 105 | 106 |
| 106 if (!options) { | 107 if (!options) { |
| 107 DCHECK(false) << "Parsing experimental options failed: " | 108 DCHECK(false) << "Parsing experimental options failed: " |
| 108 << experimental_options; | 109 << experimental_options; |
| 109 return; | 110 return nullptr; |
| 110 } | 111 } |
| 111 | 112 |
| 112 std::unique_ptr<base::DictionaryValue> dict = | 113 std::unique_ptr<base::DictionaryValue> dict = |
| 113 base::DictionaryValue::From(std::move(options)); | 114 base::DictionaryValue::From(std::move(options)); |
| 114 | 115 |
| 115 if (!dict) { | 116 if (!dict) { |
| 116 DCHECK(false) << "Experimental options string is not a dictionary: " | 117 DCHECK(false) << "Experimental options string is not a dictionary: " |
| 117 << experimental_options; | 118 << experimental_options; |
| 118 return; | 119 return nullptr; |
| 119 } | |
| 120 | |
| 121 const base::DictionaryValue* quic_args = nullptr; | |
| 122 if (dict->GetDictionary(kQuicFieldTrialName, &quic_args)) { | |
| 123 std::string quic_connection_options; | |
| 124 if (quic_args->GetString(kQuicConnectionOptions, | |
| 125 &quic_connection_options)) { | |
| 126 context_builder->set_quic_connection_options( | |
| 127 net::ParseQuicConnectionOptions(quic_connection_options)); | |
| 128 } | |
| 129 | |
| 130 // TODO(rtenneti): Delete this option after apps stop using it. | |
| 131 // Added this for backward compatibility. | |
| 132 bool quic_store_server_configs_in_properties = false; | |
| 133 if (quic_args->GetBoolean(kQuicStoreServerConfigsInProperties, | |
| 134 &quic_store_server_configs_in_properties)) { | |
| 135 context_builder->set_quic_max_server_configs_stored_in_properties( | |
| 136 net::kMaxQuicServersToPersist); | |
| 137 } | |
| 138 | |
| 139 int quic_max_server_configs_stored_in_properties = 0; | |
| 140 if (quic_args->GetInteger(kQuicMaxServerConfigsStoredInProperties, | |
| 141 &quic_max_server_configs_stored_in_properties)) { | |
| 142 context_builder->set_quic_max_server_configs_stored_in_properties( | |
| 143 static_cast<size_t>(quic_max_server_configs_stored_in_properties)); | |
| 144 } | |
| 145 | |
| 146 bool quic_delay_tcp_race = false; | |
| 147 if (quic_args->GetBoolean(kQuicDelayTcpRace, &quic_delay_tcp_race)) { | |
| 148 context_builder->set_quic_delay_tcp_race(quic_delay_tcp_race); | |
| 149 } | |
| 150 | |
| 151 int quic_idle_connection_timeout_seconds = 0; | |
| 152 if (quic_args->GetInteger(kQuicIdleConnectionTimeoutSeconds, | |
| 153 &quic_idle_connection_timeout_seconds)) { | |
| 154 context_builder->set_quic_idle_connection_timeout_seconds( | |
| 155 quic_idle_connection_timeout_seconds); | |
| 156 } | |
| 157 | |
| 158 std::string quic_host_whitelist; | |
| 159 if (quic_args->GetString(kQuicHostWhitelist, &quic_host_whitelist)) { | |
| 160 std::unordered_set<std::string> hosts; | |
| 161 for (const std::string& host : | |
| 162 base::SplitString(quic_host_whitelist, ",", base::TRIM_WHITESPACE, | |
| 163 base::SPLIT_WANT_ALL)) { | |
| 164 hosts.insert(host); | |
| 165 } | |
| 166 context_builder->set_quic_host_whitelist(hosts); | |
| 167 } | |
| 168 | |
| 169 bool quic_close_sessions_on_ip_change = false; | |
| 170 if (quic_args->GetBoolean(kQuicCloseSessionsOnIpChange, | |
| 171 &quic_close_sessions_on_ip_change)) { | |
| 172 context_builder->set_quic_close_sessions_on_ip_change( | |
| 173 quic_close_sessions_on_ip_change); | |
| 174 } | |
| 175 | |
| 176 bool quic_migrate_sessions_on_network_change = false; | |
| 177 if (quic_args->GetBoolean(kQuicMigrateSessionsOnNetworkChange, | |
| 178 &quic_migrate_sessions_on_network_change)) { | |
| 179 context_builder->set_quic_migrate_sessions_on_network_change( | |
| 180 quic_migrate_sessions_on_network_change); | |
| 181 } | |
| 182 | |
| 183 bool quic_prefer_aes = false; | |
| 184 if (quic_args->GetBoolean(kQuicPreferAes, &quic_prefer_aes)) { | |
| 185 context_builder->set_quic_prefer_aes(quic_prefer_aes); | |
| 186 } | |
| 187 | |
| 188 std::string quic_user_agent_id; | |
| 189 if (quic_args->GetString(kQuicUserAgentId, &quic_user_agent_id)) { | |
| 190 context_builder->set_quic_user_agent_id(quic_user_agent_id); | |
| 191 } | |
| 192 | |
| 193 bool quic_migrate_sessions_early = false; | |
| 194 if (quic_args->GetBoolean(kQuicMigrateSessionsEarly, | |
| 195 &quic_migrate_sessions_early)) { | |
| 196 context_builder->set_quic_migrate_sessions_early( | |
| 197 quic_migrate_sessions_early); | |
| 198 } | |
| 199 | |
| 200 bool quic_disable_bidirectional_streams = false; | |
| 201 if (quic_args->GetBoolean(kQuicDisableBidirectionalStreams, | |
| 202 &quic_disable_bidirectional_streams)) { | |
| 203 context_builder->set_quic_disable_bidirectional_streams( | |
| 204 quic_disable_bidirectional_streams); | |
| 205 } | |
| 206 | |
| 207 bool quic_race_cert_verification = false; | |
| 208 if (quic_args->GetBoolean(kQuicRaceCertVerification, | |
| 209 &quic_race_cert_verification)) { | |
| 210 context_builder->set_quic_race_cert_verification( | |
| 211 quic_race_cert_verification); | |
| 212 } | |
| 213 } | 120 } |
| 214 | 121 |
| 215 bool async_dns_enable = false; | 122 bool async_dns_enable = false; |
| 216 bool stale_dns_enable = false; | 123 bool stale_dns_enable = false; |
| 217 bool host_resolver_rules_enable = false; | 124 bool host_resolver_rules_enable = false; |
| 218 bool disable_ipv6 = false; | 125 bool disable_ipv6 = false; |
| 126 |
| 127 std::unique_ptr<base::DictionaryValue> effective_experimental_options = |
| 128 dict->CreateDeepCopy(); |
| 219 StaleHostResolver::StaleOptions stale_dns_options; | 129 StaleHostResolver::StaleOptions stale_dns_options; |
| 220 std::string host_resolver_rules_string; | 130 std::string host_resolver_rules_string; |
| 131 for (base::DictionaryValue::Iterator it(*dict.get()); !it.IsAtEnd(); |
| 132 it.Advance()) { |
| 133 if (it.key() == kQuicFieldTrialName) { |
| 134 const base::DictionaryValue* quic_args = nullptr; |
| 135 if (!it.value().GetAsDictionary(&quic_args)) { |
| 136 LOG(ERROR) << "Quic config params \"" << it.value() |
| 137 << "\" is not a dictionary value"; |
| 138 effective_experimental_options->Remove(it.key(), nullptr); |
| 139 continue; |
| 140 } |
| 141 std::string quic_connection_options; |
| 142 if (quic_args->GetString(kQuicConnectionOptions, |
| 143 &quic_connection_options)) { |
| 144 context_builder->set_quic_connection_options( |
| 145 net::ParseQuicConnectionOptions(quic_connection_options)); |
| 146 } |
| 221 | 147 |
| 222 const base::DictionaryValue* async_dns_args = nullptr; | 148 // TODO(rtenneti): Delete this option after apps stop using it. |
| 223 if (dict->GetDictionary(kAsyncDnsFieldTrialName, &async_dns_args)) | 149 // Added this for backward compatibility. |
| 224 async_dns_args->GetBoolean(kAsyncDnsEnable, &async_dns_enable); | 150 bool quic_store_server_configs_in_properties = false; |
| 151 if (quic_args->GetBoolean(kQuicStoreServerConfigsInProperties, |
| 152 &quic_store_server_configs_in_properties)) { |
| 153 context_builder->set_quic_max_server_configs_stored_in_properties( |
| 154 net::kMaxQuicServersToPersist); |
| 155 } |
| 225 | 156 |
| 226 const base::DictionaryValue* stale_dns_args = nullptr; | 157 int quic_max_server_configs_stored_in_properties = 0; |
| 227 if (dict->GetDictionary(kStaleDnsFieldTrialName, &stale_dns_args)) { | 158 if (quic_args->GetInteger( |
| 228 if (stale_dns_args->GetBoolean(kStaleDnsEnable, &stale_dns_enable) && | 159 kQuicMaxServerConfigsStoredInProperties, |
| 229 stale_dns_enable) { | 160 &quic_max_server_configs_stored_in_properties)) { |
| 230 int delay; | 161 context_builder->set_quic_max_server_configs_stored_in_properties( |
| 231 if (stale_dns_args->GetInteger(kStaleDnsDelayMs, &delay)) | 162 static_cast<size_t>(quic_max_server_configs_stored_in_properties)); |
| 232 stale_dns_options.delay = base::TimeDelta::FromMilliseconds(delay); | |
| 233 int max_expired_time_ms; | |
| 234 if (stale_dns_args->GetInteger(kStaleDnsMaxExpiredTimeMs, | |
| 235 &max_expired_time_ms)) { | |
| 236 stale_dns_options.max_expired_time = | |
| 237 base::TimeDelta::FromMilliseconds(max_expired_time_ms); | |
| 238 } | 163 } |
| 239 int max_stale_uses; | 164 |
| 240 if (stale_dns_args->GetInteger(kStaleDnsMaxStaleUses, &max_stale_uses)) | 165 bool quic_delay_tcp_race = false; |
| 241 stale_dns_options.max_stale_uses = max_stale_uses; | 166 if (quic_args->GetBoolean(kQuicDelayTcpRace, &quic_delay_tcp_race)) { |
| 242 bool allow_other_network; | 167 context_builder->set_quic_delay_tcp_race(quic_delay_tcp_race); |
| 243 if (stale_dns_args->GetBoolean(kStaleDnsAllowOtherNetwork, | |
| 244 &allow_other_network)) { | |
| 245 stale_dns_options.allow_other_network = allow_other_network; | |
| 246 } | 168 } |
| 169 |
| 170 int quic_idle_connection_timeout_seconds = 0; |
| 171 if (quic_args->GetInteger(kQuicIdleConnectionTimeoutSeconds, |
| 172 &quic_idle_connection_timeout_seconds)) { |
| 173 context_builder->set_quic_idle_connection_timeout_seconds( |
| 174 quic_idle_connection_timeout_seconds); |
| 175 } |
| 176 |
| 177 std::string quic_host_whitelist; |
| 178 if (quic_args->GetString(kQuicHostWhitelist, &quic_host_whitelist)) { |
| 179 std::unordered_set<std::string> hosts; |
| 180 for (const std::string& host : |
| 181 base::SplitString(quic_host_whitelist, ",", base::TRIM_WHITESPACE, |
| 182 base::SPLIT_WANT_ALL)) { |
| 183 hosts.insert(host); |
| 184 } |
| 185 context_builder->set_quic_host_whitelist(hosts); |
| 186 } |
| 187 |
| 188 bool quic_close_sessions_on_ip_change = false; |
| 189 if (quic_args->GetBoolean(kQuicCloseSessionsOnIpChange, |
| 190 &quic_close_sessions_on_ip_change)) { |
| 191 context_builder->set_quic_close_sessions_on_ip_change( |
| 192 quic_close_sessions_on_ip_change); |
| 193 } |
| 194 |
| 195 bool quic_migrate_sessions_on_network_change = false; |
| 196 if (quic_args->GetBoolean(kQuicMigrateSessionsOnNetworkChange, |
| 197 &quic_migrate_sessions_on_network_change)) { |
| 198 context_builder->set_quic_migrate_sessions_on_network_change( |
| 199 quic_migrate_sessions_on_network_change); |
| 200 } |
| 201 |
| 202 bool quic_prefer_aes = false; |
| 203 if (quic_args->GetBoolean(kQuicPreferAes, &quic_prefer_aes)) { |
| 204 context_builder->set_quic_prefer_aes(quic_prefer_aes); |
| 205 } |
| 206 |
| 207 std::string quic_user_agent_id; |
| 208 if (quic_args->GetString(kQuicUserAgentId, &quic_user_agent_id)) { |
| 209 context_builder->set_quic_user_agent_id(quic_user_agent_id); |
| 210 } |
| 211 |
| 212 bool quic_migrate_sessions_early = false; |
| 213 if (quic_args->GetBoolean(kQuicMigrateSessionsEarly, |
| 214 &quic_migrate_sessions_early)) { |
| 215 context_builder->set_quic_migrate_sessions_early( |
| 216 quic_migrate_sessions_early); |
| 217 } |
| 218 |
| 219 bool quic_disable_bidirectional_streams = false; |
| 220 if (quic_args->GetBoolean(kQuicDisableBidirectionalStreams, |
| 221 &quic_disable_bidirectional_streams)) { |
| 222 context_builder->set_quic_disable_bidirectional_streams( |
| 223 quic_disable_bidirectional_streams); |
| 224 } |
| 225 |
| 226 bool quic_race_cert_verification = false; |
| 227 if (quic_args->GetBoolean(kQuicRaceCertVerification, |
| 228 &quic_race_cert_verification)) { |
| 229 context_builder->set_quic_race_cert_verification( |
| 230 quic_race_cert_verification); |
| 231 } |
| 232 |
| 233 } else if (it.key() == kAsyncDnsFieldTrialName) { |
| 234 const base::DictionaryValue* async_dns_args = nullptr; |
| 235 if (!it.value().GetAsDictionary(&async_dns_args)) { |
| 236 LOG(ERROR) << "\"" << it.key() << "\" config params \"" << it.value() |
| 237 << "\" is not a dictionary value"; |
| 238 effective_experimental_options->Remove(it.key(), nullptr); |
| 239 continue; |
| 240 } |
| 241 async_dns_args->GetBoolean(kAsyncDnsEnable, &async_dns_enable); |
| 242 } else if (it.key() == kStaleDnsFieldTrialName) { |
| 243 const base::DictionaryValue* stale_dns_args = nullptr; |
| 244 if (!it.value().GetAsDictionary(&stale_dns_args)) { |
| 245 LOG(ERROR) << "\"" << it.key() << "\" config params \"" << it.value() |
| 246 << "\" is not a dictionary value"; |
| 247 effective_experimental_options->Remove(it.key(), nullptr); |
| 248 continue; |
| 249 } |
| 250 if (stale_dns_args->GetBoolean(kStaleDnsEnable, &stale_dns_enable) && |
| 251 stale_dns_enable) { |
| 252 int delay; |
| 253 if (stale_dns_args->GetInteger(kStaleDnsDelayMs, &delay)) |
| 254 stale_dns_options.delay = base::TimeDelta::FromMilliseconds(delay); |
| 255 int max_expired_time_ms; |
| 256 if (stale_dns_args->GetInteger(kStaleDnsMaxExpiredTimeMs, |
| 257 &max_expired_time_ms)) { |
| 258 stale_dns_options.max_expired_time = |
| 259 base::TimeDelta::FromMilliseconds(max_expired_time_ms); |
| 260 } |
| 261 int max_stale_uses; |
| 262 if (stale_dns_args->GetInteger(kStaleDnsMaxStaleUses, &max_stale_uses)) |
| 263 stale_dns_options.max_stale_uses = max_stale_uses; |
| 264 bool allow_other_network; |
| 265 if (stale_dns_args->GetBoolean(kStaleDnsAllowOtherNetwork, |
| 266 &allow_other_network)) { |
| 267 stale_dns_options.allow_other_network = allow_other_network; |
| 268 } |
| 269 } |
| 270 } else if (it.key() == kHostResolverRulesFieldTrialName) { |
| 271 const base::DictionaryValue* host_resolver_rules_args = nullptr; |
| 272 if (!it.value().GetAsDictionary(&host_resolver_rules_args)) { |
| 273 LOG(ERROR) << "\"" << it.key() << "\" config params \"" << it.value() |
| 274 << "\" is not a dictionary value"; |
| 275 effective_experimental_options->Remove(it.key(), nullptr); |
| 276 continue; |
| 277 } |
| 278 host_resolver_rules_enable = host_resolver_rules_args->GetString( |
| 279 kHostResolverRules, &host_resolver_rules_string); |
| 280 } else if (it.key() == kDisableIPv6) { |
| 281 if (!it.value().GetAsBoolean(&disable_ipv6)) { |
| 282 LOG(ERROR) << "\"" << it.key() << "\" config params \"" << it.value() |
| 283 << "\" is not a bool"; |
| 284 effective_experimental_options->Remove(it.key(), nullptr); |
| 285 continue; |
| 286 } |
| 287 } else if (it.key() == kSSLKeyLogFile) { |
| 288 std::string ssl_key_log_file_string; |
| 289 if (it.value().GetAsString(&ssl_key_log_file_string)) { |
| 290 DCHECK(file_task_runner); |
| 291 base::FilePath ssl_key_log_file(ssl_key_log_file_string); |
| 292 if (!ssl_key_log_file.empty() && file_task_runner) { |
| 293 // SetSSLKeyLogFile is only safe to call before any SSLClientSockets |
| 294 // are created. This should not be used if there are multiple |
| 295 // CronetEngine. |
| 296 // TODO(xunjieli): Expose this as a stable API after crbug.com/458365 |
| 297 // is resolved. |
| 298 net::SSLClientSocket::SetSSLKeyLogFile(ssl_key_log_file, |
| 299 file_task_runner); |
| 300 } |
| 301 } |
| 302 } else { |
| 303 LOG(WARNING) << "Unrecognized Cronet experimental option \"" << it.key() |
| 304 << "\" with params \"" << it.value(); |
| 305 effective_experimental_options->Remove(it.key(), nullptr); |
| 247 } | 306 } |
| 248 } | 307 } |
| 249 | 308 |
| 250 const base::DictionaryValue* host_resolver_rules_args = nullptr; | |
| 251 if (dict->GetDictionary(kHostResolverRulesFieldTrialName, | |
| 252 &host_resolver_rules_args)) { | |
| 253 host_resolver_rules_enable = host_resolver_rules_args->GetString( | |
| 254 kHostResolverRules, &host_resolver_rules_string); | |
| 255 } | |
| 256 | |
| 257 dict->GetBoolean(kDisableIPv6, &disable_ipv6); | |
| 258 | |
| 259 if (async_dns_enable || stale_dns_enable || host_resolver_rules_enable || | 309 if (async_dns_enable || stale_dns_enable || host_resolver_rules_enable || |
| 260 disable_ipv6) { | 310 disable_ipv6) { |
| 261 if (net_log == nullptr) { | 311 CHECK(net_log) << "All DNS-related experiments require NetLog."; |
| 262 CHECK(false) << "All DNS-related experiments require NetLog."; | |
| 263 } | |
| 264 std::unique_ptr<net::HostResolver> host_resolver; | 312 std::unique_ptr<net::HostResolver> host_resolver; |
| 265 if (stale_dns_enable) { | 313 if (stale_dns_enable) { |
| 266 DCHECK(!disable_ipv6); | 314 DCHECK(!disable_ipv6); |
| 267 host_resolver.reset(new StaleHostResolver( | 315 host_resolver.reset(new StaleHostResolver( |
| 268 net::HostResolver::CreateDefaultResolverImpl(net_log), | 316 net::HostResolver::CreateDefaultResolverImpl(net_log), |
| 269 stale_dns_options)); | 317 stale_dns_options)); |
| 270 } else { | 318 } else { |
| 271 host_resolver = net::HostResolver::CreateDefaultResolver(net_log); | 319 host_resolver = net::HostResolver::CreateDefaultResolver(net_log); |
| 272 } | 320 } |
| 273 if (disable_ipv6) | 321 if (disable_ipv6) |
| 274 host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); | 322 host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4); |
| 275 if (async_dns_enable) | 323 if (async_dns_enable) |
| 276 host_resolver->SetDnsClientEnabled(true); | 324 host_resolver->SetDnsClientEnabled(true); |
| 277 if (host_resolver_rules_enable) { | 325 if (host_resolver_rules_enable) { |
| 278 std::unique_ptr<net::MappedHostResolver> remapped_resolver( | 326 std::unique_ptr<net::MappedHostResolver> remapped_resolver( |
| 279 new net::MappedHostResolver(std::move(host_resolver))); | 327 new net::MappedHostResolver(std::move(host_resolver))); |
| 280 remapped_resolver->SetRulesFromString(host_resolver_rules_string); | 328 remapped_resolver->SetRulesFromString(host_resolver_rules_string); |
| 281 host_resolver = std::move(remapped_resolver); | 329 host_resolver = std::move(remapped_resolver); |
| 282 } | 330 } |
| 283 context_builder->set_host_resolver(std::move(host_resolver)); | 331 context_builder->set_host_resolver(std::move(host_resolver)); |
| 284 } | 332 } |
| 285 | 333 return effective_experimental_options; |
| 286 std::string ssl_key_log_file_string; | |
| 287 if (dict->GetString(kSSLKeyLogFile, &ssl_key_log_file_string)) { | |
| 288 DCHECK(file_task_runner); | |
| 289 base::FilePath ssl_key_log_file(ssl_key_log_file_string); | |
| 290 if (!ssl_key_log_file.empty() && file_task_runner) { | |
| 291 // SetSSLKeyLogFile is only safe to call before any SSLClientSockets are | |
| 292 // created. This should not be used if there are multiple CronetEngine. | |
| 293 // TODO(xunjieli): Expose this as a stable API after crbug.com/458365 is | |
| 294 // resolved. | |
| 295 net::SSLClientSocket::SetSSLKeyLogFile(ssl_key_log_file, | |
| 296 file_task_runner); | |
| 297 } | |
| 298 } | |
| 299 } | 334 } |
| 300 | 335 |
| 301 } // namespace | 336 } // namespace |
| 302 | 337 |
| 303 URLRequestContextConfig::QuicHint::QuicHint(const std::string& host, | 338 URLRequestContextConfig::QuicHint::QuicHint(const std::string& host, |
| 304 int port, | 339 int port, |
| 305 int alternate_port) | 340 int alternate_port) |
| 306 : host(host), port(port), alternate_port(alternate_port) {} | 341 : host(host), port(port), alternate_port(alternate_port) {} |
| 307 | 342 |
| 308 URLRequestContextConfig::QuicHint::~QuicHint() {} | 343 URLRequestContextConfig::QuicHint::~QuicHint() {} |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 context_builder->EnableHttpCache(cache_params); | 415 context_builder->EnableHttpCache(cache_params); |
| 381 } else { | 416 } else { |
| 382 context_builder->DisableHttpCache(); | 417 context_builder->DisableHttpCache(); |
| 383 } | 418 } |
| 384 context_builder->set_user_agent(user_agent); | 419 context_builder->set_user_agent(user_agent); |
| 385 context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic); | 420 context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic); |
| 386 context_builder->set_sdch_enabled(enable_sdch); | 421 context_builder->set_sdch_enabled(enable_sdch); |
| 387 if (enable_quic) | 422 if (enable_quic) |
| 388 context_builder->set_quic_user_agent_id(quic_user_agent_id); | 423 context_builder->set_quic_user_agent_id(quic_user_agent_id); |
| 389 | 424 |
| 390 ParseAndSetExperimentalOptions(experimental_options, context_builder, net_log, | 425 effective_experimental_options = ParseAndSetExperimentalOptions( |
| 391 file_task_runner); | 426 experimental_options, context_builder, net_log, file_task_runner); |
| 392 | 427 |
| 393 std::unique_ptr<net::CertVerifier> cert_verifier; | 428 std::unique_ptr<net::CertVerifier> cert_verifier; |
| 394 if (mock_cert_verifier) { | 429 if (mock_cert_verifier) { |
| 395 // Because |context_builder| expects CachingCertVerifier, wrap | 430 // Because |context_builder| expects CachingCertVerifier, wrap |
| 396 // |mock_cert_verifier| into a CachingCertVerifier. | 431 // |mock_cert_verifier| into a CachingCertVerifier. |
| 397 cert_verifier = base::MakeUnique<net::CachingCertVerifier>( | 432 cert_verifier = base::MakeUnique<net::CachingCertVerifier>( |
| 398 std::move(mock_cert_verifier)); | 433 std::move(mock_cert_verifier)); |
| 399 } else { | 434 } else { |
| 400 // net::CertVerifier::CreateDefault() returns a CachingCertVerifier. | 435 // net::CertVerifier::CreateDefault() returns a CachingCertVerifier. |
| 401 cert_verifier = net::CertVerifier::CreateDefault(); | 436 cert_verifier = net::CertVerifier::CreateDefault(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 413 enable_quic, quic_user_agent_id, enable_spdy, enable_sdch, http_cache, | 448 enable_quic, quic_user_agent_id, enable_spdy, enable_sdch, http_cache, |
| 414 http_cache_max_size, load_disable_cache, storage_path, user_agent, | 449 http_cache_max_size, load_disable_cache, storage_path, user_agent, |
| 415 experimental_options, data_reduction_proxy_key, | 450 experimental_options, data_reduction_proxy_key, |
| 416 data_reduction_primary_proxy, data_reduction_fallback_proxy, | 451 data_reduction_primary_proxy, data_reduction_fallback_proxy, |
| 417 data_reduction_secure_proxy_check_url, std::move(mock_cert_verifier), | 452 data_reduction_secure_proxy_check_url, std::move(mock_cert_verifier), |
| 418 enable_network_quality_estimator, | 453 enable_network_quality_estimator, |
| 419 bypass_public_key_pinning_for_local_trust_anchors, cert_verifier_data); | 454 bypass_public_key_pinning_for_local_trust_anchors, cert_verifier_data); |
| 420 } | 455 } |
| 421 | 456 |
| 422 } // namespace cronet | 457 } // namespace cronet |
| OLD | NEW |