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

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

Issue 1833203002: Plumb SSLKEYLOGFILE from Cronet to net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment Created 4 years, 9 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 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 <utility> 7 #include <utility>
8 8
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/sequenced_task_runner.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
14 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "net/cert/cert_verifier.h" 16 #include "net/cert/cert_verifier.h"
17 #include "net/dns/host_resolver.h" 17 #include "net/dns/host_resolver.h"
18 #include "net/http/http_server_properties.h" 18 #include "net/http/http_server_properties.h"
19 #include "net/quic/quic_protocol.h" 19 #include "net/quic/quic_protocol.h"
20 #include "net/quic/quic_utils.h" 20 #include "net/quic/quic_utils.h"
21 #include "net/socket/ssl_client_socket.h"
21 #include "net/url_request/url_request_context_builder.h" 22 #include "net/url_request/url_request_context_builder.h"
22 23
23 namespace cronet { 24 namespace cronet {
24 25
25 namespace { 26 namespace {
26 27
27 // TODO(xunjieli): Refactor constants in io_thread.cc. 28 // TODO(xunjieli): Refactor constants in io_thread.cc.
28 const char kQuicFieldTrialName[] = "QUIC"; 29 const char kQuicFieldTrialName[] = "QUIC";
29 const char kQuicConnectionOptions[] = "connection_options"; 30 const char kQuicConnectionOptions[] = "connection_options";
30 const char kQuicStoreServerConfigsInProperties[] = 31 const char kQuicStoreServerConfigsInProperties[] =
(...skipping 14 matching lines...) Expand all
45 const char kQuicUserAgentId[] = "user_agent_id"; 46 const char kQuicUserAgentId[] = "user_agent_id";
46 const char kQuicMigrateSessionsEarly[] = "migrate_sessions_early"; 47 const char kQuicMigrateSessionsEarly[] = "migrate_sessions_early";
47 const char kQuicDisableBidirectionalStreams[] = 48 const char kQuicDisableBidirectionalStreams[] =
48 "quic_disable_bidirectional_streams"; 49 "quic_disable_bidirectional_streams";
49 50
50 // AsyncDNS experiment dictionary name. 51 // AsyncDNS experiment dictionary name.
51 const char kAsyncDnsFieldTrialName[] = "AsyncDNS"; 52 const char kAsyncDnsFieldTrialName[] = "AsyncDNS";
52 // Name of boolean to enable AsyncDNS experiment. 53 // Name of boolean to enable AsyncDNS experiment.
53 const char kAsyncDnsEnable[] = "enable"; 54 const char kAsyncDnsEnable[] = "enable";
54 55
56 const char kSSLKeyLogFile[] = "ssl_key_log_file";
57
55 void ParseAndSetExperimentalOptions( 58 void ParseAndSetExperimentalOptions(
56 const std::string& experimental_options, 59 const std::string& experimental_options,
57 net::URLRequestContextBuilder* context_builder, 60 net::URLRequestContextBuilder* context_builder,
58 net::NetLog* net_log) { 61 net::NetLog* net_log,
62 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) {
59 if (experimental_options.empty()) 63 if (experimental_options.empty())
60 return; 64 return;
61 65
62 DVLOG(1) << "Experimental Options:" << experimental_options; 66 DVLOG(1) << "Experimental Options:" << experimental_options;
63 scoped_ptr<base::Value> options = 67 scoped_ptr<base::Value> options =
64 base::JSONReader::Read(experimental_options); 68 base::JSONReader::Read(experimental_options);
65 69
66 if (!options) { 70 if (!options) {
67 DCHECK(false) << "Parsing experimental options failed: " 71 DCHECK(false) << "Parsing experimental options failed: "
68 << experimental_options; 72 << experimental_options;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (net_log == nullptr) { 191 if (net_log == nullptr) {
188 DCHECK(false) << "AsyncDNS experiment requires NetLog."; 192 DCHECK(false) << "AsyncDNS experiment requires NetLog.";
189 } else { 193 } else {
190 scoped_ptr<net::HostResolver> host_resolver( 194 scoped_ptr<net::HostResolver> host_resolver(
191 net::HostResolver::CreateDefaultResolver(net_log)); 195 net::HostResolver::CreateDefaultResolver(net_log));
192 host_resolver->SetDnsClientEnabled(true); 196 host_resolver->SetDnsClientEnabled(true);
193 context_builder->set_host_resolver(std::move(host_resolver)); 197 context_builder->set_host_resolver(std::move(host_resolver));
194 } 198 }
195 } 199 }
196 } 200 }
201
202 std::string ssl_key_log_file_string;
203 if (dict->GetString(kSSLKeyLogFile, &ssl_key_log_file_string)) {
204 DCHECK(file_task_runner);
205 base::FilePath ssl_key_log_file(ssl_key_log_file_string);
206 if (!ssl_key_log_file.empty()) {
mef 2016/03/25 20:53:47 maybe set a static flag here, and don't do it agai
xunjieli 2016/03/25 20:58:36 Should we avoid static flags / globals ? That is t
mef 2016/03/28 15:14:25 Acknowledged. Maybe add a check that |file_task_ru
xunjieli 2016/03/28 15:51:16 Done.
207 // SetSSLKeyLogFile is only safe to call before any SSLClientSockets are
208 // created. This should not be used if there are multiple CronetEngine.
209 // TODO(xunjieli): Expose this as a stable API after crbug.com/458365 is
210 // resolved.
davidben 2016/03/25 20:51:03 (Probably worth mirroring this into any relevant A
xunjieli 2016/03/25 20:52:34 Yep, we don't have any documentation for experimen
211 net::SSLClientSocket::SetSSLKeyLogFile(ssl_key_log_file,
212 file_task_runner);
213 }
214 }
197 } 215 }
198 216
199 } // namespace 217 } // namespace
200 218
201 URLRequestContextConfig::QuicHint::QuicHint(const std::string& host, 219 URLRequestContextConfig::QuicHint::QuicHint(const std::string& host,
202 int port, 220 int port,
203 int alternate_port) 221 int alternate_port)
204 : host(host), port(port), alternate_port(alternate_port) {} 222 : host(host), port(port), alternate_port(alternate_port) {}
205 223
206 URLRequestContextConfig::QuicHint::~QuicHint() {} 224 URLRequestContextConfig::QuicHint::~QuicHint() {}
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 data_reduction_primary_proxy(data_reduction_primary_proxy), 262 data_reduction_primary_proxy(data_reduction_primary_proxy),
245 data_reduction_fallback_proxy(data_reduction_fallback_proxy), 263 data_reduction_fallback_proxy(data_reduction_fallback_proxy),
246 data_reduction_secure_proxy_check_url( 264 data_reduction_secure_proxy_check_url(
247 data_reduction_secure_proxy_check_url), 265 data_reduction_secure_proxy_check_url),
248 mock_cert_verifier(std::move(mock_cert_verifier)) {} 266 mock_cert_verifier(std::move(mock_cert_verifier)) {}
249 267
250 URLRequestContextConfig::~URLRequestContextConfig() {} 268 URLRequestContextConfig::~URLRequestContextConfig() {}
251 269
252 void URLRequestContextConfig::ConfigureURLRequestContextBuilder( 270 void URLRequestContextConfig::ConfigureURLRequestContextBuilder(
253 net::URLRequestContextBuilder* context_builder, 271 net::URLRequestContextBuilder* context_builder,
254 net::NetLog* net_log) { 272 net::NetLog* net_log,
273 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) {
255 std::string config_cache; 274 std::string config_cache;
256 if (http_cache != DISABLED) { 275 if (http_cache != DISABLED) {
257 net::URLRequestContextBuilder::HttpCacheParams cache_params; 276 net::URLRequestContextBuilder::HttpCacheParams cache_params;
258 if (http_cache == DISK && !storage_path.empty()) { 277 if (http_cache == DISK && !storage_path.empty()) {
259 cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::DISK; 278 cache_params.type = net::URLRequestContextBuilder::HttpCacheParams::DISK;
260 cache_params.path = base::FilePath(storage_path); 279 cache_params.path = base::FilePath(storage_path);
261 } else { 280 } else {
262 cache_params.type = 281 cache_params.type =
263 net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY; 282 net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY;
264 } 283 }
265 cache_params.max_size = http_cache_max_size; 284 cache_params.max_size = http_cache_max_size;
266 context_builder->EnableHttpCache(cache_params); 285 context_builder->EnableHttpCache(cache_params);
267 } else { 286 } else {
268 context_builder->DisableHttpCache(); 287 context_builder->DisableHttpCache();
269 } 288 }
270 context_builder->set_user_agent(user_agent); 289 context_builder->set_user_agent(user_agent);
271 context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic); 290 context_builder->SetSpdyAndQuicEnabled(enable_spdy, enable_quic);
272 context_builder->set_sdch_enabled(enable_sdch); 291 context_builder->set_sdch_enabled(enable_sdch);
273 if (enable_quic) 292 if (enable_quic)
274 context_builder->set_quic_user_agent_id(quic_user_agent_id); 293 context_builder->set_quic_user_agent_id(quic_user_agent_id);
275 294
276 ParseAndSetExperimentalOptions(experimental_options, context_builder, 295 ParseAndSetExperimentalOptions(experimental_options, context_builder, net_log,
277 net_log); 296 file_task_runner);
278 297
279 if (mock_cert_verifier) 298 if (mock_cert_verifier)
280 context_builder->SetCertVerifier(std::move(mock_cert_verifier)); 299 context_builder->SetCertVerifier(std::move(mock_cert_verifier));
281 // TODO(mef): Use |config| to set cookies. 300 // TODO(mef): Use |config| to set cookies.
282 } 301 }
283 302
284 } // namespace cronet 303 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698