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

Unified Diff: components/cronet/url_request_context_config.cc

Issue 1414053008: [Cronet] Replace setExperimentalQuicConnectionOptions with a more general API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Misha's comments Created 5 years, 2 months 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
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)) {
pauljensen 2015/10/30 18:05:23 if we're going to pull "QUIC" into a file-scoped c
xunjieli 2015/10/30 18:30:57 Done.
+ 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);

Powered by Google App Engine
This is Rietveld 408576698