| 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" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "net/http/http_auth_filter.h" | 59 #include "net/http/http_auth_filter.h" |
| 60 #include "net/http/http_auth_handler_factory.h" | 60 #include "net/http/http_auth_handler_factory.h" |
| 61 #include "net/http/http_network_layer.h" | 61 #include "net/http/http_network_layer.h" |
| 62 #include "net/http/http_server_properties_impl.h" | 62 #include "net/http/http_server_properties_impl.h" |
| 63 #include "net/proxy/proxy_config_service.h" | 63 #include "net/proxy/proxy_config_service.h" |
| 64 #include "net/proxy/proxy_script_fetcher_impl.h" | 64 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 65 #include "net/proxy/proxy_service.h" | 65 #include "net/proxy/proxy_service.h" |
| 66 #include "net/quic/quic_protocol.h" | 66 #include "net/quic/quic_protocol.h" |
| 67 #include "net/socket/tcp_client_socket.h" | 67 #include "net/socket/tcp_client_socket.h" |
| 68 #include "net/spdy/spdy_session.h" | 68 #include "net/spdy/spdy_session.h" |
| 69 #include "net/ssl/default_server_bound_cert_store.h" | 69 #include "net/ssl/channel_id_service.h" |
| 70 #include "net/ssl/server_bound_cert_service.h" | 70 #include "net/ssl/default_channel_id_store.h" |
| 71 #include "net/url_request/data_protocol_handler.h" | 71 #include "net/url_request/data_protocol_handler.h" |
| 72 #include "net/url_request/file_protocol_handler.h" | 72 #include "net/url_request/file_protocol_handler.h" |
| 73 #include "net/url_request/ftp_protocol_handler.h" | 73 #include "net/url_request/ftp_protocol_handler.h" |
| 74 #include "net/url_request/static_http_user_agent_settings.h" | 74 #include "net/url_request/static_http_user_agent_settings.h" |
| 75 #include "net/url_request/url_fetcher.h" | 75 #include "net/url_request/url_fetcher.h" |
| 76 #include "net/url_request/url_request_job_factory_impl.h" | 76 #include "net/url_request/url_request_job_factory_impl.h" |
| 77 #include "net/url_request/url_request_throttler_manager.h" | 77 #include "net/url_request/url_request_throttler_manager.h" |
| 78 #include "url/url_constants.h" | 78 #include "url/url_constants.h" |
| 79 | 79 |
| 80 #if defined(ENABLE_CONFIGURATION_POLICY) | 80 #if defined(ENABLE_CONFIGURATION_POLICY) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 context->set_cert_transparency_verifier( | 249 context->set_cert_transparency_verifier( |
| 250 globals->cert_transparency_verifier.get()); | 250 globals->cert_transparency_verifier.get()); |
| 251 context->set_http_auth_handler_factory( | 251 context->set_http_auth_handler_factory( |
| 252 globals->http_auth_handler_factory.get()); | 252 globals->http_auth_handler_factory.get()); |
| 253 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); | 253 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); |
| 254 context->set_http_transaction_factory( | 254 context->set_http_transaction_factory( |
| 255 globals->proxy_script_fetcher_http_transaction_factory.get()); | 255 globals->proxy_script_fetcher_http_transaction_factory.get()); |
| 256 context->set_job_factory( | 256 context->set_job_factory( |
| 257 globals->proxy_script_fetcher_url_request_job_factory.get()); | 257 globals->proxy_script_fetcher_url_request_job_factory.get()); |
| 258 context->set_cookie_store(globals->system_cookie_store.get()); | 258 context->set_cookie_store(globals->system_cookie_store.get()); |
| 259 context->set_server_bound_cert_service( | 259 context->set_channel_id_service( |
| 260 globals->system_server_bound_cert_service.get()); | 260 globals->system_channel_id_service.get()); |
| 261 context->set_network_delegate(globals->system_network_delegate.get()); | 261 context->set_network_delegate(globals->system_network_delegate.get()); |
| 262 context->set_http_user_agent_settings( | 262 context->set_http_user_agent_settings( |
| 263 globals->http_user_agent_settings.get()); | 263 globals->http_user_agent_settings.get()); |
| 264 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 264 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 265 // system URLRequestContext too. There's no reason this should be tied to a | 265 // system URLRequestContext too. There's no reason this should be tied to a |
| 266 // profile. | 266 // profile. |
| 267 return context; | 267 return context; |
| 268 } | 268 } |
| 269 | 269 |
| 270 net::URLRequestContext* | 270 net::URLRequestContext* |
| 271 ConstructSystemRequestContext(IOThread::Globals* globals, | 271 ConstructSystemRequestContext(IOThread::Globals* globals, |
| 272 net::NetLog* net_log) { | 272 net::NetLog* net_log) { |
| 273 net::URLRequestContext* context = new SystemURLRequestContext; | 273 net::URLRequestContext* context = new SystemURLRequestContext; |
| 274 context->set_net_log(net_log); | 274 context->set_net_log(net_log); |
| 275 context->set_host_resolver(globals->host_resolver.get()); | 275 context->set_host_resolver(globals->host_resolver.get()); |
| 276 context->set_cert_verifier(globals->cert_verifier.get()); | 276 context->set_cert_verifier(globals->cert_verifier.get()); |
| 277 context->set_transport_security_state( | 277 context->set_transport_security_state( |
| 278 globals->transport_security_state.get()); | 278 globals->transport_security_state.get()); |
| 279 context->set_cert_transparency_verifier( | 279 context->set_cert_transparency_verifier( |
| 280 globals->cert_transparency_verifier.get()); | 280 globals->cert_transparency_verifier.get()); |
| 281 context->set_http_auth_handler_factory( | 281 context->set_http_auth_handler_factory( |
| 282 globals->http_auth_handler_factory.get()); | 282 globals->http_auth_handler_factory.get()); |
| 283 context->set_proxy_service(globals->system_proxy_service.get()); | 283 context->set_proxy_service(globals->system_proxy_service.get()); |
| 284 context->set_http_transaction_factory( | 284 context->set_http_transaction_factory( |
| 285 globals->system_http_transaction_factory.get()); | 285 globals->system_http_transaction_factory.get()); |
| 286 context->set_job_factory(globals->system_url_request_job_factory.get()); | 286 context->set_job_factory(globals->system_url_request_job_factory.get()); |
| 287 context->set_cookie_store(globals->system_cookie_store.get()); | 287 context->set_cookie_store(globals->system_cookie_store.get()); |
| 288 context->set_server_bound_cert_service( | 288 context->set_channel_id_service( |
| 289 globals->system_server_bound_cert_service.get()); | 289 globals->system_channel_id_service.get()); |
| 290 context->set_throttler_manager(globals->throttler_manager.get()); | 290 context->set_throttler_manager(globals->throttler_manager.get()); |
| 291 context->set_network_delegate(globals->system_network_delegate.get()); | 291 context->set_network_delegate(globals->system_network_delegate.get()); |
| 292 context->set_http_user_agent_settings( | 292 context->set_http_user_agent_settings( |
| 293 globals->http_user_agent_settings.get()); | 293 globals->http_user_agent_settings.get()); |
| 294 return context; | 294 return context; |
| 295 } | 295 } |
| 296 | 296 |
| 297 int GetSwitchValueAsInt(const CommandLine& command_line, | 297 int GetSwitchValueAsInt(const CommandLine& command_line, |
| 298 const std::string& switch_name) { | 298 const std::string& switch_name) { |
| 299 int value; | 299 int value; |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 671 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
| 672 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 672 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( |
| 673 globals_->host_resolver.get())); | 673 globals_->host_resolver.get())); |
| 674 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 674 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
| 675 // For the ProxyScriptFetcher, we use a direct ProxyService. | 675 // For the ProxyScriptFetcher, we use a direct ProxyService. |
| 676 globals_->proxy_script_fetcher_proxy_service.reset( | 676 globals_->proxy_script_fetcher_proxy_service.reset( |
| 677 net::ProxyService::CreateDirectWithNetLog(net_log_)); | 677 net::ProxyService::CreateDirectWithNetLog(net_log_)); |
| 678 // In-memory cookie store. | 678 // In-memory cookie store. |
| 679 globals_->system_cookie_store = | 679 globals_->system_cookie_store = |
| 680 content::CreateCookieStore(content::CookieStoreConfig()); | 680 content::CreateCookieStore(content::CookieStoreConfig()); |
| 681 // In-memory server bound cert store. | 681 // In-memory channel ID store. |
| 682 globals_->system_server_bound_cert_service.reset( | 682 globals_->system_channel_id_service.reset( |
| 683 new net::ServerBoundCertService( | 683 new net::ChannelIDService( |
| 684 new net::DefaultServerBoundCertStore(NULL), | 684 new net::DefaultChannelIDStore(NULL), |
| 685 base::WorkerPool::GetTaskRunner(true))); | 685 base::WorkerPool::GetTaskRunner(true))); |
| 686 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); | 686 globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); |
| 687 globals_->host_mapping_rules.reset(new net::HostMappingRules()); | 687 globals_->host_mapping_rules.reset(new net::HostMappingRules()); |
| 688 globals_->http_user_agent_settings.reset( | 688 globals_->http_user_agent_settings.reset( |
| 689 new net::StaticHttpUserAgentSettings(std::string(), GetUserAgent())); | 689 new net::StaticHttpUserAgentSettings(std::string(), GetUserAgent())); |
| 690 if (command_line.HasSwitch(switches::kHostRules)) { | 690 if (command_line.HasSwitch(switches::kHostRules)) { |
| 691 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); | 691 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); |
| 692 globals_->host_mapping_rules->SetRulesFromString( | 692 globals_->host_mapping_rules->SetRulesFromString( |
| 693 command_line.GetSwitchValueASCII(switches::kHostRules)); | 693 command_line.GetSwitchValueASCII(switches::kHostRules)); |
| 694 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); | 694 TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 net::HttpNetworkSession::Params* params) { | 994 net::HttpNetworkSession::Params* params) { |
| 995 InitializeNetworkSessionParamsFromGlobals(*globals_, params); | 995 InitializeNetworkSessionParamsFromGlobals(*globals_, params); |
| 996 } | 996 } |
| 997 | 997 |
| 998 // static | 998 // static |
| 999 void IOThread::InitializeNetworkSessionParamsFromGlobals( | 999 void IOThread::InitializeNetworkSessionParamsFromGlobals( |
| 1000 const IOThread::Globals& globals, | 1000 const IOThread::Globals& globals, |
| 1001 net::HttpNetworkSession::Params* params) { | 1001 net::HttpNetworkSession::Params* params) { |
| 1002 params->host_resolver = globals.host_resolver.get(); | 1002 params->host_resolver = globals.host_resolver.get(); |
| 1003 params->cert_verifier = globals.cert_verifier.get(); | 1003 params->cert_verifier = globals.cert_verifier.get(); |
| 1004 params->server_bound_cert_service = | 1004 params->channel_id_service = globals.system_channel_id_service.get(); |
| 1005 globals.system_server_bound_cert_service.get(); | |
| 1006 params->transport_security_state = globals.transport_security_state.get(); | 1005 params->transport_security_state = globals.transport_security_state.get(); |
| 1007 params->ssl_config_service = globals.ssl_config_service.get(); | 1006 params->ssl_config_service = globals.ssl_config_service.get(); |
| 1008 params->http_auth_handler_factory = globals.http_auth_handler_factory.get(); | 1007 params->http_auth_handler_factory = globals.http_auth_handler_factory.get(); |
| 1009 params->http_server_properties = | 1008 params->http_server_properties = |
| 1010 globals.http_server_properties->GetWeakPtr(); | 1009 globals.http_server_properties->GetWeakPtr(); |
| 1011 params->network_delegate = globals.system_network_delegate.get(); | 1010 params->network_delegate = globals.system_network_delegate.get(); |
| 1012 params->host_mapping_rules = globals.host_mapping_rules.get(); | 1011 params->host_mapping_rules = globals.host_mapping_rules.get(); |
| 1013 params->ignore_certificate_errors = globals.ignore_certificate_errors; | 1012 params->ignore_certificate_errors = globals.ignore_certificate_errors; |
| 1014 params->testing_fixed_http_port = globals.testing_fixed_http_port; | 1013 params->testing_fixed_http_port = globals.testing_fixed_http_port; |
| 1015 params->testing_fixed_https_port = globals.testing_fixed_https_port; | 1014 params->testing_fixed_https_port = globals.testing_fixed_https_port; |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1381 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1380 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1382 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1381 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1383 net::QuicVersion version = supported_versions[i]; | 1382 net::QuicVersion version = supported_versions[i]; |
| 1384 if (net::QuicVersionToString(version) == quic_version) { | 1383 if (net::QuicVersionToString(version) == quic_version) { |
| 1385 return version; | 1384 return version; |
| 1386 } | 1385 } |
| 1387 } | 1386 } |
| 1388 | 1387 |
| 1389 return net::QUIC_VERSION_UNSUPPORTED; | 1388 return net::QUIC_VERSION_UNSUPPORTED; |
| 1390 } | 1389 } |
| OLD | NEW |