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

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

Issue 2299703003: Re-land: Only allow HTTP/0.9 support on default ports. (Closed)
Patch Set: Fix test Created 4 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
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/io_thread_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // dependencies and (2) make IOThread more flexible for testing. 311 // dependencies and (2) make IOThread more flexible for testing.
312 IOThread::IOThread( 312 IOThread::IOThread(
313 PrefService* local_state, 313 PrefService* local_state,
314 policy::PolicyService* policy_service, 314 policy::PolicyService* policy_service,
315 net_log::ChromeNetLog* net_log, 315 net_log::ChromeNetLog* net_log,
316 extensions::EventRouterForwarder* extension_event_router_forwarder) 316 extensions::EventRouterForwarder* extension_event_router_forwarder)
317 : net_log_(net_log), 317 : net_log_(net_log),
318 #if defined(ENABLE_EXTENSIONS) 318 #if defined(ENABLE_EXTENSIONS)
319 extension_event_router_forwarder_(extension_event_router_forwarder), 319 extension_event_router_forwarder_(extension_event_router_forwarder),
320 #endif 320 #endif
321 globals_(NULL), 321 globals_(nullptr),
322 is_quic_allowed_by_policy_(true), 322 is_quic_allowed_by_policy_(true),
323 http_09_on_non_default_ports_enabled_(false),
323 creation_time_(base::TimeTicks::Now()), 324 creation_time_(base::TimeTicks::Now()),
324 weak_factory_(this) { 325 weak_factory_(this) {
325 scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy = 326 scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy =
326 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); 327 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
327 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); 328 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes);
328 negotiate_disable_cname_lookup_.Init( 329 negotiate_disable_cname_lookup_.Init(
329 prefs::kDisableAuthNegotiateCnameLookup, local_state, 330 prefs::kDisableAuthNegotiateCnameLookup, local_state,
330 base::Bind(&IOThread::UpdateNegotiateDisableCnameLookup, 331 base::Bind(&IOThread::UpdateNegotiateDisableCnameLookup,
331 base::Unretained(this))); 332 base::Unretained(this)));
332 negotiate_disable_cname_lookup_.MoveToThread(io_thread_proxy); 333 negotiate_disable_cname_lookup_.MoveToThread(io_thread_proxy);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 pac_https_url_stripping_enabled_.Init(prefs::kPacHttpsUrlStrippingEnabled, 388 pac_https_url_stripping_enabled_.Init(prefs::kPacHttpsUrlStrippingEnabled,
388 local_state); 389 local_state);
389 pac_https_url_stripping_enabled_.MoveToThread(io_thread_proxy); 390 pac_https_url_stripping_enabled_.MoveToThread(io_thread_proxy);
390 391
391 const base::Value* value = policy_service->GetPolicies( 392 const base::Value* value = policy_service->GetPolicies(
392 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, 393 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME,
393 std::string())).GetValue(policy::key::kQuicAllowed); 394 std::string())).GetValue(policy::key::kQuicAllowed);
394 if (value) 395 if (value)
395 value->GetAsBoolean(&is_quic_allowed_by_policy_); 396 value->GetAsBoolean(&is_quic_allowed_by_policy_);
396 397
398 value = policy_service
399 ->GetPolicies(policy::PolicyNamespace(
400 policy::POLICY_DOMAIN_CHROME, std::string()))
401 .GetValue(policy::key::kHttp09OnNonDefaultPortsEnabled);
402 if (value)
403 value->GetAsBoolean(&http_09_on_non_default_ports_enabled_);
404
397 // Some unit tests use IOThread but do not initialize MetricsService. In that 405 // Some unit tests use IOThread but do not initialize MetricsService. In that
398 // case it is fine not to have |metrics_data_use_forwarder_|. 406 // case it is fine not to have |metrics_data_use_forwarder_|.
399 if (g_browser_process->metrics_service()) { 407 if (g_browser_process->metrics_service()) {
400 // Callback for updating data use prefs should be obtained on UI thread. 408 // Callback for updating data use prefs should be obtained on UI thread.
401 metrics_data_use_forwarder_ = 409 metrics_data_use_forwarder_ =
402 g_browser_process->metrics_service()->GetDataUseForwardingCallback(); 410 g_browser_process->metrics_service()->GetDataUseForwardingCallback();
403 } 411 }
404 412
405 chrome_browser_net::SetGlobalSTHDistributor( 413 chrome_browser_net::SetGlobalSTHDistributor(
406 std::unique_ptr<net::ct::STHDistributor>(new net::ct::STHDistributor())); 414 std::unique_ptr<net::ct::STHDistributor>(new net::ct::STHDistributor()));
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 // Check for OS support of TCP FastOpen, and turn it on for all connections if 608 // Check for OS support of TCP FastOpen, and turn it on for all connections if
601 // indicated by user. 609 // indicated by user.
602 // TODO(rch): Make the client socket factory a per-network session instance, 610 // TODO(rch): Make the client socket factory a per-network session instance,
603 // constructed from a NetworkSession::Params, to allow us to move this option 611 // constructed from a NetworkSession::Params, to allow us to move this option
604 // to IOThread::Globals & HttpNetworkSession::Params. 612 // to IOThread::Globals & HttpNetworkSession::Params.
605 bool always_enable_tfo_if_supported = 613 bool always_enable_tfo_if_supported =
606 command_line.HasSwitch(switches::kEnableTcpFastOpen); 614 command_line.HasSwitch(switches::kEnableTcpFastOpen);
607 net::CheckSupportAndMaybeEnableTCPFastOpen(always_enable_tfo_if_supported); 615 net::CheckSupportAndMaybeEnableTCPFastOpen(always_enable_tfo_if_supported);
608 616
609 ConfigureParamsFromFieldTrialsAndCommandLine( 617 ConfigureParamsFromFieldTrialsAndCommandLine(
610 command_line, is_quic_allowed_by_policy_, &params_); 618 command_line, is_quic_allowed_by_policy_,
619 http_09_on_non_default_ports_enabled_, &params_);
611 620
612 TRACE_EVENT_BEGIN0("startup", 621 TRACE_EVENT_BEGIN0("startup",
613 "IOThread::Init:ProxyScriptFetcherRequestContext"); 622 "IOThread::Init:ProxyScriptFetcherRequestContext");
614 globals_->proxy_script_fetcher_context.reset( 623 globals_->proxy_script_fetcher_context.reset(
615 ConstructProxyScriptFetcherContext(globals_, params_, net_log_)); 624 ConstructProxyScriptFetcherContext(globals_, params_, net_log_));
616 TRACE_EVENT_END0("startup", 625 TRACE_EVENT_END0("startup",
617 "IOThread::Init:ProxyScriptFetcherRequestContext"); 626 "IOThread::Init:ProxyScriptFetcherRequestContext");
618 627
619 #if defined(OS_MACOSX) 628 #if defined(OS_MACOSX)
620 // Start observing Keychain events. This needs to be done on the UI thread, 629 // Start observing Keychain events. This needs to be done on the UI thread,
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 context->set_http_transaction_factory( 889 context->set_http_transaction_factory(
881 globals->system_http_transaction_factory.get()); 890 globals->system_http_transaction_factory.get());
882 891
883 return context; 892 return context;
884 } 893 }
885 894
886 // static 895 // static
887 void IOThread::ConfigureParamsFromFieldTrialsAndCommandLine( 896 void IOThread::ConfigureParamsFromFieldTrialsAndCommandLine(
888 const base::CommandLine& command_line, 897 const base::CommandLine& command_line,
889 bool is_quic_allowed_by_policy, 898 bool is_quic_allowed_by_policy,
899 bool http_09_on_non_default_ports_enabled,
890 net::HttpNetworkSession::Params* params) { 900 net::HttpNetworkSession::Params* params) {
891 std::string quic_user_agent_id = chrome::GetChannelString(); 901 std::string quic_user_agent_id = chrome::GetChannelString();
892 if (!quic_user_agent_id.empty()) 902 if (!quic_user_agent_id.empty())
893 quic_user_agent_id.push_back(' '); 903 quic_user_agent_id.push_back(' ');
894 quic_user_agent_id.append( 904 quic_user_agent_id.append(
895 version_info::GetProductNameAndVersionForUserAgent()); 905 version_info::GetProductNameAndVersionForUserAgent());
896 quic_user_agent_id.push_back(' '); 906 quic_user_agent_id.push_back(' ');
897 quic_user_agent_id.append(content::BuildOSCpuInfo()); 907 quic_user_agent_id.append(content::BuildOSCpuInfo());
898 908
899 bool is_quic_force_disabled = !is_quic_allowed_by_policy || 909 bool is_quic_force_disabled = !is_quic_allowed_by_policy ||
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) 986 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors))
977 params->ignore_certificate_errors = true; 987 params->ignore_certificate_errors = true;
978 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { 988 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) {
979 params->testing_fixed_http_port = 989 params->testing_fixed_http_port =
980 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); 990 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort);
981 } 991 }
982 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { 992 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) {
983 params->testing_fixed_https_port = 993 params->testing_fixed_https_port =
984 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); 994 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort);
985 } 995 }
996
997 params->http_09_on_non_default_ports_enabled =
998 http_09_on_non_default_ports_enabled;
986 } 999 }
987 1000
988 // static 1001 // static
989 net::URLRequestContext* IOThread::ConstructProxyScriptFetcherContext( 1002 net::URLRequestContext* IOThread::ConstructProxyScriptFetcherContext(
990 IOThread::Globals* globals, 1003 IOThread::Globals* globals,
991 const net::HttpNetworkSession::Params& params, 1004 const net::HttpNetworkSession::Params& params,
992 net::NetLog* net_log) { 1005 net::NetLog* net_log) {
993 net::URLRequestContext* context = new net::URLRequestContext; 1006 net::URLRequestContext* context = new net::URLRequestContext;
994 context->set_net_log(net_log); 1007 context->set_net_log(net_log);
995 context->set_host_resolver(globals->host_resolver.get()); 1008 context->set_host_resolver(globals->host_resolver.get());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the 1070 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the
1058 // system URLRequestContext too. There's no reason this should be tied to a 1071 // system URLRequestContext too. There's no reason this should be tied to a
1059 // profile. 1072 // profile.
1060 return context; 1073 return context;
1061 } 1074 }
1062 1075
1063 const metrics::UpdateUsagePrefCallbackType& 1076 const metrics::UpdateUsagePrefCallbackType&
1064 IOThread::GetMetricsDataUseForwarder() { 1077 IOThread::GetMetricsDataUseForwarder() {
1065 return metrics_data_use_forwarder_; 1078 return metrics_data_use_forwarder_;
1066 } 1079 }
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.h ('k') | chrome/browser/io_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698