Index: components/cronet/url_request_context_config.cc |
diff --git a/components/cronet/url_request_context_config.cc b/components/cronet/url_request_context_config.cc |
index 6072f394d84cdde35069fc3a7e2f44eeb5ce490a..98c5a9071016f579b010c4fcc8ff16b0df619cee 100644 |
--- a/components/cronet/url_request_context_config.cc |
+++ b/components/cronet/url_request_context_config.cc |
@@ -19,6 +19,10 @@ namespace cronet { |
namespace { |
+// TODO(xunjieli): Refactor constants in io_thread.cc. |
+const char kQuicFieldTrialName[] = "QUIC"; |
+const char kQuicConnectionOptions[] = "connection_options"; |
+ |
// Using a reference to scoped_ptr is unavoidable because of the semantics of |
// RegisterCustomField. |
// TODO(xunjieli): Remove this once crbug.com/544976 is fixed. |
@@ -31,6 +35,36 @@ bool GetMockCertVerifierFromString( |
return success; |
} |
+void ParseAndSetExperimentalOptions( |
+ const std::string& experimental_options, |
+ net::URLRequestContextBuilder* context_builder) { |
+ if (experimental_options.empty()) |
+ return; |
+ |
+ scoped_ptr<base::Value> options = |
+ base::JSONReader::Read(experimental_options); |
+ |
+ if (!options) { |
+ DCHECK(false) << "Parsing experimental options failed: " |
+ << experimental_options; |
+ return; |
+ } |
+ scoped_ptr<base::DictionaryValue> dict = |
+ base::DictionaryValue::From(options.Pass()); |
+ |
+ DCHECK(dict); |
mef
2015/11/16 18:19:22
The dict will be null if experimental_options is v
xunjieli
2015/11/16 18:47:25
Done.
|
+ |
+ const base::DictionaryValue* quic_args = nullptr; |
+ if (dict->GetDictionary(kQuicFieldTrialName, &quic_args)) { |
+ std::string quic_connection_options; |
+ if (quic_args->GetString(kQuicConnectionOptions, |
+ &quic_connection_options)) { |
+ context_builder->set_quic_connection_options( |
+ net::QuicUtils::ParseQuicConnectionOptions(quic_connection_options)); |
+ } |
+ } |
+} |
+ |
} // namespace |
#define DEFINE_CONTEXT_CONFIG(x) const char REQUEST_CONTEXT_CONFIG_##x[] = #x; |
@@ -95,9 +129,10 @@ void URLRequestContextConfig::ConfigureURLRequestContextBuilder( |
} |
context_builder->set_user_agent(user_agent); |
context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic); |
- context_builder->set_quic_connection_options( |
- net::QuicUtils::ParseQuicConnectionOptions(quic_connection_options)); |
context_builder->set_sdch_enabled(enable_sdch); |
+ |
+ ParseAndSetExperimentalOptions(experimental_options, context_builder); |
+ |
if (mock_cert_verifier) |
context_builder->SetCertVerifier(mock_cert_verifier.Pass()); |
// TODO(mef): Use |config| to set cookies. |
@@ -125,8 +160,8 @@ void URLRequestContextConfig::RegisterJSONConverter( |
converter->RegisterRepeatedMessage(REQUEST_CONTEXT_CONFIG_QUIC_HINTS, |
&URLRequestContextConfig::quic_hints); |
converter->RegisterStringField( |
- REQUEST_CONTEXT_CONFIG_QUIC_OPTIONS, |
- &URLRequestContextConfig::quic_connection_options); |
+ REQUEST_CONTEXT_CONFIG_EXPERIMENTAL_OPTIONS, |
+ &URLRequestContextConfig::experimental_options); |
converter->RegisterStringField( |
REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_PRIMARY_PROXY, |
&URLRequestContextConfig::data_reduction_primary_proxy); |