| 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 00a79777ecea6c2a87f4899acf762870d8dd728c..78708165d65d17da8d5b3db58bb9ab48a8e6b4b0 100644
|
| --- a/components/cronet/url_request_context_config.cc
|
| +++ b/components/cronet/url_request_context_config.cc
|
| @@ -6,10 +6,12 @@
|
|
|
| #include "base/basictypes.h"
|
| #include "base/json/json_reader.h"
|
| +#include "base/json/json_reader.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_piece.h"
|
| #include "base/values.h"
|
| +#include "base/values.h"
|
| #include "net/cert/cert_verifier.h"
|
| #include "net/quic/quic_protocol.h"
|
| #include "net/quic/quic_utils.h"
|
| @@ -19,6 +21,9 @@ namespace cronet {
|
|
|
| namespace {
|
|
|
| +// TODO(xunjieli): Refactor constants in io_thread.cc.
|
| +const char kQuicFieldTrialName[] = "QUIC";
|
| +
|
| // 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 +36,30 @@ bool GetMockCertVerifierFromString(
|
| return success;
|
| }
|
|
|
| +void ParseAndSetExperimentalOptions(
|
| + const std::string& experimental_options,
|
| + net::URLRequestContextBuilder* context_builder) {
|
| + if (experimental_options.empty())
|
| + return;
|
| +
|
| + scoped_ptr<base::DictionaryValue> dict =
|
| + base::DictionaryValue::From(base::JSONReader::Read(experimental_options));
|
| + if (!dict) {
|
| + DCHECK(false) << "Parsing experimental options failed: "
|
| + << experimental_options;
|
| + return;
|
| + }
|
| +
|
| + const base::DictionaryValue* quic_args = nullptr;
|
| + if (dict->GetDictionary(kQuicFieldTrialName, &quic_args)) {
|
| + std::string quic_connection_options;
|
| + if (quic_args->GetString("connection_options", &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;
|
| @@ -96,9 +125,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.
|
| @@ -126,8 +156,9 @@ 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);
|
|
|