Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Unified Diff: components/cronet/url_request_context_config.cc

Issue 1487723002: [Cronet] Replace setExperimentalQuicConnectionOptions with a more general API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2564
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/cronet/url_request_context_config.h ('k') | components/cronet/url_request_context_config_list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5cd24b8664120160a03325b4288a9fd4b1c68752 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,41 @@ 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());
+
+ if (!dict) {
+ DCHECK(false) << "Experimental options string is not a dictionary: "
+ << experimental_options;
+ return;
+ }
+
+ 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 +134,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 +165,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);
« no previous file with comments | « components/cronet/url_request_context_config.h ('k') | components/cronet/url_request_context_config_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698