| 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" | |
| 39 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | |
| 40 #include "chrome/common/chrome_content_client.h" | 38 #include "chrome/common/chrome_content_client.h" |
| 41 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
| 42 #include "chrome/common/chrome_version_info.h" | 40 #include "chrome/common/chrome_version_info.h" |
| 43 #include "chrome/common/pref_names.h" | 41 #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" | |
| 46 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" | |
| 47 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" | 42 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" |
| 48 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | |
| 49 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | |
| 50 #include "components/policy/core/common/policy_service.h" | 43 #include "components/policy/core/common/policy_service.h" |
| 51 #include "components/variations/variations_associated_data.h" | 44 #include "components/variations/variations_associated_data.h" |
| 52 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
| 53 #include "content/public/browser/cookie_store_factory.h" | 46 #include "content/public/browser/cookie_store_factory.h" |
| 54 #include "net/base/host_mapping_rules.h" | 47 #include "net/base/host_mapping_rules.h" |
| 55 #include "net/base/net_util.h" | 48 #include "net/base/net_util.h" |
| 56 #include "net/cert/cert_policy_enforcer.h" | 49 #include "net/cert/cert_policy_enforcer.h" |
| 57 #include "net/cert/cert_verifier.h" | 50 #include "net/cert/cert_verifier.h" |
| 58 #include "net/cert/cert_verify_proc.h" | 51 #include "net/cert/cert_verify_proc.h" |
| 59 #include "net/cert/ct_known_logs.h" | 52 #include "net/cert/ct_known_logs.h" |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 &system_enable_referrers_)); | 587 &system_enable_referrers_)); |
| 595 | 588 |
| 596 if (command_line.HasSwitch(switches::kEnableClientHints)) | 589 if (command_line.HasSwitch(switches::kEnableClientHints)) |
| 597 chrome_network_delegate->SetEnableClientHints(); | 590 chrome_network_delegate->SetEnableClientHints(); |
| 598 | 591 |
| 599 #if defined(ENABLE_EXTENSIONS) | 592 #if defined(ENABLE_EXTENSIONS) |
| 600 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) | 593 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) |
| 601 chrome_network_delegate->NeverThrottleRequests(); | 594 chrome_network_delegate->NeverThrottleRequests(); |
| 602 #endif | 595 #endif |
| 603 | 596 |
| 604 SetupDataReductionProxy(); | 597 globals_->system_network_delegate = chrome_network_delegate.Pass(); |
| 605 | |
| 606 // This is the same as in ProfileImplIOData except that it does not collect | |
| 607 // usage stats. | |
| 608 data_reduction_proxy::DataReductionProxyNetworkDelegate* network_delegate = | |
| 609 new data_reduction_proxy::DataReductionProxyNetworkDelegate( | |
| 610 chrome_network_delegate.Pass(), | |
| 611 globals_->data_reduction_proxy_params.get(), | |
| 612 globals_->data_reduction_proxy_auth_request_handler.get(), | |
| 613 data_reduction_proxy::DataReductionProxyNetworkDelegate:: | |
| 614 ProxyConfigGetter()); | |
| 615 | |
| 616 globals_->system_network_delegate.reset(network_delegate); | |
| 617 globals_->host_resolver = CreateGlobalHostResolver(net_log_); | 598 globals_->host_resolver = CreateGlobalHostResolver(net_log_); |
| 618 UpdateDnsClientEnabled(); | 599 UpdateDnsClientEnabled(); |
| 619 #if defined(OS_CHROMEOS) | 600 #if defined(OS_CHROMEOS) |
| 620 // Creates a CertVerifyProc that doesn't allow any profile-provided certs. | 601 // Creates a CertVerifyProc that doesn't allow any profile-provided certs. |
| 621 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( | 602 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( |
| 622 new chromeos::CertVerifyProcChromeOS())); | 603 new chromeos::CertVerifyProcChromeOS())); |
| 623 #else | 604 #else |
| 624 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( | 605 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( |
| 625 net::CertVerifyProc::CreateDefault())); | 606 net::CertVerifyProc::CreateDefault())); |
| 626 #endif | 607 #endif |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 globals.quic_max_packet_length.CopyToIfSet(¶ms->quic_max_packet_length); | 1045 globals.quic_max_packet_length.CopyToIfSet(¶ms->quic_max_packet_length); |
| 1065 globals.quic_user_agent_id.CopyToIfSet(¶ms->quic_user_agent_id); | 1046 globals.quic_user_agent_id.CopyToIfSet(¶ms->quic_user_agent_id); |
| 1066 globals.quic_supported_versions.CopyToIfSet( | 1047 globals.quic_supported_versions.CopyToIfSet( |
| 1067 ¶ms->quic_supported_versions); | 1048 ¶ms->quic_supported_versions); |
| 1068 params->quic_connection_options = globals.quic_connection_options; | 1049 params->quic_connection_options = globals.quic_connection_options; |
| 1069 | 1050 |
| 1070 globals.origin_to_force_quic_on.CopyToIfSet( | 1051 globals.origin_to_force_quic_on.CopyToIfSet( |
| 1071 ¶ms->origin_to_force_quic_on); | 1052 ¶ms->origin_to_force_quic_on); |
| 1072 params->enable_user_alternate_protocol_ports = | 1053 params->enable_user_alternate_protocol_ports = |
| 1073 globals.enable_user_alternate_protocol_ports; | 1054 globals.enable_user_alternate_protocol_ports; |
| 1074 params->proxy_delegate = globals.data_reduction_proxy_delegate.get(); | |
| 1075 } | 1055 } |
| 1076 | 1056 |
| 1077 base::TimeTicks IOThread::creation_time() const { | 1057 base::TimeTicks IOThread::creation_time() const { |
| 1078 return creation_time_; | 1058 return creation_time_; |
| 1079 } | 1059 } |
| 1080 | 1060 |
| 1081 net::SSLConfigService* IOThread::GetSSLConfigService() { | 1061 net::SSLConfigService* IOThread::GetSSLConfigService() { |
| 1082 return ssl_config_service_manager_->Get(); | 1062 return ssl_config_service_manager_->Get(); |
| 1083 } | 1063 } |
| 1084 | 1064 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 const base::CommandLine& command_line = | 1098 const base::CommandLine& command_line = |
| 1119 *base::CommandLine::ForCurrentProcess(); | 1099 *base::CommandLine::ForCurrentProcess(); |
| 1120 globals_->system_proxy_service.reset( | 1100 globals_->system_proxy_service.reset( |
| 1121 ProxyServiceFactory::CreateProxyService( | 1101 ProxyServiceFactory::CreateProxyService( |
| 1122 net_log_, | 1102 net_log_, |
| 1123 globals_->proxy_script_fetcher_context.get(), | 1103 globals_->proxy_script_fetcher_context.get(), |
| 1124 globals_->system_network_delegate.get(), | 1104 globals_->system_network_delegate.get(), |
| 1125 system_proxy_config_service_.release(), | 1105 system_proxy_config_service_.release(), |
| 1126 command_line, | 1106 command_line, |
| 1127 quick_check_enabled_.GetValue())); | 1107 quick_check_enabled_.GetValue())); |
| 1128 DCHECK(globals_->data_reduction_proxy_params); | |
| 1129 | 1108 |
| 1130 net::HttpNetworkSession::Params system_params; | 1109 net::HttpNetworkSession::Params system_params; |
| 1131 InitializeNetworkSessionParams(&system_params); | 1110 InitializeNetworkSessionParams(&system_params); |
| 1132 system_params.net_log = net_log_; | 1111 system_params.net_log = net_log_; |
| 1133 system_params.proxy_service = globals_->system_proxy_service.get(); | 1112 system_params.proxy_service = globals_->system_proxy_service.get(); |
| 1134 | 1113 |
| 1135 globals_->system_http_transaction_factory.reset( | 1114 globals_->system_http_transaction_factory.reset( |
| 1136 new net::HttpNetworkLayer( | 1115 new net::HttpNetworkLayer( |
| 1137 new net::HttpNetworkSession(system_params))); | 1116 new net::HttpNetworkSession(system_params))); |
| 1138 globals_->system_url_request_job_factory.reset( | 1117 globals_->system_url_request_job_factory.reset( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1156 std::string group = | 1135 std::string group = |
| 1157 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 1136 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
| 1158 VariationParameters params; | 1137 VariationParameters params; |
| 1159 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | 1138 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { |
| 1160 params.clear(); | 1139 params.clear(); |
| 1161 } | 1140 } |
| 1162 | 1141 |
| 1163 ConfigureQuicGlobals(command_line, group, params, globals_); | 1142 ConfigureQuicGlobals(command_line, group, params, globals_); |
| 1164 } | 1143 } |
| 1165 | 1144 |
| 1166 void IOThread::SetupDataReductionProxy() { | |
| 1167 // TODO(kundaji): Move flags initialization to DataReductionProxyParams and | |
| 1168 // merge with flag initialization in | |
| 1169 // data_reduction_proxy_chrome_settings_factory.cc. | |
| 1170 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed | | |
| 1171 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | | |
| 1172 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; | |
| 1173 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 1174 IsIncludedInPromoFieldTrial()) { | |
| 1175 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; | |
| 1176 } | |
| 1177 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 1178 IsIncludedInHoldbackFieldTrial()) { | |
| 1179 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; | |
| 1180 } | |
| 1181 #if defined(OS_ANDROID) | |
| 1182 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 1183 IsIncludedInAndroidOnePromoFieldTrial( | |
| 1184 base::android::BuildInfo::GetInstance()->android_build_fp())) { | |
| 1185 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; | |
| 1186 } | |
| 1187 #endif | |
| 1188 globals_->data_reduction_proxy_params.reset( | |
| 1189 new data_reduction_proxy::DataReductionProxyParams(flags)); | |
| 1190 globals_->data_reduction_proxy_auth_request_handler.reset( | |
| 1191 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | |
| 1192 DataReductionProxyChromeSettings::GetClient(), | |
| 1193 globals_->data_reduction_proxy_params.get(), | |
| 1194 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | |
| 1195 globals_->data_reduction_proxy_delegate.reset( | |
| 1196 new data_reduction_proxy::DataReductionProxyDelegate( | |
| 1197 globals_->data_reduction_proxy_auth_request_handler.get(), | |
| 1198 globals_->data_reduction_proxy_params.get())); | |
| 1199 } | |
| 1200 | |
| 1201 // static | 1145 // static |
| 1202 void IOThread::ConfigureQuicGlobals( | 1146 void IOThread::ConfigureQuicGlobals( |
| 1203 const base::CommandLine& command_line, | 1147 const base::CommandLine& command_line, |
| 1204 base::StringPiece quic_trial_group, | 1148 base::StringPiece quic_trial_group, |
| 1205 const VariationParameters& quic_trial_params, | 1149 const VariationParameters& quic_trial_params, |
| 1206 IOThread::Globals* globals) { | 1150 IOThread::Globals* globals) { |
| 1207 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); | 1151 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); |
| 1208 globals->enable_quic.set(enable_quic); | 1152 globals->enable_quic.set(enable_quic); |
| 1209 if (enable_quic) { | 1153 if (enable_quic) { |
| 1210 globals->quic_always_require_handshake_confirmation.set( | 1154 globals->quic_always_require_handshake_confirmation.set( |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1453 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1397 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1454 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1398 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1455 net::QuicVersion version = supported_versions[i]; | 1399 net::QuicVersion version = supported_versions[i]; |
| 1456 if (net::QuicVersionToString(version) == quic_version) { | 1400 if (net::QuicVersionToString(version) == quic_version) { |
| 1457 return version; | 1401 return version; |
| 1458 } | 1402 } |
| 1459 } | 1403 } |
| 1460 | 1404 |
| 1461 return net::QUIC_VERSION_UNSUPPORTED; | 1405 return net::QUIC_VERSION_UNSUPPORTED; |
| 1462 } | 1406 } |
| OLD | NEW |