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

Unified Diff: components/cronet/url_request_context_config.cc

Issue 1389213003: [Cronet] Use Https for Quic Test Server (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ryancl
Patch Set: Address Paul'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 da924532bbbf241de19b7963b43cfca74925bc54..576f042162359ee96654c9ac95f37cac79e386aa 100644
--- a/components/cronet/url_request_context_config.cc
+++ b/components/cronet/url_request_context_config.cc
@@ -4,14 +4,33 @@
#include "components/cronet/url_request_context_config.h"
+#include "base/basictypes.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 "net/cert/cert_verifier.h"
#include "net/quic/quic_protocol.h"
#include "net/quic/quic_utils.h"
#include "net/url_request/url_request_context_builder.h"
namespace cronet {
+namespace {
+
+bool GetMockCertVerifierFromString(
+ const base::StringPiece& mock_cert_verifier_string,
+ net::CertVerifier** result) {
+ int64 val;
+ bool success = base::StringToInt64(mock_cert_verifier_string, &val);
+ net::CertVerifier* cert_verifier = reinterpret_cast<net::CertVerifier*>(val);
pauljensen 2015/10/19 18:52:29 can we combine this and the next line into: *resul
xunjieli 2015/10/19 20:24:15 Done.
+ *result = cert_verifier;
+ return success;
+}
+
+} // namespace
+
#define DEFINE_CONTEXT_CONFIG(x) const char REQUEST_CONTEXT_CONFIG_##x[] = #x;
#include "components/cronet/url_request_context_config_list.h"
#undef DEFINE_CONTEXT_CONFIG
@@ -35,8 +54,8 @@ void URLRequestContextConfig::QuicHint::RegisterJSONConverter(
&URLRequestContextConfig::QuicHint::alternate_port);
}
-URLRequestContextConfig::URLRequestContextConfig() {
-}
+URLRequestContextConfig::URLRequestContextConfig()
+ : mock_cert_verifier(nullptr) {}
URLRequestContextConfig::~URLRequestContextConfig() {
}
@@ -79,7 +98,8 @@ void URLRequestContextConfig::ConfigureURLRequestContextBuilder(
context_builder->set_quic_connection_options(
net::QuicUtils::ParseQuicConnectionOptions(quic_connection_options));
context_builder->set_sdch_enabled(enable_sdch);
-
+ if (mock_cert_verifier != nullptr)
+ context_builder->SetCertVerifier(make_scoped_ptr(mock_cert_verifier));
}
// static
@@ -118,6 +138,12 @@ void URLRequestContextConfig::RegisterJSONConverter(
converter->RegisterStringField(
REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_PROXY_KEY,
&URLRequestContextConfig::data_reduction_proxy_key);
+
+ // For Testing.
+ converter->RegisterCustomField<net::CertVerifier*>(
+ REQUEST_CONTEXT_CONFIG_MOCK_CERT_VERIFIER,
+ &URLRequestContextConfig::mock_cert_verifier,
+ &GetMockCertVerifierFromString);
}
} // namespace cronet

Powered by Google App Engine
This is Rietveld 408576698