Chromium Code Reviews| Index: chrome/browser/io_thread.cc |
| diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc |
| index 7663c8a7418b60268085214e8950c1d9059049ff..b8b4b91c24295010031b60f8b1efa023285a6392 100644 |
| --- a/chrome/browser/io_thread.cc |
| +++ b/chrome/browser/io_thread.cc |
| @@ -38,6 +38,7 @@ |
| #include "net/base/cert_verifier.h" |
| #include "net/base/default_server_bound_cert_store.h" |
| #include "net/base/host_cache.h" |
| +#include "net/base/host_mapping_rules.h" |
| #include "net/base/host_resolver.h" |
| #include "net/base/mapped_host_resolver.h" |
| #include "net/base/net_util.h" |
| @@ -307,7 +308,12 @@ SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() { |
| IOThread::Globals::Globals() |
| : ALLOW_THIS_IN_INITIALIZER_LIST( |
| - system_request_context_leak_checker(this)) {} |
| + system_request_context_leak_checker(this)), |
| + ignore_certificate_errors(false), |
| + http_pipelining_enabled(false), |
| + testing_fixed_http_port(0), |
| + testing_fixed_https_port(0) {} |
| + |
| IOThread::Globals::~Globals() {} |
| // |local_state| is passed in explicitly in order to (1) reduce implicit |
| @@ -386,6 +392,8 @@ void IOThread::Init() { |
| net::SetMessageLoopForNSSHttpIO(); |
| #endif // defined(USE_NSS) |
| + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| + |
| DCHECK(!globals_); |
| globals_ = new Globals; |
| @@ -409,10 +417,8 @@ void IOThread::Init() { |
| NULL, |
| &system_enable_referrers_, |
| NULL); |
| - if (CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kDisableExtensionsHttpThrottling)) { |
| + if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) |
| network_delegate->NeverThrottleRequests(); |
| - } |
| globals_->system_network_delegate.reset(network_delegate); |
| globals_->host_resolver.reset( |
| CreateGlobalHostResolver(net_log_)); |
| @@ -433,6 +439,31 @@ void IOThread::Init() { |
| new net::DefaultServerBoundCertStore(NULL), |
| base::WorkerPool::GetTaskRunner(true))); |
| globals_->load_time_stats.reset(new chrome_browser_net::LoadTimeStats()); |
| + globals_->host_mapping_rules.reset(new net::HostMappingRules()); |
| + if (command_line.HasSwitch(switches::kHostRules)) |
| + globals_->host_mapping_rules->SetRulesFromString( |
| + command_line.GetSwitchValueASCII(switches::kHostRules)); |
|
mmenke
2012/08/23 18:11:28
nit: Use braces when the body of an if statement
|
| + if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) |
| + globals_->ignore_certificate_errors = true; |
| + if (command_line.HasSwitch(switches::kEnableHttpPipelining)) |
| + globals_->http_pipelining_enabled = true; |
| + if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { |
| + int value; |
| + base::StringToInt( |
| + command_line.GetSwitchValueASCII( |
| + switches::kTestingFixedHttpPort), |
| + &value); |
| + globals_->testing_fixed_http_port = value; |
| + } |
| + if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { |
| + int value; |
| + base::StringToInt( |
| + command_line.GetSwitchValueASCII( |
| + switches::kTestingFixedHttpsPort), |
| + &value); |
| + globals_->testing_fixed_https_port = value; |
| + } |
| + |
| net::HttpNetworkSession::Params session_params; |
| session_params.host_resolver = globals_->host_resolver.get(); |
| session_params.cert_verifier = globals_->cert_verifier.get(); |
| @@ -442,16 +473,23 @@ void IOThread::Init() { |
| globals_->transport_security_state.get(); |
| session_params.proxy_service = |
| globals_->proxy_script_fetcher_proxy_service.get(); |
| + session_params.ssl_config_service = globals_->ssl_config_service.get(); |
| session_params.http_auth_handler_factory = |
| globals_->http_auth_handler_factory.get(); |
| + session_params.http_server_properties = |
| + globals_->http_server_properties.get(); |
| session_params.network_delegate = globals_->system_network_delegate.get(); |
| // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| // system URLRequestContext too. There's no reason this should be tied to a |
| // profile. |
| - session_params.http_server_properties = |
| - globals_->http_server_properties.get(); |
| session_params.net_log = net_log_; |
| - session_params.ssl_config_service = globals_->ssl_config_service; |
| + session_params.ignore_certificate_errors = |
| + globals_->ignore_certificate_errors; |
| + session_params.host_mapping_rules = globals_->host_mapping_rules.get(); |
|
mmenke
2012/08/23 18:11:28
nit: This should go before ignore_certificate_err
|
| + session_params.http_pipelining_enabled = globals_->http_pipelining_enabled; |
| + session_params.testing_fixed_http_port = globals_->testing_fixed_http_port; |
| + session_params.testing_fixed_https_port = globals_->http_pipelining_enabled; |
| + |
| scoped_refptr<net::HttpNetworkSession> network_session( |
| new net::HttpNetworkSession(session_params)); |
| globals_->proxy_script_fetcher_http_transaction_factory.reset( |
| @@ -613,6 +651,7 @@ void IOThread::InitSystemRequestContextOnIOThread() { |
| globals_->proxy_script_fetcher_context.get(), |
| system_proxy_config_service_.release(), |
| command_line)); |
| + |
| net::HttpNetworkSession::Params system_params; |
| system_params.host_resolver = globals_->host_resolver.get(); |
| system_params.cert_verifier = globals_->cert_verifier.get(); |
| @@ -627,6 +666,12 @@ void IOThread::InitSystemRequestContextOnIOThread() { |
| system_params.http_server_properties = globals_->http_server_properties.get(); |
| system_params.network_delegate = globals_->system_network_delegate.get(); |
| system_params.net_log = net_log_; |
| + system_params.ignore_certificate_errors = globals_->ignore_certificate_errors; |
| + system_params.host_mapping_rules = globals_->host_mapping_rules.get(); |
|
mmenke
2012/08/23 18:11:28
nit: Move host_mapping_rules up, as above.
|
| + system_params.http_pipelining_enabled = globals_->http_pipelining_enabled; |
| + system_params.testing_fixed_http_port = globals_->testing_fixed_http_port; |
| + system_params.testing_fixed_https_port = globals_->testing_fixed_https_port; |
| + |
| globals_->system_http_transaction_factory.reset( |
| new net::HttpNetworkLayer( |
| new net::HttpNetworkSession(system_params))); |