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

Side by Side Diff: components/cronet/url_request_context_config.cc

Issue 1407263010: [Cronet] Public key pinning for Java API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments & Rebase Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/cronet/url_request_context_config.h" 5 #include "components/cronet/url_request_context_config.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 double quic_packet_loss_threshold = 0.0; 97 double quic_packet_loss_threshold = 0.0;
98 if (quic_args->GetDouble(kQuicPacketLossThreshold, 98 if (quic_args->GetDouble(kQuicPacketLossThreshold,
99 &quic_packet_loss_threshold)) { 99 &quic_packet_loss_threshold)) {
100 context_builder->set_quic_packet_loss_threshold( 100 context_builder->set_quic_packet_loss_threshold(
101 quic_packet_loss_threshold); 101 quic_packet_loss_threshold);
102 } 102 }
103 } 103 }
104 } 104 }
105 105
106 bool GetTimeFromDouble(const base::Value* json_value, base::Time* time) {
107 double time_double;
108 bool success = json_value->GetAsDouble(&time_double);
109 if (success) {
110 *time = base::Time::FromDoubleT(time_double);
111 }
112 return success;
113 }
114
106 } // namespace 115 } // namespace
107 116
108 #define DEFINE_CONTEXT_CONFIG(x) const char REQUEST_CONTEXT_CONFIG_##x[] = #x; 117 #define DEFINE_CONTEXT_CONFIG(x) const char REQUEST_CONTEXT_CONFIG_##x[] = #x;
109 #include "components/cronet/url_request_context_config_list.h" 118 #include "components/cronet/url_request_context_config_list.h"
110 #undef DEFINE_CONTEXT_CONFIG 119 #undef DEFINE_CONTEXT_CONFIG
111 120
112 URLRequestContextConfig::QuicHint::QuicHint() { 121 URLRequestContextConfig::QuicHint::QuicHint() {
113 } 122 }
114 123
115 URLRequestContextConfig::QuicHint::~QuicHint() { 124 URLRequestContextConfig::QuicHint::~QuicHint() {
116 } 125 }
117 126
118 // static 127 // static
119 void URLRequestContextConfig::QuicHint::RegisterJSONConverter( 128 void URLRequestContextConfig::QuicHint::RegisterJSONConverter(
120 base::JSONValueConverter<URLRequestContextConfig::QuicHint>* converter) { 129 base::JSONValueConverter<URLRequestContextConfig::QuicHint>* converter) {
121 converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_QUIC_HINT_HOST, 130 converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_QUIC_HINT_HOST,
122 &URLRequestContextConfig::QuicHint::host); 131 &URLRequestContextConfig::QuicHint::host);
123 converter->RegisterIntField( 132 converter->RegisterIntField(
124 REQUEST_CONTEXT_CONFIG_QUIC_HINT_PORT, 133 REQUEST_CONTEXT_CONFIG_QUIC_HINT_PORT,
125 &URLRequestContextConfig::QuicHint::port); 134 &URLRequestContextConfig::QuicHint::port);
126 converter->RegisterIntField( 135 converter->RegisterIntField(
127 REQUEST_CONTEXT_CONFIG_QUIC_HINT_ALT_PORT, 136 REQUEST_CONTEXT_CONFIG_QUIC_HINT_ALT_PORT,
128 &URLRequestContextConfig::QuicHint::alternate_port); 137 &URLRequestContextConfig::QuicHint::alternate_port);
129 } 138 }
130 139
140 URLRequestContextConfig::Pkp::Pkp() {}
pauljensen 2015/12/01 20:50:13 add newline between braces to match line 121
kapishnikov 2015/12/02 22:11:37 I am running "git cl format" and it moves the clos
141
142 URLRequestContextConfig::Pkp::~Pkp() {}
pauljensen 2015/12/01 20:50:13 ditto
kapishnikov 2015/12/02 22:11:36 Same here.
143
144 // static
145 void URLRequestContextConfig::Pkp::RegisterJSONConverter(
146 base::JSONValueConverter<URLRequestContextConfig::Pkp>* converter) {
147 converter->RegisterStringField(REQUEST_CONTEXT_CONFIG_PKP_HOST,
148 &URLRequestContextConfig::Pkp::host);
149 converter->RegisterRepeatedString(REQUEST_CONTEXT_CONFIG_PKP_PIN_HASHES,
150 &URLRequestContextConfig::Pkp::pin_hashes);
151 converter->RegisterBoolField(
152 REQUEST_CONTEXT_CONFIG_PKP_INCLUDE_SUBDOMAINS,
153 &URLRequestContextConfig::Pkp::include_subdomains);
154 converter->RegisterCustomValueField<base::Time>(
155 REQUEST_CONTEXT_CONFIG_PKP_EXPIRATION_DATE,
156 &URLRequestContextConfig::Pkp::expiration_date, &GetTimeFromDouble);
157 }
158
131 URLRequestContextConfig::URLRequestContextConfig() {} 159 URLRequestContextConfig::URLRequestContextConfig() {}
132 160
133 URLRequestContextConfig::~URLRequestContextConfig() {} 161 URLRequestContextConfig::~URLRequestContextConfig() {}
134 162
135 bool URLRequestContextConfig::LoadFromJSON(const std::string& config_string) { 163 bool URLRequestContextConfig::LoadFromJSON(const std::string& config_string) {
136 scoped_ptr<base::Value> config_value = base::JSONReader::Read(config_string); 164 scoped_ptr<base::Value> config_value = base::JSONReader::Read(config_string);
137 if (!config_value || !config_value->IsType(base::Value::TYPE_DICTIONARY)) { 165 if (!config_value || !config_value->IsType(base::Value::TYPE_DICTIONARY)) {
138 DLOG(ERROR) << "Bad JSON: " << config_string; 166 DLOG(ERROR) << "Bad JSON: " << config_string;
139 return false; 167 return false;
140 } 168 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 &URLRequestContextConfig::data_reduction_primary_proxy); 233 &URLRequestContextConfig::data_reduction_primary_proxy);
206 converter->RegisterStringField( 234 converter->RegisterStringField(
207 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_FALLBACK_PROXY, 235 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_FALLBACK_PROXY,
208 &URLRequestContextConfig::data_reduction_fallback_proxy); 236 &URLRequestContextConfig::data_reduction_fallback_proxy);
209 converter->RegisterStringField( 237 converter->RegisterStringField(
210 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_SECURE_PROXY_CHECK_URL, 238 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_SECURE_PROXY_CHECK_URL,
211 &URLRequestContextConfig::data_reduction_secure_proxy_check_url); 239 &URLRequestContextConfig::data_reduction_secure_proxy_check_url);
212 converter->RegisterStringField( 240 converter->RegisterStringField(
213 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_PROXY_KEY, 241 REQUEST_CONTEXT_CONFIG_DATA_REDUCTION_PROXY_KEY,
214 &URLRequestContextConfig::data_reduction_proxy_key); 242 &URLRequestContextConfig::data_reduction_proxy_key);
243 converter->RegisterRepeatedMessage(REQUEST_CONTEXT_CONFIG_PKP_LIST,
244 &URLRequestContextConfig::pkp_list);
215 245
216 // For Testing. 246 // For Testing.
217 converter->RegisterCustomField<scoped_ptr<net::CertVerifier>>( 247 converter->RegisterCustomField<scoped_ptr<net::CertVerifier>>(
218 REQUEST_CONTEXT_CONFIG_MOCK_CERT_VERIFIER, 248 REQUEST_CONTEXT_CONFIG_MOCK_CERT_VERIFIER,
219 &URLRequestContextConfig::mock_cert_verifier, 249 &URLRequestContextConfig::mock_cert_verifier,
220 &GetMockCertVerifierFromString); 250 &GetMockCertVerifierFromString);
221 } 251 }
222 252
223 } // namespace cronet 253 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698