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

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

Issue 778463002: Wrapped data reduction proxy initialization into its own class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@network-delegate
Patch Set: 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 17 matching lines...) Expand all
28 #include "base/time/time.h" 28 #include "base/time/time.h"
29 #include "build/build_config.h" 29 #include "build/build_config.h"
30 #include "chrome/browser/browser_process.h" 30 #include "chrome/browser/browser_process.h"
31 #include "chrome/browser/net/async_dns_field_trial.h" 31 #include "chrome/browser/net/async_dns_field_trial.h"
32 #include "chrome/browser/net/chrome_net_log.h" 32 #include "chrome/browser/net/chrome_net_log.h"
33 #include "chrome/browser/net/chrome_network_delegate.h" 33 #include "chrome/browser/net/chrome_network_delegate.h"
34 #include "chrome/browser/net/connect_interceptor.h" 34 #include "chrome/browser/net/connect_interceptor.h"
35 #include "chrome/browser/net/dns_probe_service.h" 35 #include "chrome/browser/net/dns_probe_service.h"
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_io_data.h"
39 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact ory.h"
40 #include "chrome/common/chrome_content_client.h" 39 #include "chrome/common/chrome_content_client.h"
41 #include "chrome/common/chrome_switches.h" 40 #include "chrome/common/chrome_switches.h"
42 #include "chrome/common/chrome_version_info.h" 41 #include "chrome/common/chrome_version_info.h"
43 #include "chrome/common/pref_names.h" 42 #include "chrome/common/pref_names.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" 43 #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" 44 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h"
47 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" 45 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h"
48 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prot ocol.h"
49 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h"
50 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
51 #include "components/policy/core/common/policy_service.h" 46 #include "components/policy/core/common/policy_service.h"
52 #include "components/variations/variations_associated_data.h" 47 #include "components/variations/variations_associated_data.h"
53 #include "content/public/browser/browser_thread.h" 48 #include "content/public/browser/browser_thread.h"
54 #include "content/public/browser/cookie_store_factory.h" 49 #include "content/public/browser/cookie_store_factory.h"
55 #include "net/base/host_mapping_rules.h" 50 #include "net/base/host_mapping_rules.h"
56 #include "net/base/net_util.h" 51 #include "net/base/net_util.h"
57 #include "net/cert/cert_policy_enforcer.h" 52 #include "net/cert/cert_policy_enforcer.h"
58 #include "net/cert/cert_verifier.h" 53 #include "net/cert/cert_verifier.h"
59 #include "net/cert/cert_verify_proc.h" 54 #include "net/cert/cert_verify_proc.h"
60 #include "net/cert/ct_known_logs.h" 55 #include "net/cert/ct_known_logs.h"
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 &system_enable_referrers_)); 585 &system_enable_referrers_));
591 586
592 if (command_line.HasSwitch(switches::kEnableClientHints)) 587 if (command_line.HasSwitch(switches::kEnableClientHints))
593 chrome_network_delegate->SetEnableClientHints(); 588 chrome_network_delegate->SetEnableClientHints();
594 589
595 #if defined(ENABLE_EXTENSIONS) 590 #if defined(ENABLE_EXTENSIONS)
596 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) 591 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling))
597 chrome_network_delegate->NeverThrottleRequests(); 592 chrome_network_delegate->NeverThrottleRequests();
598 #endif 593 #endif
599 594
600 SetupDataReductionProxy(); 595 globals_->data_reduction_proxy_io_data =
596 CreateDataReductionProxyChromeIODataForSystem(
597 net_log_,
598 nullptr, /* PrefServiceSyncable */
599 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
600 BrowserThread::GetMessageLoopProxyForThread(
601 BrowserThread::UI)).Pass();
601 602
602 // This is the same as in ProfileImplIOData except that it does not collect 603 globals_->data_reduction_proxy_io_data->Init(
603 // usage stats. 604 chrome_network_delegate.Pass(),
604 data_reduction_proxy::DataReductionProxyNetworkDelegate* network_delegate = 605 false, false, true);
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 606
612 globals_->system_network_delegate.reset(network_delegate); 607 globals_->system_network_delegate.reset(
608 globals_->data_reduction_proxy_io_data->network_delegate());
mmenke 2014/12/17 21:37:22 BUG: You're storing the DRP's network delegate in
bengr 2014/12/19 20:05:57 Uggh. Thanks for catching this. I didn't do what y
613 globals_->host_resolver = CreateGlobalHostResolver(net_log_); 609 globals_->host_resolver = CreateGlobalHostResolver(net_log_);
614 UpdateDnsClientEnabled(); 610 UpdateDnsClientEnabled();
615 #if defined(OS_CHROMEOS) 611 #if defined(OS_CHROMEOS)
616 // Creates a CertVerifyProc that doesn't allow any profile-provided certs. 612 // Creates a CertVerifyProc that doesn't allow any profile-provided certs.
617 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( 613 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier(
618 new chromeos::CertVerifyProcChromeOS())); 614 new chromeos::CertVerifyProcChromeOS()));
619 #else 615 #else
620 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier( 616 globals_->cert_verifier.reset(new net::MultiThreadedCertVerifier(
621 net::CertVerifyProc::CreateDefault())); 617 net::CertVerifyProc::CreateDefault()));
622 #endif 618 #endif
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 globals.quic_max_packet_length.CopyToIfSet(&params->quic_max_packet_length); 1054 globals.quic_max_packet_length.CopyToIfSet(&params->quic_max_packet_length);
1059 globals.quic_user_agent_id.CopyToIfSet(&params->quic_user_agent_id); 1055 globals.quic_user_agent_id.CopyToIfSet(&params->quic_user_agent_id);
1060 globals.quic_supported_versions.CopyToIfSet( 1056 globals.quic_supported_versions.CopyToIfSet(
1061 &params->quic_supported_versions); 1057 &params->quic_supported_versions);
1062 params->quic_connection_options = globals.quic_connection_options; 1058 params->quic_connection_options = globals.quic_connection_options;
1063 1059
1064 globals.origin_to_force_quic_on.CopyToIfSet( 1060 globals.origin_to_force_quic_on.CopyToIfSet(
1065 &params->origin_to_force_quic_on); 1061 &params->origin_to_force_quic_on);
1066 params->enable_user_alternate_protocol_ports = 1062 params->enable_user_alternate_protocol_ports =
1067 globals.enable_user_alternate_protocol_ports; 1063 globals.enable_user_alternate_protocol_ports;
1068 params->proxy_delegate = globals.data_reduction_proxy_delegate.get(); 1064 params->proxy_delegate =
1065 globals.data_reduction_proxy_io_data->proxy_delegate();
1069 } 1066 }
1070 1067
1071 base::TimeTicks IOThread::creation_time() const { 1068 base::TimeTicks IOThread::creation_time() const {
1072 return creation_time_; 1069 return creation_time_;
1073 } 1070 }
1074 1071
1075 net::SSLConfigService* IOThread::GetSSLConfigService() { 1072 net::SSLConfigService* IOThread::GetSSLConfigService() {
1076 return ssl_config_service_manager_->Get(); 1073 return ssl_config_service_manager_->Get();
1077 } 1074 }
1078 1075
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 1108
1112 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 1109 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
1113 globals_->system_proxy_service.reset( 1110 globals_->system_proxy_service.reset(
1114 ProxyServiceFactory::CreateProxyService( 1111 ProxyServiceFactory::CreateProxyService(
1115 net_log_, 1112 net_log_,
1116 globals_->proxy_script_fetcher_context.get(), 1113 globals_->proxy_script_fetcher_context.get(),
1117 globals_->system_network_delegate.get(), 1114 globals_->system_network_delegate.get(),
1118 system_proxy_config_service_.release(), 1115 system_proxy_config_service_.release(),
1119 command_line, 1116 command_line,
1120 quick_check_enabled_.GetValue())); 1117 quick_check_enabled_.GetValue()));
1121 DCHECK(globals_->data_reduction_proxy_params); 1118 DCHECK(globals_->data_reduction_proxy_io_data);
1122 1119
1123 net::HttpNetworkSession::Params system_params; 1120 net::HttpNetworkSession::Params system_params;
1124 InitializeNetworkSessionParams(&system_params); 1121 InitializeNetworkSessionParams(&system_params);
1125 system_params.net_log = net_log_; 1122 system_params.net_log = net_log_;
1126 system_params.proxy_service = globals_->system_proxy_service.get(); 1123 system_params.proxy_service = globals_->system_proxy_service.get();
1127 1124
1128 globals_->system_http_transaction_factory.reset( 1125 globals_->system_http_transaction_factory.reset(
1129 new net::HttpNetworkLayer( 1126 new net::HttpNetworkLayer(
1130 new net::HttpNetworkSession(system_params))); 1127 new net::HttpNetworkSession(system_params)));
1131 globals_->system_url_request_job_factory.reset( 1128 globals_->system_url_request_job_factory.reset(
(...skipping 17 matching lines...) Expand all
1149 std::string group = 1146 std::string group =
1150 base::FieldTrialList::FindFullName(kQuicFieldTrialName); 1147 base::FieldTrialList::FindFullName(kQuicFieldTrialName);
1151 VariationParameters params; 1148 VariationParameters params;
1152 if (!variations::GetVariationParams(kQuicFieldTrialName, &params)) { 1149 if (!variations::GetVariationParams(kQuicFieldTrialName, &params)) {
1153 params.clear(); 1150 params.clear();
1154 } 1151 }
1155 1152
1156 ConfigureQuicGlobals(command_line, group, params, globals_); 1153 ConfigureQuicGlobals(command_line, group, params, globals_);
1157 } 1154 }
1158 1155
1159 void IOThread::SetupDataReductionProxy() {
1160 // TODO(kundaji): Move flags initialization to DataReductionProxyParams and
1161 // merge with flag initialization in
1162 // data_reduction_proxy_chrome_settings_factory.cc.
1163 int flags = data_reduction_proxy::DataReductionProxyParams::kAllowed |
1164 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed |
1165 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed;
1166 if (data_reduction_proxy::DataReductionProxyParams::
1167 IsIncludedInPromoFieldTrial()) {
1168 flags |= data_reduction_proxy::DataReductionProxyParams::kPromoAllowed;
1169 }
1170 if (data_reduction_proxy::DataReductionProxyParams::
1171 IsIncludedInHoldbackFieldTrial()) {
1172 flags |= data_reduction_proxy::DataReductionProxyParams::kHoldback;
1173 }
1174 globals_->data_reduction_proxy_params.reset(
1175 new data_reduction_proxy::DataReductionProxyParams(flags));
1176 globals_->data_reduction_proxy_auth_request_handler.reset(
1177 new data_reduction_proxy::DataReductionProxyAuthRequestHandler(
1178 DataReductionProxyChromeSettings::GetClient(),
1179 globals_->data_reduction_proxy_params.get(),
1180 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
1181 globals_->data_reduction_proxy_delegate.reset(
1182 new data_reduction_proxy::DataReductionProxyDelegate(
1183 globals_->data_reduction_proxy_auth_request_handler.get(),
1184 globals_->data_reduction_proxy_params.get()));
1185 }
1186
1187 // static 1156 // static
1188 void IOThread::ConfigureQuicGlobals( 1157 void IOThread::ConfigureQuicGlobals(
1189 const base::CommandLine& command_line, 1158 const base::CommandLine& command_line,
1190 base::StringPiece quic_trial_group, 1159 base::StringPiece quic_trial_group,
1191 const VariationParameters& quic_trial_params, 1160 const VariationParameters& quic_trial_params,
1192 IOThread::Globals* globals) { 1161 IOThread::Globals* globals) {
1193 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group); 1162 bool enable_quic = ShouldEnableQuic(command_line, quic_trial_group);
1194 globals->enable_quic.set(enable_quic); 1163 globals->enable_quic.set(enable_quic);
1195 if (enable_quic) { 1164 if (enable_quic) {
1196 globals->quic_always_require_handshake_confirmation.set( 1165 globals->quic_always_require_handshake_confirmation.set(
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 net::QuicVersionVector supported_versions = net::QuicSupportedVersions(); 1376 net::QuicVersionVector supported_versions = net::QuicSupportedVersions();
1408 for (size_t i = 0; i < supported_versions.size(); ++i) { 1377 for (size_t i = 0; i < supported_versions.size(); ++i) {
1409 net::QuicVersion version = supported_versions[i]; 1378 net::QuicVersion version = supported_versions[i];
1410 if (net::QuicVersionToString(version) == quic_version) { 1379 if (net::QuicVersionToString(version) == quic_version) {
1411 return version; 1380 return version;
1412 } 1381 }
1413 } 1382 }
1414 1383
1415 return net::QUIC_VERSION_UNSUPPORTED; 1384 return net::QUIC_VERSION_UNSUPPORTED;
1416 } 1385 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698