| 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 20 matching lines...) Expand all Loading... |
| 31 "store_server_configs_in_properties"; | 31 "store_server_configs_in_properties"; |
| 32 const char kQuicMaxServerConfigsStoredInProperties[] = | 32 const char kQuicMaxServerConfigsStoredInProperties[] = |
| 33 "max_server_configs_stored_in_properties"; | 33 "max_server_configs_stored_in_properties"; |
| 34 const char kQuicDelayTcpRace[] = "delay_tcp_race"; | 34 const char kQuicDelayTcpRace[] = "delay_tcp_race"; |
| 35 const char kQuicMaxNumberOfLossyConnections[] = | 35 const char kQuicMaxNumberOfLossyConnections[] = |
| 36 "max_number_of_lossy_connections"; | 36 "max_number_of_lossy_connections"; |
| 37 const char kQuicPacketLossThreshold[] = "packet_loss_threshold"; | 37 const char kQuicPacketLossThreshold[] = "packet_loss_threshold"; |
| 38 const char kQuicIdleConnectionTimeoutSeconds[] = | 38 const char kQuicIdleConnectionTimeoutSeconds[] = |
| 39 "idle_connection_timeout_seconds"; | 39 "idle_connection_timeout_seconds"; |
| 40 const char kQuicHostWhitelist[] = "host_whitelist"; | 40 const char kQuicHostWhitelist[] = "host_whitelist"; |
| 41 const char kQuicPreferAes[] = "prefer_aes"; |
| 41 | 42 |
| 42 // AsyncDNS experiment dictionary name. | 43 // AsyncDNS experiment dictionary name. |
| 43 const char kAsyncDnsFieldTrialName[] = "AsyncDNS"; | 44 const char kAsyncDnsFieldTrialName[] = "AsyncDNS"; |
| 44 // Name of boolean to enable AsyncDNS experiment. | 45 // Name of boolean to enable AsyncDNS experiment. |
| 45 const char kAsyncDnsEnable[] = "enable"; | 46 const char kAsyncDnsEnable[] = "enable"; |
| 46 | 47 |
| 47 void ParseAndSetExperimentalOptions( | 48 void ParseAndSetExperimentalOptions( |
| 48 const std::string& experimental_options, | 49 const std::string& experimental_options, |
| 49 net::URLRequestContextBuilder* context_builder, | 50 net::URLRequestContextBuilder* context_builder, |
| 50 net::NetLog* net_log) { | 51 net::NetLog* net_log) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 std::string quic_host_whitelist; | 125 std::string quic_host_whitelist; |
| 125 if (quic_args->GetString(kQuicHostWhitelist, &quic_host_whitelist)) { | 126 if (quic_args->GetString(kQuicHostWhitelist, &quic_host_whitelist)) { |
| 126 std::unordered_set<std::string> hosts; | 127 std::unordered_set<std::string> hosts; |
| 127 for (const std::string& host : | 128 for (const std::string& host : |
| 128 base::SplitString(quic_host_whitelist, ",", base::TRIM_WHITESPACE, | 129 base::SplitString(quic_host_whitelist, ",", base::TRIM_WHITESPACE, |
| 129 base::SPLIT_WANT_ALL)) { | 130 base::SPLIT_WANT_ALL)) { |
| 130 hosts.insert(host); | 131 hosts.insert(host); |
| 131 } | 132 } |
| 132 context_builder->set_quic_host_whitelist(hosts); | 133 context_builder->set_quic_host_whitelist(hosts); |
| 133 } | 134 } |
| 135 |
| 136 bool quic_prefer_aes = false; |
| 137 if (quic_args->GetBoolean(kQuicPreferAes, &quic_prefer_aes)) { |
| 138 context_builder->set_quic_prefer_aes(quic_prefer_aes); |
| 139 } |
| 134 } | 140 } |
| 135 | 141 |
| 136 const base::DictionaryValue* async_dns_args = nullptr; | 142 const base::DictionaryValue* async_dns_args = nullptr; |
| 137 if (dict->GetDictionary(kAsyncDnsFieldTrialName, &async_dns_args)) { | 143 if (dict->GetDictionary(kAsyncDnsFieldTrialName, &async_dns_args)) { |
| 138 bool async_dns_enable = false; | 144 bool async_dns_enable = false; |
| 139 if (async_dns_args->GetBoolean(kAsyncDnsEnable, &async_dns_enable) && | 145 if (async_dns_args->GetBoolean(kAsyncDnsEnable, &async_dns_enable) && |
| 140 async_dns_enable) { | 146 async_dns_enable) { |
| 141 if (net_log == nullptr) { | 147 if (net_log == nullptr) { |
| 142 DCHECK(false) << "AsyncDNS experiment requires NetLog."; | 148 DCHECK(false) << "AsyncDNS experiment requires NetLog."; |
| 143 } else { | 149 } else { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 163 bool include_subdomains, | 169 bool include_subdomains, |
| 164 const base::Time& expiration_date) | 170 const base::Time& expiration_date) |
| 165 : host(host), | 171 : host(host), |
| 166 include_subdomains(include_subdomains), | 172 include_subdomains(include_subdomains), |
| 167 expiration_date(expiration_date) {} | 173 expiration_date(expiration_date) {} |
| 168 | 174 |
| 169 URLRequestContextConfig::Pkp::~Pkp() {} | 175 URLRequestContextConfig::Pkp::~Pkp() {} |
| 170 | 176 |
| 171 URLRequestContextConfig::URLRequestContextConfig( | 177 URLRequestContextConfig::URLRequestContextConfig( |
| 172 bool enable_quic, | 178 bool enable_quic, |
| 179 const std::string& quic_user_agent_id, |
| 173 bool enable_spdy, | 180 bool enable_spdy, |
| 174 bool enable_sdch, | 181 bool enable_sdch, |
| 175 HttpCacheType http_cache, | 182 HttpCacheType http_cache, |
| 176 int http_cache_max_size, | 183 int http_cache_max_size, |
| 177 bool load_disable_cache, | 184 bool load_disable_cache, |
| 178 const std::string& storage_path, | 185 const std::string& storage_path, |
| 179 const std::string& user_agent, | 186 const std::string& user_agent, |
| 180 const std::string& experimental_options, | 187 const std::string& experimental_options, |
| 181 const std::string& data_reduction_proxy_key, | 188 const std::string& data_reduction_proxy_key, |
| 182 const std::string& data_reduction_primary_proxy, | 189 const std::string& data_reduction_primary_proxy, |
| 183 const std::string& data_reduction_fallback_proxy, | 190 const std::string& data_reduction_fallback_proxy, |
| 184 const std::string& data_reduction_secure_proxy_check_url, | 191 const std::string& data_reduction_secure_proxy_check_url, |
| 185 scoped_ptr<net::CertVerifier> mock_cert_verifier) | 192 scoped_ptr<net::CertVerifier> mock_cert_verifier) |
| 186 : enable_quic(enable_quic), | 193 : enable_quic(enable_quic), |
| 194 quic_user_agent_id(quic_user_agent_id), |
| 187 enable_spdy(enable_spdy), | 195 enable_spdy(enable_spdy), |
| 188 enable_sdch(enable_sdch), | 196 enable_sdch(enable_sdch), |
| 189 http_cache(http_cache), | 197 http_cache(http_cache), |
| 190 http_cache_max_size(http_cache_max_size), | 198 http_cache_max_size(http_cache_max_size), |
| 191 load_disable_cache(load_disable_cache), | 199 load_disable_cache(load_disable_cache), |
| 192 storage_path(storage_path), | 200 storage_path(storage_path), |
| 193 user_agent(user_agent), | 201 user_agent(user_agent), |
| 194 experimental_options(experimental_options), | 202 experimental_options(experimental_options), |
| 195 data_reduction_proxy_key(data_reduction_proxy_key), | 203 data_reduction_proxy_key(data_reduction_proxy_key), |
| 196 data_reduction_primary_proxy(data_reduction_primary_proxy), | 204 data_reduction_primary_proxy(data_reduction_primary_proxy), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 215 net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY; | 223 net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY; |
| 216 } | 224 } |
| 217 cache_params.max_size = http_cache_max_size; | 225 cache_params.max_size = http_cache_max_size; |
| 218 context_builder->EnableHttpCache(cache_params); | 226 context_builder->EnableHttpCache(cache_params); |
| 219 } else { | 227 } else { |
| 220 context_builder->DisableHttpCache(); | 228 context_builder->DisableHttpCache(); |
| 221 } | 229 } |
| 222 context_builder->set_user_agent(user_agent); | 230 context_builder->set_user_agent(user_agent); |
| 223 context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic); | 231 context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic); |
| 224 context_builder->set_sdch_enabled(enable_sdch); | 232 context_builder->set_sdch_enabled(enable_sdch); |
| 233 context_builder->set_quic_user_agent_id(quic_user_agent_id); |
| 225 | 234 |
| 226 ParseAndSetExperimentalOptions(experimental_options, context_builder, | 235 ParseAndSetExperimentalOptions(experimental_options, context_builder, |
| 227 net_log); | 236 net_log); |
| 228 | 237 |
| 229 if (mock_cert_verifier) | 238 if (mock_cert_verifier) |
| 230 context_builder->SetCertVerifier(std::move(mock_cert_verifier)); | 239 context_builder->SetCertVerifier(std::move(mock_cert_verifier)); |
| 231 // TODO(mef): Use |config| to set cookies. | 240 // TODO(mef): Use |config| to set cookies. |
| 232 } | 241 } |
| 233 | 242 |
| 234 } // namespace cronet | 243 } // namespace cronet |
| OLD | NEW |