Chromium Code Reviews| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 #include "net/spdy/spdy_session.h" | 80 #include "net/spdy/spdy_session.h" |
| 81 #include "net/ssl/channel_id_service.h" | 81 #include "net/ssl/channel_id_service.h" |
| 82 #include "net/ssl/default_channel_id_store.h" | 82 #include "net/ssl/default_channel_id_store.h" |
| 83 #include "net/url_request/data_protocol_handler.h" | 83 #include "net/url_request/data_protocol_handler.h" |
| 84 #include "net/url_request/file_protocol_handler.h" | 84 #include "net/url_request/file_protocol_handler.h" |
| 85 #include "net/url_request/ftp_protocol_handler.h" | 85 #include "net/url_request/ftp_protocol_handler.h" |
| 86 #include "net/url_request/static_http_user_agent_settings.h" | 86 #include "net/url_request/static_http_user_agent_settings.h" |
| 87 #include "net/url_request/url_fetcher.h" | 87 #include "net/url_request/url_fetcher.h" |
| 88 #include "net/url_request/url_request_backoff_manager.h" | 88 #include "net/url_request/url_request_backoff_manager.h" |
| 89 #include "net/url_request/url_request_context.h" | 89 #include "net/url_request/url_request_context.h" |
| 90 #include "net/url_request/url_request_context_builder.h" | |
| 90 #include "net/url_request/url_request_context_getter.h" | 91 #include "net/url_request/url_request_context_getter.h" |
| 91 #include "net/url_request/url_request_job_factory_impl.h" | 92 #include "net/url_request/url_request_job_factory_impl.h" |
| 92 #include "url/url_constants.h" | 93 #include "url/url_constants.h" |
| 93 | 94 |
| 94 #if defined(ENABLE_CONFIGURATION_POLICY) | 95 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 95 #include "policy/policy_constants.h" | 96 #include "policy/policy_constants.h" |
| 96 #endif | 97 #endif |
| 97 | 98 |
| 98 #if defined(ENABLE_EXTENSIONS) | 99 #if defined(ENABLE_EXTENSIONS) |
| 99 #include "chrome/browser/extensions/event_router_forwarder.h" | 100 #include "chrome/browser/extensions/event_router_forwarder.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 if (!command_line.HasSwitch(switches::kHostResolverRules)) | 208 if (!command_line.HasSwitch(switches::kHostResolverRules)) |
| 208 return global_host_resolver.Pass(); | 209 return global_host_resolver.Pass(); |
| 209 | 210 |
| 210 scoped_ptr<net::MappedHostResolver> remapped_resolver( | 211 scoped_ptr<net::MappedHostResolver> remapped_resolver( |
| 211 new net::MappedHostResolver(global_host_resolver.Pass())); | 212 new net::MappedHostResolver(global_host_resolver.Pass())); |
| 212 remapped_resolver->SetRulesFromString( | 213 remapped_resolver->SetRulesFromString( |
| 213 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); | 214 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); |
| 214 return remapped_resolver.Pass(); | 215 return remapped_resolver.Pass(); |
| 215 } | 216 } |
| 216 | 217 |
| 217 // TODO(willchan): Remove proxy script fetcher context since it's not necessary | |
| 218 // now that I got rid of refcounting URLRequestContexts. | |
| 219 // See IOThread::Globals for details. | |
| 220 net::URLRequestContext* | |
| 221 ConstructProxyScriptFetcherContext(IOThread::Globals* globals, | |
| 222 net::NetLog* net_log) { | |
| 223 net::URLRequestContext* context = new net::URLRequestContext; | |
| 224 context->set_net_log(net_log); | |
| 225 context->set_host_resolver(globals->host_resolver.get()); | |
| 226 context->set_cert_verifier(globals->cert_verifier.get()); | |
| 227 context->set_transport_security_state( | |
| 228 globals->transport_security_state.get()); | |
| 229 context->set_cert_transparency_verifier( | |
| 230 globals->cert_transparency_verifier.get()); | |
| 231 context->set_http_auth_handler_factory( | |
| 232 globals->http_auth_handler_factory.get()); | |
| 233 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); | |
| 234 context->set_http_transaction_factory( | |
| 235 globals->proxy_script_fetcher_http_transaction_factory.get()); | |
| 236 context->set_job_factory( | |
| 237 globals->proxy_script_fetcher_url_request_job_factory.get()); | |
| 238 context->set_cookie_store(globals->system_cookie_store.get()); | |
| 239 context->set_channel_id_service( | |
| 240 globals->system_channel_id_service.get()); | |
| 241 context->set_network_delegate(globals->system_network_delegate.get()); | |
| 242 context->set_http_user_agent_settings( | |
| 243 globals->http_user_agent_settings.get()); | |
| 244 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | |
| 245 // system URLRequestContext too. There's no reason this should be tied to a | |
| 246 // profile. | |
| 247 return context; | |
| 248 } | |
| 249 | |
| 250 net::URLRequestContext* | |
| 251 ConstructSystemRequestContext(IOThread::Globals* globals, | |
| 252 net::NetLog* net_log) { | |
| 253 net::URLRequestContext* context = new SystemURLRequestContext; | |
| 254 context->set_net_log(net_log); | |
| 255 context->set_host_resolver(globals->host_resolver.get()); | |
| 256 context->set_cert_verifier(globals->cert_verifier.get()); | |
| 257 context->set_transport_security_state( | |
| 258 globals->transport_security_state.get()); | |
| 259 context->set_cert_transparency_verifier( | |
| 260 globals->cert_transparency_verifier.get()); | |
| 261 context->set_http_auth_handler_factory( | |
| 262 globals->http_auth_handler_factory.get()); | |
| 263 context->set_proxy_service(globals->system_proxy_service.get()); | |
| 264 context->set_http_transaction_factory( | |
| 265 globals->system_http_transaction_factory.get()); | |
| 266 context->set_job_factory(globals->system_url_request_job_factory.get()); | |
| 267 context->set_cookie_store(globals->system_cookie_store.get()); | |
| 268 context->set_channel_id_service( | |
| 269 globals->system_channel_id_service.get()); | |
| 270 context->set_network_delegate(globals->system_network_delegate.get()); | |
| 271 context->set_http_user_agent_settings( | |
| 272 globals->http_user_agent_settings.get()); | |
| 273 context->set_network_quality_estimator( | |
| 274 globals->network_quality_estimator.get()); | |
| 275 context->set_backoff_manager(globals->url_request_backoff_manager.get()); | |
| 276 return context; | |
| 277 } | |
| 278 | |
| 279 int GetSwitchValueAsInt(const base::CommandLine& command_line, | 218 int GetSwitchValueAsInt(const base::CommandLine& command_line, |
| 280 const std::string& switch_name) { | 219 const std::string& switch_name) { |
| 281 int value; | 220 int value; |
| 282 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name), | 221 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name), |
| 283 &value)) { | 222 &value)) { |
| 284 return 0; | 223 return 0; |
| 285 } | 224 } |
| 286 return value; | 225 return value; |
| 287 } | 226 } |
| 288 | 227 |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 809 switches::kEnableUserAlternateProtocolPorts)) { | 748 switches::kEnableUserAlternateProtocolPorts)) { |
| 810 globals_->enable_user_alternate_protocol_ports = true; | 749 globals_->enable_user_alternate_protocol_ports = true; |
| 811 } | 750 } |
| 812 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 751 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
| 813 // is fixed. | 752 // is fixed. |
| 814 tracked_objects::ScopedTracker tracking_profile13( | 753 tracked_objects::ScopedTracker tracking_profile13( |
| 815 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 754 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 816 "466432 IOThread::InitAsync::InitializeNetworkOptions")); | 755 "466432 IOThread::InitAsync::InitializeNetworkOptions")); |
| 817 InitializeNetworkOptions(command_line); | 756 InitializeNetworkOptions(command_line); |
| 818 | 757 |
| 819 net::HttpNetworkSession::Params session_params; | 758 TRACE_EVENT_BEGIN0("startup", |
| 820 InitializeNetworkSessionParams(&session_params); | 759 "IOThread::Init:ProxyScriptFetcherRequestContext"); |
| 821 session_params.net_log = net_log_; | |
| 822 session_params.proxy_service = | |
| 823 globals_->proxy_script_fetcher_proxy_service.get(); | |
| 824 | |
| 825 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | |
| 826 // is fixed. | |
| 827 tracked_objects::ScopedTracker tracking_profile14( | |
| 828 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 829 "466432 IOThread::InitAsync::HttpNetorkSession::Start")); | |
| 830 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:HttpNetworkSession"); | |
| 831 scoped_refptr<net::HttpNetworkSession> network_session( | |
| 832 new net::HttpNetworkSession(session_params)); | |
| 833 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | |
| 834 // is fixed. | |
| 835 tracked_objects::ScopedTracker tracking_profile15( | |
| 836 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 837 "466432 IOThread::InitAsync::HttpNetorkSession::End")); | |
| 838 globals_->proxy_script_fetcher_http_transaction_factory | |
| 839 .reset(new net::HttpNetworkLayer(network_session.get())); | |
| 840 TRACE_EVENT_END0("startup", "IOThread::InitAsync:HttpNetworkSession"); | |
| 841 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | |
| 842 new net::URLRequestJobFactoryImpl()); | |
| 843 | |
| 844 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | |
| 845 // is fixed. | |
| 846 tracked_objects::ScopedTracker tracking_profile16( | |
| 847 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 848 "466432 IOThread::InitAsync::SetProtocolHandler")); | |
| 849 job_factory->SetProtocolHandler(url::kDataScheme, | |
| 850 new net::DataProtocolHandler()); | |
| 851 job_factory->SetProtocolHandler( | |
| 852 url::kFileScheme, | |
| 853 new net::FileProtocolHandler( | |
| 854 content::BrowserThread::GetBlockingPool()-> | |
| 855 GetTaskRunnerWithShutdownBehavior( | |
| 856 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); | |
| 857 #if !defined(DISABLE_FTP_SUPPORT) | |
| 858 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( | |
| 859 new net::FtpNetworkLayer(globals_->host_resolver.get())); | |
| 860 job_factory->SetProtocolHandler( | |
| 861 url::kFtpScheme, | |
| 862 new net::FtpProtocolHandler( | |
| 863 globals_->proxy_script_fetcher_ftp_transaction_factory.get())); | |
| 864 #endif | |
| 865 globals_->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); | |
| 866 | |
| 867 globals_->proxy_script_fetcher_context.reset( | 760 globals_->proxy_script_fetcher_context.reset( |
| 868 ConstructProxyScriptFetcherContext(globals_, net_log_)); | 761 ConstructProxyScriptFetcherContext(globals_, net_log_)); |
| 762 TRACE_EVENT_END0("startup", | |
| 763 "IOThread::Init:ProxyScriptFetcherRequestContext"); | |
| 869 | 764 |
| 870 const version_info::Channel channel = chrome::GetChannel(); | 765 const version_info::Channel channel = chrome::GetChannel(); |
| 871 if (channel == version_info::Channel::UNKNOWN || | 766 if (channel == version_info::Channel::UNKNOWN || |
| 872 channel == version_info::Channel::CANARY || | 767 channel == version_info::Channel::CANARY || |
| 873 channel == version_info::Channel::DEV) { | 768 channel == version_info::Channel::DEV) { |
| 874 globals_->url_request_backoff_manager.reset( | 769 globals_->url_request_backoff_manager.reset( |
| 875 new net::URLRequestBackoffManager()); | 770 new net::URLRequestBackoffManager()); |
| 876 } | 771 } |
| 877 | 772 |
| 878 #if defined(OS_MACOSX) && !defined(OS_IOS) | 773 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1093 | 988 |
| 1094 void IOThread::InitializeNetworkSessionParams( | 989 void IOThread::InitializeNetworkSessionParams( |
| 1095 net::HttpNetworkSession::Params* params) { | 990 net::HttpNetworkSession::Params* params) { |
| 1096 InitializeNetworkSessionParamsFromGlobals(*globals_, params); | 991 InitializeNetworkSessionParamsFromGlobals(*globals_, params); |
| 1097 } | 992 } |
| 1098 | 993 |
| 1099 // static | 994 // static |
| 1100 void IOThread::InitializeNetworkSessionParamsFromGlobals( | 995 void IOThread::InitializeNetworkSessionParamsFromGlobals( |
| 1101 const IOThread::Globals& globals, | 996 const IOThread::Globals& globals, |
| 1102 net::HttpNetworkSession::Params* params) { | 997 net::HttpNetworkSession::Params* params) { |
| 1103 params->host_resolver = globals.host_resolver.get(); | 998 // The next two properties of the params don't seem to be |
| 1104 params->cert_verifier = globals.cert_verifier.get(); | 999 // elements of URLRequestContext, so they must be set here. |
| 1105 params->cert_policy_enforcer = globals.cert_policy_enforcer.get(); | 1000 params->cert_policy_enforcer = globals.cert_policy_enforcer.get(); |
| 1106 params->channel_id_service = globals.system_channel_id_service.get(); | |
| 1107 params->transport_security_state = globals.transport_security_state.get(); | |
| 1108 params->ssl_config_service = globals.ssl_config_service.get(); | |
| 1109 params->http_auth_handler_factory = globals.http_auth_handler_factory.get(); | |
| 1110 params->http_server_properties = | |
| 1111 globals.http_server_properties->GetWeakPtr(); | |
| 1112 params->network_delegate = globals.system_network_delegate.get(); | |
| 1113 params->host_mapping_rules = globals.host_mapping_rules.get(); | 1001 params->host_mapping_rules = globals.host_mapping_rules.get(); |
| 1002 | |
| 1114 params->ignore_certificate_errors = globals.ignore_certificate_errors; | 1003 params->ignore_certificate_errors = globals.ignore_certificate_errors; |
| 1115 params->testing_fixed_http_port = globals.testing_fixed_http_port; | 1004 params->testing_fixed_http_port = globals.testing_fixed_http_port; |
| 1116 params->testing_fixed_https_port = globals.testing_fixed_https_port; | 1005 params->testing_fixed_https_port = globals.testing_fixed_https_port; |
| 1117 globals.enable_tcp_fast_open_for_ssl.CopyToIfSet( | 1006 globals.enable_tcp_fast_open_for_ssl.CopyToIfSet( |
| 1118 ¶ms->enable_tcp_fast_open_for_ssl); | 1007 ¶ms->enable_tcp_fast_open_for_ssl); |
| 1119 | 1008 |
| 1120 globals.initial_max_spdy_concurrent_streams.CopyToIfSet( | 1009 globals.initial_max_spdy_concurrent_streams.CopyToIfSet( |
| 1121 ¶ms->spdy_initial_max_concurrent_streams); | 1010 ¶ms->spdy_initial_max_concurrent_streams); |
| 1122 globals.enable_spdy_compression.CopyToIfSet( | 1011 globals.enable_spdy_compression.CopyToIfSet( |
| 1123 ¶ms->enable_spdy_compression); | 1012 ¶ms->enable_spdy_compression); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1214 *base::CommandLine::ForCurrentProcess(); | 1103 *base::CommandLine::ForCurrentProcess(); |
| 1215 globals_->system_proxy_service.reset( | 1104 globals_->system_proxy_service.reset( |
| 1216 ProxyServiceFactory::CreateProxyService( | 1105 ProxyServiceFactory::CreateProxyService( |
| 1217 net_log_, | 1106 net_log_, |
| 1218 globals_->proxy_script_fetcher_context.get(), | 1107 globals_->proxy_script_fetcher_context.get(), |
| 1219 globals_->system_network_delegate.get(), | 1108 globals_->system_network_delegate.get(), |
| 1220 system_proxy_config_service_.release(), | 1109 system_proxy_config_service_.release(), |
| 1221 command_line, | 1110 command_line, |
| 1222 quick_check_enabled_.GetValue())); | 1111 quick_check_enabled_.GetValue())); |
| 1223 | 1112 |
| 1224 net::HttpNetworkSession::Params system_params; | |
| 1225 InitializeNetworkSessionParams(&system_params); | |
| 1226 system_params.net_log = net_log_; | |
| 1227 system_params.proxy_service = globals_->system_proxy_service.get(); | |
| 1228 | |
| 1229 globals_->system_http_transaction_factory.reset( | |
| 1230 new net::HttpNetworkLayer( | |
| 1231 new net::HttpNetworkSession(system_params))); | |
| 1232 globals_->system_url_request_job_factory.reset( | |
| 1233 new net::URLRequestJobFactoryImpl()); | |
| 1234 globals_->system_request_context.reset( | 1113 globals_->system_request_context.reset( |
| 1235 ConstructSystemRequestContext(globals_, net_log_)); | 1114 ConstructSystemRequestContext(globals_, net_log_)); |
| 1236 globals_->system_request_context->set_ssl_config_service( | |
| 1237 globals_->ssl_config_service.get()); | |
| 1238 globals_->system_request_context->set_http_server_properties( | |
| 1239 globals_->http_server_properties->GetWeakPtr()); | |
| 1240 } | 1115 } |
| 1241 | 1116 |
| 1242 void IOThread::UpdateDnsClientEnabled() { | 1117 void IOThread::UpdateDnsClientEnabled() { |
| 1243 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); | 1118 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); |
| 1244 } | 1119 } |
| 1245 | 1120 |
| 1246 void IOThread::ConfigureQuic(const base::CommandLine& command_line) { | 1121 void IOThread::ConfigureQuic(const base::CommandLine& command_line) { |
| 1247 // Always fetch the field trial group to ensure it is reported correctly. | 1122 // Always fetch the field trial group to ensure it is reported correctly. |
| 1248 // The command line flags will be associated with a group that is reported | 1123 // The command line flags will be associated with a group that is reported |
| 1249 // so long as trial is actually queried. | 1124 // so long as trial is actually queried. |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1593 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1468 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1594 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1469 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1595 net::QuicVersion version = supported_versions[i]; | 1470 net::QuicVersion version = supported_versions[i]; |
| 1596 if (net::QuicVersionToString(version) == quic_version) { | 1471 if (net::QuicVersionToString(version) == quic_version) { |
| 1597 return version; | 1472 return version; |
| 1598 } | 1473 } |
| 1599 } | 1474 } |
| 1600 | 1475 |
| 1601 return net::QUIC_VERSION_UNSUPPORTED; | 1476 return net::QUIC_VERSION_UNSUPPORTED; |
| 1602 } | 1477 } |
| 1478 | |
| 1479 // static | |
| 1480 net::URLRequestContext* | |
| 1481 IOThread::ConstructSystemRequestContext(IOThread::Globals* globals, | |
| 1482 net::NetLog* net_log) { | |
|
mmenke
2015/08/18 18:30:32
fix indent
wjmaclean
2015/08/18 18:55:37
Done.
| |
| 1483 net::URLRequestContext* context = new SystemURLRequestContext; | |
| 1484 context->set_net_log(net_log); | |
| 1485 context->set_host_resolver(globals->host_resolver.get()); | |
| 1486 context->set_cert_verifier(globals->cert_verifier.get()); | |
| 1487 context->set_transport_security_state( | |
| 1488 globals->transport_security_state.get()); | |
| 1489 context->set_cert_transparency_verifier( | |
| 1490 globals->cert_transparency_verifier.get()); | |
| 1491 context->set_ssl_config_service(globals->ssl_config_service.get()); | |
| 1492 context->set_http_auth_handler_factory( | |
| 1493 globals->http_auth_handler_factory.get()); | |
| 1494 context->set_proxy_service(globals->system_proxy_service.get()); | |
| 1495 | |
| 1496 globals->system_url_request_job_factory.reset( | |
| 1497 new net::URLRequestJobFactoryImpl()); | |
| 1498 context->set_job_factory(globals->system_url_request_job_factory.get()); | |
| 1499 | |
| 1500 context->set_cookie_store(globals->system_cookie_store.get()); | |
| 1501 context->set_channel_id_service( | |
| 1502 globals->system_channel_id_service.get()); | |
| 1503 context->set_network_delegate(globals->system_network_delegate.get()); | |
| 1504 context->set_http_user_agent_settings( | |
| 1505 globals->http_user_agent_settings.get()); | |
| 1506 context->set_network_quality_estimator( | |
| 1507 globals->network_quality_estimator.get()); | |
| 1508 context->set_backoff_manager(globals->url_request_backoff_manager.get()); | |
| 1509 | |
| 1510 context->set_ssl_config_service( | |
| 1511 globals->ssl_config_service.get()); | |
|
mmenke
2015/08/18 18:30:32
You're doing this twice.
wjmaclean
2015/08/18 18:55:37
Thanks for spotting this ... fixed!
| |
| 1512 context->set_http_server_properties( | |
| 1513 globals->http_server_properties->GetWeakPtr()); | |
| 1514 | |
| 1515 net::HttpNetworkSession::Params system_params; | |
| 1516 InitializeNetworkSessionParamsFromGlobals(*globals, &system_params); | |
| 1517 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents( | |
| 1518 context, &system_params); | |
| 1519 | |
| 1520 globals->system_http_transaction_factory.reset( | |
| 1521 new net::HttpNetworkLayer(new net::HttpNetworkSession(system_params))); | |
| 1522 context->set_http_transaction_factory( | |
| 1523 globals->system_http_transaction_factory.get()); | |
| 1524 | |
| 1525 return context; | |
| 1526 } | |
| 1527 | |
| 1528 // TODO(willchan): Remove proxy script fetcher context since it's not necessary | |
| 1529 // now that I got rid of refcounting URLRequestContexts. | |
| 1530 // See IOThread::Globals for details. | |
|
mmenke
2015/08/18 18:30:32
Method level comments should go with the definitio
wjmaclean
2015/08/18 18:55:37
Done.
| |
| 1531 // static | |
|
mmenke
2015/08/18 18:30:32
optional nit: The latest google style guide says
wjmaclean
2015/08/18 18:55:37
Done. (Removed throughout this file.)
| |
| 1532 net::URLRequestContext* IOThread::ConstructProxyScriptFetcherContext( | |
| 1533 IOThread::Globals* globals, | |
| 1534 net::NetLog* net_log) { | |
| 1535 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | |
| 1536 // is fixed. | |
| 1537 tracked_objects::ScopedTracker tracking_profile16( | |
| 1538 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 1539 "466432 IOThread::ConstructProxyScriptFetcherContext")); | |
| 1540 net::URLRequestContext* context = new net::URLRequestContext; | |
| 1541 context->set_net_log(net_log); | |
| 1542 context->set_host_resolver(globals->host_resolver.get()); | |
| 1543 context->set_cert_verifier(globals->cert_verifier.get()); | |
| 1544 context->set_transport_security_state( | |
| 1545 globals->transport_security_state.get()); | |
| 1546 context->set_cert_transparency_verifier( | |
| 1547 globals->cert_transparency_verifier.get()); | |
| 1548 context->set_ssl_config_service(globals->ssl_config_service.get()); | |
| 1549 context->set_http_auth_handler_factory( | |
| 1550 globals->http_auth_handler_factory.get()); | |
| 1551 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); | |
| 1552 | |
| 1553 context->set_cookie_store(globals->system_cookie_store.get()); | |
| 1554 context->set_channel_id_service( | |
| 1555 globals->system_channel_id_service.get()); | |
| 1556 context->set_network_delegate(globals->system_network_delegate.get()); | |
| 1557 context->set_http_user_agent_settings( | |
| 1558 globals->http_user_agent_settings.get()); | |
| 1559 context->set_http_server_properties( | |
| 1560 globals->http_server_properties->GetWeakPtr()); | |
| 1561 | |
| 1562 net::HttpNetworkSession::Params session_params; | |
| 1563 InitializeNetworkSessionParamsFromGlobals(*globals, &session_params); | |
| 1564 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents( | |
| 1565 context, &session_params); | |
| 1566 | |
| 1567 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | |
| 1568 // is fixed. | |
| 1569 tracked_objects::ScopedTracker tracking_profile14( | |
| 1570 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 1571 "466432 IOThread::ConstructProxyScriptFetcherContext2")); | |
| 1572 scoped_refptr<net::HttpNetworkSession> network_session( | |
| 1573 new net::HttpNetworkSession(session_params)); | |
| 1574 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | |
| 1575 // is fixed. | |
| 1576 tracked_objects::ScopedTracker tracking_profile15( | |
|
mmenke
2015/08/18 18:30:32
nit: Should probably renumber these to match thei
wjmaclean
2015/08/18 18:55:37
Done.
| |
| 1577 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 1578 "466432 IOThread::InitAsync::HttpNetorkSession::End")); | |
|
mmenke
2015/08/18 18:30:32
IOThread::ConstructProxyScriptFetcherContext3?
wjmaclean
2015/08/18 18:55:37
Done.
| |
| 1579 globals->proxy_script_fetcher_http_transaction_factory | |
| 1580 .reset(new net::HttpNetworkLayer(network_session.get())); | |
| 1581 context->set_http_transaction_factory( | |
| 1582 globals->proxy_script_fetcher_http_transaction_factory.get()); | |
| 1583 | |
| 1584 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory( | |
| 1585 new net::URLRequestJobFactoryImpl()); | |
| 1586 | |
| 1587 job_factory->SetProtocolHandler(url::kDataScheme, | |
| 1588 new net::DataProtocolHandler()); | |
| 1589 job_factory->SetProtocolHandler( | |
| 1590 url::kFileScheme, | |
| 1591 new net::FileProtocolHandler( | |
| 1592 content::BrowserThread::GetBlockingPool()-> | |
| 1593 GetTaskRunnerWithShutdownBehavior( | |
| 1594 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); | |
| 1595 #if !defined(DISABLE_FTP_SUPPORT) | |
| 1596 globals->proxy_script_fetcher_ftp_transaction_factory.reset( | |
| 1597 new net::FtpNetworkLayer(globals->host_resolver.get())); | |
| 1598 job_factory->SetProtocolHandler( | |
| 1599 url::kFtpScheme, | |
| 1600 new net::FtpProtocolHandler( | |
| 1601 globals->proxy_script_fetcher_ftp_transaction_factory.get())); | |
| 1602 #endif | |
| 1603 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); | |
| 1604 | |
| 1605 context->set_job_factory( | |
| 1606 globals->proxy_script_fetcher_url_request_job_factory.get()); | |
| 1607 | |
| 1608 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | |
| 1609 // system URLRequestContext too. There's no reason this should be tied to a | |
| 1610 // profile. | |
| 1611 return context; | |
| 1612 } | |
| OLD | NEW |