| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "chrome/common/chrome_switches.h" | 46 #include "chrome/common/chrome_switches.h" |
| 47 #include "chrome/common/pref_names.h" | 47 #include "chrome/common/pref_names.h" |
| 48 #include "components/certificate_transparency/tree_state_tracker.h" | 48 #include "components/certificate_transparency/tree_state_tracker.h" |
| 49 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" | 49 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" |
| 50 #include "components/data_usage/core/data_use_aggregator.h" | 50 #include "components/data_usage/core/data_use_aggregator.h" |
| 51 #include "components/data_usage/core/data_use_amortizer.h" | 51 #include "components/data_usage/core/data_use_amortizer.h" |
| 52 #include "components/data_usage/core/data_use_annotator.h" | 52 #include "components/data_usage/core/data_use_annotator.h" |
| 53 #include "components/data_use_measurement/core/data_use_ascriber.h" | 53 #include "components/data_use_measurement/core/data_use_ascriber.h" |
| 54 #include "components/metrics/metrics_service.h" | 54 #include "components/metrics/metrics_service.h" |
| 55 #include "components/net_log/chrome_net_log.h" | 55 #include "components/net_log/chrome_net_log.h" |
| 56 #include "components/network_session_configurator/network_session_configurator.h
" | 56 #include "components/network_session_configurator/browser/network_session_config
urator.h" |
| 57 #include "components/policy/core/common/policy_service.h" | 57 #include "components/policy/core/common/policy_service.h" |
| 58 #include "components/policy/policy_constants.h" | 58 #include "components/policy/policy_constants.h" |
| 59 #include "components/prefs/pref_registry_simple.h" | 59 #include "components/prefs/pref_registry_simple.h" |
| 60 #include "components/prefs/pref_service.h" | 60 #include "components/prefs/pref_service.h" |
| 61 #include "components/proxy_config/pref_proxy_config_tracker.h" | 61 #include "components/proxy_config/pref_proxy_config_tracker.h" |
| 62 #include "components/variations/variations_associated_data.h" | 62 #include "components/variations/variations_associated_data.h" |
| 63 #include "components/version_info/version_info.h" | 63 #include "components/version_info/version_info.h" |
| 64 #include "content/public/browser/browser_thread.h" | 64 #include "content/public/browser/browser_thread.h" |
| 65 #include "content/public/browser/cookie_store_factory.h" | 65 #include "content/public/browser/cookie_store_factory.h" |
| 66 #include "content/public/browser/network_quality_observer_factory.h" | 66 #include "content/public/browser/network_quality_observer_factory.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 if (!command_line.HasSwitch(switches::kHostResolverRules)) | 238 if (!command_line.HasSwitch(switches::kHostResolverRules)) |
| 239 return global_host_resolver; | 239 return global_host_resolver; |
| 240 | 240 |
| 241 std::unique_ptr<net::MappedHostResolver> remapped_resolver( | 241 std::unique_ptr<net::MappedHostResolver> remapped_resolver( |
| 242 new net::MappedHostResolver(std::move(global_host_resolver))); | 242 new net::MappedHostResolver(std::move(global_host_resolver))); |
| 243 remapped_resolver->SetRulesFromString( | 243 remapped_resolver->SetRulesFromString( |
| 244 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); | 244 command_line.GetSwitchValueASCII(switches::kHostResolverRules)); |
| 245 return std::move(remapped_resolver); | 245 return std::move(remapped_resolver); |
| 246 } | 246 } |
| 247 | 247 |
| 248 int GetSwitchValueAsInt(const base::CommandLine& command_line, | |
| 249 const std::string& switch_name) { | |
| 250 int value; | |
| 251 if (!base::StringToInt(command_line.GetSwitchValueASCII(switch_name), | |
| 252 &value)) { | |
| 253 return 0; | |
| 254 } | |
| 255 return value; | |
| 256 } | |
| 257 | |
| 258 // This function is for forwarding metrics usage pref changes to the metrics | 248 // This function is for forwarding metrics usage pref changes to the metrics |
| 259 // service on the appropriate thread. | 249 // service on the appropriate thread. |
| 260 // TODO(gayane): Reduce the frequency of posting tasks from IO to UI thread. | 250 // TODO(gayane): Reduce the frequency of posting tasks from IO to UI thread. |
| 261 void UpdateMetricsUsagePrefsOnUIThread(const std::string& service_name, | 251 void UpdateMetricsUsagePrefsOnUIThread(const std::string& service_name, |
| 262 int message_size, | 252 int message_size, |
| 263 bool is_cellular) { | 253 bool is_cellular) { |
| 264 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 254 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 265 base::BindOnce( | 255 base::BindOnce( |
| 266 [](const std::string& service_name, | 256 [](const std::string& service_name, |
| 267 int message_size, bool is_cellular) { | 257 int message_size, bool is_cellular) { |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 bool http_09_on_non_default_ports_enabled, | 927 bool http_09_on_non_default_ports_enabled, |
| 938 net::HttpNetworkSession::Params* params) { | 928 net::HttpNetworkSession::Params* params) { |
| 939 std::string quic_user_agent_id = chrome::GetChannelString(); | 929 std::string quic_user_agent_id = chrome::GetChannelString(); |
| 940 if (!quic_user_agent_id.empty()) | 930 if (!quic_user_agent_id.empty()) |
| 941 quic_user_agent_id.push_back(' '); | 931 quic_user_agent_id.push_back(' '); |
| 942 quic_user_agent_id.append( | 932 quic_user_agent_id.append( |
| 943 version_info::GetProductNameAndVersionForUserAgent()); | 933 version_info::GetProductNameAndVersionForUserAgent()); |
| 944 quic_user_agent_id.push_back(' '); | 934 quic_user_agent_id.push_back(' '); |
| 945 quic_user_agent_id.append(content::BuildOSCpuInfo()); | 935 quic_user_agent_id.append(content::BuildOSCpuInfo()); |
| 946 | 936 |
| 947 bool is_quic_force_disabled = !is_quic_allowed_by_policy || | 937 network_session_configurator::ParseCommandLineAndFieldTrials( |
| 948 command_line.HasSwitch(switches::kDisableQuic); | 938 command_line, !is_quic_allowed_by_policy, quic_user_agent_id, params); |
| 949 bool is_quic_force_enabled = command_line.HasSwitch(switches::kEnableQuic); | |
| 950 | 939 |
| 951 network_session_configurator::ParseFieldTrials(is_quic_force_disabled, | |
| 952 is_quic_force_enabled, | |
| 953 quic_user_agent_id, params); | |
| 954 | |
| 955 // Command line flags override field trials. | |
| 956 if (command_line.HasSwitch(switches::kIgnoreUrlFetcherCertRequests)) | 940 if (command_line.HasSwitch(switches::kIgnoreUrlFetcherCertRequests)) |
| 957 net::URLFetcher::SetIgnoreCertificateRequests(true); | 941 net::URLFetcher::SetIgnoreCertificateRequests(true); |
| 958 | 942 |
| 959 if (command_line.HasSwitch(switches::kDisableHttp2)) | |
| 960 params->enable_http2 = false; | |
| 961 | |
| 962 if (params->enable_quic) { | |
| 963 if (command_line.HasSwitch(switches::kQuicConnectionOptions)) { | |
| 964 params->quic_connection_options = | |
| 965 net::ParseQuicConnectionOptions( | |
| 966 command_line.GetSwitchValueASCII( | |
| 967 switches::kQuicConnectionOptions)); | |
| 968 } | |
| 969 | |
| 970 if (command_line.HasSwitch(switches::kQuicMaxPacketLength)) { | |
| 971 unsigned value; | |
| 972 if (base::StringToUint( | |
| 973 command_line.GetSwitchValueASCII(switches::kQuicMaxPacketLength), | |
| 974 &value)) { | |
| 975 params->quic_max_packet_length = value; | |
| 976 } | |
| 977 } | |
| 978 | |
| 979 if (command_line.HasSwitch(switches::kQuicVersion)) { | |
| 980 net::QuicVersion version = network_session_configurator::ParseQuicVersion( | |
| 981 command_line.GetSwitchValueASCII(switches::kQuicVersion)); | |
| 982 if (version != net::QUIC_VERSION_UNSUPPORTED) { | |
| 983 net::QuicVersionVector supported_versions; | |
| 984 supported_versions.push_back(version); | |
| 985 params->quic_supported_versions = supported_versions; | |
| 986 } | |
| 987 } | |
| 988 | |
| 989 if (command_line.HasSwitch(switches::kOriginToForceQuicOn)) { | |
| 990 std::string origins = | |
| 991 command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn); | |
| 992 for (const std::string& host_port : base::SplitString( | |
| 993 origins, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { | |
| 994 if (host_port == "*") | |
| 995 params->origins_to_force_quic_on.insert(net::HostPortPair()); | |
| 996 net::HostPortPair quic_origin = | |
| 997 net::HostPortPair::FromString(host_port); | |
| 998 if (!quic_origin.IsEmpty()) | |
| 999 params->origins_to_force_quic_on.insert(quic_origin); | |
| 1000 } | |
| 1001 } | |
| 1002 } | |
| 1003 | |
| 1004 // Parameters only controlled by command line. | |
| 1005 if (command_line.HasSwitch(switches::kEnableUserAlternateProtocolPorts)) { | |
| 1006 params->enable_user_alternate_protocol_ports = true; | |
| 1007 } | |
| 1008 if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) { | |
| 1009 params->ignore_certificate_errors = true; | |
| 1010 } | |
| 1011 UMA_HISTOGRAM_BOOLEAN( | |
| 1012 "Net.Certificate.IgnoreErrors", | |
| 1013 command_line.HasSwitch(switches::kIgnoreCertificateErrors)); | |
| 1014 if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { | |
| 1015 params->testing_fixed_http_port = | |
| 1016 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); | |
| 1017 } | |
| 1018 if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { | |
| 1019 params->testing_fixed_https_port = | |
| 1020 GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); | |
| 1021 } | |
| 1022 | |
| 1023 params->http_09_on_non_default_ports_enabled = | 943 params->http_09_on_non_default_ports_enabled = |
| 1024 http_09_on_non_default_ports_enabled; | 944 http_09_on_non_default_ports_enabled; |
| 1025 } | 945 } |
| 1026 | 946 |
| 1027 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() { | 947 metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() { |
| 1028 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread); | 948 return base::Bind(&UpdateMetricsUsagePrefsOnUIThread); |
| 1029 } | 949 } |
| OLD | NEW |