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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 // TODO(eranm): Control with Finch, crbug.com/437766 | 659 // TODO(eranm): Control with Finch, crbug.com/437766 |
647 if (command_line.HasSwitch(switches::kRequireCTForEV)) { | 660 if (command_line.HasSwitch(switches::kRequireCTForEV)) { |
648 policy_enforcer = new net::CertPolicyEnforcer(kNumKnownCTLogs, true); | 661 policy_enforcer = new net::CertPolicyEnforcer(kNumKnownCTLogs, true); |
649 } else { | 662 } else { |
650 policy_enforcer = new net::CertPolicyEnforcer(kNumKnownCTLogs, false); | 663 policy_enforcer = new net::CertPolicyEnforcer(kNumKnownCTLogs, false); |
651 } | 664 } |
652 globals_->cert_policy_enforcer.reset(policy_enforcer); | 665 globals_->cert_policy_enforcer.reset(policy_enforcer); |
653 | 666 |
654 globals_->ssl_config_service = GetSSLConfigService(); | 667 globals_->ssl_config_service = GetSSLConfigService(); |
655 | 668 |
656 SetupDataReductionProxy(network_delegate); | |
657 | |
658 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 669 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( |
659 globals_->host_resolver.get())); | 670 globals_->host_resolver.get())); |
660 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 671 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
661 // For the ProxyScriptFetcher, we use a direct ProxyService. | 672 // For the ProxyScriptFetcher, we use a direct ProxyService. |
662 globals_->proxy_script_fetcher_proxy_service.reset( | 673 globals_->proxy_script_fetcher_proxy_service.reset( |
663 net::ProxyService::CreateDirectWithNetLog(net_log_)); | 674 net::ProxyService::CreateDirectWithNetLog(net_log_)); |
664 // In-memory cookie store. | 675 // In-memory cookie store. |
665 globals_->system_cookie_store = | 676 globals_->system_cookie_store = |
666 content::CreateCookieStore(content::CookieStoreConfig()); | 677 content::CreateCookieStore(content::CookieStoreConfig()); |
667 // In-memory channel ID store. | 678 // In-memory channel ID store. |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 std::string group = | 1149 std::string group = |
1139 base::FieldTrialList::FindFullName(kQuicFieldTrialName); | 1150 base::FieldTrialList::FindFullName(kQuicFieldTrialName); |
1140 VariationParameters params; | 1151 VariationParameters params; |
1141 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { | 1152 if (!variations::GetVariationParams(kQuicFieldTrialName, ¶ms)) { |
1142 params.clear(); | 1153 params.clear(); |
1143 } | 1154 } |
1144 | 1155 |
1145 ConfigureQuicGlobals(command_line, group, params, globals_); | 1156 ConfigureQuicGlobals(command_line, group, params, globals_); |
1146 } | 1157 } |
1147 | 1158 |
1148 void IOThread::SetupDataReductionProxy( | 1159 void IOThread::SetupDataReductionProxy() { |
1149 ChromeNetworkDelegate* network_delegate) { | |
1150 // TODO(kundaji): Move flags initialization to DataReductionProxyParams and | 1160 // TODO(kundaji): Move flags initialization to DataReductionProxyParams and |
1151 // merge with flag initialization in | 1161 // merge with flag initialization in |
1152 // data_reduction_proxy_chrome_settings_factory.cc. | 1162 // data_reduction_proxy_chrome_settings_factory.cc. |
1153 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed | | 1163 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed | |
1154 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | | 1164 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | |
1155 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; | 1165 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; |
1156 if (data_reduction_proxy::DataReductionProxyParams:: | 1166 if (data_reduction_proxy::DataReductionProxyParams:: |
1157 IsIncludedInPromoFieldTrial()) { | 1167 IsIncludedInPromoFieldTrial()) { |
1158 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; | 1168 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; |
1159 } | 1169 } |
1160 if (data_reduction_proxy::DataReductionProxyParams:: | 1170 if (data_reduction_proxy::DataReductionProxyParams:: |
1161 IsIncludedInHoldbackFieldTrial()) { | 1171 IsIncludedInHoldbackFieldTrial()) { |
1162 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; | 1172 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; |
1163 } | 1173 } |
1164 globals_->data_reduction_proxy_params.reset( | 1174 globals_->data_reduction_proxy_params.reset( |
1165 new data_reduction_proxy::DataReductionProxyParams(flags)); | 1175 new data_reduction_proxy::DataReductionProxyParams(flags)); |
1166 globals_->data_reduction_proxy_auth_request_handler.reset( | 1176 globals_->data_reduction_proxy_auth_request_handler.reset( |
1167 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( | 1177 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( |
1168 DataReductionProxyChromeSettings::GetClient(), | 1178 DataReductionProxyChromeSettings::GetClient(), |
1169 globals_->data_reduction_proxy_params.get(), | 1179 globals_->data_reduction_proxy_params.get(), |
1170 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 1180 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
1171 globals_->data_reduction_proxy_delegate.reset( | 1181 globals_->data_reduction_proxy_delegate.reset( |
1172 new data_reduction_proxy::DataReductionProxyDelegate( | 1182 new data_reduction_proxy::DataReductionProxyDelegate( |
1173 globals_->data_reduction_proxy_auth_request_handler.get(), | 1183 globals_->data_reduction_proxy_auth_request_handler.get(), |
1174 globals_->data_reduction_proxy_params.get())); | 1184 globals_->data_reduction_proxy_params.get())); |
1175 // This is the same as in ProfileImplIOData except that we do not collect | |
1176 // usage stats. | |
1177 network_delegate->set_data_reduction_proxy_params( | |
1178 globals_->data_reduction_proxy_params.get()); | |
1179 network_delegate->set_data_reduction_proxy_auth_request_handler( | |
1180 globals_->data_reduction_proxy_auth_request_handler.get()); | |
1181 network_delegate->set_on_resolve_proxy_handler( | |
1182 base::Bind(data_reduction_proxy::OnResolveProxyHandler)); | |
1183 } | 1185 } |
1184 | 1186 |
1185 // static | 1187 // static |
1186 void IOThread::ConfigureQuicGlobals( | 1188 void IOThread::ConfigureQuicGlobals( |
1187 const base::CommandLine& command_line, | 1189 const base::CommandLine& command_line, |
1188 base::StringPiece quic_trial_group, | 1190 base::StringPiece quic_trial_group, |
1189 const VariationParameters& quic_trial_params, | 1191 const VariationParameters& quic_trial_params, |
1190 IOThread::Globals* globals) { | 1192 IOThread::Globals* globals) { |
1191 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); | 1193 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); |
1192 globals->enable_quic.set(enable_quic); | 1194 globals->enable_quic.set(enable_quic); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); | 1407 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); |
1406 for (size_t i = 0; i < supported_versions.size(); ++i) { | 1408 for (size_t i = 0; i < supported_versions.size(); ++i) { |
1407 net::QuicVersion version = supported_versions[i]; | 1409 net::QuicVersion version = supported_versions[i]; |
1408 if (net::QuicVersionToString(version) == quic_version) { | 1410 if (net::QuicVersionToString(version) == quic_version) { |
1409 return version; | 1411 return version; |
1410 } | 1412 } |
1411 } | 1413 } |
1412 | 1414 |
1413 return net::QUIC_VERSION_UNSUPPORTED; | 1415 return net::QUIC_VERSION_UNSUPPORTED; |
1414 } | 1416 } |
OLD | NEW |