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 <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 Loading... |
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 Loading... |
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 Loading... |
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_, ¶ms_); | 618 command_line, is_quic_allowed_by_policy_, |
| 619 http_09_on_non_default_ports_enabled_, ¶ms_); |
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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 context->set_http_transaction_factory( | 888 context->set_http_transaction_factory( |
880 globals->system_http_transaction_factory.get()); | 889 globals->system_http_transaction_factory.get()); |
881 | 890 |
882 return context; | 891 return context; |
883 } | 892 } |
884 | 893 |
885 // static | 894 // static |
886 void IOThread::ConfigureParamsFromFieldTrialsAndCommandLine( | 895 void IOThread::ConfigureParamsFromFieldTrialsAndCommandLine( |
887 const base::CommandLine& command_line, | 896 const base::CommandLine& command_line, |
888 bool is_quic_allowed_by_policy, | 897 bool is_quic_allowed_by_policy, |
| 898 bool http_09_on_non_default_ports_enabled, |
889 net::HttpNetworkSession::Params* params) { | 899 net::HttpNetworkSession::Params* params) { |
890 std::string quic_user_agent_id = chrome::GetChannelString(); | 900 std::string quic_user_agent_id = chrome::GetChannelString(); |
891 if (!quic_user_agent_id.empty()) | 901 if (!quic_user_agent_id.empty()) |
892 quic_user_agent_id.push_back(' '); | 902 quic_user_agent_id.push_back(' '); |
893 quic_user_agent_id.append( | 903 quic_user_agent_id.append( |
894 version_info::GetProductNameAndVersionForUserAgent()); | 904 version_info::GetProductNameAndVersionForUserAgent()); |
895 quic_user_agent_id.push_back(' '); | 905 quic_user_agent_id.push_back(' '); |
896 quic_user_agent_id.append(content::BuildOSCpuInfo()); | 906 quic_user_agent_id.append(content::BuildOSCpuInfo()); |
897 | 907 |
898 bool is_quic_force_disabled = !is_quic_allowed_by_policy || | 908 bool is_quic_force_disabled = !is_quic_allowed_by_policy || |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) | 985 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) |
976 params->ignore_certificate_errors = true; | 986 params->ignore_certificate_errors = true; |
977 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { | 987 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { |
978 params->testing_fixed_http_port = | 988 params->testing_fixed_http_port = |
979 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); | 989 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); |
980 } | 990 } |
981 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { | 991 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { |
982 params->testing_fixed_https_port = | 992 params->testing_fixed_https_port = |
983 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); | 993 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); |
984 } | 994 } |
| 995 |
| 996 params->http_09_on_non_default_ports_enabled = |
| 997 http_09_on_non_default_ports_enabled; |
985 } | 998 } |
986 | 999 |
987 // static | 1000 // static |
988 net::URLRequestContext* IOThread::ConstructProxyScriptFetcherContext( | 1001 net::URLRequestContext* IOThread::ConstructProxyScriptFetcherContext( |
989 IOThread::Globals* globals, | 1002 IOThread::Globals* globals, |
990 const net::HttpNetworkSession::Params& params, | 1003 const net::HttpNetworkSession::Params& params, |
991 net::NetLog* net_log) { | 1004 net::NetLog* net_log) { |
992 net::URLRequestContext* context = new net::URLRequestContext; | 1005 net::URLRequestContext* context = new net::URLRequestContext; |
993 context->set_net_log(net_log); | 1006 context->set_net_log(net_log); |
994 context->set_host_resolver(globals->host_resolver.get()); | 1007 context->set_host_resolver(globals->host_resolver.get()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 1069 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
1057 // system URLRequestContext too. There's no reason this should be tied to a | 1070 // system URLRequestContext too. There's no reason this should be tied to a |
1058 // profile. | 1071 // profile. |
1059 return context; | 1072 return context; |
1060 } | 1073 } |
1061 | 1074 |
1062 const metrics::UpdateUsagePrefCallbackType& | 1075 const metrics::UpdateUsagePrefCallbackType& |
1063 IOThread::GetMetricsDataUseForwarder() { | 1076 IOThread::GetMetricsDataUseForwarder() { |
1064 return metrics_data_use_forwarder_; | 1077 return metrics_data_use_forwarder_; |
1065 } | 1078 } |
OLD | NEW |