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 17 matching lines...) Expand all Loading... | |
| 28 #include "base/time/time.h" | 28 #include "base/time/time.h" |
| 29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 30 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
| 31 #include "chrome/browser/net/async_dns_field_trial.h" | 31 #include "chrome/browser/net/async_dns_field_trial.h" |
| 32 #include "chrome/browser/net/chrome_net_log.h" | 32 #include "chrome/browser/net/chrome_net_log.h" |
| 33 #include "chrome/browser/net/chrome_network_delegate.h" | 33 #include "chrome/browser/net/chrome_network_delegate.h" |
| 34 #include "chrome/browser/net/connect_interceptor.h" | 34 #include "chrome/browser/net/connect_interceptor.h" |
| 35 #include "chrome/browser/net/dns_probe_service.h" | 35 #include "chrome/browser/net/dns_probe_service.h" |
| 36 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 36 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
| 37 #include "chrome/browser/net/proxy_service_factory.h" | 37 #include "chrome/browser/net/proxy_service_factory.h" |
| 38 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 38 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h" |
| 39 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h" | |
| 40 #include "chrome/common/chrome_content_client.h" | 39 #include "chrome/common/chrome_content_client.h" |
| 41 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
| 42 #include "chrome/common/chrome_version_info.h" | 41 #include "chrome/common/chrome_version_info.h" |
| 43 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
| 44 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth _request_handler.h" | |
| 45 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_dele gate.h" | 43 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_dele gate.h" |
| 46 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h" | 44 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" |
| 47 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" | 45 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" |
| 48 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prot ocol.h" | |
| 49 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" | |
| 50 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" | |
| 51 #include "components/policy/core/common/policy_service.h" | 46 #include "components/policy/core/common/policy_service.h" |
| 52 #include "components/variations/variations_associated_data.h" | 47 #include "components/variations/variations_associated_data.h" |
| 53 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
| 54 #include "content/public/browser/cookie_store_factory.h" | 49 #include "content/public/browser/cookie_store_factory.h" |
| 55 #include "net/base/host_mapping_rules.h" | 50 #include "net/base/host_mapping_rules.h" |
| 56 #include "net/base/net_util.h" | 51 #include "net/base/net_util.h" |
| 57 #include "net/cert/cert_policy_enforcer.h" | 52 #include "net/cert/cert_policy_enforcer.h" |
| 58 #include "net/cert/cert_verifier.h" | 53 #include "net/cert/cert_verifier.h" |
| 59 #include "net/cert/cert_verify_proc.h" | 54 #include "net/cert/cert_verify_proc.h" |
| 60 #include "net/cert/ct_known_logs.h" | 55 #include "net/cert/ct_known_logs.h" |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 &system_enable_referrers_)); | 585 &system_enable_referrers_)); |
| 591 | 586 |
| 592 if (command_line.HasSwitch(switches::kEnableClientHints)) | 587 if (command_line.HasSwitch(switches::kEnableClientHints)) |
| 593 chrome_network_delegate->SetEnableClientHints(); | 588 chrome_network_delegate->SetEnableClientHints(); |
| 594 | 589 |
| 595 #if defined(ENABLE_EXTENSIONS) | 590 #if defined(ENABLE_EXTENSIONS) |
| 596 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) | 591 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) |
| 597 chrome_network_delegate->NeverThrottleRequests(); | 592 chrome_network_delegate->NeverThrottleRequests(); |
| 598 #endif | 593 #endif |
| 599 | 594 |
| 600 SetupDataReductionProxy(); | 595 globals_->data_reduction_proxy_io_data = |
| 596 CreateDataReductionProxyChromeIODataForSystem( | |
| 597 net_log_, | |
| 598 nullptr, /* PrefServiceSyncable */ | |
| 599 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | |
| 600 BrowserThread::GetMessageLoopProxyForThread( | |
| 601 BrowserThread::UI)).Pass(); | |
| 601 | 602 |
| 602 // This is the same as in ProfileImplIOData except that it does not collect | 603 globals_->system_network_delegate = |
| 603 // usage stats. | 604 globals_->data_reduction_proxy_io_data->CreateNetworkDelegate( |
| 604 data_reduction_proxy::DataReductionProxyNetworkDelegate* network_delegate = | 605 chrome_network_delegate.Pass(), false, false).Pass(); |
| 605 new data_reduction_proxy::DataReductionProxyNetworkDelegate( | 606 globals_->data_reduction_proxy_io_data->CreateProxyDelegate(); |
| 606 chrome_network_delegate.Pass(), | |
| 607 globals_->data_reduction_proxy_params.get(), | |
| 608 globals_->data_reduction_proxy_auth_request_handler.get(), | |
| 609 data_reduction_proxy::DataReductionProxyNetworkDelegate:: | |
| 610 ProxyConfigGetter()); | |
| 611 | |
| 612 globals_->system_network_delegate.reset(network_delegate); | |
| 613 globals_->host_resolver = CreateGlobalHostResolver(net_log_); | 607 globals_->host_resolver = CreateGlobalHostResolver(net_log_); |
| 614 UpdateDnsClientEnabled(); | 608 UpdateDnsClientEnabled(); |
| 615 #if defined(OS_CHROMEOS) | 609 #if defined(OS_CHROMEOS) |
| 616 // Creates a CertVerifyProc that doesn't allow any profile-provided certs. | 610 // Creates a CertVerifyProc that doesn't allow any profile-provided certs. |
| 617 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( | 611 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( |
| 618 new chromeos::CertVerifyProcChromeOS())); | 612 new chromeos::CertVerifyProcChromeOS())); |
| 619 #else | 613 #else |
| 620 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( | 614 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( |
| 621 net::CertVerifyProc::CreateDefault())); | 615 net::CertVerifyProc::CreateDefault())); |
| 622 #endif | 616 #endif |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1058 globals.quic_max_packet_length.CopyToIfSet(¶ms->quic_max_packet_length); | 1052 globals.quic_max_packet_length.CopyToIfSet(¶ms->quic_max_packet_length); |
| 1059 globals.quic_user_agent_id.CopyToIfSet(¶ms->quic_user_agent_id); | 1053 globals.quic_user_agent_id.CopyToIfSet(¶ms->quic_user_agent_id); |
| 1060 globals.quic_supported_versions.CopyToIfSet( | 1054 globals.quic_supported_versions.CopyToIfSet( |
| 1061 ¶ms->quic_supported_versions); | 1055 ¶ms->quic_supported_versions); |
| 1062 params->quic_connection_options = globals.quic_connection_options; | 1056 params->quic_connection_options = globals.quic_connection_options; |
| 1063 | 1057 |
| 1064 globals.origin_to_force_quic_on.CopyToIfSet( | 1058 globals.origin_to_force_quic_on.CopyToIfSet( |
| 1065 ¶ms->origin_to_force_quic_on); | 1059 ¶ms->origin_to_force_quic_on); |
| 1066 params->enable_user_alternate_protocol_ports = | 1060 params->enable_user_alternate_protocol_ports = |
| 1067 globals.enable_user_alternate_protocol_ports; | 1061 globals.enable_user_alternate_protocol_ports; |
| 1068 params->proxy_delegate = globals.data_reduction_proxy_delegate.get(); | 1062 params->proxy_delegate = |
| 1063 globals.data_reduction_proxy_io_data->proxy_delegate(); | |
|
mmenke
2015/01/09 21:09:50
This seems like a bad idea. DataReductionProxyIOD
bengr
2015/01/14 21:39:54
Done.
| |
| 1069 } | 1064 } |
| 1070 | 1065 |
| 1071 base::TimeTicks IOThread::creation_time() const { | 1066 base::TimeTicks IOThread::creation_time() const { |
| 1072 return creation_time_; | 1067 return creation_time_; |
| 1073 } | 1068 } |
| 1074 | 1069 |
| 1075 net::SSLConfigService* IOThread::GetSSLConfigService() { | 1070 net::SSLConfigService* IOThread::GetSSLConfigService() { |
| 1076 return ssl_config_service_manager_->Get(); | 1071 return ssl_config_service_manager_->Get(); |
| 1077 } | 1072 } |
| 1078 | 1073 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 | 1106 |
| 1112 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1107 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 1113 globals_->system_proxy_service.reset( | 1108 globals_->system_proxy_service.reset( |
| 1114 ProxyServiceFactory::CreateProxyService( | 1109 ProxyServiceFactory::CreateProxyService( |
| 1115 net_log_, | 1110 net_log_, |
| 1116 globals_->proxy_script_fetcher_context.get(), | 1111 globals_->proxy_script_fetcher_context.get(), |
| 1117 globals_->system_network_delegate.get(), | 1112 globals_->system_network_delegate.get(), |
| 1118 system_proxy_config_service_.release(), | 1113 system_proxy_config_service_.release(), |
| 1119 command_line, | 1114 command_line, |
| 1120 quick_check_enabled_.GetValue())); | 1115 quick_check_enabled_.GetValue())); |
| 1121 DCHECK(globals_->data_reduction_proxy_params); | 1116 DCHECK(globals_->data_reduction_proxy_io_data); |
| 1122 | 1117 |
| 1123 net::HttpNetworkSession::Params system_params; | 1118 net::HttpNetworkSession::Params system_params; |
| 1124 InitializeNetworkSessionParams(&system_params); | 1119 InitializeNetworkSessionParams(&system_params); |
| 1125 system_params.net_log = net_log_; | 1120 system_params.net_log = net_log_; |
| 1126 system_params.proxy_service = globals_->system_proxy_service.get(); | 1121 system_params.proxy_service = globals_->system_proxy_service.get(); |
| 1127 | 1122 |
| 1128 globals_->system_http_transaction_factory.reset( | 1123 globals_->system_http_transaction_factory.reset( |
| 1129 new net::HttpNetworkLayer( | 1124 new net::HttpNetworkLayer( |
| 1130 new net::HttpNetworkSession(system_params))); | 1125 new net::HttpNetworkSession(system_params))); |
| 1131 globals_->system_url_request_job_factory.reset( | 1126 globals_->system_url_request_job_factory.reset( |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1149 std::string group = | 1144 std::string group = |
| 1150 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 1145 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
| 1151 VariationParameters params; | 1146 VariationParameters params; |
| 1152 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | 1147 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { |
| 1153 params.clear(); | 1148 params.clear(); |
| 1154 } | 1149 } |
| 1155 | 1150 |
| 1156 ConfigureQuicGlobals(command_line, group, params, globals_); | 1151 ConfigureQuicGlobals(command_line, group, params, globals_); |
| 1157 } | 1152 } |
| 1158 | 1153 |
| 1159 void IOThread::SetupDataReductionProxy() { | |
| 1160 // TODO(kundaji): Move flags initialization to DataReductionProxyParams and | |
| 1161 // merge with flag initialization in | |
| 1162 // data_reduction_proxy_chrome_settings_factory.cc. | |
| 1163 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed | | |
| 1164 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | | |
| 1165 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; | |
| 1166 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 1167 IsIncludedInPromoFieldTrial()) { | |
| 1168 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; | |
| 1169 } | |
| 1170 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 1171 IsIncludedInHoldbackFieldTrial()) { | |
| 1172 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; | |
| 1173 } | |
| 1174 globals_->data_reduction_proxy_params.reset( | |
| 1175 new data_reduction_proxy::DataReductionProxyParams(flags)); | |
| 1176 globals_->data_reduction_proxy_auth_request_handler.reset( | |
| 1177 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | |
| 1178 DataReductionProxyChromeSettings::GetClient(), | |
| 1179 globals_->data_reduction_proxy_params.get(), | |
| 1180 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | |
| 1181 globals_->data_reduction_proxy_delegate.reset( | |
| 1182 new data_reduction_proxy::DataReductionProxyDelegate( | |
| 1183 globals_->data_reduction_proxy_auth_request_handler.get(), | |
| 1184 globals_->data_reduction_proxy_params.get())); | |
| 1185 } | |
| 1186 | |
| 1187 // static | 1154 // static |
| 1188 void IOThread::ConfigureQuicGlobals( | 1155 void IOThread::ConfigureQuicGlobals( |
| 1189 const base::CommandLine& command_line, | 1156 const base::CommandLine& command_line, |
| 1190 base::StringPiece quic_trial_group, | 1157 base::StringPiece quic_trial_group, |
| 1191 const VariationParameters& quic_trial_params, | 1158 const VariationParameters& quic_trial_params, |
| 1192 IOThread::Globals* globals) { | 1159 IOThread::Globals* globals) { |
| 1193 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); | 1160 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); |
| 1194 globals->enable_quic.set(enable_quic); | 1161 globals->enable_quic.set(enable_quic); |
| 1195 if (enable_quic) { | 1162 if (enable_quic) { |
| 1196 globals->quic_always_require_handshake_confirmation.set( | 1163 globals->quic_always_require_handshake_confirmation.set( |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1407 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1374 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1408 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1375 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1409 net::QuicVersion version = supported_versions[i]; | 1376 net::QuicVersion version = supported_versions[i]; |
| 1410 if (net::QuicVersionToString(version) == quic_version) { | 1377 if (net::QuicVersionToString(version) == quic_version) { |
| 1411 return version; | 1378 return version; |
| 1412 } | 1379 } |
| 1413 } | 1380 } |
| 1414 | 1381 |
| 1415 return net::QUIC_VERSION_UNSUPPORTED; | 1382 return net::QUIC_VERSION_UNSUPPORTED; |
| 1416 } | 1383 } |
| OLD | NEW |