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

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

Issue 734263003: Move data reduction proxy logic out of chrome and android webview network delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing mmenke and jochen comments Created 6 years 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 25 matching lines...) Expand all
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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 new LoggingNetworkChangeObserver(net_log_)); 576 new LoggingNetworkChangeObserver(net_log_));
576 577
577 // Setup the HistogramWatcher to run on the IO thread. 578 // Setup the HistogramWatcher to run on the IO thread.
578 net::NetworkChangeNotifier::InitHistogramWatcher(); 579 net::NetworkChangeNotifier::InitHistogramWatcher();
579 580
580 #if defined(ENABLE_EXTENSIONS) 581 #if defined(ENABLE_EXTENSIONS)
581 globals_->extension_event_router_forwarder = 582 globals_->extension_event_router_forwarder =
582 extension_event_router_forwarder_; 583 extension_event_router_forwarder_;
583 #endif 584 #endif
584 585
585 ChromeNetworkDelegate* network_delegate = 586 scoped_ptr<ChromeNetworkDelegate> chrome_network_delegate(
586 new ChromeNetworkDelegate(extension_event_router_forwarder(), 587 new ChromeNetworkDelegate(extension_event_router_forwarder(),
587 &system_enable_referrers_); 588 &system_enable_referrers_));
588 589
589 if (command_line.HasSwitch(switches::kEnableClientHints)) 590 if (command_line.HasSwitch(switches::kEnableClientHints))
590 network_delegate->SetEnableClientHints(); 591 chrome_network_delegate->SetEnableClientHints();
591 592
592 #if defined(ENABLE_EXTENSIONS) 593 #if defined(ENABLE_EXTENSIONS)
593 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) 594 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling))
594 network_delegate->NeverThrottleRequests(); 595 chrome_network_delegate->NeverThrottleRequests();
595 #endif 596 #endif
596 597
598 SetupDataReductionProxy();
599
600 // This is the same as in ProfileImplIOData except that we do not collect
601 // usage stats.
602 data_reduction_proxy::DataReductionProxyNetworkDelegate* network_delegate =
603 new data_reduction_proxy::DataReductionProxyNetworkDelegate(
604 chrome_network_delegate.Pass());
605
606 network_delegate->Init(
607 NULL, NULL, NULL,
608 globals_->data_reduction_proxy_params.get(), NULL,
609 globals_->data_reduction_proxy_auth_request_handler.get(), NULL,
610 data_reduction_proxy::DataReductionProxyNetworkDelegate::
611 OnResolveProxyHandler(),
612 data_reduction_proxy::DataReductionProxyNetworkDelegate::
613 ProxyConfigGetter());
614
597 globals_->system_network_delegate.reset(network_delegate); 615 globals_->system_network_delegate.reset(network_delegate);
598 globals_->host_resolver = CreateGlobalHostResolver(net_log_); 616 globals_->host_resolver = CreateGlobalHostResolver(net_log_);
599 UpdateDnsClientEnabled(); 617 UpdateDnsClientEnabled();
600 #if defined(OS_CHROMEOS) 618 #if defined(OS_CHROMEOS)
601 // Creates a CertVerifyProc that doesn't allow any profile-provided certs. 619 // Creates a CertVerifyProc that doesn't allow any profile-provided certs.
602 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( 620 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier(
603 new chromeos::CertVerifyProcChromeOS())); 621 new chromeos::CertVerifyProcChromeOS()));
604 #else 622 #else
605 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( 623 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier(
606 net::CertVerifyProc::CreateDefault())); 624 net::CertVerifyProc::CreateDefault()));
(...skipping 28 matching lines...) Expand all
635 scoped_ptr<net::CTLogVerifier> external_log_verifier( 653 scoped_ptr<net::CTLogVerifier> external_log_verifier(
636 net::CTLogVerifier::Create(ct_public_key_data, log_description)); 654 net::CTLogVerifier::Create(ct_public_key_data, log_description));
637 CHECK(external_log_verifier) << "Unable to parse CT public key."; 655 CHECK(external_log_verifier) << "Unable to parse CT public key.";
638 VLOG(1) << "Adding log with description " << log_description; 656 VLOG(1) << "Adding log with description " << log_description;
639 ct_verifier->AddLog(external_log_verifier.Pass()); 657 ct_verifier->AddLog(external_log_verifier.Pass());
640 } 658 }
641 } 659 }
642 660
643 globals_->ssl_config_service = GetSSLConfigService(); 661 globals_->ssl_config_service = GetSSLConfigService();
644 662
645 SetupDataReductionProxy(network_delegate);
646
647 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( 663 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory(
648 globals_->host_resolver.get())); 664 globals_->host_resolver.get()));
649 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); 665 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl());
650 // For the ProxyScriptFetcher, we use a direct ProxyService. 666 // For the ProxyScriptFetcher, we use a direct ProxyService.
651 globals_->proxy_script_fetcher_proxy_service.reset( 667 globals_->proxy_script_fetcher_proxy_service.reset(
652 net::ProxyService::CreateDirectWithNetLog(net_log_)); 668 net::ProxyService::CreateDirectWithNetLog(net_log_));
653 // In-memory cookie store. 669 // In-memory cookie store.
654 globals_->system_cookie_store = 670 globals_->system_cookie_store =
655 content::CreateCookieStore(content::CookieStoreConfig()); 671 content::CreateCookieStore(content::CookieStoreConfig());
656 // In-memory channel ID store. 672 // In-memory channel ID store.
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 std::string group = 1142 std::string group =
1127 base::FieldTrialList::FindFullName(kQuicFieldTrialName); 1143 base::FieldTrialList::FindFullName(kQuicFieldTrialName);
1128 VariationParameters params; 1144 VariationParameters params;
1129 if (!variations::GetVariationParams(kQuicFieldTrialName, &params)) { 1145 if (!variations::GetVariationParams(kQuicFieldTrialName, &params)) {
1130 params.clear(); 1146 params.clear();
1131 } 1147 }
1132 1148
1133 ConfigureQuicGlobals(command_line, group, params, globals_); 1149 ConfigureQuicGlobals(command_line, group, params, globals_);
1134 } 1150 }
1135 1151
1136 void IOThread::SetupDataReductionProxy( 1152 void IOThread::SetupDataReductionProxy() {
1137 ChromeNetworkDelegate* network_delegate) {
1138 // TODO(kundaji): Move flags initialization to DataReductionProxyParams and 1153 // TODO(kundaji): Move flags initialization to DataReductionProxyParams and
1139 // merge with flag initialization in 1154 // merge with flag initialization in
1140 // data_reduction_proxy_chrome_settings_factory.cc. 1155 // data_reduction_proxy_chrome_settings_factory.cc.
1141 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed | 1156 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed |
1142 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | 1157 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed |
1143 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed; 1158 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed;
1144 if (data_reduction_proxy::DataReductionProxyParams:: 1159 if (data_reduction_proxy::DataReductionProxyParams::
1145 IsIncludedInPromoFieldTrial()) { 1160 IsIncludedInPromoFieldTrial()) {
1146 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed; 1161 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed;
1147 } 1162 }
1148 if (data_reduction_proxy::DataReductionProxyParams:: 1163 if (data_reduction_proxy::DataReductionProxyParams::
1149 IsIncludedInHoldbackFieldTrial()) { 1164 IsIncludedInHoldbackFieldTrial()) {
1150 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback; 1165 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback;
1151 } 1166 }
1152 globals_->data_reduction_proxy_params.reset( 1167 globals_->data_reduction_proxy_params.reset(
1153 new data_reduction_proxy::DataReductionProxyParams(flags)); 1168 new data_reduction_proxy::DataReductionProxyParams(flags));
1154 globals_->data_reduction_proxy_auth_request_handler.reset( 1169 globals_->data_reduction_proxy_auth_request_handler.reset(
1155 new data_reduction_proxy::DataReductionProxyAuthRequestHandler( 1170 new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
1156 DataReductionProxyChromeSettings::GetClient(), 1171 DataReductionProxyChromeSettings::GetClient(),
1157 globals_->data_reduction_proxy_params.get(), 1172 globals_->data_reduction_proxy_params.get(),
1158 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); 1173 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
1159 globals_->data_reduction_proxy_delegate.reset( 1174 globals_->data_reduction_proxy_delegate.reset(
1160 new data_reduction_proxy::DataReductionProxyDelegate( 1175 new data_reduction_proxy::DataReductionProxyDelegate(
1161 globals_->data_reduction_proxy_auth_request_handler.get(), 1176 globals_->data_reduction_proxy_auth_request_handler.get(),
1162 globals_->data_reduction_proxy_params.get())); 1177 globals_->data_reduction_proxy_params.get()));
1163 // This is the same as in ProfileImplIOData except that we do not collect
1164 // usage stats.
1165 network_delegate->set_data_reduction_proxy_params(
1166 globals_->data_reduction_proxy_params.get());
1167 network_delegate->set_data_reduction_proxy_auth_request_handler(
1168 globals_->data_reduction_proxy_auth_request_handler.get());
1169 network_delegate->set_on_resolve_proxy_handler(
1170 base::Bind(data_reduction_proxy::OnResolveProxyHandler));
1171 } 1178 }
1172 1179
1173 // static 1180 // static
1174 void IOThread::ConfigureQuicGlobals( 1181 void IOThread::ConfigureQuicGlobals(
1175 const base::CommandLine& command_line, 1182 const base::CommandLine& command_line,
1176 base::StringPiece quic_trial_group, 1183 base::StringPiece quic_trial_group,
1177 const VariationParameters& quic_trial_params, 1184 const VariationParameters& quic_trial_params,
1178 IOThread::Globals* globals) { 1185 IOThread::Globals* globals) {
1179 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); 1186 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group);
1180 globals->enable_quic.set(enable_quic); 1187 globals->enable_quic.set(enable_quic);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); 1421 net::QuicVersionVector supported_versions = net::QuicSupportedVersions();
1415 for (size_t i = 0; i < supported_versions.size(); ++i) { 1422 for (size_t i = 0; i < supported_versions.size(); ++i) {
1416 net::QuicVersion version = supported_versions[i]; 1423 net::QuicVersion version = supported_versions[i];
1417 if (net::QuicVersionToString(version) == quic_version) { 1424 if (net::QuicVersionToString(version) == quic_version) {
1418 return version; 1425 return version;
1419 } 1426 }
1420 } 1427 }
1421 1428
1422 return net::QUIC_VERSION_UNSUPPORTED; 1429 return net::QUIC_VERSION_UNSUPPORTED;
1423 } 1430 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698