| 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 25 matching lines...) Expand all Loading... |
| 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_settings.h" |
| 39 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | 39 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" |
| 40 #include "chrome/common/chrome_content_client.h" | 40 #include "chrome/common/chrome_content_client.h" |
| 41 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
| 42 #include "chrome/common/chrome_version_info.h" | 42 #include "chrome/common/chrome_version_info.h" |
| 43 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
| 44 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_auth
_request_handler.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" | 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" |
| 46 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" | 47 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" |
| 47 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prot
ocol.h" | 48 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prot
ocol.h" |
| 48 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | 49 #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/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 50 #include "components/policy/core/common/policy_service.h" | 51 #include "components/policy/core/common/policy_service.h" |
| 51 #include "components/variations/variations_associated_data.h" | 52 #include "components/variations/variations_associated_data.h" |
| 52 #include "content/public/browser/browser_thread.h" | 53 #include "content/public/browser/browser_thread.h" |
| 53 #include "content/public/browser/cookie_store_factory.h" | 54 #include "content/public/browser/cookie_store_factory.h" |
| 54 #include "net/base/host_mapping_rules.h" | 55 #include "net/base/host_mapping_rules.h" |
| 55 #include "net/base/net_util.h" | 56 #include "net/base/net_util.h" |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 new LoggingNetworkChangeObserver(net_log_)); | 578 new LoggingNetworkChangeObserver(net_log_)); |
| 578 | 579 |
| 579 // Setup the HistogramWatcher to run on the IO thread. | 580 // Setup the HistogramWatcher to run on the IO thread. |
| 580 net::NetworkChangeNotifier::InitHistogramWatcher(); | 581 net::NetworkChangeNotifier::InitHistogramWatcher(); |
| 581 | 582 |
| 582 #if defined(ENABLE_EXTENSIONS) | 583 #if defined(ENABLE_EXTENSIONS) |
| 583 globals_->extension_event_router_forwarder = | 584 globals_->extension_event_router_forwarder = |
| 584 extension_event_router_forwarder_; | 585 extension_event_router_forwarder_; |
| 585 #endif | 586 #endif |
| 586 | 587 |
| 587 ChromeNetworkDelegate* network_delegate = | 588 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate( |
| 588 new ChromeNetworkDelegate(extension_event_router_forwarder(), | 589 new ChromeNetworkDelegate(extension_event_router_forwarder(), |
| 589 &system_enable_referrers_); | 590 &system_enable_referrers_)); |
| 590 | 591 |
| 591 if (command_line.HasSwitch(switches::kEnableClientHints)) | 592 if (command_line.HasSwitch(switches::kEnableClientHints)) |
| 592 network_delegate->SetEnableClientHints(); | 593 chrome_network_delegate->SetEnableClientHints(); |
| 593 | 594 |
| 594 #if defined(ENABLE_EXTENSIONS) | 595 #if defined(ENABLE_EXTENSIONS) |
| 595 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) | 596 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) |
| 596 network_delegate->NeverThrottleRequests(); | 597 chrome_network_delegate->NeverThrottleRequests(); |
| 597 #endif | 598 #endif |
| 598 | 599 |
| 600 SetupDataReductionProxy(); |
| 601 |
| 602 // This is the same as in ProfileImplIOData except that it does not collect |
| 603 // usage stats. |
| 604 data_reduction_proxy::DataReductionProxyNetworkDelegate* network_delegate = |
| 605 new data_reduction_proxy::DataReductionProxyNetworkDelegate( |
| 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 |
| 599 globals_->system_network_delegate.reset(network_delegate); | 612 globals_->system_network_delegate.reset(network_delegate); |
| 600 globals_->host_resolver = CreateGlobalHostResolver(net_log_); | 613 globals_->host_resolver = CreateGlobalHostResolver(net_log_); |
| 601 UpdateDnsClientEnabled(); | 614 UpdateDnsClientEnabled(); |
| 602 #if defined(OS_CHROMEOS) | 615 #if defined(OS_CHROMEOS) |
| 603 // Creates a CertVerifyProc that doesn't allow any profile-provided certs. | 616 // Creates a CertVerifyProc that doesn't allow any profile-provided certs. |
| 604 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( | 617 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( |
| 605 new chromeos::CertVerifyProcChromeOS())); | 618 new chromeos::CertVerifyProcChromeOS())); |
| 606 #else | 619 #else |
| 607 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( | 620 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( |
| 608 net::CertVerifyProc::CreateDefault())); | 621 net::CertVerifyProc::CreateDefault())); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 637 scoped_ptr<net::CTLogVerifier> external_log_verifier( | 650 scoped_ptr<net::CTLogVerifier> external_log_verifier( |
| 638 net::CTLogVerifier::Create(ct_public_key_data, log_description)); | 651 net::CTLogVerifier::Create(ct_public_key_data, log_description)); |
| 639 CHECK(external_log_verifier) << "Unable to parse CT public key."; | 652 CHECK(external_log_verifier) << "Unable to parse CT public key."; |
| 640 VLOG(1) << "Adding log with description " << log_description; | 653 VLOG(1) << "Adding log with description " << log_description; |
| 641 ct_verifier->AddLog(external_log_verifier.Pass()); | 654 ct_verifier->AddLog(external_log_verifier.Pass()); |
| 642 } | 655 } |
| 643 } | 656 } |
| 644 | 657 |
| 645 globals_->ssl_config_service = GetSSLConfigService(); | 658 globals_->ssl_config_service = GetSSLConfigService(); |
| 646 | 659 |
| 647 SetupDataReductionProxy(network_delegate); | |
| 648 | |
| 649 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 660 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( |
| 650 globals_->host_resolver.get())); | 661 globals_->host_resolver.get())); |
| 651 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 662 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
| 652 // For the ProxyScriptFetcher, we use a direct ProxyService. | 663 // For the ProxyScriptFetcher, we use a direct ProxyService. |
| 653 globals_->proxy_script_fetcher_proxy_service.reset( | 664 globals_->proxy_script_fetcher_proxy_service.reset( |
| 654 net::ProxyService::CreateDirectWithNetLog(net_log_)); | 665 net::ProxyService::CreateDirectWithNetLog(net_log_)); |
| 655 // In-memory cookie store. | 666 // In-memory cookie store. |
| 656 globals_->system_cookie_store = | 667 globals_->system_cookie_store = |
| 657 content::CreateCookieStore(content::CookieStoreConfig()); | 668 content::CreateCookieStore(content::CookieStoreConfig()); |
| 658 // In-memory channel ID store. | 669 // In-memory channel ID store. |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 std::string group = | 1139 std::string group = |
| 1129 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 1140 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
| 1130 VariationParameters params; | 1141 VariationParameters params; |
| 1131 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | 1142 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { |
| 1132 params.clear(); | 1143 params.clear(); |
| 1133 } | 1144 } |
| 1134 | 1145 |
| 1135 ConfigureQuicGlobals(command_line, group, params, globals_); | 1146 ConfigureQuicGlobals(command_line, group, params, globals_); |
| 1136 } | 1147 } |
| 1137 | 1148 |
| 1138 void IOThread::SetupDataReductionProxy( | 1149 void IOThread::SetupDataReductionProxy() { |
| 1139 ChromeNetworkDelegate* network_delegate) { | |
| 1140 // TODO(kundaji): Move flags initialization to DataReductionProxyParams and | 1150 // TODO(kundaji): Move flags initialization to DataReductionProxyParams and |
| 1141 // merge with flag initialization in | 1151 // merge with flag initialization in |
| 1142 // data_reduction_proxy_chrome_settings_factory.cc. | 1152 // data_reduction_proxy_chrome_settings_factory.cc. |
| 1143 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed | | 1153 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed | |
| 1144 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | | 1154 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | |
| 1145 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; | 1155 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; |
| 1146 if (data_reduction_proxy::DataReductionProxyParams:: | 1156 if (data_reduction_proxy::DataReductionProxyParams:: |
| 1147 IsIncludedInPromoFieldTrial()) { | 1157 IsIncludedInPromoFieldTrial()) { |
| 1148 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; | 1158 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; |
| 1149 } | 1159 } |
| 1150 if (data_reduction_proxy::DataReductionProxyParams:: | 1160 if (data_reduction_proxy::DataReductionProxyParams:: |
| 1151 IsIncludedInHoldbackFieldTrial()) { | 1161 IsIncludedInHoldbackFieldTrial()) { |
| 1152 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; | 1162 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; |
| 1153 } | 1163 } |
| 1154 globals_->data_reduction_proxy_params.reset( | 1164 globals_->data_reduction_proxy_params.reset( |
| 1155 new data_reduction_proxy::DataReductionProxyParams(flags)); | 1165 new data_reduction_proxy::DataReductionProxyParams(flags)); |
| 1156 globals_->data_reduction_proxy_auth_request_handler.reset( | 1166 globals_->data_reduction_proxy_auth_request_handler.reset( |
| 1157 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | 1167 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( |
| 1158 DataReductionProxyChromeSettings::GetClient(), | 1168 DataReductionProxyChromeSettings::GetClient(), |
| 1159 globals_->data_reduction_proxy_params.get(), | 1169 globals_->data_reduction_proxy_params.get(), |
| 1160 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 1170 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
| 1161 globals_->data_reduction_proxy_delegate.reset( | 1171 globals_->data_reduction_proxy_delegate.reset( |
| 1162 new data_reduction_proxy::DataReductionProxyDelegate( | 1172 new data_reduction_proxy::DataReductionProxyDelegate( |
| 1163 globals_->data_reduction_proxy_auth_request_handler.get(), | 1173 globals_->data_reduction_proxy_auth_request_handler.get(), |
| 1164 globals_->data_reduction_proxy_params.get())); | 1174 globals_->data_reduction_proxy_params.get())); |
| 1165 // This is the same as in ProfileImplIOData except that we do not collect | |
| 1166 // usage stats. | |
| 1167 network_delegate->set_data_reduction_proxy_params( | |
| 1168 globals_->data_reduction_proxy_params.get()); | |
| 1169 network_delegate->set_data_reduction_proxy_auth_request_handler( | |
| 1170 globals_->data_reduction_proxy_auth_request_handler.get()); | |
| 1171 network_delegate->set_on_resolve_proxy_handler( | |
| 1172 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | |
| 1173 } | 1175 } |
| 1174 | 1176 |
| 1175 // static | 1177 // static |
| 1176 void IOThread::ConfigureQuicGlobals( | 1178 void IOThread::ConfigureQuicGlobals( |
| 1177 const base::CommandLine& command_line, | 1179 const base::CommandLine& command_line, |
| 1178 base::StringPiece quic_trial_group, | 1180 base::StringPiece quic_trial_group, |
| 1179 const VariationParameters& quic_trial_params, | 1181 const VariationParameters& quic_trial_params, |
| 1180 IOThread::Globals* globals) { | 1182 IOThread::Globals* globals) { |
| 1181 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); | 1183 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); |
| 1182 globals->enable_quic.set(enable_quic); | 1184 globals->enable_quic.set(enable_quic); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1418 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
| 1417 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1419 for (size_t i = 0; i < supported_versions.size(); ++i) { |
| 1418 net::QuicVersion version = supported_versions[i]; | 1420 net::QuicVersion version = supported_versions[i]; |
| 1419 if (net::QuicVersionToString(version) == quic_version) { | 1421 if (net::QuicVersionToString(version) == quic_version) { |
| 1420 return version; | 1422 return version; |
| 1421 } | 1423 } |
| 1422 } | 1424 } |
| 1423 | 1425 |
| 1424 return net::QUIC_VERSION_UNSUPPORTED; | 1426 return net::QUIC_VERSION_UNSUPPORTED; |
| 1425 } | 1427 } |
| OLD | NEW |