Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: chrome/browser/io_thread.cc

Issue 382313003: Add data reduction functionality to all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to head Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 21 matching lines...) Expand all
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/common/chrome_content_client.h" 38 #include "chrome/common/chrome_content_client.h"
39 #include "chrome/common/chrome_switches.h" 39 #include "chrome/common/chrome_switches.h"
40 #include "chrome/common/chrome_version_info.h" 40 #include "chrome/common/chrome_version_info.h"
41 #include "chrome/common/pref_names.h" 41 #include "chrome/common/pref_names.h"
42 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ est_handler.h"
43 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
42 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" 44 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h"
45 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h"
46 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings. h"
43 #include "components/policy/core/common/policy_service.h" 47 #include "components/policy/core/common/policy_service.h"
44 #include "components/variations/variations_associated_data.h" 48 #include "components/variations/variations_associated_data.h"
45 #include "content/public/browser/browser_thread.h" 49 #include "content/public/browser/browser_thread.h"
46 #include "content/public/browser/cookie_store_factory.h" 50 #include "content/public/browser/cookie_store_factory.h"
47 #include "net/base/host_mapping_rules.h" 51 #include "net/base/host_mapping_rules.h"
48 #include "net/base/net_util.h" 52 #include "net/base/net_util.h"
49 #include "net/cert/cert_verifier.h" 53 #include "net/cert/cert_verifier.h"
50 #include "net/cert/cert_verify_proc.h" 54 #include "net/cert/cert_verify_proc.h"
51 #include "net/cert/ct_known_logs.h" 55 #include "net/cert/ct_known_logs.h"
52 #include "net/cert/ct_log_verifier.h" 56 #include "net/cert/ct_log_verifier.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 #endif 91 #endif
88 92
89 #if defined(ENABLE_EXTENSIONS) 93 #if defined(ENABLE_EXTENSIONS)
90 #include "chrome/browser/extensions/event_router_forwarder.h" 94 #include "chrome/browser/extensions/event_router_forwarder.h"
91 #endif 95 #endif
92 96
93 #if defined(USE_NSS) || defined(OS_IOS) 97 #if defined(USE_NSS) || defined(OS_IOS)
94 #include "net/ocsp/nss_ocsp.h" 98 #include "net/ocsp/nss_ocsp.h"
95 #endif 99 #endif
96 100
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_protocol. h"
102 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
103
104 #if defined(OS_CHROMEOS) 101 #if defined(OS_CHROMEOS)
105 #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h" 102 #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h"
106 #include "chromeos/network/host_resolver_impl_chromeos.h" 103 #include "chromeos/network/host_resolver_impl_chromeos.h"
107 #endif 104 #endif
108 105
109 using content::BrowserThread; 106 using content::BrowserThread;
110 107
111 class SafeBrowsingURLRequestContext; 108 class SafeBrowsingURLRequestContext;
112 109
113 // The IOThread object must outlive any tasks posted to the IO thread before the 110 // The IOThread object must outlive any tasks posted to the IO thread before the
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 << "Unable to decode CT public key."; 615 << "Unable to decode CT public key.";
619 scoped_ptr<net::CTLogVerifier> external_log_verifier( 616 scoped_ptr<net::CTLogVerifier> external_log_verifier(
620 net::CTLogVerifier::Create(ct_public_key_data, log_description)); 617 net::CTLogVerifier::Create(ct_public_key_data, log_description));
621 CHECK(external_log_verifier) << "Unable to parse CT public key."; 618 CHECK(external_log_verifier) << "Unable to parse CT public key.";
622 VLOG(1) << "Adding log with description " << log_description; 619 VLOG(1) << "Adding log with description " << log_description;
623 ct_verifier->AddLog(external_log_verifier.Pass()); 620 ct_verifier->AddLog(external_log_verifier.Pass());
624 } 621 }
625 } 622 }
626 623
627 globals_->ssl_config_service = GetSSLConfigService(); 624 globals_->ssl_config_service = GetSSLConfigService();
628 625 SetupDataReductionProxy(network_delegate);
629 #if defined(SPDY_PROXY_AUTH_ORIGIN)
630 int drp_flags = 0;
631 if (data_reduction_proxy::DataReductionProxyParams::
632 IsIncludedInFieldTrial()) {
633 drp_flags |=
634 (data_reduction_proxy::DataReductionProxyParams::kAllowed |
635 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed);
636 }
637 if (data_reduction_proxy::DataReductionProxyParams::
638 IsIncludedInAlternativeFieldTrial()) {
639 drp_flags |=
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 chrome::VersionInfo().Version(),
654 globals_->data_reduction_proxy_params.get(),
655 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
656 // This is the same as in ProfileImplIOData except that we do not collect
657 // usage stats.
658 network_delegate->set_data_reduction_proxy_params(
659 globals_->data_reduction_proxy_params.get());
660 network_delegate->set_data_reduction_proxy_auth_request_handler(
661 globals_->data_reduction_proxy_auth_request_handler.get());
662 network_delegate->set_on_resolve_proxy_handler(
663 base::Bind(data_reduction_proxy::OnResolveProxyHandler));
664 #endif // defined(SPDY_PROXY_AUTH_ORIGIN)
665
666 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( 626 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory(
667 globals_->host_resolver.get())); 627 globals_->host_resolver.get()));
668 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); 628 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl());
669 // For the ProxyScriptFetcher, we use a direct ProxyService. 629 // For the ProxyScriptFetcher, we use a direct ProxyService.
670 globals_->proxy_script_fetcher_proxy_service.reset( 630 globals_->proxy_script_fetcher_proxy_service.reset(
671 net::ProxyService::CreateDirectWithNetLog(net_log_)); 631 net::ProxyService::CreateDirectWithNetLog(net_log_));
672 // In-memory cookie store. 632 // In-memory cookie store.
673 globals_->system_cookie_store = 633 globals_->system_cookie_store =
674 content::CreateCookieStore(content::CookieStoreConfig()); 634 content::CreateCookieStore(content::CookieStoreConfig());
675 // In-memory channel ID store. 635 // In-memory channel ID store.
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 1055
1096 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 1056 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
1097 globals_->system_proxy_service.reset( 1057 globals_->system_proxy_service.reset(
1098 ProxyServiceFactory::CreateProxyService( 1058 ProxyServiceFactory::CreateProxyService(
1099 net_log_, 1059 net_log_,
1100 globals_->proxy_script_fetcher_context.get(), 1060 globals_->proxy_script_fetcher_context.get(),
1101 globals_->system_network_delegate.get(), 1061 globals_->system_network_delegate.get(),
1102 system_proxy_config_service_.release(), 1062 system_proxy_config_service_.release(),
1103 command_line, 1063 command_line,
1104 quick_check_enabled_.GetValue())); 1064 quick_check_enabled_.GetValue()));
1065 DCHECK(globals_->data_reduction_proxy_params);
1105 1066
1106 net::HttpNetworkSession::Params system_params; 1067 net::HttpNetworkSession::Params system_params;
1107 InitializeNetworkSessionParams(&system_params); 1068 InitializeNetworkSessionParams(&system_params);
1108 system_params.net_log = net_log_; 1069 system_params.net_log = net_log_;
1109 system_params.proxy_service = globals_->system_proxy_service.get(); 1070 system_params.proxy_service = globals_->system_proxy_service.get();
1110 1071
1111 globals_->system_http_transaction_factory.reset( 1072 globals_->system_http_transaction_factory.reset(
1112 new net::HttpNetworkLayer( 1073 new net::HttpNetworkLayer(
1113 new net::HttpNetworkSession(system_params))); 1074 new net::HttpNetworkSession(system_params)));
1114 globals_->system_url_request_job_factory.reset( 1075 globals_->system_url_request_job_factory.reset(
(...skipping 17 matching lines...) Expand all
1132 std::string group = 1093 std::string group =
1133 base::FieldTrialList::FindFullName(kQuicFieldTrialName); 1094 base::FieldTrialList::FindFullName(kQuicFieldTrialName);
1134 VariationParameters params; 1095 VariationParameters params;
1135 if (!variations::GetVariationParams(kQuicFieldTrialName, &params)) { 1096 if (!variations::GetVariationParams(kQuicFieldTrialName, &params)) {
1136 params.clear(); 1097 params.clear();
1137 } 1098 }
1138 1099
1139 ConfigureQuicGlobals(command_line, group, params, globals_); 1100 ConfigureQuicGlobals(command_line, group, params, globals_);
1140 } 1101 }
1141 1102
1103 void IOThread::SetupDataReductionProxy(
1104 ChromeNetworkDelegate* network_delegate) {
1105 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed |
1106 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed;
1107 if (data_reduction_proxy::DataReductionProxyParams::
1108 IsIncludedInAlternativeFieldTrial()) {
1109 flags |=
1110 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed;
1111 }
1112 if (data_reduction_proxy::DataReductionProxyParams::
1113 IsIncludedInPromoFieldTrial()) {
1114 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed;
1115 }
1116 if (data_reduction_proxy::DataReductionProxyParams::
1117 IsIncludedInHoldbackFieldTrial()) {
1118 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback;
1119 }
mmenke 2014/09/08 18:11:14 Should all this fieldtrial / flags stuff be moved
Not at Google. Contact bengr 2014/09/08 19:18:34 Added a TODO. I don't see any reason for it to be
1120 globals_->data_reduction_proxy_params.reset(
1121 new data_reduction_proxy::DataReductionProxyParams(flags));
1122 globals_->data_reduction_proxy_auth_request_handler.reset(
1123 new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
1124 DataReductionProxyChromeSettings::GetClient(),
1125 chrome::VersionInfo().Version(),
1126 globals_->data_reduction_proxy_params.get(),
1127 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
1128 // This is the same as in ProfileImplIOData except that we do not collect
1129 // usage stats.
1130 network_delegate->set_data_reduction_proxy_params(
1131 globals_->data_reduction_proxy_params.get());
1132 network_delegate->set_data_reduction_proxy_auth_request_handler(
1133 globals_->data_reduction_proxy_auth_request_handler.get());
1134 network_delegate->set_on_resolve_proxy_handler(
1135 base::Bind(data_reduction_proxy::OnResolveProxyHandler));
1136 }
1137
1142 // static 1138 // static
1143 void IOThread::ConfigureQuicGlobals( 1139 void IOThread::ConfigureQuicGlobals(
1144 const base::CommandLine& command_line, 1140 const base::CommandLine& command_line,
1145 base::StringPiece quic_trial_group, 1141 base::StringPiece quic_trial_group,
1146 const VariationParameters& quic_trial_params, 1142 const VariationParameters& quic_trial_params,
1147 IOThread::Globals* globals) { 1143 IOThread::Globals* globals) {
1148 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); 1144 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group);
1149 globals->enable_quic.set(enable_quic); 1145 globals->enable_quic.set(enable_quic);
1150 if (enable_quic) { 1146 if (enable_quic) {
1151 globals->enable_quic_time_based_loss_detection.set( 1147 globals->enable_quic_time_based_loss_detection.set(
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); 1391 net::QuicVersionVector supported_versions = net::QuicSupportedVersions();
1396 for (size_t i = 0; i < supported_versions.size(); ++i) { 1392 for (size_t i = 0; i < supported_versions.size(); ++i) {
1397 net::QuicVersion version = supported_versions[i]; 1393 net::QuicVersion version = supported_versions[i];
1398 if (net::QuicVersionToString(version) == quic_version) { 1394 if (net::QuicVersionToString(version) == quic_version) {
1399 return version; 1395 return version;
1400 } 1396 }
1401 } 1397 }
1402 1398
1403 return net::QUIC_VERSION_UNSUPPORTED; 1399 return net::QUIC_VERSION_UNSUPPORTED;
1404 } 1400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698