| 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 "build/build_config.h" | 28 #include "build/build_config.h" |
| 29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
| 30 #include "chrome/browser/net/async_dns_field_trial.h" | 30 #include "chrome/browser/net/async_dns_field_trial.h" |
| 31 #include "chrome/browser/net/chrome_net_log.h" | 31 #include "chrome/browser/net/chrome_net_log.h" |
| 32 #include "chrome/browser/net/chrome_network_delegate.h" | 32 #include "chrome/browser/net/chrome_network_delegate.h" |
| 33 #include "chrome/browser/net/connect_interceptor.h" | 33 #include "chrome/browser/net/connect_interceptor.h" |
| 34 #include "chrome/browser/net/dns_probe_service.h" | 34 #include "chrome/browser/net/dns_probe_service.h" |
| 35 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 35 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
| 36 #include "chrome/browser/net/proxy_service_factory.h" | 36 #include "chrome/browser/net/proxy_service_factory.h" |
| 37 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 37 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| 38 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" |
| 38 #include "chrome/common/chrome_content_client.h" | 39 #include "chrome/common/chrome_content_client.h" |
| 39 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
| 40 #include "chrome/common/chrome_version_info.h" | 41 #include "chrome/common/chrome_version_info.h" |
| 41 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
| 43 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" |
| 44 #include "components/data_reduction_proxy/browser/data_reduction_proxy_delegate.
h" |
| 45 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
| 42 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" | 46 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" |
| 47 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" |
| 48 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
| 43 #include "components/policy/core/common/policy_service.h" | 49 #include "components/policy/core/common/policy_service.h" |
| 44 #include "components/variations/variations_associated_data.h" | 50 #include "components/variations/variations_associated_data.h" |
| 45 #include "content/public/browser/browser_thread.h" | 51 #include "content/public/browser/browser_thread.h" |
| 46 #include "content/public/browser/cookie_store_factory.h" | 52 #include "content/public/browser/cookie_store_factory.h" |
| 47 #include "net/base/host_mapping_rules.h" | 53 #include "net/base/host_mapping_rules.h" |
| 48 #include "net/base/net_util.h" | 54 #include "net/base/net_util.h" |
| 49 #include "net/cert/cert_verifier.h" | 55 #include "net/cert/cert_verifier.h" |
| 50 #include "net/cert/cert_verify_proc.h" | 56 #include "net/cert/cert_verify_proc.h" |
| 51 #include "net/cert/ct_known_logs.h" | 57 #include "net/cert/ct_known_logs.h" |
| 52 #include "net/cert/ct_log_verifier.h" | 58 #include "net/cert/ct_log_verifier.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #endif | 93 #endif |
| 88 | 94 |
| 89 #if defined(ENABLE_EXTENSIONS) | 95 #if defined(ENABLE_EXTENSIONS) |
| 90 #include "chrome/browser/extensions/event_router_forwarder.h" | 96 #include "chrome/browser/extensions/event_router_forwarder.h" |
| 91 #endif | 97 #endif |
| 92 | 98 |
| 93 #if defined(USE_NSS) || defined(OS_IOS) | 99 #if defined(USE_NSS) || defined(OS_IOS) |
| 94 #include "net/ocsp/nss_ocsp.h" | 100 #include "net/ocsp/nss_ocsp.h" |
| 95 #endif | 101 #endif |
| 96 | 102 |
| 97 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 98 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | |
| 99 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | |
| 100 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" | |
| 101 #include "components/data_reduction_proxy/browser/data_reduction_proxy_delegate.
h" | |
| 102 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol.
h" | |
| 103 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 104 | |
| 105 #if defined(OS_CHROMEOS) | 103 #if defined(OS_CHROMEOS) |
| 106 #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h" | 104 #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h" |
| 107 #include "chromeos/network/host_resolver_impl_chromeos.h" | 105 #include "chromeos/network/host_resolver_impl_chromeos.h" |
| 108 #endif | 106 #endif |
| 109 | 107 |
| 110 using content::BrowserThread; | 108 using content::BrowserThread; |
| 111 | 109 |
| 112 class SafeBrowsingURLRequestContext; | 110 class SafeBrowsingURLRequestContext; |
| 113 | 111 |
| 114 // The IOThread object must outlive any tasks posted to the IO thread before the | 112 // The IOThread object must outlive any tasks posted to the IO thread before the |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 scoped_ptr<net::CTLogVerifier> external_log_verifier( | 621 scoped_ptr<net::CTLogVerifier> external_log_verifier( |
| 624 net::CTLogVerifier::Create(ct_public_key_data, log_description)); | 622 net::CTLogVerifier::Create(ct_public_key_data, log_description)); |
| 625 CHECK(external_log_verifier) << "Unable to parse CT public key."; | 623 CHECK(external_log_verifier) << "Unable to parse CT public key."; |
| 626 VLOG(1) << "Adding log with description " << log_description; | 624 VLOG(1) << "Adding log with description " << log_description; |
| 627 ct_verifier->AddLog(external_log_verifier.Pass()); | 625 ct_verifier->AddLog(external_log_verifier.Pass()); |
| 628 } | 626 } |
| 629 } | 627 } |
| 630 | 628 |
| 631 globals_->ssl_config_service = GetSSLConfigService(); | 629 globals_->ssl_config_service = GetSSLConfigService(); |
| 632 | 630 |
| 633 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 631 SetupDataReductionProxy(network_delegate); |
| 634 int drp_flags = 0; | |
| 635 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 636 IsIncludedInFieldTrial()) { | |
| 637 drp_flags |= | |
| 638 (data_reduction_proxy::DataReductionProxyParams::kAllowed | | |
| 639 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | | |
| 640 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed); | |
| 641 } | |
| 642 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 643 IsIncludedInPromoFieldTrial()) | |
| 644 drp_flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; | |
| 645 if (data_reduction_proxy::DataReductionProxyParams:: | |
| 646 IsIncludedInHoldbackFieldTrial()) | |
| 647 drp_flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; | |
| 648 globals_->data_reduction_proxy_params.reset( | |
| 649 new data_reduction_proxy::DataReductionProxyParams(drp_flags)); | |
| 650 globals_->data_reduction_proxy_auth_request_handler.reset( | |
| 651 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | |
| 652 DataReductionProxyChromeSettings::GetClient(), | |
| 653 globals_->data_reduction_proxy_params.get(), | |
| 654 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | |
| 655 globals_->data_reduction_proxy_delegate.reset( | |
| 656 new data_reduction_proxy::DataReductionProxyDelegate( | |
| 657 globals_->data_reduction_proxy_auth_request_handler.get())); | |
| 658 // This is the same as in ProfileImplIOData except that we do not collect | |
| 659 // usage stats. | |
| 660 network_delegate->set_data_reduction_proxy_params( | |
| 661 globals_->data_reduction_proxy_params.get()); | |
| 662 network_delegate->set_data_reduction_proxy_auth_request_handler( | |
| 663 globals_->data_reduction_proxy_auth_request_handler.get()); | |
| 664 network_delegate->set_on_resolve_proxy_handler( | |
| 665 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | |
| 666 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 667 | 632 |
| 668 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 633 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( |
| 669 globals_->host_resolver.get())); | 634 globals_->host_resolver.get())); |
| 670 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 635 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
| 671 // For the ProxyScriptFetcher, we use a direct ProxyService. | 636 // For the ProxyScriptFetcher, we use a direct ProxyService. |
| 672 globals_->proxy_script_fetcher_proxy_service.reset( | 637 globals_->proxy_script_fetcher_proxy_service.reset( |
| 673 net::ProxyService::CreateDirectWithNetLog(net_log_)); | 638 net::ProxyService::CreateDirectWithNetLog(net_log_)); |
| 674 // In-memory cookie store. | 639 // In-memory cookie store. |
| 675 globals_->system_cookie_store = | 640 globals_->system_cookie_store = |
| 676 content::CreateCookieStore(content::CookieStoreConfig()); | 641 content::CreateCookieStore(content::CookieStoreConfig()); |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 globals.quic_max_packet_length.CopyToIfSet(¶ms->quic_max_packet_length); | 1026 globals.quic_max_packet_length.CopyToIfSet(¶ms->quic_max_packet_length); |
| 1062 globals.quic_user_agent_id.CopyToIfSet(¶ms->quic_user_agent_id); | 1027 globals.quic_user_agent_id.CopyToIfSet(¶ms->quic_user_agent_id); |
| 1063 globals.quic_supported_versions.CopyToIfSet( | 1028 globals.quic_supported_versions.CopyToIfSet( |
| 1064 ¶ms->quic_supported_versions); | 1029 ¶ms->quic_supported_versions); |
| 1065 params->quic_connection_options = globals.quic_connection_options; | 1030 params->quic_connection_options = globals.quic_connection_options; |
| 1066 | 1031 |
| 1067 globals.origin_to_force_quic_on.CopyToIfSet( | 1032 globals.origin_to_force_quic_on.CopyToIfSet( |
| 1068 ¶ms->origin_to_force_quic_on); | 1033 ¶ms->origin_to_force_quic_on); |
| 1069 params->enable_user_alternate_protocol_ports = | 1034 params->enable_user_alternate_protocol_ports = |
| 1070 globals.enable_user_alternate_protocol_ports; | 1035 globals.enable_user_alternate_protocol_ports; |
| 1071 #if defined(SPDY_PROXY_AUTH_ORIGIN) | |
| 1072 params->proxy_delegate = globals.data_reduction_proxy_delegate.get(); | 1036 params->proxy_delegate = globals.data_reduction_proxy_delegate.get(); |
| 1073 #endif | |
| 1074 } | 1037 } |
| 1075 | 1038 |
| 1076 base::TimeTicks IOThread::creation_time() const { | 1039 base::TimeTicks IOThread::creation_time() const { |
| 1077 return creation_time_; | 1040 return creation_time_; |
| 1078 } | 1041 } |
| 1079 | 1042 |
| 1080 net::SSLConfigService* IOThread::GetSSLConfigService() { | 1043 net::SSLConfigService* IOThread::GetSSLConfigService() { |
| 1081 return ssl_config_service_manager_->Get(); | 1044 return ssl_config_service_manager_->Get(); |
| 1082 } | 1045 } |
| 1083 | 1046 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 | 1079 |
| 1117 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 1080 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 1118 globals_->system_proxy_service.reset( | 1081 globals_->system_proxy_service.reset( |
| 1119 ProxyServiceFactory::CreateProxyService( | 1082 ProxyServiceFactory::CreateProxyService( |
| 1120 net_log_, | 1083 net_log_, |
| 1121 globals_->proxy_script_fetcher_context.get(), | 1084 globals_->proxy_script_fetcher_context.get(), |
| 1122 globals_->system_network_delegate.get(), | 1085 globals_->system_network_delegate.get(), |
| 1123 system_proxy_config_service_.release(), | 1086 system_proxy_config_service_.release(), |
| 1124 command_line, | 1087 command_line, |
| 1125 quick_check_enabled_.GetValue())); | 1088 quick_check_enabled_.GetValue())); |
| 1089 DCHECK(globals_->data_reduction_proxy_params); |
| 1126 | 1090 |
| 1127 net::HttpNetworkSession::Params system_params; | 1091 net::HttpNetworkSession::Params system_params; |
| 1128 InitializeNetworkSessionParams(&system_params); | 1092 InitializeNetworkSessionParams(&system_params); |
| 1129 system_params.net_log = net_log_; | 1093 system_params.net_log = net_log_; |
| 1130 system_params.proxy_service = globals_->system_proxy_service.get(); | 1094 system_params.proxy_service = globals_->system_proxy_service.get(); |
| 1131 | 1095 |
| 1132 globals_->system_http_transaction_factory.reset( | 1096 globals_->system_http_transaction_factory.reset( |
| 1133 new net::HttpNetworkLayer( | 1097 new net::HttpNetworkLayer( |
| 1134 new net::HttpNetworkSession(system_params))); | 1098 new net::HttpNetworkSession(system_params))); |
| 1135 globals_->system_url_request_job_factory.reset( | 1099 globals_->system_url_request_job_factory.reset( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1153 std::string group = | 1117 std::string group = |
| 1154 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 1118 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
| 1155 VariationParameters params; | 1119 VariationParameters params; |
| 1156 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | 1120 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { |
| 1157 params.clear(); | 1121 params.clear(); |
| 1158 } | 1122 } |
| 1159 | 1123 |
| 1160 ConfigureQuicGlobals(command_line, group, params, globals_); | 1124 ConfigureQuicGlobals(command_line, group, params, globals_); |
| 1161 } | 1125 } |
| 1162 | 1126 |
| 1127 void IOThread::SetupDataReductionProxy( |
| 1128 ChromeNetworkDelegate* network_delegate) { |
| 1129 // TODO(kundaji): Move flags initialization to DataReductionProxyParams and |
| 1130 // merge with flag initialization in |
| 1131 // data_reduction_proxy_chrome_settings_factory.cc. |
| 1132 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed | |
| 1133 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | |
| 1134 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; |
| 1135 if (data_reduction_proxy::DataReductionProxyParams:: |
| 1136 IsIncludedInPromoFieldTrial()) { |
| 1137 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; |
| 1138 } |
| 1139 if (data_reduction_proxy::DataReductionProxyParams:: |
| 1140 IsIncludedInHoldbackFieldTrial()) { |
| 1141 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; |
| 1142 } |
| 1143 globals_->data_reduction_proxy_params.reset( |
| 1144 new data_reduction_proxy::DataReductionProxyParams(flags)); |
| 1145 globals_->data_reduction_proxy_auth_request_handler.reset( |
| 1146 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( |
| 1147 DataReductionProxyChromeSettings::GetClient(), |
| 1148 globals_->data_reduction_proxy_params.get(), |
| 1149 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
| 1150 globals_->data_reduction_proxy_delegate.reset( |
| 1151 new data_reduction_proxy::DataReductionProxyDelegate( |
| 1152 globals_->data_reduction_proxy_auth_request_handler.get())); |
| 1153 // This is the same as in ProfileImplIOData except that we do not collect |
| 1154 // usage stats. |
| 1155 network_delegate->set_data_reduction_proxy_params( |
| 1156 globals_->data_reduction_proxy_params.get()); |
| 1157 network_delegate->set_data_reduction_proxy_auth_request_handler( |
| 1158 globals_->data_reduction_proxy_auth_request_handler.get()); |
| 1159 network_delegate->set_on_resolve_proxy_handler( |
| 1160 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); |
| 1161 } |
| 1162 |
| 1163 // static | 1163 // static |
| 1164 void IOThread::ConfigureQuicGlobals( | 1164 void IOThread::ConfigureQuicGlobals( |
| 1165 const base::CommandLine& command_line, | 1165 const base::CommandLine& command_line, |
| 1166 base::StringPiece quic_trial_group, | 1166 base::StringPiece quic_trial_group, |
| 1167 const VariationParameters& quic_trial_params, | 1167 const VariationParameters& quic_trial_params, |
| 1168 IOThread::Globals* globals) { | 1168 IOThread::Globals* globals) { |
| 1169 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); | 1169 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); |
| 1170 globals->enable_quic.set(enable_quic); | 1170 globals->enable_quic.set(enable_quic); |
| 1171 if (enable_quic) { | 1171 if (enable_quic) { |
| 1172 globals->enable_quic_time_based_loss_detection.set( | 1172 globals->enable_quic_time_based_loss_detection.set( |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1429 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1430 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1430 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1431 net::QuicVersion version = supported_versions[i]; | 1431 net::QuicVersion version = supported_versions[i]; |
| 1432 if (net::QuicVersionToString(version) == quic_version) { | 1432 if (net::QuicVersionToString(version) == quic_version) { |
| 1433 return version; | 1433 return version; |
| 1434 } | 1434 } |
| 1435 } | 1435 } |
| 1436 | 1436 |
| 1437 return net::QUIC_VERSION_UNSUPPORTED; | 1437 return net::QUIC_VERSION_UNSUPPORTED; |
| 1438 } | 1438 } |
| OLD | NEW |