OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/debug/leak_tracker.h" | 14 #include "base/debug/leak_tracker.h" |
15 #include "base/environment.h" | |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/metrics/field_trial.h" | 17 #include "base/metrics/field_trial.h" |
17 #include "base/prefs/pref_registry_simple.h" | 18 #include "base/prefs/pref_registry_simple.h" |
18 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
19 #include "base/profiler/scoped_tracker.h" | 20 #include "base/profiler/scoped_tracker.h" |
20 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
21 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
22 #include "base/strings/string_piece.h" | 23 #include "base/strings/string_piece.h" |
23 #include "base/strings/string_split.h" | 24 #include "base/strings/string_split.h" |
24 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 #include "net/http/http_auth_filter.h" | 74 #include "net/http/http_auth_filter.h" |
74 #include "net/http/http_auth_handler_factory.h" | 75 #include "net/http/http_auth_handler_factory.h" |
75 #include "net/http/http_network_layer.h" | 76 #include "net/http/http_network_layer.h" |
76 #include "net/http/http_server_properties_impl.h" | 77 #include "net/http/http_server_properties_impl.h" |
77 #include "net/proxy/proxy_config_service.h" | 78 #include "net/proxy/proxy_config_service.h" |
78 #include "net/proxy/proxy_script_fetcher_impl.h" | 79 #include "net/proxy/proxy_script_fetcher_impl.h" |
79 #include "net/proxy/proxy_service.h" | 80 #include "net/proxy/proxy_service.h" |
80 #include "net/quic/crypto/crypto_protocol.h" | 81 #include "net/quic/crypto/crypto_protocol.h" |
81 #include "net/quic/quic_protocol.h" | 82 #include "net/quic/quic_protocol.h" |
82 #include "net/quic/quic_utils.h" | 83 #include "net/quic/quic_utils.h" |
84 #include "net/socket/ssl_client_socket.h" | |
83 #include "net/socket/tcp_client_socket.h" | 85 #include "net/socket/tcp_client_socket.h" |
84 #include "net/spdy/spdy_session.h" | 86 #include "net/spdy/spdy_session.h" |
85 #include "net/ssl/channel_id_service.h" | 87 #include "net/ssl/channel_id_service.h" |
86 #include "net/ssl/default_channel_id_store.h" | 88 #include "net/ssl/default_channel_id_store.h" |
87 #include "net/url_request/data_protocol_handler.h" | 89 #include "net/url_request/data_protocol_handler.h" |
88 #include "net/url_request/file_protocol_handler.h" | 90 #include "net/url_request/file_protocol_handler.h" |
89 #include "net/url_request/ftp_protocol_handler.h" | 91 #include "net/url_request/ftp_protocol_handler.h" |
90 #include "net/url_request/static_http_user_agent_settings.h" | 92 #include "net/url_request/static_http_user_agent_settings.h" |
91 #include "net/url_request/url_fetcher.h" | 93 #include "net/url_request/url_fetcher.h" |
92 #include "net/url_request/url_request_backoff_manager.h" | 94 #include "net/url_request/url_request_backoff_manager.h" |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 } | 528 } |
527 | 529 |
528 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { | 530 net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { |
529 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 531 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
530 if (!system_url_request_context_getter_.get()) { | 532 if (!system_url_request_context_getter_.get()) { |
531 InitSystemRequestContext(); | 533 InitSystemRequestContext(); |
532 } | 534 } |
533 return system_url_request_context_getter_.get(); | 535 return system_url_request_context_getter_.get(); |
534 } | 536 } |
535 | 537 |
538 void IOThread::GetSSLKeyLogFile(const base::CommandLine& command_line, | |
davidben
2015/10/15 19:08:23
This can just be a function defined after line 299
Bryan McQuade
2015/10/15 19:11:12
if this method doesn't depend any IOThread class s
Zhongyi Shi
2015/10/15 19:47:56
Done.
| |
539 std::string& ssl_keylog_file){ | |
davidben
2015/10/15 19:08:23
Style guide prohibits non-const reference paramete
Zhongyi Shi
2015/10/15 19:47:56
Done.
| |
540 if (command_line.HasSwitch(switches::kSSLKeyLogFile)) { | |
541 ssl_keylog_file = command_line.GetSwitchValueASCII( | |
542 switches::kSSLKeyLogFile); | |
543 if (!ssl_keylog_file.empty()) { | |
544 return; | |
545 } else { | |
546 LOG(WARNING) << "ssl-key-log-file argument missing"; | |
547 } | |
548 } | |
549 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
550 env->GetVar("SSLKEYLOGFILE", &ssl_keylog_file); | |
551 } | |
552 | |
536 void IOThread::Init() { | 553 void IOThread::Init() { |
537 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 554 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
538 // is fixed. | 555 // is fixed. |
539 tracked_objects::ScopedTracker tracking_profile1( | 556 tracked_objects::ScopedTracker tracking_profile1( |
540 FROM_HERE_WITH_EXPLICIT_FUNCTION("466432 IOThread::InitAsync::Start")); | 557 FROM_HERE_WITH_EXPLICIT_FUNCTION("466432 IOThread::InitAsync::Start")); |
541 TRACE_EVENT0("startup", "IOThread::InitAsync"); | 558 TRACE_EVENT0("startup", "IOThread::InitAsync"); |
542 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 559 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
543 | 560 |
544 #if defined(USE_NSS_CERTS) || defined(OS_IOS) | 561 #if defined(USE_NSS_CERTS) || defined(OS_IOS) |
545 net::SetMessageLoopForNSSHttpIO(); | 562 net::SetMessageLoopForNSSHttpIO(); |
546 #endif | 563 #endif |
547 | 564 |
548 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 565 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
549 // is fixed. | 566 // is fixed. |
550 tracked_objects::ScopedTracker tracking_profile2( | 567 tracked_objects::ScopedTracker tracking_profile2( |
551 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 568 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
552 "466432 IOThread::InitAsync::CommandLineForCurrentProcess")); | 569 "466432 IOThread::InitAsync::CommandLineForCurrentProcess")); |
553 const base::CommandLine& command_line = | 570 const base::CommandLine& command_line = |
554 *base::CommandLine::ForCurrentProcess(); | 571 *base::CommandLine::ForCurrentProcess(); |
555 | 572 |
573 // Export ssl keys if log file specified. | |
574 std::string ssl_keylog_file; | |
575 GetSSLKeyLogFile(command_line, ssl_keylog_file); | |
576 if (!ssl_keylog_file.empty()) { | |
davidben
2015/10/15 19:08:23
Nit: I actually really dislike this rule and prefe
| |
577 net::SSLClientSocket::SetSSLKeyLogFile(ssl_keylog_file); | |
578 } | |
579 | |
556 DCHECK(!globals_); | 580 DCHECK(!globals_); |
557 globals_ = new Globals; | 581 globals_ = new Globals; |
558 | 582 |
559 // Add an observer that will emit network change events to the ChromeNetLog. | 583 // Add an observer that will emit network change events to the ChromeNetLog. |
560 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be | 584 // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be |
561 // logging the network change before other IO thread consumers respond to it. | 585 // logging the network change before other IO thread consumers respond to it. |
562 network_change_observer_.reset( | 586 network_change_observer_.reset( |
563 new LoggingNetworkChangeObserver(net_log_)); | 587 new LoggingNetworkChangeObserver(net_log_)); |
564 | 588 |
565 // Setup the HistogramWatcher to run on the IO thread. | 589 // Setup the HistogramWatcher to run on the IO thread. |
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1592 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); | 1616 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); |
1593 | 1617 |
1594 context->set_job_factory( | 1618 context->set_job_factory( |
1595 globals->proxy_script_fetcher_url_request_job_factory.get()); | 1619 globals->proxy_script_fetcher_url_request_job_factory.get()); |
1596 | 1620 |
1597 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 1621 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
1598 // system URLRequestContext too. There's no reason this should be tied to a | 1622 // system URLRequestContext too. There's no reason this should be tied to a |
1599 // profile. | 1623 // profile. |
1600 return context; | 1624 return context; |
1601 } | 1625 } |
OLD | NEW |