[email protected] | d24fc3a0 | 2012-02-11 02:08:34 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/io_thread.h" |
[email protected] | e83326f | 2010-07-31 17:29:25 | [diff] [blame] | 6 | |
dcheng | e73d8520c | 2015-12-27 01:19:09 | [diff] [blame] | 7 | #include <utility> |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 8 | #include <vector> |
| 9 | |
[email protected] | 284303b6 | 2013-11-28 15:11:54 | [diff] [blame] | 10 | #include "base/base64.h" |
[email protected] | 21ee224e | 2011-11-21 02:17:53 | [diff] [blame] | 11 | #include "base/bind.h" |
| 12 | #include "base/bind_helpers.h" |
[email protected] | aa84a7e | 2012-03-15 21:29:06 | [diff] [blame] | 13 | #include "base/command_line.h" |
[email protected] | c93123fa | 2012-04-19 02:49:48 | [diff] [blame] | 14 | #include "base/compiler_specific.h" |
[email protected] | 5858035 | 2010-10-26 04:07:50 | [diff] [blame] | 15 | #include "base/debug/leak_tracker.h" |
zhongyi | 81f85c6d9 | 2015-10-16 19:34:14 | [diff] [blame] | 16 | #include "base/environment.h" |
davidben | 2a811e4e | 2015-12-01 10:49:34 | [diff] [blame] | 17 | #include "base/files/file_path.h" |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 18 | #include "base/logging.h" |
avi | 6846aef | 2015-12-26 01:09:38 | [diff] [blame] | 19 | #include "base/macros.h" |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 20 | #include "base/memory/ptr_util.h" |
[email protected] | 903e6338 | 2013-06-01 00:40:58 | [diff] [blame] | 21 | #include "base/metrics/field_trial.h" |
davidben | 45eb1995 | 2016-05-05 16:30:44 | [diff] [blame] | 22 | #include "base/metrics/histogram_macros.h" |
Gabriel Charette | 5ff87ce | 2017-05-16 18:03:45 | [diff] [blame] | 23 | #include "base/single_thread_task_runner.h" |
[email protected] | 7286e3fc | 2011-07-19 22:13:24 | [diff] [blame] | 24 | #include "base/stl_util.h" |
[email protected] | 3ea1b18 | 2013-02-08 22:38:41 | [diff] [blame] | 25 | #include "base/strings/string_number_conversions.h" |
bnc | e3553d9 | 2014-10-30 22:29:45 | [diff] [blame] | 26 | #include "base/strings/string_piece.h" |
[email protected] | 1988e1c | 2013-02-28 20:27:42 | [diff] [blame] | 27 | #include "base/strings/string_split.h" |
[email protected] | 9c7ddc9 | 2013-06-11 01:40:57 | [diff] [blame] | 28 | #include "base/strings/string_util.h" |
davidben | 2a811e4e | 2015-12-01 10:49:34 | [diff] [blame] | 29 | #include "base/strings/utf_string_conversions.h" |
fdoray | dd7eb40 | 2017-04-26 21:44:25 | [diff] [blame] | 30 | #include "base/task_scheduler/post_task.h" |
[email protected] | 3fc40c14 | 2011-12-01 13:09:04 | [diff] [blame] | 31 | #include "base/threading/thread.h" |
[email protected] | d827e11 | 2014-03-31 17:45:05 | [diff] [blame] | 32 | #include "base/time/time.h" |
primiano | 6221e57 | 2015-01-28 12:14:34 | [diff] [blame] | 33 | #include "base/trace_event/trace_event.h" |
[email protected] | addb324 | 2011-06-13 21:39:16 | [diff] [blame] | 34 | #include "build/build_config.h" |
[email protected] | df2840d | 2011-02-20 16:32:32 | [diff] [blame] | 35 | #include "chrome/browser/browser_process.h" |
sclittle | a133de0 | 2015-11-10 23:54:21 | [diff] [blame] | 36 | #include "chrome/browser/data_usage/tab_id_annotator.h" |
kundaji | f617523b | 2016-09-09 22:41:24 | [diff] [blame] | 37 | #include "chrome/browser/data_use_measurement/chrome_data_use_ascriber.h" |
[email protected] | 026876f3 | 2012-08-22 23:53:40 | [diff] [blame] | 38 | #include "chrome/browser/net/async_dns_field_trial.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 39 | #include "chrome/browser/net/chrome_network_delegate.h" |
[email protected] | 4588b3d | 2012-11-14 00:37:38 | [diff] [blame] | 40 | #include "chrome/browser/net/dns_probe_service.h" |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 41 | #include "chrome/browser/net/proxy_service_factory.h" |
eranm | 3c2d643 | 2016-06-01 10:17:27 | [diff] [blame] | 42 | #include "chrome/browser/net/sth_distributor_provider.h" |
martinkr | 8402d3c | 2017-05-23 20:10:47 | [diff] [blame] | 43 | #include "chrome/browser/ssl/ignore_errors_cert_verifier.h" |
sdefresne | 9fb6769 | 2015-08-03 18:48:22 | [diff] [blame] | 44 | #include "chrome/common/channel_info.h" |
[email protected] | aa05127 | 2014-03-10 05:56:56 | [diff] [blame] | 45 | #include "chrome/common/chrome_content_client.h" |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 46 | #include "chrome/common/chrome_switches.h" |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 47 | #include "chrome/common/pref_names.h" |
eranm | 3c2d643 | 2016-06-01 10:17:27 | [diff] [blame] | 48 | #include "components/certificate_transparency/tree_state_tracker.h" |
megjablon | 3476e04 | 2014-10-14 19:21:59 | [diff] [blame] | 49 | #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.h" |
sclittle | 3f98c6c | 2015-11-19 22:59:29 | [diff] [blame] | 50 | #include "components/data_usage/core/data_use_aggregator.h" |
sclittle | c441f78 | 2015-11-12 01:12:09 | [diff] [blame] | 51 | #include "components/data_usage/core/data_use_amortizer.h" |
sclittle | 3f98c6c | 2015-11-19 22:59:29 | [diff] [blame] | 52 | #include "components/data_usage/core/data_use_annotator.h" |
kundaji | c613596 | 2016-09-26 17:54:28 | [diff] [blame] | 53 | #include "components/data_use_measurement/core/data_use_ascriber.h" |
gayane | 0b46091c | 2016-04-07 21:01:05 | [diff] [blame] | 54 | #include "components/metrics/metrics_service.h" |
droger | c690e880 | 2015-09-21 14:29:16 | [diff] [blame] | 55 | #include "components/net_log/chrome_net_log.h" |
bnc | 210d6f3 | 2016-05-24 07:40:47 | [diff] [blame] | 56 | #include "components/network_session_configurator/network_session_configurator.h" |
[email protected] | 76b4b15 | 2013-12-08 21:10:04 | [diff] [blame] | 57 | #include "components/policy/core/common/policy_service.h" |
brettw | 39d6ba4 | 2016-08-24 16:56:38 | [diff] [blame] | 58 | #include "components/policy/policy_constants.h" |
brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 59 | #include "components/prefs/pref_registry_simple.h" |
| 60 | #include "components/prefs/pref_service.h" |
abhishek.a21 | 71c61285 | 2015-08-31 10:48:19 | [diff] [blame] | 61 | #include "components/proxy_config/pref_proxy_config_tracker.h" |
[email protected] | 488a0e25 | 2014-06-25 04:37:44 | [diff] [blame] | 62 | #include "components/variations/variations_associated_data.h" |
sdefresne | 9fb6769 | 2015-08-03 18:48:22 | [diff] [blame] | 63 | #include "components/version_info/version_info.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 64 | #include "content/public/browser/browser_thread.h" |
[email protected] | 7c4b66b | 2014-01-04 12:28:13 | [diff] [blame] | 65 | #include "content/public/browser/cookie_store_factory.h" |
tbansal | 15973c3 | 2017-05-10 18:40:44 | [diff] [blame] | 66 | #include "content/public/browser/network_quality_observer_factory.h" |
eustas | fbec913 | 2015-12-30 14:56:51 | [diff] [blame] | 67 | #include "content/public/common/content_features.h" |
brettw | 90e9260 | 2015-10-10 00:12:40 | [diff] [blame] | 68 | #include "content/public/common/content_switches.h" |
rtenneti | 4d126a7 | 2015-06-23 17:32:09 | [diff] [blame] | 69 | #include "content/public/common/user_agent.h" |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 70 | #include "extensions/features/features.h" |
[email protected] | c2dad29 | 2012-09-07 21:27:35 | [diff] [blame] | 71 | #include "net/base/host_mapping_rules.h" |
pauljensen | 7b34e52 | 2016-05-12 18:20:59 | [diff] [blame] | 72 | #include "net/base/logging_network_change_observer.h" |
rdsmith | 60e6e6fb | 2015-03-05 16:49:20 | [diff] [blame] | 73 | #include "net/base/sdch_manager.h" |
rsleevi | 6df5418 | 2016-06-13 14:34:23 | [diff] [blame] | 74 | #include "net/cert/caching_cert_verifier.h" |
[email protected] | 6e7845ae | 2013-03-29 21:48:11 | [diff] [blame] | 75 | #include "net/cert/cert_verifier.h" |
[email protected] | f46f6d5 | 2014-02-08 04:00:39 | [diff] [blame] | 76 | #include "net/cert/cert_verify_proc.h" |
[email protected] | 284303b6 | 2013-11-28 15:11:54 | [diff] [blame] | 77 | #include "net/cert/ct_known_logs.h" |
davidben | eb5f8ef3 | 2014-09-04 14:14:32 | [diff] [blame] | 78 | #include "net/cert/ct_log_verifier.h" |
estark | 6f9b3d8 | 2016-01-12 21:37:05 | [diff] [blame] | 79 | #include "net/cert/ct_policy_enforcer.h" |
[email protected] | 284303b6 | 2013-11-28 15:11:54 | [diff] [blame] | 80 | #include "net/cert/ct_verifier.h" |
davidben | eb5f8ef3 | 2014-09-04 14:14:32 | [diff] [blame] | 81 | #include "net/cert/multi_log_ct_verifier.h" |
[email protected] | f46f6d5 | 2014-02-08 04:00:39 | [diff] [blame] | 82 | #include "net/cert/multi_threaded_cert_verifier.h" |
eranm | 3c2d643 | 2016-06-01 10:17:27 | [diff] [blame] | 83 | #include "net/cert/sth_distributor.h" |
| 84 | #include "net/cert/sth_observer.h" |
[email protected] | 9a6c2aa | 2014-01-11 22:39:39 | [diff] [blame] | 85 | #include "net/cookies/cookie_store.h" |
[email protected] | bc71b877 | 2013-04-10 20:55:16 | [diff] [blame] | 86 | #include "net/dns/host_cache.h" |
[email protected] | f2cb3cf | 2013-03-21 01:40:53 | [diff] [blame] | 87 | #include "net/dns/host_resolver.h" |
| 88 | #include "net/dns/mapped_host_resolver.h" |
[email protected] | eb3cac7 | 2010-02-26 21:07:45 | [diff] [blame] | 89 | #include "net/http/http_auth_filter.h" |
[email protected] | fa55e19 | 2010-02-15 14:25:50 | [diff] [blame] | 90 | #include "net/http/http_auth_handler_factory.h" |
aberent | bba302d | 2015-12-03 10:20:19 | [diff] [blame] | 91 | #include "net/http/http_auth_preferences.h" |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 92 | #include "net/http/http_network_layer.h" |
[email protected] | 17291a02 | 2011-10-10 07:32:53 | [diff] [blame] | 93 | #include "net/http/http_server_properties_impl.h" |
brettw | a1228ebb | 2016-10-28 03:51:34 | [diff] [blame] | 94 | #include "net/net_features.h" |
tbansal | ca83c00 | 2016-04-28 20:56:28 | [diff] [blame] | 95 | #include "net/nqe/external_estimate_provider.h" |
tbansal | d3e08ca6 | 2017-05-04 19:51:09 | [diff] [blame] | 96 | #include "net/nqe/network_quality_estimator_params.h" |
[email protected] | 6104ea5d | 2011-04-27 21:37:12 | [diff] [blame] | 97 | #include "net/proxy/proxy_config_service.h" |
[email protected] | 8693361 | 2010-10-16 23:10:33 | [diff] [blame] | 98 | #include "net/proxy/proxy_script_fetcher_impl.h" |
[email protected] | 6104ea5d | 2011-04-27 21:37:12 | [diff] [blame] | 99 | #include "net/proxy/proxy_service.h" |
rch | 4c967ea | 2016-12-22 01:41:07 | [diff] [blame] | 100 | #include "net/quic/chromium/quic_utils_chromium.h" |
zhongyi | 81f85c6d9 | 2015-10-16 19:34:14 | [diff] [blame] | 101 | #include "net/socket/ssl_client_socket.h" |
[email protected] | 717e4e2 | 2013-04-10 20:52:23 | [diff] [blame] | 102 | #include "net/socket/tcp_client_socket.h" |
[email protected] | 6b8a3c74 | 2014-07-25 00:25:35 | [diff] [blame] | 103 | #include "net/ssl/channel_id_service.h" |
| 104 | #include "net/ssl/default_channel_id_store.h" |
[email protected] | b3ae2db | 2013-05-30 05:00:05 | [diff] [blame] | 105 | #include "net/url_request/data_protocol_handler.h" |
| 106 | #include "net/url_request/file_protocol_handler.h" |
| 107 | #include "net/url_request/ftp_protocol_handler.h" |
[email protected] | aa05127 | 2014-03-10 05:56:56 | [diff] [blame] | 108 | #include "net/url_request/static_http_user_agent_settings.h" |
[email protected] | 3dc1bc4 | 2012-06-19 08:20:53 | [diff] [blame] | 109 | #include "net/url_request/url_fetcher.h" |
[email protected] | f9c8c7c | 2014-07-31 16:42:31 | [diff] [blame] | 110 | #include "net/url_request/url_request_context.h" |
wjmaclean | ea309f7 | 2015-08-25 20:56:59 | [diff] [blame] | 111 | #include "net/url_request/url_request_context_builder.h" |
[email protected] | f9c8c7c | 2014-07-31 16:42:31 | [diff] [blame] | 112 | #include "net/url_request/url_request_context_getter.h" |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 113 | #include "net/url_request/url_request_context_storage.h" |
[email protected] | b3ae2db | 2013-05-30 05:00:05 | [diff] [blame] | 114 | #include "net/url_request/url_request_job_factory_impl.h" |
brettw | 03e6196 | 2016-03-15 06:27:04 | [diff] [blame] | 115 | #include "url/url_constants.h" |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 116 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 117 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | 84b7a55 | 2014-07-19 04:52:06 | [diff] [blame] | 118 | #include "chrome/browser/extensions/event_router_forwarder.h" |
| 119 | #endif |
| 120 | |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 121 | #if defined(USE_NSS_CERTS) |
eroman | ed744f3 | 2015-04-09 06:35:49 | [diff] [blame] | 122 | #include "net/cert_net/nss_ocsp.h" |
[email protected] | a592c043 | 2012-12-01 18:10:29 | [diff] [blame] | 123 | #endif |
[email protected] | 77feb46 | 2011-05-16 23:37:25 | [diff] [blame] | 124 | |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 125 | #if defined(OS_ANDROID) |
jeremyim | b6c97ae | 2015-01-05 22:57:14 | [diff] [blame] | 126 | #include "base/android/build_info.h" |
megjablon | 174bc34 | 2015-11-05 00:30:06 | [diff] [blame] | 127 | #include "chrome/browser/android/data_usage/external_data_use_observer.h" |
tbansal | dafbb3e | 2015-08-19 19:55:33 | [diff] [blame] | 128 | #include "chrome/browser/android/net/external_estimate_provider_android.h" |
sclittle | c441f78 | 2015-11-12 01:12:09 | [diff] [blame] | 129 | #include "components/data_usage/android/traffic_stats_amortizer.h" |
estark | 9a26378 | 2017-01-20 02:13:04 | [diff] [blame] | 130 | #include "net/cert/cert_net_fetcher.h" |
| 131 | #include "net/cert/cert_verify_proc_android.h" |
| 132 | #include "net/cert_net/cert_net_fetcher_impl.h" |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 133 | #endif // defined(OS_ANDROID) |
jeremyim | b6c97ae | 2015-01-05 22:57:14 | [diff] [blame] | 134 | |
[email protected] | f46f6d5 | 2014-02-08 04:00:39 | [diff] [blame] | 135 | #if defined(OS_CHROMEOS) |
| 136 | #include "chrome/browser/chromeos/net/cert_verify_proc_chromeos.h" |
zentaro | e032635 | 2017-05-09 13:11:51 | [diff] [blame] | 137 | #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
[email protected] | 106ccd2c | 2014-06-17 09:21:00 | [diff] [blame] | 138 | #include "chromeos/network/host_resolver_impl_chromeos.h" |
[email protected] | f46f6d5 | 2014-02-08 04:00:39 | [diff] [blame] | 139 | #endif |
| 140 | |
davidben | 45eb1995 | 2016-05-05 16:30:44 | [diff] [blame] | 141 | #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
davidben | 45eb1995 | 2016-05-05 16:30:44 | [diff] [blame] | 142 | #include "crypto/openssl_util.h" |
tfarina | 29a3a174 | 2016-10-28 18:47:33 | [diff] [blame] | 143 | #include "third_party/boringssl/src/include/openssl/cpu.h" |
davidben | 45eb1995 | 2016-05-05 16:30:44 | [diff] [blame] | 144 | #endif |
| 145 | |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 146 | using content::BrowserThread; |
| 147 | |
[email protected] | 075c032 | 2012-02-14 00:56:44 | [diff] [blame] | 148 | class SafeBrowsingURLRequestContext; |
| 149 | |
[email protected] | 21ee224e | 2011-11-21 02:17:53 | [diff] [blame] | 150 | // The IOThread object must outlive any tasks posted to the IO thread before the |
| 151 | // Quit task, so base::Bind() calls are not refcounted. |
| 152 | |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 153 | namespace { |
| 154 | |
tbansal | b177b539 | 2015-06-25 11:13:02 | [diff] [blame] | 155 | // Field trial for network quality estimator. Seeds RTT and downstream |
| 156 | // throughput observations with values that correspond to the connection type |
| 157 | // determined by the operating system. |
| 158 | const char kNetworkQualityEstimatorFieldTrialName[] = "NetworkQualityEstimator"; |
| 159 | |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 160 | #if defined(OS_MACOSX) |
[email protected] | 11f5e3a | 2012-09-27 00:30:13 | [diff] [blame] | 161 | void ObserveKeychainEvents() { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 162 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | 11f5e3a | 2012-09-27 00:30:13 | [diff] [blame] | 163 | net::CertDatabase::GetInstance()->SetMessageLoopForKeychainEvents(); |
| 164 | } |
| 165 | #endif |
| 166 | |
zhongyi | 81f85c6d9 | 2015-10-16 19:34:14 | [diff] [blame] | 167 | // Gets file path into ssl_keylog_file from command line argument or |
| 168 | // environment variable. Command line argument has priority when |
| 169 | // both specified. |
davidben | 2a811e4e | 2015-12-01 10:49:34 | [diff] [blame] | 170 | base::FilePath GetSSLKeyLogFile(const base::CommandLine& command_line) { |
zhongyi | 81f85c6d9 | 2015-10-16 19:34:14 | [diff] [blame] | 171 | if (command_line.HasSwitch(switches::kSSLKeyLogFile)) { |
davidben | 2a811e4e | 2015-12-01 10:49:34 | [diff] [blame] | 172 | base::FilePath path = |
| 173 | command_line.GetSwitchValuePath(switches::kSSLKeyLogFile); |
| 174 | if (!path.empty()) |
| 175 | return path; |
zhongyi | 81f85c6d9 | 2015-10-16 19:34:14 | [diff] [blame] | 176 | LOG(WARNING) << "ssl-key-log-file argument missing"; |
| 177 | } |
davidben | 2a811e4e | 2015-12-01 10:49:34 | [diff] [blame] | 178 | |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 179 | std::unique_ptr<base::Environment> env(base::Environment::Create()); |
davidben | 2a811e4e | 2015-12-01 10:49:34 | [diff] [blame] | 180 | std::string path_str; |
| 181 | env->GetVar("SSLKEYLOGFILE", &path_str); |
| 182 | #if defined(OS_WIN) |
| 183 | // base::Environment returns environment variables in UTF-8 on Windows. |
| 184 | return base::FilePath(base::UTF8ToUTF16(path_str)); |
| 185 | #else |
| 186 | return base::FilePath(path_str); |
| 187 | #endif |
zhongyi | 81f85c6d9 | 2015-10-16 19:34:14 | [diff] [blame] | 188 | } |
| 189 | |
[email protected] | ee4c30d | 2012-11-07 15:08:43 | [diff] [blame] | 190 | // Used for the "system" URLRequestContext. |
| 191 | class SystemURLRequestContext : public net::URLRequestContext { |
[email protected] | 77feb46 | 2011-05-16 23:37:25 | [diff] [blame] | 192 | public: |
| 193 | SystemURLRequestContext() { |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 194 | #if defined(USE_NSS_CERTS) |
[email protected] | 8c434cbc | 2012-03-14 14:25:09 | [diff] [blame] | 195 | net::SetURLRequestContextForNSSHttpIO(this); |
[email protected] | a592c043 | 2012-12-01 18:10:29 | [diff] [blame] | 196 | #endif |
estark | 9a26378 | 2017-01-20 02:13:04 | [diff] [blame] | 197 | #if defined(OS_ANDROID) |
| 198 | net::CertVerifyProcAndroid::SetCertNetFetcher( |
| 199 | net::CreateCertNetFetcher(this)); |
| 200 | #endif |
[email protected] | 77feb46 | 2011-05-16 23:37:25 | [diff] [blame] | 201 | } |
| 202 | |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 203 | ~SystemURLRequestContext() override { |
[email protected] | 42455949 | 2014-07-22 00:27:40 | [diff] [blame] | 204 | AssertNoURLRequests(); |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 205 | #if defined(USE_NSS_CERTS) |
[email protected] | 8c434cbc | 2012-03-14 14:25:09 | [diff] [blame] | 206 | net::SetURLRequestContextForNSSHttpIO(NULL); |
[email protected] | a592c043 | 2012-12-01 18:10:29 | [diff] [blame] | 207 | #endif |
mmenke | 02505da | 2017-05-15 16:37:34 | [diff] [blame] | 208 | |
| 209 | #if defined(OS_ANDROID) |
| 210 | net::CertVerifyProcAndroid::ShutdownCertNetFetcher(); |
| 211 | #endif |
[email protected] | 77feb46 | 2011-05-16 23:37:25 | [diff] [blame] | 212 | } |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 213 | |
| 214 | private: |
| 215 | DISALLOW_COPY_AND_ASSIGN(SystemURLRequestContext); |
[email protected] | 77feb46 | 2011-05-16 23:37:25 | [diff] [blame] | 216 | }; |
| 217 | |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 218 | std::unique_ptr<net::HostResolver> CreateGlobalHostResolver( |
| 219 | net::NetLog* net_log) { |
[email protected] | d22f06e | 2013-06-11 16:01:17 | [diff] [blame] | 220 | TRACE_EVENT0("startup", "IOThread::CreateGlobalHostResolver"); |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 221 | const base::CommandLine& command_line = |
| 222 | *base::CommandLine::ForCurrentProcess(); |
[email protected] | 962b9821 | 2010-07-17 03:37:51 | [diff] [blame] | 223 | |
[email protected] | c54a891 | 2012-10-22 22:09:43 | [diff] [blame] | 224 | net::HostResolver::Options options; |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 225 | std::unique_ptr<net::HostResolver> global_host_resolver; |
[email protected] | 106ccd2c | 2014-06-17 09:21:00 | [diff] [blame] | 226 | #if defined OS_CHROMEOS |
| 227 | global_host_resolver = |
| 228 | chromeos::HostResolverImplChromeOS::CreateSystemResolver(options, |
| 229 | net_log); |
| 230 | #else |
| 231 | global_host_resolver = |
| 232 | net::HostResolver::CreateSystemResolver(options, net_log); |
| 233 | #endif |
[email protected] | 9087aa3 | 2010-02-18 08:03:38 | [diff] [blame] | 234 | |
[email protected] | 3dc5d7ef | 2014-03-28 19:18:21 | [diff] [blame] | 235 | // If hostname remappings were specified on the command-line, layer these |
| 236 | // rules on top of the real host resolver. This allows forwarding all requests |
| 237 | // through a designated test server. |
| 238 | if (!command_line.HasSwitch(switches::kHostResolverRules)) |
dcheng | e73d8520c | 2015-12-27 01:19:09 | [diff] [blame] | 239 | return global_host_resolver; |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 240 | |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 241 | std::unique_ptr<net::MappedHostResolver> remapped_resolver( |
dcheng | e73d8520c | 2015-12-27 01:19:09 | [diff] [blame] | 242 | new net::MappedHostResolver(std::move(global_host_resolver))); |
[email protected] | 3dc5d7ef | 2014-03-28 19:18:21 | [diff] [blame] | 243 | remapped_resolver->SetRulesFromString( |
| 244 | command_line.GetSwitchValueASCII(switches::kHostResolverRules)); |
dcheng | e73d8520c | 2015-12-27 01:19:09 | [diff] [blame] | 245 | return std::move(remapped_resolver); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 246 | } |
| 247 | |
jam | 1671ed3 | 2016-07-27 16:31:24 | [diff] [blame] | 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 | |
robliao | 7253fd2 | 2016-12-01 18:41:38 | [diff] [blame] | 258 | // This function is for forwarding metrics usage pref changes to the metrics |
| 259 | // service on the appropriate thread. |
| 260 | // TODO(gayane): Reduce the frequency of posting tasks from IO to UI thread. |
| 261 | void UpdateMetricsUsagePrefsOnUIThread(const std::string& service_name, |
| 262 | int message_size, |
| 263 | bool is_cellular) { |
tzik | 3f7781d | 2017-04-20 17:09:33 | [diff] [blame] | 264 | BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 265 | base::BindOnce( |
| 266 | [](const std::string& service_name, |
| 267 | int message_size, bool is_cellular) { |
| 268 | // Some unit tests use IOThread but do not |
| 269 | // initialize MetricsService. In that case it's |
| 270 | // fine to skip the update. |
| 271 | auto* metrics_service = |
| 272 | g_browser_process->metrics_service(); |
| 273 | if (metrics_service) { |
| 274 | metrics_service->UpdateMetricsUsagePrefs( |
| 275 | service_name, message_size, is_cellular); |
| 276 | } |
| 277 | }, |
| 278 | service_name, message_size, is_cellular)); |
robliao | 7253fd2 | 2016-12-01 18:41:38 | [diff] [blame] | 279 | } |
| 280 | |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 281 | } // namespace |
| 282 | |
[email protected] | abe2c03 | 2011-03-31 18:49:34 | [diff] [blame] | 283 | class SystemURLRequestContextGetter : public net::URLRequestContextGetter { |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 284 | public: |
| 285 | explicit SystemURLRequestContextGetter(IOThread* io_thread); |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 286 | |
[email protected] | abe2c03 | 2011-03-31 18:49:34 | [diff] [blame] | 287 | // Implementation for net::UrlRequestContextGetter. |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 288 | net::URLRequestContext* GetURLRequestContext() override; |
| 289 | scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
| 290 | const override; |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 291 | |
[email protected] | 13ed17f8 | 2012-04-06 02:27:18 | [diff] [blame] | 292 | protected: |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 293 | ~SystemURLRequestContextGetter() override; |
[email protected] | 13ed17f8 | 2012-04-06 02:27:18 | [diff] [blame] | 294 | |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 295 | private: |
| 296 | IOThread* const io_thread_; // Weak pointer, owned by BrowserProcess. |
[email protected] | 4969b012 | 2012-06-16 01:58:28 | [diff] [blame] | 297 | scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 298 | |
| 299 | base::debug::LeakTracker<SystemURLRequestContextGetter> leak_tracker_; |
| 300 | }; |
| 301 | |
| 302 | SystemURLRequestContextGetter::SystemURLRequestContextGetter( |
| 303 | IOThread* io_thread) |
| 304 | : io_thread_(io_thread), |
[email protected] | 4969b012 | 2012-06-16 01:58:28 | [diff] [blame] | 305 | network_task_runner_( |
thestig | 529ad8a | 2016-07-08 20:30:12 | [diff] [blame] | 306 | BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)) {} |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 307 | |
| 308 | SystemURLRequestContextGetter::~SystemURLRequestContextGetter() {} |
| 309 | |
| 310 | net::URLRequestContext* SystemURLRequestContextGetter::GetURLRequestContext() { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 311 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | ef2bf42 | 2012-05-11 03:27:09 | [diff] [blame] | 312 | DCHECK(io_thread_->globals()->system_request_context.get()); |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 313 | |
[email protected] | ef2bf42 | 2012-05-11 03:27:09 | [diff] [blame] | 314 | return io_thread_->globals()->system_request_context.get(); |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 315 | } |
| 316 | |
[email protected] | 4969b012 | 2012-06-16 01:58:28 | [diff] [blame] | 317 | scoped_refptr<base::SingleThreadTaskRunner> |
| 318 | SystemURLRequestContextGetter::GetNetworkTaskRunner() const { |
| 319 | return network_task_runner_; |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 320 | } |
| 321 | |
[email protected] | c93123fa | 2012-04-19 02:49:48 | [diff] [blame] | 322 | IOThread::Globals:: |
| 323 | SystemRequestContextLeakChecker::SystemRequestContextLeakChecker( |
| 324 | Globals* globals) |
| 325 | : globals_(globals) { |
| 326 | DCHECK(globals_); |
[email protected] | 7613faae | 2012-04-18 01:01:19 | [diff] [blame] | 327 | } |
[email protected] | 1889dc1b | 2010-10-14 22:03:13 | [diff] [blame] | 328 | |
[email protected] | c93123fa | 2012-04-19 02:49:48 | [diff] [blame] | 329 | IOThread::Globals:: |
| 330 | SystemRequestContextLeakChecker::~SystemRequestContextLeakChecker() { |
| 331 | if (globals_->system_request_context.get()) |
| 332 | globals_->system_request_context->AssertNoURLRequests(); |
| 333 | } |
| 334 | |
maksim.sisov | 3d40c81 | 2016-05-02 13:27:16 | [diff] [blame] | 335 | IOThread::Globals::Globals() : system_request_context_leak_checker(this), |
| 336 | enable_brotli(false) {} |
[email protected] | c2dad29 | 2012-09-07 21:27:35 | [diff] [blame] | 337 | |
[email protected] | c93123fa | 2012-04-19 02:49:48 | [diff] [blame] | 338 | IOThread::Globals::~Globals() {} |
| 339 | |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 340 | // |local_state| is passed in explicitly in order to (1) reduce implicit |
| 341 | // dependencies and (2) make IOThread more flexible for testing. |
[email protected] | 3ce0241 | 2011-03-01 12:01:15 | [diff] [blame] | 342 | IOThread::IOThread( |
[email protected] | b1de2c7 | 2013-02-06 02:45:47 | [diff] [blame] | 343 | PrefService* local_state, |
[email protected] | 7730542 | 2012-11-29 16:51:39 | [diff] [blame] | 344 | policy::PolicyService* policy_service, |
droger | c690e880 | 2015-09-21 14:29:16 | [diff] [blame] | 345 | net_log::ChromeNetLog* net_log, |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 346 | extensions::EventRouterForwarder* extension_event_router_forwarder) |
[email protected] | 2e5b60a2 | 2011-11-28 15:56:41 | [diff] [blame] | 347 | : net_log_(net_log), |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 348 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | 3ce0241 | 2011-03-01 12:01:15 | [diff] [blame] | 349 | extension_event_router_forwarder_(extension_event_router_forwarder), |
[email protected] | 84b7a55 | 2014-07-19 04:52:06 | [diff] [blame] | 350 | #endif |
mmenke | a7da6da | 2016-09-01 21:56:52 | [diff] [blame] | 351 | globals_(nullptr), |
peletskyi | 5df83d4 | 2015-04-30 16:37:46 | [diff] [blame] | 352 | is_quic_allowed_by_policy_(true), |
mmenke | 82d19a58 | 2017-01-27 23:26:32 | [diff] [blame] | 353 | http_09_on_non_default_ports_enabled_(false), |
mohan.reddy | 14cb4ad4 | 2014-09-17 18:15:14 | [diff] [blame] | 354 | creation_time_(base::TimeTicks::Now()), |
| 355 | weak_factory_(this) { |
aberent | bba302d | 2015-12-03 10:20:19 | [diff] [blame] | 356 | scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy = |
thestig | 529ad8a | 2016-07-08 20:30:12 | [diff] [blame] | 357 | BrowserThread::GetTaskRunnerForThread(BrowserThread::IO); |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 358 | auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
aberent | bba302d | 2015-12-03 10:20:19 | [diff] [blame] | 359 | negotiate_disable_cname_lookup_.Init( |
| 360 | prefs::kDisableAuthNegotiateCnameLookup, local_state, |
| 361 | base::Bind(&IOThread::UpdateNegotiateDisableCnameLookup, |
| 362 | base::Unretained(this))); |
| 363 | negotiate_disable_cname_lookup_.MoveToThread(io_thread_proxy); |
| 364 | negotiate_enable_port_.Init( |
| 365 | prefs::kEnableAuthNegotiatePort, local_state, |
| 366 | base::Bind(&IOThread::UpdateNegotiateEnablePort, base::Unretained(this))); |
| 367 | negotiate_enable_port_.MoveToThread(io_thread_proxy); |
| 368 | auth_server_whitelist_.Init( |
| 369 | prefs::kAuthServerWhitelist, local_state, |
| 370 | base::Bind(&IOThread::UpdateServerWhitelist, base::Unretained(this))); |
| 371 | auth_server_whitelist_.MoveToThread(io_thread_proxy); |
| 372 | auth_delegate_whitelist_.Init( |
| 373 | prefs::kAuthNegotiateDelegateWhitelist, local_state, |
| 374 | base::Bind(&IOThread::UpdateDelegateWhitelist, base::Unretained(this))); |
| 375 | auth_delegate_whitelist_.MoveToThread(io_thread_proxy); |
| 376 | #if defined(OS_ANDROID) |
| 377 | auth_android_negotiate_account_type_.Init( |
| 378 | prefs::kAuthAndroidNegotiateAccountType, local_state, |
| 379 | base::Bind(&IOThread::UpdateAndroidAuthNegotiateAccountType, |
| 380 | base::Unretained(this))); |
| 381 | auth_android_negotiate_account_type_.MoveToThread(io_thread_proxy); |
| 382 | #endif |
| 383 | #if defined(OS_POSIX) && !defined(OS_ANDROID) |
[email protected] | ac7f3fdb | 2010-11-12 12:47:05 | [diff] [blame] | 384 | gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); |
aberent | bba302d | 2015-12-03 10:20:19 | [diff] [blame] | 385 | #endif |
zentaro | e032635 | 2017-05-09 13:11:51 | [diff] [blame] | 386 | #if defined(OS_CHROMEOS) |
| 387 | policy::BrowserPolicyConnectorChromeOS* connector = |
| 388 | g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 389 | allow_gssapi_library_load_ = connector->IsActiveDirectoryManaged(); |
| 390 | #endif |
[email protected] | 6f96cbcb | 2011-11-04 02:26:07 | [diff] [blame] | 391 | pref_proxy_config_tracker_.reset( |
[email protected] | e2930d090 | 2013-07-17 05:25:42 | [diff] [blame] | 392 | ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 393 | local_state)); |
mmenke | 02505da | 2017-05-15 16:37:34 | [diff] [blame] | 394 | system_proxy_config_service_ = ProxyServiceFactory::CreateProxyConfigService( |
| 395 | pref_proxy_config_tracker_.get()); |
[email protected] | 9d8cfb68 | 2012-09-13 16:48:04 | [diff] [blame] | 396 | ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 397 | &system_enable_referrers_, |
igorcov | 193d8ad3 | 2016-05-27 11:03:21 | [diff] [blame] | 398 | nullptr, |
| 399 | nullptr, |
| 400 | nullptr, |
| 401 | nullptr, |
[email protected] | 9d8cfb68 | 2012-09-13 16:48:04 | [diff] [blame] | 402 | local_state); |
[email protected] | 4d45a6de | 2011-05-13 05:20:18 | [diff] [blame] | 403 | ssl_config_service_manager_.reset( |
abhishek.a21 | 2849cee | 2015-10-20 11:27:29 | [diff] [blame] | 404 | ssl_config::SSLConfigServiceManager::CreateDefaultManager( |
| 405 | local_state, |
thestig | 529ad8a | 2016-07-08 20:30:12 | [diff] [blame] | 406 | BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); |
[email protected] | 2e5b60a2 | 2011-11-28 15:56:41 | [diff] [blame] | 407 | |
jdoerrie | 23972357 | 2017-03-02 12:09:19 | [diff] [blame] | 408 | base::Value* dns_client_enabled_default = |
| 409 | new base::Value(chrome_browser_net::ConfigureAsyncDnsFieldTrial()); |
[email protected] | 68a9b0d8 | 2013-03-08 07:05:07 | [diff] [blame] | 410 | local_state->SetDefaultPrefValue(prefs::kBuiltInDnsClientEnabled, |
| 411 | dns_client_enabled_default); |
ttuttle | 53018496 | 2015-01-13 00:24:07 | [diff] [blame] | 412 | chrome_browser_net::LogAsyncDnsPrefSource( |
| 413 | local_state->FindPreference(prefs::kBuiltInDnsClientEnabled)); |
[email protected] | 68a9b0d8 | 2013-03-08 07:05:07 | [diff] [blame] | 414 | |
[email protected] | fa4b6c3 | 2012-11-26 23:02:39 | [diff] [blame] | 415 | dns_client_enabled_.Init(prefs::kBuiltInDnsClientEnabled, |
| 416 | local_state, |
| 417 | base::Bind(&IOThread::UpdateDnsClientEnabled, |
| 418 | base::Unretained(this))); |
aberent | bba302d | 2015-12-03 10:20:19 | [diff] [blame] | 419 | dns_client_enabled_.MoveToThread(io_thread_proxy); |
[email protected] | fa4b6c3 | 2012-11-26 23:02:39 | [diff] [blame] | 420 | |
[email protected] | 6737814 | 2013-12-17 21:57:17 | [diff] [blame] | 421 | quick_check_enabled_.Init(prefs::kQuickCheckEnabled, |
| 422 | local_state); |
aberent | bba302d | 2015-12-03 10:20:19 | [diff] [blame] | 423 | quick_check_enabled_.MoveToThread(io_thread_proxy); |
[email protected] | 6737814 | 2013-12-17 21:57:17 | [diff] [blame] | 424 | |
eroman | 9f7ea64 | 2016-06-03 21:28:29 | [diff] [blame] | 425 | pac_https_url_stripping_enabled_.Init(prefs::kPacHttpsUrlStrippingEnabled, |
| 426 | local_state); |
| 427 | pac_https_url_stripping_enabled_.MoveToThread(io_thread_proxy); |
| 428 | |
peletskyi | 5df83d4 | 2015-04-30 16:37:46 | [diff] [blame] | 429 | const base::Value* value = policy_service->GetPolicies( |
| 430 | policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, |
| 431 | std::string())).GetValue(policy::key::kQuicAllowed); |
| 432 | if (value) |
| 433 | value->GetAsBoolean(&is_quic_allowed_by_policy_); |
[email protected] | 7730542 | 2012-11-29 16:51:39 | [diff] [blame] | 434 | |
mmenke | a7da6da | 2016-09-01 21:56:52 | [diff] [blame] | 435 | value = policy_service |
| 436 | ->GetPolicies(policy::PolicyNamespace( |
| 437 | policy::POLICY_DOMAIN_CHROME, std::string())) |
| 438 | .GetValue(policy::key::kHttp09OnNonDefaultPortsEnabled); |
| 439 | if (value) |
| 440 | value->GetAsBoolean(&http_09_on_non_default_ports_enabled_); |
| 441 | |
eranm | 3c2d643 | 2016-06-01 10:17:27 | [diff] [blame] | 442 | chrome_browser_net::SetGlobalSTHDistributor( |
| 443 | std::unique_ptr<net::ct::STHDistributor>(new net::ct::STHDistributor())); |
| 444 | |
gab | 90becc9 | 2016-12-08 17:19:34 | [diff] [blame] | 445 | BrowserThread::SetIOThreadDelegate(this); |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 446 | } |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 447 | |
| 448 | IOThread::~IOThread() { |
[email protected] | 2e5b60a2 | 2011-11-28 15:56:41 | [diff] [blame] | 449 | // This isn't needed for production code, but in tests, IOThread may |
| 450 | // be multiply constructed. |
gab | 90becc9 | 2016-12-08 17:19:34 | [diff] [blame] | 451 | BrowserThread::SetIOThreadDelegate(nullptr); |
[email protected] | 2e5b60a2 | 2011-11-28 15:56:41 | [diff] [blame] | 452 | |
[email protected] | d461ed2 | 2013-01-18 03:18:56 | [diff] [blame] | 453 | pref_proxy_config_tracker_->DetachFromPrefService(); |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 454 | DCHECK(!globals_); |
eranm | 3c2d643 | 2016-06-01 10:17:27 | [diff] [blame] | 455 | |
| 456 | // Destroy the old distributor to check that the observers list it holds is |
| 457 | // empty. |
| 458 | chrome_browser_net::SetGlobalSTHDistributor(nullptr); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 459 | } |
| 460 | |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 461 | IOThread::Globals* IOThread::globals() { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 462 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 463 | return globals_; |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 464 | } |
| 465 | |
[email protected] | 37ac95b | 2013-07-23 23:39:35 | [diff] [blame] | 466 | void IOThread::SetGlobalsForTesting(Globals* globals) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 467 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | 37ac95b | 2013-07-23 23:39:35 | [diff] [blame] | 468 | DCHECK(!globals || !globals_); |
| 469 | globals_ = globals; |
| 470 | } |
| 471 | |
droger | c690e880 | 2015-09-21 14:29:16 | [diff] [blame] | 472 | net_log::ChromeNetLog* IOThread::net_log() { |
[email protected] | b2fcd0e | 2010-12-01 15:19:40 | [diff] [blame] | 473 | return net_log_; |
| 474 | } |
| 475 | |
[email protected] | b09f76d6 | 2011-12-07 01:51:06 | [diff] [blame] | 476 | void IOThread::ChangedToOnTheRecord() { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 477 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | b09f76d6 | 2011-12-07 01:51:06 | [diff] [blame] | 478 | BrowserThread::PostTask( |
tzik | 3f7781d | 2017-04-20 17:09:33 | [diff] [blame] | 479 | BrowserThread::IO, FROM_HERE, |
| 480 | base::BindOnce(&IOThread::ChangedToOnTheRecordOnIOThread, |
| 481 | base::Unretained(this))); |
[email protected] | b09f76d6 | 2011-12-07 01:51:06 | [diff] [blame] | 482 | } |
| 483 | |
[email protected] | abe2c03 | 2011-03-31 18:49:34 | [diff] [blame] | 484 | net::URLRequestContextGetter* IOThread::system_url_request_context_getter() { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 485 | DCHECK_CURRENTLY_ON(BrowserThread::UI); |
[email protected] | 5173de8b | 2013-06-02 21:16:02 | [diff] [blame] | 486 | if (!system_url_request_context_getter_.get()) { |
mmenke | 02505da | 2017-05-15 16:37:34 | [diff] [blame] | 487 | system_url_request_context_getter_ = |
| 488 | new SystemURLRequestContextGetter(this); |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 489 | } |
[email protected] | 5173de8b | 2013-06-02 21:16:02 | [diff] [blame] | 490 | return system_url_request_context_getter_.get(); |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 491 | } |
| 492 | |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 493 | void IOThread::Init() { |
[email protected] | a5e73b8 | 2013-07-17 08:58:39 | [diff] [blame] | 494 | TRACE_EVENT0("startup", "IOThread::InitAsync"); |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 495 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | 70b9234 | 2010-10-12 05:54:06 | [diff] [blame] | 496 | |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 497 | #if defined(USE_NSS_CERTS) |
[email protected] | 8c434cbc | 2012-03-14 14:25:09 | [diff] [blame] | 498 | net::SetMessageLoopForNSSHttpIO(); |
[email protected] | a592c043 | 2012-12-01 18:10:29 | [diff] [blame] | 499 | #endif |
[email protected] | 70b9234 | 2010-10-12 05:54:06 | [diff] [blame] | 500 | |
avi | 556c0502 | 2014-12-22 23:31:43 | [diff] [blame] | 501 | const base::CommandLine& command_line = |
| 502 | *base::CommandLine::ForCurrentProcess(); |
[email protected] | c2dad29 | 2012-09-07 21:27:35 | [diff] [blame] | 503 | |
zhongyi | 81f85c6d9 | 2015-10-16 19:34:14 | [diff] [blame] | 504 | // Export ssl keys if log file specified. |
davidben | 2a811e4e | 2015-12-01 10:49:34 | [diff] [blame] | 505 | base::FilePath ssl_keylog_file = GetSSLKeyLogFile(command_line); |
zhongyi | 81f85c6d9 | 2015-10-16 19:34:14 | [diff] [blame] | 506 | if (!ssl_keylog_file.empty()) { |
davidben | 2a811e4e | 2015-12-01 10:49:34 | [diff] [blame] | 507 | net::SSLClientSocket::SetSSLKeyLogFile( |
| 508 | ssl_keylog_file, |
thestig | 529ad8a | 2016-07-08 20:30:12 | [diff] [blame] | 509 | BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)); |
zhongyi | 81f85c6d9 | 2015-10-16 19:34:14 | [diff] [blame] | 510 | } |
| 511 | |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 512 | DCHECK(!globals_); |
| 513 | globals_ = new Globals; |
| 514 | |
[email protected] | 58bc704 | 2010-07-07 18:04:14 | [diff] [blame] | 515 | // Add an observer that will emit network change events to the ChromeNetLog. |
| 516 | // Assuming NetworkChangeNotifier dispatches in FIFO order, we should be |
| 517 | // logging the network change before other IO thread consumers respond to it. |
| 518 | network_change_observer_.reset( |
pauljensen | 7b34e52 | 2016-05-12 18:20:59 | [diff] [blame] | 519 | new net::LoggingNetworkChangeObserver(net_log_)); |
[email protected] | 58bc704 | 2010-07-07 18:04:14 | [diff] [blame] | 520 | |
[email protected] | cde8b3c | 2012-08-13 19:20:52 | [diff] [blame] | 521 | // Setup the HistogramWatcher to run on the IO thread. |
| 522 | net::NetworkChangeNotifier::InitHistogramWatcher(); |
| 523 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 524 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
[email protected] | 3ce0241 | 2011-03-01 12:01:15 | [diff] [blame] | 525 | globals_->extension_event_router_forwarder = |
| 526 | extension_event_router_forwarder_; |
[email protected] | 84b7a55 | 2014-07-19 04:52:06 | [diff] [blame] | 527 | #endif |
| 528 | |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 529 | std::unique_ptr<data_usage::DataUseAmortizer> data_use_amortizer; |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 530 | #if defined(OS_ANDROID) |
sclittle | c441f78 | 2015-11-12 01:12:09 | [diff] [blame] | 531 | data_use_amortizer.reset(new data_usage::android::TrafficStatsAmortizer()); |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 532 | #endif // defined(OS_ANDROID) |
sclittle | c441f78 | 2015-11-12 01:12:09 | [diff] [blame] | 533 | |
kundaji | f617523b | 2016-09-09 22:41:24 | [diff] [blame] | 534 | globals_->data_use_ascriber = |
| 535 | base::MakeUnique<data_use_measurement::ChromeDataUseAscriber>(); |
| 536 | |
sclittle | 3f98c6c | 2015-11-19 22:59:29 | [diff] [blame] | 537 | globals_->data_use_aggregator.reset(new data_usage::DataUseAggregator( |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 538 | std::unique_ptr<data_usage::DataUseAnnotator>( |
sclittle | c441f78 | 2015-11-12 01:12:09 | [diff] [blame] | 539 | new chrome_browser_data_usage::TabIdAnnotator()), |
dcheng | e73d8520c | 2015-12-27 01:19:09 | [diff] [blame] | 540 | std::move(data_use_amortizer))); |
sclittle | ae932be | 2015-10-08 20:53:50 | [diff] [blame] | 541 | |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 542 | #if defined(OS_ANDROID) |
sclittle | 3f98c6c | 2015-11-19 22:59:29 | [diff] [blame] | 543 | globals_->external_data_use_observer.reset( |
tbansal | 7c98c0a | 2015-11-03 21:39:51 | [diff] [blame] | 544 | new chrome::android::ExternalDataUseObserver( |
sclittle | 3f98c6c | 2015-11-19 22:59:29 | [diff] [blame] | 545 | globals_->data_use_aggregator.get(), |
thestig | 529ad8a | 2016-07-08 20:30:12 | [diff] [blame] | 546 | BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), |
| 547 | BrowserThread::GetTaskRunnerForThread(BrowserThread::UI))); |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 548 | #endif // defined(OS_ANDROID) |
[email protected] | 84b7a55 | 2014-07-19 04:52:06 | [diff] [blame] | 549 | |
[email protected] | c54a891 | 2012-10-22 22:09:43 | [diff] [blame] | 550 | globals_->host_resolver = CreateGlobalHostResolver(net_log_); |
tbansal | ea2fb8c | 2015-05-22 22:23:00 | [diff] [blame] | 551 | |
tbansal | b177b539 | 2015-06-25 11:13:02 | [diff] [blame] | 552 | std::map<std::string, std::string> network_quality_estimator_params; |
| 553 | variations::GetVariationParams(kNetworkQualityEstimatorFieldTrialName, |
| 554 | &network_quality_estimator_params); |
tbansal | 1c92d5b | 2015-08-14 20:14:43 | [diff] [blame] | 555 | |
tbansal | d3e08ca6 | 2017-05-04 19:51:09 | [diff] [blame] | 556 | if (command_line.HasSwitch(switches::kForceEffectiveConnectionType)) { |
| 557 | const std::string force_ect_value = |
| 558 | base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 559 | switches::kForceEffectiveConnectionType); |
| 560 | |
| 561 | if (!force_ect_value.empty()) { |
| 562 | // If the effective connection type is forced using command line switch, |
| 563 | // it overrides the one set by field trial. |
| 564 | network_quality_estimator_params[net::kForceEffectiveConnectionType] = |
| 565 | force_ect_value; |
| 566 | } |
| 567 | } |
| 568 | |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 569 | std::unique_ptr<net::ExternalEstimateProvider> external_estimate_provider; |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 570 | #if defined(OS_ANDROID) |
tbansal | 1c92d5b | 2015-08-14 20:14:43 | [diff] [blame] | 571 | external_estimate_provider.reset( |
tbansal | dafbb3e | 2015-08-19 19:55:33 | [diff] [blame] | 572 | new chrome::android::ExternalEstimateProviderAndroid()); |
zpeng | db4a58e | 2017-01-10 17:40:32 | [diff] [blame] | 573 | #endif // defined(OS_ANDROID) |
tbansal | 1c92d5b | 2015-08-14 20:14:43 | [diff] [blame] | 574 | // Pass ownership. |
| 575 | globals_->network_quality_estimator.reset(new net::NetworkQualityEstimator( |
tbansal | 97e38a2 | 2017-01-20 20:43:02 | [diff] [blame] | 576 | std::move(external_estimate_provider), network_quality_estimator_params, |
| 577 | net_log_)); |
tbansal | 15973c3 | 2017-05-10 18:40:44 | [diff] [blame] | 578 | globals_->network_quality_observer = content::CreateNetworkQualityObserver( |
| 579 | globals_->network_quality_estimator.get()); |
tbansal | ea2fb8c | 2015-05-22 22:23:00 | [diff] [blame] | 580 | |
[email protected] | fa4b6c3 | 2012-11-26 23:02:39 | [diff] [blame] | 581 | UpdateDnsClientEnabled(); |
[email protected] | f46f6d5 | 2014-02-08 04:00:39 | [diff] [blame] | 582 | #if defined(OS_CHROMEOS) |
[email protected] | f9357a44 | 2014-05-15 18:44:07 | [diff] [blame] | 583 | // Creates a CertVerifyProc that doesn't allow any profile-provided certs. |
rsleevi | 6df5418 | 2016-06-13 14:34:23 | [diff] [blame] | 584 | globals_->cert_verifier = base::MakeUnique<net::CachingCertVerifier>( |
| 585 | base::MakeUnique<net::MultiThreadedCertVerifier>( |
| 586 | new chromeos::CertVerifyProcChromeOS())); |
[email protected] | f9357a44 | 2014-05-15 18:44:07 | [diff] [blame] | 587 | #else |
martinkr | 8402d3c | 2017-05-23 20:10:47 | [diff] [blame] | 588 | globals_->cert_verifier = IgnoreErrorsCertVerifier::MaybeWrapCertVerifier( |
| 589 | command_line, net::CertVerifier::CreateDefault()); |
| 590 | UMA_HISTOGRAM_BOOLEAN( |
| 591 | "Net.Certificate.IgnoreCertificateErrorsSPKIListPresent", |
| 592 | command_line.HasSwitch(switches::kIgnoreCertificateErrorsSPKIList)); |
[email protected] | f9357a44 | 2014-05-15 18:44:07 | [diff] [blame] | 593 | #endif |
| 594 | |
eranm | 1a79db2 | 2015-11-24 10:56:49 | [diff] [blame] | 595 | std::vector<scoped_refptr<const net::CTLogVerifier>> ct_logs( |
eranm | 03d454c | 2015-07-02 09:12:03 | [diff] [blame] | 596 | net::ct::CreateLogVerifiersForKnownLogs()); |
[email protected] | 284303b6 | 2013-11-28 15:11:54 | [diff] [blame] | 597 | |
eranm | 1a79db2 | 2015-11-24 10:56:49 | [diff] [blame] | 598 | globals_->ct_logs.assign(ct_logs.begin(), ct_logs.end()); |
| 599 | |
eranm | 03d454c | 2015-07-02 09:12:03 | [diff] [blame] | 600 | net::MultiLogCTVerifier* ct_verifier = new net::MultiLogCTVerifier(); |
| 601 | globals_->cert_transparency_verifier.reset(ct_verifier); |
| 602 | // Add built-in logs |
eranm | 1a79db2 | 2015-11-24 10:56:49 | [diff] [blame] | 603 | ct_verifier->AddLogs(globals_->ct_logs); |
eranm | 03d454c | 2015-07-02 09:12:03 | [diff] [blame] | 604 | |
eranm | bbf5af70 | 2017-02-02 16:06:18 | [diff] [blame] | 605 | ct_tree_tracker_.reset(new certificate_transparency::TreeStateTracker( |
| 606 | globals_->ct_logs, net_log_)); |
eranm | 3c2d643 | 2016-06-01 10:17:27 | [diff] [blame] | 607 | // Register the ct_tree_tracker_ as observer for new STHs. |
| 608 | RegisterSTHObserver(ct_tree_tracker_.get()); |
| 609 | // Register the ct_tree_tracker_ as observer for verified SCTs. |
| 610 | globals_->cert_transparency_verifier->SetObserver(ct_tree_tracker_.get()); |
| 611 | |
aberent | bba302d | 2015-12-03 10:20:19 | [diff] [blame] | 612 | CreateDefaultAuthHandlerFactory(); |
[email protected] | 4588b3d | 2012-11-14 00:37:38 | [diff] [blame] | 613 | globals_->dns_probe_service.reset(new chrome_browser_net::DnsProbeService()); |
[email protected] | c2dad29 | 2012-09-07 21:27:35 | [diff] [blame] | 614 | globals_->host_mapping_rules.reset(new net::HostMappingRules()); |
| 615 | if (command_line.HasSwitch(switches::kHostRules)) { |
[email protected] | a5e73b8 | 2013-07-17 08:58:39 | [diff] [blame] | 616 | TRACE_EVENT_BEGIN0("startup", "IOThread::InitAsync:SetRulesFromString"); |
[email protected] | c2dad29 | 2012-09-07 21:27:35 | [diff] [blame] | 617 | globals_->host_mapping_rules->SetRulesFromString( |
| 618 | command_line.GetSwitchValueASCII(switches::kHostRules)); |
[email protected] | a5e73b8 | 2013-07-17 08:58:39 | [diff] [blame] | 619 | TRACE_EVENT_END0("startup", "IOThread::InitAsync:SetRulesFromString"); |
[email protected] | c2dad29 | 2012-09-07 21:27:35 | [diff] [blame] | 620 | } |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame^] | 621 | |
| 622 | session_params_.host_mapping_rules = *globals_->host_mapping_rules.get(); |
maksim.sisov | 3d40c81 | 2016-05-02 13:27:16 | [diff] [blame] | 623 | globals_->enable_brotli = |
bnc | 18fb77f | 2016-04-04 20:54:04 | [diff] [blame] | 624 | base::FeatureList::IsEnabled(features::kBrotliEncoding); |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame^] | 625 | session_params_.enable_token_binding = |
nharper | ef261864 | 2016-02-03 22:23:44 | [diff] [blame] | 626 | base::FeatureList::IsEnabled(features::kTokenBinding); |
bnc | e87c7c71 | 2016-08-01 23:59:48 | [diff] [blame] | 627 | |
| 628 | // Check for OS support of TCP FastOpen, and turn it on for all connections if |
| 629 | // indicated by user. |
bnc | 18fb77f | 2016-04-04 20:54:04 | [diff] [blame] | 630 | // TODO(rch): Make the client socket factory a per-network session instance, |
| 631 | // constructed from a NetworkSession::Params, to allow us to move this option |
| 632 | // to IOThread::Globals & HttpNetworkSession::Params. |
bnc | 18fb77f | 2016-04-04 20:54:04 | [diff] [blame] | 633 | bool always_enable_tfo_if_supported = |
| 634 | command_line.HasSwitch(switches::kEnableTcpFastOpen); |
bnc | 18fb77f | 2016-04-04 20:54:04 | [diff] [blame] | 635 | net::CheckSupportAndMaybeEnableTCPFastOpen(always_enable_tfo_if_supported); |
[email protected] | f9cf557 | 2012-12-04 15:52:09 | [diff] [blame] | 636 | |
bnc | e87c7c71 | 2016-08-01 23:59:48 | [diff] [blame] | 637 | ConfigureParamsFromFieldTrialsAndCommandLine( |
mmenke | a7da6da | 2016-09-01 21:56:52 | [diff] [blame] | 638 | command_line, is_quic_allowed_by_policy_, |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame^] | 639 | http_09_on_non_default_ports_enabled_, &session_params_); |
bnc | e87c7c71 | 2016-08-01 23:59:48 | [diff] [blame] | 640 | |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 641 | #if defined(OS_MACOSX) |
[email protected] | 11f5e3a | 2012-09-27 00:30:13 | [diff] [blame] | 642 | // Start observing Keychain events. This needs to be done on the UI thread, |
| 643 | // as Keychain services requires a CFRunLoop. |
| 644 | BrowserThread::PostTask(BrowserThread::UI, |
| 645 | FROM_HERE, |
| 646 | base::Bind(&ObserveKeychainEvents)); |
| 647 | #endif |
| 648 | |
davidben | 45eb1995 | 2016-05-05 16:30:44 | [diff] [blame] | 649 | #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
| 650 | // Record how common CPUs with broken NEON units are. See |
| 651 | // https://crbug.com/341598. |
| 652 | crypto::EnsureOpenSSLInit(); |
| 653 | UMA_HISTOGRAM_BOOLEAN("Net.HasBrokenNEON", CRYPTO_has_broken_NEON()); |
| 654 | #endif |
mmenke | 02505da | 2017-05-15 16:37:34 | [diff] [blame] | 655 | |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 656 | ConstructSystemRequestContext(); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 657 | } |
| 658 | |
[email protected] | 2a92cd9 | 2010-04-27 00:01:41 | [diff] [blame] | 659 | void IOThread::CleanUp() { |
[email protected] | 075c032 | 2012-02-14 00:56:44 | [diff] [blame] | 660 | base::debug::LeakTracker<SafeBrowsingURLRequestContext>::CheckForLeaks(); |
| 661 | |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 662 | #if defined(USE_NSS_CERTS) |
[email protected] | 8c434cbc | 2012-03-14 14:25:09 | [diff] [blame] | 663 | net::ShutdownNSSHttpIO(); |
[email protected] | a592c043 | 2012-12-01 18:10:29 | [diff] [blame] | 664 | #endif |
[email protected] | 59a3b36 | 2010-10-21 21:52:41 | [diff] [blame] | 665 | |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 666 | system_url_request_context_getter_ = NULL; |
| 667 | |
eranm | 3c2d643 | 2016-06-01 10:17:27 | [diff] [blame] | 668 | // Unlink the ct_tree_tracker_ from the global cert_transparency_verifier |
| 669 | // and unregister it from new STH notifications so it will take no actions |
| 670 | // on anything observed during CleanUp process. |
mmenke | 02505da | 2017-05-15 16:37:34 | [diff] [blame] | 671 | // |
| 672 | // Null checks are just for tests that use TestingIOThreadState. |
| 673 | if (globals()->cert_transparency_verifier) |
| 674 | globals()->cert_transparency_verifier->SetObserver(nullptr); |
| 675 | if (ct_tree_tracker_.get()) { |
| 676 | UnregisterSTHObserver(ct_tree_tracker_.get()); |
| 677 | ct_tree_tracker_.reset(); |
| 678 | } |
eranm | 3c2d643 | 2016-06-01 10:17:27 | [diff] [blame] | 679 | |
mmenke | ab0c11d | 2017-05-30 17:15:17 | [diff] [blame] | 680 | if (globals_->system_request_context) |
| 681 | globals_->system_request_context->proxy_service()->OnShutdown(); |
| 682 | |
[email protected] | af66993 | 2012-01-17 19:26:58 | [diff] [blame] | 683 | // Release objects that the net::URLRequestContext could have been pointing |
| 684 | // to. |
[email protected] | 0ee7a3b | 2010-11-09 06:13:40 | [diff] [blame] | 685 | |
[email protected] | 7592b41f | 2014-04-01 01:44:43 | [diff] [blame] | 686 | // Shutdown the HistogramWatcher on the IO thread. |
| 687 | net::NetworkChangeNotifier::ShutdownHistogramWatcher(); |
| 688 | |
[email protected] | 0ee7a3b | 2010-11-09 06:13:40 | [diff] [blame] | 689 | // This must be reset before the ChromeNetLog is destroyed. |
| 690 | network_change_observer_.reset(); |
| 691 | |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 692 | system_proxy_config_service_.reset(); |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 693 | delete globals_; |
| 694 | globals_ = NULL; |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 695 | |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 696 | base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 697 | } |
| 698 | |
bnc | 18fb77f | 2016-04-04 20:54:04 | [diff] [blame] | 699 | // static |
[email protected] | b1de2c7 | 2013-02-06 02:45:47 | [diff] [blame] | 700 | void IOThread::RegisterPrefs(PrefRegistrySimple* registry) { |
| 701 | registry->RegisterStringPref(prefs::kAuthSchemes, |
bengr | 70266e2 | 2015-06-12 19:38:17 | [diff] [blame] | 702 | "basic,digest,ntlm,negotiate"); |
[email protected] | 68a9b0d8 | 2013-03-08 07:05:07 | [diff] [blame] | 703 | registry->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, false); |
[email protected] | b1de2c7 | 2013-02-06 02:45:47 | [diff] [blame] | 704 | registry->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); |
[email protected] | 007b3f8 | 2013-04-09 08:46:45 | [diff] [blame] | 705 | registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); |
| 706 | registry->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, |
| 707 | std::string()); |
| 708 | registry->RegisterStringPref(prefs::kGSSAPILibraryName, std::string()); |
aberent | ec894a5 | 2015-07-09 14:45:53 | [diff] [blame] | 709 | registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, |
| 710 | std::string()); |
[email protected] | b1de2c7 | 2013-02-06 02:45:47 | [diff] [blame] | 711 | registry->RegisterBooleanPref(prefs::kEnableReferrers, true); |
[email protected] | 1575e3d | 2014-05-03 22:21:44 | [diff] [blame] | 712 | data_reduction_proxy::RegisterPrefs(registry); |
[email protected] | 68a9b0d8 | 2013-03-08 07:05:07 | [diff] [blame] | 713 | registry->RegisterBooleanPref(prefs::kBuiltInDnsClientEnabled, true); |
[email protected] | 6737814 | 2013-12-17 21:57:17 | [diff] [blame] | 714 | registry->RegisterBooleanPref(prefs::kQuickCheckEnabled, true); |
eroman | 9f7ea64 | 2016-06-03 21:28:29 | [diff] [blame] | 715 | registry->RegisterBooleanPref(prefs::kPacHttpsUrlStrippingEnabled, true); |
[email protected] | bcefe0f | 2010-11-10 16:19:10 | [diff] [blame] | 716 | } |
| 717 | |
aberent | bba302d | 2015-12-03 10:20:19 | [diff] [blame] | 718 | void IOThread::UpdateServerWhitelist() { |
| 719 | globals_->http_auth_preferences->set_server_whitelist( |
| 720 | auth_server_whitelist_.GetValue()); |
| 721 | } |
[email protected] | b730416 | 2010-08-23 17:42:29 | [diff] [blame] | 722 | |
aberent | bba302d | 2015-12-03 10:20:19 | [diff] [blame] | 723 | void IOThread::UpdateDelegateWhitelist() { |
| 724 | globals_->http_auth_preferences->set_delegate_whitelist( |
| 725 | auth_delegate_whitelist_.GetValue()); |
| 726 | } |
| 727 | |
| 728 | #if defined(OS_ANDROID) |
| 729 | void IOThread::UpdateAndroidAuthNegotiateAccountType() { |
| 730 | globals_->http_auth_preferences->set_auth_android_negotiate_account_type( |
| 731 | auth_android_negotiate_account_type_.GetValue()); |
| 732 | } |
| 733 | #endif |
| 734 | |
| 735 | void IOThread::UpdateNegotiateDisableCnameLookup() { |
| 736 | globals_->http_auth_preferences->set_negotiate_disable_cname_lookup( |
| 737 | negotiate_disable_cname_lookup_.GetValue()); |
| 738 | } |
| 739 | |
| 740 | void IOThread::UpdateNegotiateEnablePort() { |
| 741 | globals_->http_auth_preferences->set_negotiate_enable_port( |
| 742 | negotiate_enable_port_.GetValue()); |
| 743 | } |
| 744 | |
| 745 | void IOThread::CreateDefaultAuthHandlerFactory() { |
| 746 | std::vector<std::string> supported_schemes = base::SplitString( |
| 747 | auth_schemes_, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 748 | globals_->http_auth_preferences.reset(new net::HttpAuthPreferences( |
| 749 | supported_schemes |
| 750 | #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 751 | , |
| 752 | gssapi_library_name_ |
| 753 | #endif |
zentaro | e032635 | 2017-05-09 13:11:51 | [diff] [blame] | 754 | #if defined(OS_CHROMEOS) |
| 755 | , |
| 756 | allow_gssapi_library_load_ |
| 757 | #endif |
aberent | bba302d | 2015-12-03 10:20:19 | [diff] [blame] | 758 | )); |
| 759 | UpdateServerWhitelist(); |
| 760 | UpdateDelegateWhitelist(); |
| 761 | UpdateNegotiateDisableCnameLookup(); |
| 762 | UpdateNegotiateEnablePort(); |
| 763 | #if defined(OS_ANDROID) |
| 764 | UpdateAndroidAuthNegotiateAccountType(); |
| 765 | #endif |
| 766 | globals_->http_auth_handler_factory = |
[email protected] | ec44ee0 | 2012-09-28 21:31:51 | [diff] [blame] | 767 | net::HttpAuthHandlerRegistryFactory::Create( |
dcheng | e73d8520c | 2015-12-27 01:19:09 | [diff] [blame] | 768 | globals_->http_auth_preferences.get(), globals_->host_resolver.get()); |
[email protected] | eb3cac7 | 2010-02-26 21:07:45 | [diff] [blame] | 769 | } |
| 770 | |
msramek | 94f5656c | 2016-08-31 17:08:29 | [diff] [blame] | 771 | void IOThread::ClearHostCache( |
| 772 | const base::Callback<bool(const std::string&)>& host_filter) { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 773 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | d6f37fc | 2011-02-13 23:58:41 | [diff] [blame] | 774 | |
[email protected] | 489d1a8 | 2011-10-12 03:09:11 | [diff] [blame] | 775 | net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); |
| 776 | if (host_cache) |
msramek | 94f5656c | 2016-08-31 17:08:29 | [diff] [blame] | 777 | host_cache->ClearForHosts(host_filter); |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 778 | } |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 779 | |
bnc | 18fb77f | 2016-04-04 20:54:04 | [diff] [blame] | 780 | const net::HttpNetworkSession::Params& IOThread::NetworkSessionParams() const { |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame^] | 781 | return session_params_; |
[email protected] | f9cf557 | 2012-12-04 15:52:09 | [diff] [blame] | 782 | } |
| 783 | |
pmarko | 6ab8be24 | 2017-01-11 11:02:55 | [diff] [blame] | 784 | void IOThread::DisableQuic() { |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame^] | 785 | session_params_.enable_quic = false; |
pmarko | 6ab8be24 | 2017-01-11 11:02:55 | [diff] [blame] | 786 | |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 787 | if (globals_->system_request_context_storage) |
| 788 | globals_->system_request_context_storage->http_network_session() |
| 789 | ->DisableQuic(); |
pmarko | 6ab8be24 | 2017-01-11 11:02:55 | [diff] [blame] | 790 | } |
| 791 | |
[email protected] | d827e11 | 2014-03-31 17:45:05 | [diff] [blame] | 792 | base::TimeTicks IOThread::creation_time() const { |
| 793 | return creation_time_; |
| 794 | } |
| 795 | |
[email protected] | 4d45a6de | 2011-05-13 05:20:18 | [diff] [blame] | 796 | net::SSLConfigService* IOThread::GetSSLConfigService() { |
| 797 | return ssl_config_service_manager_->Get(); |
| 798 | } |
| 799 | |
[email protected] | b09f76d6 | 2011-12-07 01:51:06 | [diff] [blame] | 800 | void IOThread::ChangedToOnTheRecordOnIOThread() { |
thestig | 00844cea | 2015-09-08 21:44:52 | [diff] [blame] | 801 | DCHECK_CURRENTLY_ON(BrowserThread::IO); |
[email protected] | b09f76d6 | 2011-12-07 01:51:06 | [diff] [blame] | 802 | |
| 803 | // Clear the host cache to avoid showing entries from the OTR session |
| 804 | // in about:net-internals. |
msramek | 94f5656c | 2016-08-31 17:08:29 | [diff] [blame] | 805 | ClearHostCache(base::Callback<bool(const std::string&)>()); |
[email protected] | b09f76d6 | 2011-12-07 01:51:06 | [diff] [blame] | 806 | } |
| 807 | |
[email protected] | fa4b6c3 | 2012-11-26 23:02:39 | [diff] [blame] | 808 | void IOThread::UpdateDnsClientEnabled() { |
| 809 | globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); |
| 810 | } |
[email protected] | 903e6338 | 2013-06-01 00:40:58 | [diff] [blame] | 811 | |
eranm | 3c2d643 | 2016-06-01 10:17:27 | [diff] [blame] | 812 | void IOThread::RegisterSTHObserver(net::ct::STHObserver* observer) { |
| 813 | chrome_browser_net::GetGlobalSTHDistributor()->RegisterObserver(observer); |
| 814 | } |
| 815 | |
| 816 | void IOThread::UnregisterSTHObserver(net::ct::STHObserver* observer) { |
| 817 | chrome_browser_net::GetGlobalSTHDistributor()->UnregisterObserver(observer); |
| 818 | } |
| 819 | |
eroman | 9f7ea64 | 2016-06-03 21:28:29 | [diff] [blame] | 820 | bool IOThread::WpadQuickCheckEnabled() const { |
| 821 | return quick_check_enabled_.GetValue(); |
| 822 | } |
| 823 | |
| 824 | bool IOThread::PacHttpsUrlStrippingEnabled() const { |
| 825 | return pac_https_url_stripping_enabled_.GetValue(); |
| 826 | } |
| 827 | |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 828 | void IOThread::ConstructSystemRequestContext() { |
| 829 | globals_->system_request_context = |
| 830 | base::MakeUnique<SystemURLRequestContext>(); |
| 831 | net::URLRequestContext* context = globals_->system_request_context.get(); |
| 832 | globals_->system_request_context_storage = |
| 833 | base::MakeUnique<net::URLRequestContextStorage>(context); |
| 834 | net::URLRequestContextStorage* context_storage = |
| 835 | globals_->system_request_context_storage.get(); |
mmenke | 518c27b | 2017-05-04 23:15:21 | [diff] [blame] | 836 | |
| 837 | context->set_network_quality_estimator( |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 838 | globals_->network_quality_estimator.get()); |
| 839 | context->set_enable_brotli(globals_->enable_brotli); |
mmenke | 518c27b | 2017-05-04 23:15:21 | [diff] [blame] | 840 | context->set_name("system"); |
| 841 | |
mmenke | 15992ce | 2017-05-30 21:05:02 | [diff] [blame] | 842 | context_storage->set_http_user_agent_settings( |
| 843 | base::MakeUnique<net::StaticHttpUserAgentSettings>(std::string(), |
| 844 | GetUserAgent())); |
| 845 | std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate( |
| 846 | new ChromeNetworkDelegate(extension_event_router_forwarder(), |
| 847 | &system_enable_referrers_)); |
| 848 | // By default, data usage is considered off the record. |
| 849 | chrome_network_delegate->set_data_use_aggregator( |
| 850 | globals_->data_use_aggregator.get(), |
| 851 | true /* is_data_usage_off_the_record */); |
| 852 | context_storage->set_network_delegate( |
| 853 | globals_->data_use_ascriber->CreateNetworkDelegate( |
| 854 | std::move(chrome_network_delegate), GetMetricsDataUseForwarder())); |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 855 | context->set_net_log(net_log_); |
| 856 | context->set_host_resolver(globals_->host_resolver.get()); |
| 857 | |
mmenke | 15992ce | 2017-05-30 21:05:02 | [diff] [blame] | 858 | context_storage->set_ssl_config_service(GetSSLConfigService()); |
wjmaclean | ea309f7 | 2015-08-25 20:56:59 | [diff] [blame] | 859 | context->set_http_auth_handler_factory( |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 860 | globals_->http_auth_handler_factory.get()); |
wjmaclean | ea309f7 | 2015-08-25 20:56:59 | [diff] [blame] | 861 | |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 862 | // In-memory cookie store. |
| 863 | context_storage->set_cookie_store( |
| 864 | content::CreateCookieStore(content::CookieStoreConfig())); |
| 865 | // In-memory channel ID store. |
| 866 | context_storage->set_channel_id_service( |
| 867 | base::MakeUnique<net::ChannelIDService>( |
| 868 | new net::DefaultChannelIDStore(nullptr))); |
| 869 | context->cookie_store()->SetChannelIDServiceID( |
| 870 | context->channel_id_service()->GetUniqueID()); |
| 871 | |
mmenke | 15992ce | 2017-05-30 21:05:02 | [diff] [blame] | 872 | context_storage->set_transport_security_state( |
| 873 | base::MakeUnique<net::TransportSecurityState>()); |
wjmaclean | ea309f7 | 2015-08-25 20:56:59 | [diff] [blame] | 874 | |
mmenke | 15992ce | 2017-05-30 21:05:02 | [diff] [blame] | 875 | context_storage->set_http_server_properties( |
| 876 | base::MakeUnique<net::HttpServerPropertiesImpl>()); |
wjmaclean | ea309f7 | 2015-08-25 20:56:59 | [diff] [blame] | 877 | |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 878 | context->set_cert_verifier(globals_->cert_verifier.get()); |
mmenke | 518c27b | 2017-05-04 23:15:21 | [diff] [blame] | 879 | context->set_cert_transparency_verifier( |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 880 | globals_->cert_transparency_verifier.get()); |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame^] | 881 | |
mmenke | 15992ce | 2017-05-30 21:05:02 | [diff] [blame] | 882 | context_storage->set_ct_policy_enforcer( |
| 883 | base::MakeUnique<net::CTPolicyEnforcer>()); |
maksim.sisov | 3d40c81 | 2016-05-02 13:27:16 | [diff] [blame] | 884 | |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 885 | const base::CommandLine& command_line = |
| 886 | *base::CommandLine::ForCurrentProcess(); |
| 887 | context_storage->set_proxy_service(ProxyServiceFactory::CreateProxyService( |
mmenke | 15992ce | 2017-05-30 21:05:02 | [diff] [blame] | 888 | net_log_, context, context->network_delegate(), |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 889 | std::move(system_proxy_config_service_), command_line, |
| 890 | WpadQuickCheckEnabled(), PacHttpsUrlStrippingEnabled())); |
| 891 | |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame^] | 892 | net::HttpNetworkSession::Context session_context; |
wjmaclean | ea309f7 | 2015-08-25 20:56:59 | [diff] [blame] | 893 | net::URLRequestContextBuilder::SetHttpNetworkSessionComponents( |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame^] | 894 | context, &session_context); |
wjmaclean | ea309f7 | 2015-08-25 20:56:59 | [diff] [blame] | 895 | |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 896 | context_storage->set_http_network_session( |
mmenke | 6ddfbea | 2017-05-31 21:48:41 | [diff] [blame^] | 897 | base::MakeUnique<net::HttpNetworkSession>(session_params_, |
| 898 | session_context)); |
mmenke | f2e53b2 | 2017-05-15 18:40:18 | [diff] [blame] | 899 | context_storage->set_http_transaction_factory( |
| 900 | base::MakeUnique<net::HttpNetworkLayer>( |
| 901 | context_storage->http_network_session())); |
mmenke | 518c27b | 2017-05-04 23:15:21 | [diff] [blame] | 902 | |
mmenke | ab0c11d | 2017-05-30 17:15:17 | [diff] [blame] | 903 | std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory( |
| 904 | new net::URLRequestJobFactoryImpl()); |
| 905 | |
| 906 | job_factory->SetProtocolHandler(url::kDataScheme, |
| 907 | base::MakeUnique<net::DataProtocolHandler>()); |
| 908 | job_factory->SetProtocolHandler( |
| 909 | url::kFileScheme, |
| 910 | base::MakeUnique<net::FileProtocolHandler>( |
| 911 | base::CreateTaskRunnerWithTraits( |
| 912 | {base::MayBlock(), base::TaskPriority::USER_VISIBLE, |
| 913 | base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}))); |
| 914 | #if !BUILDFLAG(DISABLE_FTP_SUPPORT) |
| 915 | job_factory->SetProtocolHandler( |
| 916 | url::kFtpScheme, |
| 917 | net::FtpProtocolHandler::Create(globals_->host_resolver.get())); |
| 918 | #endif |
| 919 | |
| 920 | context_storage->set_job_factory(std::move(job_factory)); |
wjmaclean | ea309f7 | 2015-08-25 20:56:59 | [diff] [blame] | 921 | } |
| 922 | |
bnc | 0f6bff6 | 2016-04-05 16:51:09 | [diff] [blame] | 923 | // static |
bnc | e87c7c71 | 2016-08-01 23:59:48 | [diff] [blame] | 924 | void IOThread::ConfigureParamsFromFieldTrialsAndCommandLine( |
| 925 | const base::CommandLine& command_line, |
| 926 | bool is_quic_allowed_by_policy, |
mmenke | a7da6da | 2016-09-01 21:56:52 | [diff] [blame] | 927 | bool http_09_on_non_default_ports_enabled, |
bnc | e87c7c71 | 2016-08-01 23:59:48 | [diff] [blame] | 928 | net::HttpNetworkSession::Params* params) { |
| 929 | std::string quic_user_agent_id = chrome::GetChannelString(); |
| 930 | if (!quic_user_agent_id.empty()) |
| 931 | quic_user_agent_id.push_back(' '); |
| 932 | quic_user_agent_id.append( |
| 933 | version_info::GetProductNameAndVersionForUserAgent()); |
| 934 | quic_user_agent_id.push_back(' '); |
| 935 | quic_user_agent_id.append(content::BuildOSCpuInfo()); |
| 936 | |
| 937 | bool is_quic_force_disabled = !is_quic_allowed_by_policy || |
| 938 | command_line.HasSwitch(switches::kDisableQuic); |
| 939 | bool is_quic_force_enabled = command_line.HasSwitch(switches::kEnableQuic); |
| 940 | |
| 941 | network_session_configurator::ParseFieldTrials(is_quic_force_disabled, |
| 942 | is_quic_force_enabled, |
| 943 | quic_user_agent_id, params); |
| 944 | |
| 945 | // Command line flags override field trials. |
| 946 | if (command_line.HasSwitch(switches::kIgnoreUrlFetcherCertRequests)) |
| 947 | net::URLFetcher::SetIgnoreCertificateRequests(true); |
| 948 | |
| 949 | if (command_line.HasSwitch(switches::kDisableHttp2)) |
| 950 | params->enable_http2 = false; |
| 951 | |
bnc | e87c7c71 | 2016-08-01 23:59:48 | [diff] [blame] | 952 | if (params->enable_quic) { |
| 953 | if (command_line.HasSwitch(switches::kQuicConnectionOptions)) { |
| 954 | params->quic_connection_options = |
rch | 4c967ea | 2016-12-22 01:41:07 | [diff] [blame] | 955 | net::ParseQuicConnectionOptions( |
bnc | e87c7c71 | 2016-08-01 23:59:48 | [diff] [blame] | 956 | command_line.GetSwitchValueASCII( |
| 957 | switches::kQuicConnectionOptions)); |
| 958 | } |
| 959 | |
bnc | e87c7c71 | 2016-08-01 23:59:48 | [diff] [blame] | 960 | if (command_line.HasSwitch(switches::kQuicMaxPacketLength)) { |
| 961 | unsigned value; |
| 962 | if (base::StringToUint( |
| 963 | command_line.GetSwitchValueASCII(switches::kQuicMaxPacketLength), |
| 964 | &value)) { |
| 965 | params->quic_max_packet_length = value; |
| 966 | } |
| 967 | } |
| 968 | |
| 969 | if (command_line.HasSwitch(switches::kQuicVersion)) { |
| 970 | net::QuicVersion version = network_session_configurator::ParseQuicVersion( |
| 971 | command_line.GetSwitchValueASCII(switches::kQuicVersion)); |
| 972 | if (version != net::QUIC_VERSION_UNSUPPORTED) { |
| 973 | net::QuicVersionVector supported_versions; |
| 974 | supported_versions.push_back(version); |
| 975 | params->quic_supported_versions = supported_versions; |
| 976 | } |
| 977 | } |
| 978 | |
| 979 | if (command_line.HasSwitch(switches::kOriginToForceQuicOn)) { |
| 980 | std::string origins = |
| 981 | command_line.GetSwitchValueASCII(switches::kOriginToForceQuicOn); |
| 982 | for (const std::string& host_port : base::SplitString( |
| 983 | origins, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) { |
| 984 | if (host_port == "*") |
| 985 | params->origins_to_force_quic_on.insert(net::HostPortPair()); |
| 986 | net::HostPortPair quic_origin = |
| 987 | net::HostPortPair::FromString(host_port); |
| 988 | if (!quic_origin.IsEmpty()) |
| 989 | params->origins_to_force_quic_on.insert(quic_origin); |
| 990 | } |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | // Parameters only controlled by command line. |
| 995 | if (command_line.HasSwitch(switches::kEnableUserAlternateProtocolPorts)) { |
| 996 | params->enable_user_alternate_protocol_ports = true; |
| 997 | } |
martinkr | fc8514d | 2017-01-20 01:37:11 | [diff] [blame] | 998 | if (command_line.HasSwitch(switches::kIgnoreCertificateErrors)) { |
bnc | e87c7c71 | 2016-08-01 23:59:48 | [diff] [blame] | 999 | params->ignore_certificate_errors = true; |
martinkr | fc8514d | 2017-01-20 01:37:11 | [diff] [blame] | 1000 | } |
| 1001 | UMA_HISTOGRAM_BOOLEAN( |
| 1002 | "Net.Certificate.IgnoreErrors", |
| 1003 | command_line.HasSwitch(switches::kIgnoreCertificateErrors)); |
bnc | e87c7c71 | 2016-08-01 23:59:48 | [diff] [blame] | 1004 | if (command_line.HasSwitch(switches::kTestingFixedHttpPort)) { |
| 1005 | params->testing_fixed_http_port = |
| 1006 | GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpPort); |
| 1007 | } |
| 1008 | if (command_line.HasSwitch(switches::kTestingFixedHttpsPort)) { |
| 1009 | params->testing_fixed_https_port = |
| 1010 | GetSwitchValueAsInt(command_line, switches::kTestingFixedHttpsPort); |
| 1011 | } |
mmenke | a7da6da | 2016-09-01 21:56:52 | [diff] [blame] | 1012 | |
| 1013 | params->http_09_on_non_default_ports_enabled = |
| 1014 | http_09_on_non_default_ports_enabled; |
bnc | e87c7c71 | 2016-08-01 23:59:48 | [diff] [blame] | 1015 | } |
| 1016 | |
robliao | 7253fd2 | 2016-12-01 18:41:38 | [diff] [blame] | 1017 | metrics::UpdateUsagePrefCallbackType IOThread::GetMetricsDataUseForwarder() { |
| 1018 | return base::Bind(&UpdateMetricsUsagePrefsOnUIThread); |
gayane | 0b46091c | 2016-04-07 21:01:05 | [diff] [blame] | 1019 | } |