| 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/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
| 14 #include "base/strings/string_split.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "net/cert/cert_verifier.h" | 16 #include "net/cert/cert_verifier.h" |
| 16 #include "net/dns/host_resolver.h" | 17 #include "net/dns/host_resolver.h" |
| 17 #include "net/quic/quic_protocol.h" | 18 #include "net/quic/quic_protocol.h" |
| 18 #include "net/quic/quic_utils.h" | 19 #include "net/quic/quic_utils.h" |
| 19 #include "net/url_request/url_request_context_builder.h" | 20 #include "net/url_request/url_request_context_builder.h" |
| 20 | 21 |
| 21 namespace cronet { | 22 namespace cronet { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // TODO(xunjieli): Refactor constants in io_thread.cc. | 26 // TODO(xunjieli): Refactor constants in io_thread.cc. |
| 26 const char kQuicFieldTrialName[] = "QUIC"; | 27 const char kQuicFieldTrialName[] = "QUIC"; |
| 27 const char kQuicConnectionOptions[] = "connection_options"; | 28 const char kQuicConnectionOptions[] = "connection_options"; |
| 28 const char kQuicStoreServerConfigsInProperties[] = | 29 const char kQuicStoreServerConfigsInProperties[] = |
| 29 "store_server_configs_in_properties"; | 30 "store_server_configs_in_properties"; |
| 30 const char kQuicDelayTcpRace[] = "delay_tcp_race"; | 31 const char kQuicDelayTcpRace[] = "delay_tcp_race"; |
| 31 const char kQuicMaxNumberOfLossyConnections[] = | 32 const char kQuicMaxNumberOfLossyConnections[] = |
| 32 "max_number_of_lossy_connections"; | 33 "max_number_of_lossy_connections"; |
| 33 const char kQuicPacketLossThreshold[] = "packet_loss_threshold"; | 34 const char kQuicPacketLossThreshold[] = "packet_loss_threshold"; |
| 34 const char kQuicIdleConnectionTimeoutSeconds[] = | 35 const char kQuicIdleConnectionTimeoutSeconds[] = |
| 35 "idle_connection_timeout_seconds"; | 36 "idle_connection_timeout_seconds"; |
| 37 const char kQuicHostWhitelist[] = "host_whitelist"; |
| 36 | 38 |
| 37 // AsyncDNS experiment dictionary name. | 39 // AsyncDNS experiment dictionary name. |
| 38 const char kAsyncDnsFieldTrialName[] = "AsyncDNS"; | 40 const char kAsyncDnsFieldTrialName[] = "AsyncDNS"; |
| 39 // Name of boolean to enable AsyncDNS experiment. | 41 // Name of boolean to enable AsyncDNS experiment. |
| 40 const char kAsyncDnsEnable[] = "enable"; | 42 const char kAsyncDnsEnable[] = "enable"; |
| 41 | 43 |
| 42 void ParseAndSetExperimentalOptions( | 44 void ParseAndSetExperimentalOptions( |
| 43 const std::string& experimental_options, | 45 const std::string& experimental_options, |
| 44 net::URLRequestContextBuilder* context_builder, | 46 net::URLRequestContextBuilder* context_builder, |
| 45 net::NetLog* net_log) { | 47 net::NetLog* net_log) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 context_builder->set_quic_packet_loss_threshold( | 101 context_builder->set_quic_packet_loss_threshold( |
| 100 quic_packet_loss_threshold); | 102 quic_packet_loss_threshold); |
| 101 } | 103 } |
| 102 | 104 |
| 103 int quic_idle_connection_timeout_seconds = 0; | 105 int quic_idle_connection_timeout_seconds = 0; |
| 104 if (quic_args->GetInteger(kQuicIdleConnectionTimeoutSeconds, | 106 if (quic_args->GetInteger(kQuicIdleConnectionTimeoutSeconds, |
| 105 &quic_idle_connection_timeout_seconds)) { | 107 &quic_idle_connection_timeout_seconds)) { |
| 106 context_builder->set_quic_idle_connection_timeout_seconds( | 108 context_builder->set_quic_idle_connection_timeout_seconds( |
| 107 quic_idle_connection_timeout_seconds); | 109 quic_idle_connection_timeout_seconds); |
| 108 } | 110 } |
| 111 |
| 112 std::string quic_host_whitelist; |
| 113 if (quic_args->GetString(kQuicHostWhitelist, &quic_host_whitelist)) { |
| 114 std::unordered_set<std::string> hosts; |
| 115 for (const std::string& host : |
| 116 base::SplitString(quic_host_whitelist, ",", base::TRIM_WHITESPACE, |
| 117 base::SPLIT_WANT_ALL)) { |
| 118 hosts.insert(host); |
| 119 } |
| 120 context_builder->set_quic_host_whitelist(hosts); |
| 121 } |
| 109 } | 122 } |
| 110 | 123 |
| 111 const base::DictionaryValue* async_dns_args = nullptr; | 124 const base::DictionaryValue* async_dns_args = nullptr; |
| 112 if (dict->GetDictionary(kAsyncDnsFieldTrialName, &async_dns_args)) { | 125 if (dict->GetDictionary(kAsyncDnsFieldTrialName, &async_dns_args)) { |
| 113 bool async_dns_enable = false; | 126 bool async_dns_enable = false; |
| 114 if (async_dns_args->GetBoolean(kAsyncDnsEnable, &async_dns_enable) && | 127 if (async_dns_args->GetBoolean(kAsyncDnsEnable, &async_dns_enable) && |
| 115 async_dns_enable) { | 128 async_dns_enable) { |
| 116 if (net_log == nullptr) { | 129 if (net_log == nullptr) { |
| 117 DCHECK(false) << "AsyncDNS experiment requires NetLog."; | 130 DCHECK(false) << "AsyncDNS experiment requires NetLog."; |
| 118 } else { | 131 } else { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 213 |
| 201 ParseAndSetExperimentalOptions(experimental_options, context_builder, | 214 ParseAndSetExperimentalOptions(experimental_options, context_builder, |
| 202 net_log); | 215 net_log); |
| 203 | 216 |
| 204 if (mock_cert_verifier) | 217 if (mock_cert_verifier) |
| 205 context_builder->SetCertVerifier(std::move(mock_cert_verifier)); | 218 context_builder->SetCertVerifier(std::move(mock_cert_verifier)); |
| 206 // TODO(mef): Use |config| to set cookies. | 219 // TODO(mef): Use |config| to set cookies. |
| 207 } | 220 } |
| 208 | 221 |
| 209 } // namespace cronet | 222 } // namespace cronet |
| OLD | NEW |