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

Side by Side Diff: chrome/browser/io_thread.cc

Issue 1288383002: Use common code to set HttpNetworkSession::Param pointers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to r345348. Created 5 years, 4 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
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/profiles/profile_io_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #include "net/spdy/spdy_session.h" 81 #include "net/spdy/spdy_session.h"
82 #include "net/ssl/channel_id_service.h" 82 #include "net/ssl/channel_id_service.h"
83 #include "net/ssl/default_channel_id_store.h" 83 #include "net/ssl/default_channel_id_store.h"
84 #include "net/url_request/data_protocol_handler.h" 84 #include "net/url_request/data_protocol_handler.h"
85 #include "net/url_request/file_protocol_handler.h" 85 #include "net/url_request/file_protocol_handler.h"
86 #include "net/url_request/ftp_protocol_handler.h" 86 #include "net/url_request/ftp_protocol_handler.h"
87 #include "net/url_request/static_http_user_agent_settings.h" 87 #include "net/url_request/static_http_user_agent_settings.h"
88 #include "net/url_request/url_fetcher.h" 88 #include "net/url_request/url_fetcher.h"
89 #include "net/url_request/url_request_backoff_manager.h" 89 #include "net/url_request/url_request_backoff_manager.h"
90 #include "net/url_request/url_request_context.h" 90 #include "net/url_request/url_request_context.h"
91 #include "net/url_request/url_request_context_builder.h"
91 #include "net/url_request/url_request_context_getter.h" 92 #include "net/url_request/url_request_context_getter.h"
92 #include "net/url_request/url_request_job_factory_impl.h" 93 #include "net/url_request/url_request_job_factory_impl.h"
93 #include "url/url_constants.h" 94 #include "url/url_constants.h"
94 95
95 #if defined(ENABLE_CONFIGURATION_POLICY) 96 #if defined(ENABLE_CONFIGURATION_POLICY)
96 #include "policy/policy_constants.h" 97 #include "policy/policy_constants.h"
97 #endif 98 #endif
98 99
99 #if defined(ENABLE_EXTENSIONS) 100 #if defined(ENABLE_EXTENSIONS)
100 #include "chrome/browser/extensions/event_router_forwarder.h" 101 #include "chrome/browser/extensions/event_router_forwarder.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if (!command_line.HasSwitch(switches::kHostResolverRules)) 210 if (!command_line.HasSwitch(switches::kHostResolverRules))
210 return global_host_resolver.Pass(); 211 return global_host_resolver.Pass();
211 212
212 scoped_ptr<net::MappedHostResolver> remapped_resolver( 213 scoped_ptr<net::MappedHostResolver> remapped_resolver(
213 new net::MappedHostResolver(global_host_resolver.Pass())); 214 new net::MappedHostResolver(global_host_resolver.Pass()));
214 remapped_resolver->SetRulesFromString( 215 remapped_resolver->SetRulesFromString(
215 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); 216 command_line.GetSwitchValueASCII(switches::kHostResolverRules));
216 return remapped_resolver.Pass(); 217 return remapped_resolver.Pass();
217 } 218 }
218 219
219 // TODO(willchan): Remove proxy script fetcher context since it's not necessary
220 // now that I got rid of refcounting URLRequestContexts.
221 // See IOThread::Globals for details.
222 net::URLRequestContext*
223 ConstructProxyScriptFetcherContext(IOThread::Globals* globals,
224 net::NetLog* net_log) {
225 net::URLRequestContext* context = new net::URLRequestContext;
226 context->set_net_log(net_log);
227 context->set_host_resolver(globals->host_resolver.get());
228 context->set_cert_verifier(globals->cert_verifier.get());
229 context->set_transport_security_state(
230 globals->transport_security_state.get());
231 context->set_cert_transparency_verifier(
232 globals->cert_transparency_verifier.get());
233 context->set_http_auth_handler_factory(
234 globals->http_auth_handler_factory.get());
235 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get());
236 context->set_http_transaction_factory(
237 globals->proxy_script_fetcher_http_transaction_factory.get());
238 context->set_job_factory(
239 globals->proxy_script_fetcher_url_request_job_factory.get());
240 context->set_cookie_store(globals->system_cookie_store.get());
241 context->set_channel_id_service(
242 globals->system_channel_id_service.get());
243 context->set_network_delegate(globals->system_network_delegate.get());
244 context->set_http_user_agent_settings(
245 globals->http_user_agent_settings.get());
246 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the
247 // system URLRequestContext too. There's no reason this should be tied to a
248 // profile.
249 return context;
250 }
251
252 net::URLRequestContext*
253 ConstructSystemRequestContext(IOThread::Globals* globals,
254 net::NetLog* net_log) {
255 net::URLRequestContext* context = new SystemURLRequestContext;
256 context->set_net_log(net_log);
257 context->set_host_resolver(globals->host_resolver.get());
258 context->set_cert_verifier(globals->cert_verifier.get());
259 context->set_transport_security_state(
260 globals->transport_security_state.get());
261 context->set_cert_transparency_verifier(
262 globals->cert_transparency_verifier.get());
263 context->set_http_auth_handler_factory(
264 globals->http_auth_handler_factory.get());
265 context->set_proxy_service(globals->system_proxy_service.get());
266 context->set_http_transaction_factory(
267 globals->system_http_transaction_factory.get());
268 context->set_job_factory(globals->system_url_request_job_factory.get());
269 context->set_cookie_store(globals->system_cookie_store.get());
270 context->set_channel_id_service(
271 globals->system_channel_id_service.get());
272 context->set_network_delegate(globals->system_network_delegate.get());
273 context->set_http_user_agent_settings(
274 globals->http_user_agent_settings.get());
275 context->set_network_quality_estimator(
276 globals->network_quality_estimator.get());
277 context->set_backoff_manager(globals->url_request_backoff_manager.get());
278 return context;
279 }
280
281 int GetSwitchValueAsInt(const base::CommandLine& command_line, 220 int GetSwitchValueAsInt(const base::CommandLine& command_line,
282 const std::string& switch_name) { 221 const std::string& switch_name) {
283 int value; 222 int value;
284 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name), 223 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name),
285 &value)) { 224 &value)) {
286 return 0; 225 return 0;
287 } 226 }
288 return value; 227 return value;
289 } 228 }
290 229
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 switches::kEnableUserAlternateProtocolPorts)) { 751 switches::kEnableUserAlternateProtocolPorts)) {
813 globals_->enable_user_alternate_protocol_ports = true; 752 globals_->enable_user_alternate_protocol_ports = true;
814 } 753 }
815 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 754 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432
816 // is fixed. 755 // is fixed.
817 tracked_objects::ScopedTracker tracking_profile13( 756 tracked_objects::ScopedTracker tracking_profile13(
818 FROM_HERE_WITH_EXPLICIT_FUNCTION( 757 FROM_HERE_WITH_EXPLICIT_FUNCTION(
819 "466432 IOThread::InitAsync::InitializeNetworkOptions")); 758 "466432 IOThread::InitAsync::InitializeNetworkOptions"));
820 InitializeNetworkOptions(command_line); 759 InitializeNetworkOptions(command_line);
821 760
822 net::HttpNetworkSession::Params session_params; 761 TRACE_EVENT_BEGIN0("startup",
823 InitializeNetworkSessionParams(&session_params); 762 "IOThread::Init:ProxyScriptFetcherRequestContext");
824 session_params.net_log = net_log_;
825 session_params.proxy_service =
826 globals_->proxy_script_fetcher_proxy_service.get();
827
828 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432
829 // is fixed.
830 tracked_objects::ScopedTracker tracking_profile14(
831 FROM_HERE_WITH_EXPLICIT_FUNCTION(
832 "466432 IOThread::InitAsync::HttpNetorkSession::Start"));
833 TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:HttpNetworkSession");
834 scoped_refptr<net::HttpNetworkSession> network_session(
835 new net::HttpNetworkSession(session_params));
836 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432
837 // is fixed.
838 tracked_objects::ScopedTracker tracking_profile15(
839 FROM_HERE_WITH_EXPLICIT_FUNCTION(
840 "466432 IOThread::InitAsync::HttpNetorkSession::End"));
841 globals_->proxy_script_fetcher_http_transaction_factory
842 .reset(new net::HttpNetworkLayer(network_session.get()));
843 TRACE_EVENT_END0("startup", "IOThread::InitAsync:HttpNetworkSession");
844 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
845 new net::URLRequestJobFactoryImpl());
846
847 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432
848 // is fixed.
849 tracked_objects::ScopedTracker tracking_profile16(
850 FROM_HERE_WITH_EXPLICIT_FUNCTION(
851 "466432 IOThread::InitAsync::SetProtocolHandler"));
852 job_factory->SetProtocolHandler(
853 url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler()));
854 job_factory->SetProtocolHandler(
855 url::kFileScheme,
856 make_scoped_ptr(new net::FileProtocolHandler(
857 content::BrowserThread::GetBlockingPool()
858 ->GetTaskRunnerWithShutdownBehavior(
859 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))));
860 #if !defined(DISABLE_FTP_SUPPORT)
861 globals_->proxy_script_fetcher_ftp_transaction_factory.reset(
862 new net::FtpNetworkLayer(globals_->host_resolver.get()));
863 job_factory->SetProtocolHandler(
864 url::kFtpScheme,
865 make_scoped_ptr(new net::FtpProtocolHandler(
866 globals_->proxy_script_fetcher_ftp_transaction_factory.get())));
867 #endif
868 globals_->proxy_script_fetcher_url_request_job_factory = job_factory.Pass();
869
870 globals_->proxy_script_fetcher_context.reset( 763 globals_->proxy_script_fetcher_context.reset(
871 ConstructProxyScriptFetcherContext(globals_, net_log_)); 764 ConstructProxyScriptFetcherContext(globals_, net_log_));
765 TRACE_EVENT_END0("startup",
766 "IOThread::Init:ProxyScriptFetcherRequestContext");
872 767
873 const version_info::Channel channel = chrome::GetChannel(); 768 const version_info::Channel channel = chrome::GetChannel();
874 if (channel == version_info::Channel::UNKNOWN || 769 if (channel == version_info::Channel::UNKNOWN ||
875 channel == version_info::Channel::CANARY || 770 channel == version_info::Channel::CANARY ||
876 channel == version_info::Channel::DEV) { 771 channel == version_info::Channel::DEV) {
877 globals_->url_request_backoff_manager.reset( 772 globals_->url_request_backoff_manager.reset(
878 new net::URLRequestBackoffManager()); 773 new net::URLRequestBackoffManager());
879 } 774 }
880 775
881 #if defined(OS_MACOSX) && !defined(OS_IOS) 776 #if defined(OS_MACOSX) && !defined(OS_IOS)
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 base::FieldTrialList::FindFullName(kTCPFastOpenFieldTrialName); 852 base::FieldTrialList::FindFullName(kTCPFastOpenFieldTrialName);
958 if (trial_group == kTCPFastOpenHttpsEnabledGroupName) 853 if (trial_group == kTCPFastOpenHttpsEnabledGroupName)
959 globals_->enable_tcp_fast_open_for_ssl.set(true); 854 globals_->enable_tcp_fast_open_for_ssl.set(true);
960 bool always_enable_if_supported = 855 bool always_enable_if_supported =
961 command_line.HasSwitch(switches::kEnableTcpFastOpen); 856 command_line.HasSwitch(switches::kEnableTcpFastOpen);
962 // Check for OS support of TCP FastOpen, and turn it on for all connections 857 // Check for OS support of TCP FastOpen, and turn it on for all connections
963 // if indicated by user. 858 // if indicated by user.
964 net::CheckSupportAndMaybeEnableTCPFastOpen(always_enable_if_supported); 859 net::CheckSupportAndMaybeEnableTCPFastOpen(always_enable_if_supported);
965 } 860 }
966 861
967 // static
968 void IOThread::ConfigureSpdyGlobals( 862 void IOThread::ConfigureSpdyGlobals(
969 const base::CommandLine& command_line, 863 const base::CommandLine& command_line,
970 base::StringPiece spdy_trial_group, 864 base::StringPiece spdy_trial_group,
971 const VariationParameters& spdy_trial_params, 865 const VariationParameters& spdy_trial_params,
972 IOThread::Globals* globals) { 866 IOThread::Globals* globals) {
973 if (command_line.HasSwitch(switches::kTrustedSpdyProxy)) { 867 if (command_line.HasSwitch(switches::kTrustedSpdyProxy)) {
974 globals->trusted_spdy_proxy.set( 868 globals->trusted_spdy_proxy.set(
975 command_line.GetSwitchValueASCII(switches::kTrustedSpdyProxy)); 869 command_line.GetSwitchValueASCII(switches::kTrustedSpdyProxy));
976 } 870 }
977 if (command_line.HasSwitch(switches::kIgnoreUrlFetcherCertRequests)) 871 if (command_line.HasSwitch(switches::kIgnoreUrlFetcherCertRequests))
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 return; 927 return;
1034 } 928 }
1035 929
1036 // By default, enable HTTP/2. 930 // By default, enable HTTP/2.
1037 globals->next_protos.push_back(net::kProtoSPDY31); 931 globals->next_protos.push_back(net::kProtoSPDY31);
1038 globals->next_protos.push_back(net::kProtoHTTP2_14); 932 globals->next_protos.push_back(net::kProtoHTTP2_14);
1039 globals->next_protos.push_back(net::kProtoHTTP2); 933 globals->next_protos.push_back(net::kProtoHTTP2);
1040 globals->use_alternative_services.set(true); 934 globals->use_alternative_services.set(true);
1041 } 935 }
1042 936
1043 // static
1044 void IOThread::RegisterPrefs(PrefRegistrySimple* registry) { 937 void IOThread::RegisterPrefs(PrefRegistrySimple* registry) {
1045 registry->RegisterStringPref(prefs::kAuthSchemes, 938 registry->RegisterStringPref(prefs::kAuthSchemes,
1046 "basic,digest,ntlm,negotiate"); 939 "basic,digest,ntlm,negotiate");
1047 registry->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, false); 940 registry->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, false);
1048 registry->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); 941 registry->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false);
1049 registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); 942 registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string());
1050 registry->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, 943 registry->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist,
1051 std::string()); 944 std::string());
1052 registry->RegisterStringPref(prefs::kGSSAPILibraryName, std::string()); 945 registry->RegisterStringPref(prefs::kGSSAPILibraryName, std::string());
1053 registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, 946 registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); 985 net::HostCache* host_cache = globals_->host_resolver->GetHostCache();
1093 if (host_cache) 986 if (host_cache)
1094 host_cache->clear(); 987 host_cache->clear();
1095 } 988 }
1096 989
1097 void IOThread::InitializeNetworkSessionParams( 990 void IOThread::InitializeNetworkSessionParams(
1098 net::HttpNetworkSession::Params* params) { 991 net::HttpNetworkSession::Params* params) {
1099 InitializeNetworkSessionParamsFromGlobals(*globals_, params); 992 InitializeNetworkSessionParamsFromGlobals(*globals_, params);
1100 } 993 }
1101 994
1102 // static
1103 void IOThread::InitializeNetworkSessionParamsFromGlobals( 995 void IOThread::InitializeNetworkSessionParamsFromGlobals(
1104 const IOThread::Globals& globals, 996 const IOThread::Globals& globals,
1105 net::HttpNetworkSession::Params* params) { 997 net::HttpNetworkSession::Params* params) {
1106 params->host_resolver = globals.host_resolver.get(); 998 // The next two properties of the params don't seem to be
1107 params->cert_verifier = globals.cert_verifier.get(); 999 // elements of URLRequestContext, so they must be set here.
1108 params->cert_policy_enforcer = globals.cert_policy_enforcer.get(); 1000 params->cert_policy_enforcer = globals.cert_policy_enforcer.get();
1109 params->channel_id_service = globals.system_channel_id_service.get();
1110 params->transport_security_state = globals.transport_security_state.get();
1111 params->ssl_config_service = globals.ssl_config_service.get();
1112 params->http_auth_handler_factory = globals.http_auth_handler_factory.get();
1113 params->http_server_properties =
1114 globals.http_server_properties->GetWeakPtr();
1115 params->network_delegate = globals.system_network_delegate.get();
1116 params->host_mapping_rules = globals.host_mapping_rules.get(); 1001 params->host_mapping_rules = globals.host_mapping_rules.get();
1002
1117 params->ignore_certificate_errors = globals.ignore_certificate_errors; 1003 params->ignore_certificate_errors = globals.ignore_certificate_errors;
1118 params->testing_fixed_http_port = globals.testing_fixed_http_port; 1004 params->testing_fixed_http_port = globals.testing_fixed_http_port;
1119 params->testing_fixed_https_port = globals.testing_fixed_https_port; 1005 params->testing_fixed_https_port = globals.testing_fixed_https_port;
1120 globals.enable_tcp_fast_open_for_ssl.CopyToIfSet( 1006 globals.enable_tcp_fast_open_for_ssl.CopyToIfSet(
1121 &params->enable_tcp_fast_open_for_ssl); 1007 &params->enable_tcp_fast_open_for_ssl);
1122 1008
1123 globals.initial_max_spdy_concurrent_streams.CopyToIfSet( 1009 globals.initial_max_spdy_concurrent_streams.CopyToIfSet(
1124 &params->spdy_initial_max_concurrent_streams); 1010 &params->spdy_initial_max_concurrent_streams);
1125 globals.enable_spdy_compression.CopyToIfSet( 1011 globals.enable_spdy_compression.CopyToIfSet(
1126 &params->enable_spdy_compression); 1012 &params->enable_spdy_compression);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 *base::CommandLine::ForCurrentProcess(); 1103 *base::CommandLine::ForCurrentProcess();
1218 globals_->system_proxy_service.reset( 1104 globals_->system_proxy_service.reset(
1219 ProxyServiceFactory::CreateProxyService( 1105 ProxyServiceFactory::CreateProxyService(
1220 net_log_, 1106 net_log_,
1221 globals_->proxy_script_fetcher_context.get(), 1107 globals_->proxy_script_fetcher_context.get(),
1222 globals_->system_network_delegate.get(), 1108 globals_->system_network_delegate.get(),
1223 system_proxy_config_service_.release(), 1109 system_proxy_config_service_.release(),
1224 command_line, 1110 command_line,
1225 quick_check_enabled_.GetValue())); 1111 quick_check_enabled_.GetValue()));
1226 1112
1227 net::HttpNetworkSession::Params system_params;
1228 InitializeNetworkSessionParams(&system_params);
1229 system_params.net_log = net_log_;
1230 system_params.proxy_service = globals_->system_proxy_service.get();
1231
1232 globals_->system_http_transaction_factory.reset(
1233 new net::HttpNetworkLayer(
1234 new net::HttpNetworkSession(system_params)));
1235 globals_->system_url_request_job_factory.reset(
1236 new net::URLRequestJobFactoryImpl());
1237 globals_->system_request_context.reset( 1113 globals_->system_request_context.reset(
1238 ConstructSystemRequestContext(globals_, net_log_)); 1114 ConstructSystemRequestContext(globals_, net_log_));
1239 globals_->system_request_context->set_ssl_config_service(
1240 globals_->ssl_config_service.get());
1241 globals_->system_request_context->set_http_server_properties(
1242 globals_->http_server_properties->GetWeakPtr());
1243 } 1115 }
1244 1116
1245 void IOThread::UpdateDnsClientEnabled() { 1117 void IOThread::UpdateDnsClientEnabled() {
1246 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); 1118 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_);
1247 } 1119 }
1248 1120
1249 void IOThread::ConfigureQuic(const base::CommandLine& command_line) { 1121 void IOThread::ConfigureQuic(const base::CommandLine& command_line) {
1250 // 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.
1251 // 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
1252 // so long as trial is actually queried. 1124 // so long as trial is actually queried.
1253 std::string group = 1125 std::string group =
1254 base::FieldTrialList::FindFullName(kQuicFieldTrialName); 1126 base::FieldTrialList::FindFullName(kQuicFieldTrialName);
1255 VariationParameters params; 1127 VariationParameters params;
1256 if (!variations::GetVariationParams(kQuicFieldTrialName, &params)) { 1128 if (!variations::GetVariationParams(kQuicFieldTrialName, &params)) {
1257 params.clear(); 1129 params.clear();
1258 } 1130 }
1259 1131
1260 ConfigureQuicGlobals(command_line, group, params, is_quic_allowed_by_policy_, 1132 ConfigureQuicGlobals(command_line, group, params, is_quic_allowed_by_policy_,
1261 globals_); 1133 globals_);
1262 } 1134 }
1263 1135
1264 // static
1265 void IOThread::ConfigureQuicGlobals( 1136 void IOThread::ConfigureQuicGlobals(
1266 const base::CommandLine& command_line, 1137 const base::CommandLine& command_line,
1267 base::StringPiece quic_trial_group, 1138 base::StringPiece quic_trial_group,
1268 const VariationParameters& quic_trial_params, 1139 const VariationParameters& quic_trial_params,
1269 bool quic_allowed_by_policy, 1140 bool quic_allowed_by_policy,
1270 IOThread::Globals* globals) { 1141 IOThread::Globals* globals) {
1271 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group, 1142 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group,
1272 quic_allowed_by_policy); 1143 quic_allowed_by_policy);
1273 globals->enable_quic.set(enable_quic); 1144 globals->enable_quic.set(enable_quic);
1274 bool enable_quic_for_proxies = ShouldEnableQuicForProxies( 1145 bool enable_quic_for_proxies = ShouldEnableQuicForProxies(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 if (command_line.HasSwitch(switches::kDisableQuic) || !quic_allowed_by_policy) 1231 if (command_line.HasSwitch(switches::kDisableQuic) || !quic_allowed_by_policy)
1361 return false; 1232 return false;
1362 1233
1363 if (command_line.HasSwitch(switches::kEnableQuic)) 1234 if (command_line.HasSwitch(switches::kEnableQuic))
1364 return true; 1235 return true;
1365 1236
1366 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) || 1237 return quic_trial_group.starts_with(kQuicFieldTrialEnabledGroupName) ||
1367 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName); 1238 quic_trial_group.starts_with(kQuicFieldTrialHttpsEnabledGroupName);
1368 } 1239 }
1369 1240
1370 // static
1371 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line, 1241 bool IOThread::ShouldEnableQuicForProxies(const base::CommandLine& command_line,
1372 base::StringPiece quic_trial_group, 1242 base::StringPiece quic_trial_group,
1373 bool quic_allowed_by_policy) { 1243 bool quic_allowed_by_policy) {
1374 return ShouldEnableQuic( 1244 return ShouldEnableQuic(
1375 command_line, quic_trial_group, quic_allowed_by_policy) || 1245 command_line, quic_trial_group, quic_allowed_by_policy) ||
1376 ShouldEnableQuicForDataReductionProxy(); 1246 ShouldEnableQuicForDataReductionProxy();
1377 } 1247 }
1378 1248
1379 // static
1380 bool IOThread::ShouldEnableQuicForDataReductionProxy() { 1249 bool IOThread::ShouldEnableQuicForDataReductionProxy() {
1381 const base::CommandLine& command_line = 1250 const base::CommandLine& command_line =
1382 *base::CommandLine::ForCurrentProcess(); 1251 *base::CommandLine::ForCurrentProcess();
1383 1252
1384 if (command_line.HasSwitch(switches::kDisableQuic)) 1253 if (command_line.HasSwitch(switches::kDisableQuic))
1385 return false; 1254 return false;
1386 1255
1387 return data_reduction_proxy::params::IsIncludedInQuicFieldTrial(); 1256 return data_reduction_proxy::params::IsIncludedInQuicFieldTrial();
1388 } 1257 }
1389 1258
1390 // static
1391 bool IOThread::ShouldEnableInsecureQuic( 1259 bool IOThread::ShouldEnableInsecureQuic(
1392 const base::CommandLine& command_line, 1260 const base::CommandLine& command_line,
1393 const VariationParameters& quic_trial_params) { 1261 const VariationParameters& quic_trial_params) {
1394 if (command_line.HasSwitch(switches::kEnableInsecureQuic)) 1262 if (command_line.HasSwitch(switches::kEnableInsecureQuic))
1395 return true; 1263 return true;
1396 1264
1397 return base::LowerCaseEqualsASCII( 1265 return base::LowerCaseEqualsASCII(
1398 GetVariationParam(quic_trial_params, "enable_insecure_quic"), 1266 GetVariationParam(quic_trial_params, "enable_insecure_quic"),
1399 "true"); 1267 "true");
1400 } 1268 }
(...skipping 19 matching lines...) Expand all
1420 1288
1421 VariationParameters::const_iterator it = 1289 VariationParameters::const_iterator it =
1422 quic_trial_params.find("connection_options"); 1290 quic_trial_params.find("connection_options");
1423 if (it == quic_trial_params.end()) { 1291 if (it == quic_trial_params.end()) {
1424 return net::QuicTagVector(); 1292 return net::QuicTagVector();
1425 } 1293 }
1426 1294
1427 return net::QuicUtils::ParseQuicConnectionOptions(it->second); 1295 return net::QuicUtils::ParseQuicConnectionOptions(it->second);
1428 } 1296 }
1429 1297
1430 // static
1431 double IOThread::GetAlternativeProtocolProbabilityThreshold( 1298 double IOThread::GetAlternativeProtocolProbabilityThreshold(
1432 const base::CommandLine& command_line, 1299 const base::CommandLine& command_line,
1433 const VariationParameters& quic_trial_params) { 1300 const VariationParameters& quic_trial_params) {
1434 double value; 1301 double value;
1435 if (command_line.HasSwitch( 1302 if (command_line.HasSwitch(
1436 switches::kAlternativeServiceProbabilityThreshold)) { 1303 switches::kAlternativeServiceProbabilityThreshold)) {
1437 if (base::StringToDouble( 1304 if (base::StringToDouble(
1438 command_line.GetSwitchValueASCII( 1305 command_line.GetSwitchValueASCII(
1439 switches::kAlternativeServiceProbabilityThreshold), 1306 switches::kAlternativeServiceProbabilityThreshold),
1440 &value)) { 1307 &value)) {
(...skipping 13 matching lines...) Expand all
1454 } 1321 }
1455 if (base::StringToDouble( 1322 if (base::StringToDouble(
1456 GetVariationParam(quic_trial_params, 1323 GetVariationParam(quic_trial_params,
1457 "alternative_service_probability_threshold"), 1324 "alternative_service_probability_threshold"),
1458 &value)) { 1325 &value)) {
1459 return value; 1326 return value;
1460 } 1327 }
1461 return -1; 1328 return -1;
1462 } 1329 }
1463 1330
1464 // static
1465 bool IOThread::ShouldQuicAlwaysRequireHandshakeConfirmation( 1331 bool IOThread::ShouldQuicAlwaysRequireHandshakeConfirmation(
1466 const VariationParameters& quic_trial_params) { 1332 const VariationParameters& quic_trial_params) {
1467 return base::LowerCaseEqualsASCII( 1333 return base::LowerCaseEqualsASCII(
1468 GetVariationParam(quic_trial_params, 1334 GetVariationParam(quic_trial_params,
1469 "always_require_handshake_confirmation"), 1335 "always_require_handshake_confirmation"),
1470 "true"); 1336 "true");
1471 } 1337 }
1472 1338
1473 // static
1474 bool IOThread::ShouldQuicDisableConnectionPooling( 1339 bool IOThread::ShouldQuicDisableConnectionPooling(
1475 const VariationParameters& quic_trial_params) { 1340 const VariationParameters& quic_trial_params) {
1476 return base::LowerCaseEqualsASCII( 1341 return base::LowerCaseEqualsASCII(
1477 GetVariationParam(quic_trial_params, "disable_connection_pooling"), 1342 GetVariationParam(quic_trial_params, "disable_connection_pooling"),
1478 "true"); 1343 "true");
1479 } 1344 }
1480 1345
1481 // static
1482 float IOThread::GetQuicLoadServerInfoTimeoutSrttMultiplier( 1346 float IOThread::GetQuicLoadServerInfoTimeoutSrttMultiplier(
1483 const VariationParameters& quic_trial_params) { 1347 const VariationParameters& quic_trial_params) {
1484 double value; 1348 double value;
1485 if (base::StringToDouble(GetVariationParam(quic_trial_params, 1349 if (base::StringToDouble(GetVariationParam(quic_trial_params,
1486 "load_server_info_time_to_srtt"), 1350 "load_server_info_time_to_srtt"),
1487 &value)) { 1351 &value)) {
1488 return static_cast<float>(value); 1352 return static_cast<float>(value);
1489 } 1353 }
1490 return 0.0f; 1354 return 0.0f;
1491 } 1355 }
1492 1356
1493 // static
1494 bool IOThread::ShouldQuicEnableConnectionRacing( 1357 bool IOThread::ShouldQuicEnableConnectionRacing(
1495 const VariationParameters& quic_trial_params) { 1358 const VariationParameters& quic_trial_params) {
1496 return base::LowerCaseEqualsASCII( 1359 return base::LowerCaseEqualsASCII(
1497 GetVariationParam(quic_trial_params, "enable_connection_racing"), 1360 GetVariationParam(quic_trial_params, "enable_connection_racing"),
1498 "true"); 1361 "true");
1499 } 1362 }
1500 1363
1501 // static
1502 bool IOThread::ShouldQuicEnableNonBlockingIO( 1364 bool IOThread::ShouldQuicEnableNonBlockingIO(
1503 const VariationParameters& quic_trial_params) { 1365 const VariationParameters& quic_trial_params) {
1504 return base::LowerCaseEqualsASCII( 1366 return base::LowerCaseEqualsASCII(
1505 GetVariationParam(quic_trial_params, "enable_non_blocking_io"), 1367 GetVariationParam(quic_trial_params, "enable_non_blocking_io"),
1506 "true"); 1368 "true");
1507 } 1369 }
1508 1370
1509 // static
1510 bool IOThread::ShouldQuicDisableDiskCache( 1371 bool IOThread::ShouldQuicDisableDiskCache(
1511 const VariationParameters& quic_trial_params) { 1372 const VariationParameters& quic_trial_params) {
1512 return base::LowerCaseEqualsASCII( 1373 return base::LowerCaseEqualsASCII(
1513 GetVariationParam(quic_trial_params, "disable_disk_cache"), "true"); 1374 GetVariationParam(quic_trial_params, "disable_disk_cache"), "true");
1514 } 1375 }
1515 1376
1516 // static
1517 bool IOThread::ShouldQuicPreferAes( 1377 bool IOThread::ShouldQuicPreferAes(
1518 const VariationParameters& quic_trial_params) { 1378 const VariationParameters& quic_trial_params) {
1519 return base::LowerCaseEqualsASCII( 1379 return base::LowerCaseEqualsASCII(
1520 GetVariationParam(quic_trial_params, "prefer_aes"), "true"); 1380 GetVariationParam(quic_trial_params, "prefer_aes"), "true");
1521 } 1381 }
1522 1382
1523 // static
1524 int IOThread::GetQuicMaxNumberOfLossyConnections( 1383 int IOThread::GetQuicMaxNumberOfLossyConnections(
1525 const VariationParameters& quic_trial_params) { 1384 const VariationParameters& quic_trial_params) {
1526 int value; 1385 int value;
1527 if (base::StringToInt(GetVariationParam(quic_trial_params, 1386 if (base::StringToInt(GetVariationParam(quic_trial_params,
1528 "max_number_of_lossy_connections"), 1387 "max_number_of_lossy_connections"),
1529 &value)) { 1388 &value)) {
1530 return value; 1389 return value;
1531 } 1390 }
1532 return 0; 1391 return 0;
1533 } 1392 }
1534 1393
1535 // static
1536 float IOThread::GetQuicPacketLossThreshold( 1394 float IOThread::GetQuicPacketLossThreshold(
1537 const VariationParameters& quic_trial_params) { 1395 const VariationParameters& quic_trial_params) {
1538 double value; 1396 double value;
1539 if (base::StringToDouble(GetVariationParam(quic_trial_params, 1397 if (base::StringToDouble(GetVariationParam(quic_trial_params,
1540 "packet_loss_threshold"), 1398 "packet_loss_threshold"),
1541 &value)) { 1399 &value)) {
1542 return static_cast<float>(value); 1400 return static_cast<float>(value);
1543 } 1401 }
1544 return 0.0f; 1402 return 0.0f;
1545 } 1403 }
1546 1404
1547 // static
1548 int IOThread::GetQuicSocketReceiveBufferSize( 1405 int IOThread::GetQuicSocketReceiveBufferSize(
1549 const VariationParameters& quic_trial_params) { 1406 const VariationParameters& quic_trial_params) {
1550 int value; 1407 int value;
1551 if (base::StringToInt(GetVariationParam(quic_trial_params, 1408 if (base::StringToInt(GetVariationParam(quic_trial_params,
1552 "receive_buffer_size"), 1409 "receive_buffer_size"),
1553 &value)) { 1410 &value)) {
1554 return value; 1411 return value;
1555 } 1412 }
1556 return 0; 1413 return 0;
1557 } 1414 }
1558 1415
1559 // static
1560 size_t IOThread::GetQuicMaxPacketLength( 1416 size_t IOThread::GetQuicMaxPacketLength(
1561 const base::CommandLine& command_line, 1417 const base::CommandLine& command_line,
1562 const VariationParameters& quic_trial_params) { 1418 const VariationParameters& quic_trial_params) {
1563 if (command_line.HasSwitch(switches::kQuicMaxPacketLength)) { 1419 if (command_line.HasSwitch(switches::kQuicMaxPacketLength)) {
1564 unsigned value; 1420 unsigned value;
1565 if (!base::StringToUint( 1421 if (!base::StringToUint(
1566 command_line.GetSwitchValueASCII(switches::kQuicMaxPacketLength), 1422 command_line.GetSwitchValueASCII(switches::kQuicMaxPacketLength),
1567 &value)) { 1423 &value)) {
1568 return 0; 1424 return 0;
1569 } 1425 }
1570 return value; 1426 return value;
1571 } 1427 }
1572 1428
1573 unsigned value; 1429 unsigned value;
1574 if (base::StringToUint(GetVariationParam(quic_trial_params, 1430 if (base::StringToUint(GetVariationParam(quic_trial_params,
1575 "max_packet_length"), 1431 "max_packet_length"),
1576 &value)) { 1432 &value)) {
1577 return value; 1433 return value;
1578 } 1434 }
1579 return 0; 1435 return 0;
1580 } 1436 }
1581 1437
1582 // static
1583 net::QuicVersion IOThread::GetQuicVersion( 1438 net::QuicVersion IOThread::GetQuicVersion(
1584 const base::CommandLine& command_line, 1439 const base::CommandLine& command_line,
1585 const VariationParameters& quic_trial_params) { 1440 const VariationParameters& quic_trial_params) {
1586 if (command_line.HasSwitch(switches::kQuicVersion)) { 1441 if (command_line.HasSwitch(switches::kQuicVersion)) {
1587 return ParseQuicVersion( 1442 return ParseQuicVersion(
1588 command_line.GetSwitchValueASCII(switches::kQuicVersion)); 1443 command_line.GetSwitchValueASCII(switches::kQuicVersion));
1589 } 1444 }
1590 1445
1591 return ParseQuicVersion(GetVariationParam(quic_trial_params, "quic_version")); 1446 return ParseQuicVersion(GetVariationParam(quic_trial_params, "quic_version"));
1592 } 1447 }
1593 1448
1594 // static
1595 net::QuicVersion IOThread::ParseQuicVersion(const std::string& quic_version) { 1449 net::QuicVersion IOThread::ParseQuicVersion(const std::string& quic_version) {
1596 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); 1450 net::QuicVersionVector supported_versions = net::QuicSupportedVersions();
1597 for (size_t i = 0; i < supported_versions.size(); ++i) { 1451 for (size_t i = 0; i < supported_versions.size(); ++i) {
1598 net::QuicVersion version = supported_versions[i]; 1452 net::QuicVersion version = supported_versions[i];
1599 if (net::QuicVersionToString(version) == quic_version) { 1453 if (net::QuicVersionToString(version) == quic_version) {
1600 return version; 1454 return version;
1601 } 1455 }
1602 } 1456 }
1603 1457
1604 return net::QUIC_VERSION_UNSUPPORTED; 1458 return net::QUIC_VERSION_UNSUPPORTED;
1605 } 1459 }
1460
1461 net::URLRequestContext* IOThread::ConstructSystemRequestContext(
1462 IOThread::Globals* globals,
1463 net::NetLog* net_log) {
1464 net::URLRequestContext* context = new SystemURLRequestContext;
1465 context->set_net_log(net_log);
1466 context->set_host_resolver(globals->host_resolver.get());
1467 context->set_cert_verifier(globals->cert_verifier.get());
1468 context->set_transport_security_state(
1469 globals->transport_security_state.get());
1470 context->set_cert_transparency_verifier(
1471 globals->cert_transparency_verifier.get());
1472 context->set_ssl_config_service(globals->ssl_config_service.get());
1473 context->set_http_auth_handler_factory(
1474 globals->http_auth_handler_factory.get());
1475 context->set_proxy_service(globals->system_proxy_service.get());
1476
1477 globals->system_url_request_job_factory.reset(
1478 new net::URLRequestJobFactoryImpl());
1479 context->set_job_factory(globals->system_url_request_job_factory.get());
1480
1481 context->set_cookie_store(globals->system_cookie_store.get());
1482 context->set_channel_id_service(
1483 globals->system_channel_id_service.get());
1484 context->set_network_delegate(globals->system_network_delegate.get());
1485 context->set_http_user_agent_settings(
1486 globals->http_user_agent_settings.get());
1487 context->set_network_quality_estimator(
1488 globals->network_quality_estimator.get());
1489 context->set_backoff_manager(globals->url_request_backoff_manager.get());
1490
1491 context->set_http_server_properties(
1492 globals->http_server_properties->GetWeakPtr());
1493
1494 net::HttpNetworkSession::Params system_params;
1495 InitializeNetworkSessionParamsFromGlobals(*globals, &system_params);
1496 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents(
1497 context, &system_params);
1498
1499 globals->system_http_transaction_factory.reset(
1500 new net::HttpNetworkLayer(new net::HttpNetworkSession(system_params)));
1501 context->set_http_transaction_factory(
1502 globals->system_http_transaction_factory.get());
1503
1504 return context;
1505 }
1506
1507 net::URLRequestContext* IOThread::ConstructProxyScriptFetcherContext(
1508 IOThread::Globals* globals,
1509 net::NetLog* net_log) {
1510 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432
1511 // is fixed.
1512 tracked_objects::ScopedTracker tracking_profile1(
1513 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1514 "466432 IOThread::ConstructProxyScriptFetcherContext1"));
1515 net::URLRequestContext* context = new net::URLRequestContext;
1516 context->set_net_log(net_log);
1517 context->set_host_resolver(globals->host_resolver.get());
1518 context->set_cert_verifier(globals->cert_verifier.get());
1519 context->set_transport_security_state(
1520 globals->transport_security_state.get());
1521 context->set_cert_transparency_verifier(
1522 globals->cert_transparency_verifier.get());
1523 context->set_ssl_config_service(globals->ssl_config_service.get());
1524 context->set_http_auth_handler_factory(
1525 globals->http_auth_handler_factory.get());
1526 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get());
1527
1528 context->set_job_factory(
1529 globals->proxy_script_fetcher_url_request_job_factory.get());
1530
1531 context->set_cookie_store(globals->system_cookie_store.get());
1532 context->set_channel_id_service(
1533 globals->system_channel_id_service.get());
1534 context->set_network_delegate(globals->system_network_delegate.get());
1535 context->set_http_user_agent_settings(
1536 globals->http_user_agent_settings.get());
1537 context->set_http_server_properties(
1538 globals->http_server_properties->GetWeakPtr());
1539
1540 net::HttpNetworkSession::Params session_params;
1541 InitializeNetworkSessionParamsFromGlobals(*globals, &session_params);
1542 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents(
1543 context, &session_params);
1544
1545 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432
1546 // is fixed.
1547 tracked_objects::ScopedTracker tracking_profile2(
1548 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1549 "466432 IOThread::ConstructProxyScriptFetcherContext2"));
1550 scoped_refptr<net::HttpNetworkSession> network_session(
1551 new net::HttpNetworkSession(session_params));
1552 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432
1553 // is fixed.
1554 tracked_objects::ScopedTracker tracking_profile3(
1555 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1556 "466432 IOThread::ConstructProxyScriptFetcherContext3"));
1557 globals->proxy_script_fetcher_http_transaction_factory
1558 .reset(new net::HttpNetworkLayer(network_session.get()));
1559 context->set_http_transaction_factory(
1560 globals->proxy_script_fetcher_http_transaction_factory.get());
1561
1562 scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(
1563 new net::URLRequestJobFactoryImpl());
1564
1565 job_factory->SetProtocolHandler(
1566 url::kDataScheme, make_scoped_ptr(new net::DataProtocolHandler()));
1567 job_factory->SetProtocolHandler(
1568 url::kFileScheme,
1569 make_scoped_ptr(new net::FileProtocolHandler(
1570 content::BrowserThread::GetBlockingPool()
1571 ->GetTaskRunnerWithShutdownBehavior(
1572 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))));
1573 #if !defined(DISABLE_FTP_SUPPORT)
1574 globals->proxy_script_fetcher_ftp_transaction_factory.reset(
1575 new net::FtpNetworkLayer(globals->host_resolver.get()));
1576 job_factory->SetProtocolHandler(
1577 url::kFtpScheme,
1578 make_scoped_ptr(new net::FtpProtocolHandler(
1579 globals->proxy_script_fetcher_ftp_transaction_factory.get())));
1580 #endif
1581 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass();
1582
1583 context->set_job_factory(
1584 globals->proxy_script_fetcher_url_request_job_factory.get());
1585
1586 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the
1587 // system URLRequestContext too. There's no reason this should be tied to a
1588 // profile.
1589 return context;
1590 }
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/profiles/profile_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698