• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_DNS_HOST_RESOLVER_MANAGER_H_
6 #define NET_DNS_HOST_RESOLVER_MANAGER_H_
7 
8 #include <stddef.h>
9 #include <stdint.h>
10 
11 #include <deque>
12 #include <map>
13 #include <memory>
14 #include <set>
15 #include <string>
16 #include <vector>
17 
18 #include "base/functional/callback.h"
19 #include "base/functional/callback_helpers.h"
20 #include "base/memory/raw_ptr.h"
21 #include "base/memory/scoped_refptr.h"
22 #include "base/memory/weak_ptr.h"
23 #include "base/observer_list.h"
24 #include "base/strings/string_piece.h"
25 #include "base/time/time.h"
26 #include "base/timer/timer.h"
27 #include "base/values.h"
28 #include "net/base/completion_once_callback.h"
29 #include "net/base/host_port_pair.h"
30 #include "net/base/network_anonymization_key.h"
31 #include "net/base/network_change_notifier.h"
32 #include "net/base/network_handle.h"
33 #include "net/base/prioritized_dispatcher.h"
34 #include "net/dns/dns_config.h"
35 #include "net/dns/host_cache.h"
36 #include "net/dns/host_resolver.h"
37 #include "net/dns/httpssvc_metrics.h"
38 #include "net/dns/public/dns_config_overrides.h"
39 #include "net/dns/public/dns_query_type.h"
40 #include "net/dns/public/secure_dns_mode.h"
41 #include "net/dns/public/secure_dns_policy.h"
42 #include "net/dns/resolve_context.h"
43 #include "net/dns/system_dns_config_change_notifier.h"
44 #include "net/log/net_log_with_source.h"
45 #include "net/socket/datagram_client_socket.h"
46 #include "third_party/abseil-cpp/absl/types/optional.h"
47 #include "third_party/abseil-cpp/absl/types/variant.h"
48 #include "url/gurl.h"
49 #include "url/scheme_host_port.h"
50 
51 namespace base {
52 class TickClock;
53 }  // namespace base
54 
55 namespace net {
56 
57 class DnsClient;
58 class DnsProbeRunner;
59 class IPAddress;
60 class MDnsClient;
61 class MDnsSocketFactory;
62 class NetLog;
63 
64 // Scheduler and controller of host resolution requests. Because of the global
65 // nature of host resolutions, this class is generally expected to be singleton
66 // within the browser and only be interacted with through per-context
67 // ContextHostResolver objects (which are themselves generally interacted with
68 // though the HostResolver interface).
69 //
70 // For each hostname that is requested, HostResolver creates a
71 // HostResolverManager::Job. When this job gets dispatched it creates a task
72 // (HostResolverSystemTask for the system resolver or DnsTask for the async
73 // resolver) which resolves the hostname. If requests for that same host are
74 // made during the job's lifetime, they are attached to the existing job rather
75 // than creating a new one. This avoids doing parallel resolves for the same
76 // host.
77 //
78 // The way these classes fit together is illustrated by:
79 //
80 //
81 //            +----------- HostResolverManager ----------+
82 //            |                    |                     |
83 //           Job                  Job                   Job
84 //    (for host1, fam1)    (for host2, fam2)     (for hostx, famx)
85 //       /    |   |            /   |   |             /   |   |
86 //   Request ... Request  Request ... Request   Request ... Request
87 //  (port1)     (port2)  (port3)      (port4)  (port5)      (portX)
88 //
89 // When a HostResolverManager::Job finishes, the callbacks of each waiting
90 // request are run on the origin thread.
91 //
92 // Thread safety: This class is not threadsafe, and must only be called
93 // from one thread!
94 //
95 // The HostResolverManager enforces limits on the maximum number of concurrent
96 // threads using PrioritizedDispatcher::Limits.
97 //
98 // Jobs are ordered in the queue based on their priority and order of arrival.
99 class NET_EXPORT HostResolverManager
100     : public NetworkChangeNotifier::IPAddressObserver,
101       public NetworkChangeNotifier::ConnectionTypeObserver,
102       public SystemDnsConfigChangeNotifier::Observer {
103  public:
104   using MdnsListener = HostResolver::MdnsListener;
105   using ResolveHostParameters = HostResolver::ResolveHostParameters;
106   using PassKey = base::PassKey<HostResolverManager>;
107 
108   // Creates a HostResolver as specified by |options|. Blocking tasks are run in
109   // ThreadPool.
110   //
111   // If Options.enable_caching is true, a cache is created using
112   // HostCache::CreateDefaultCache(). Otherwise no cache is used.
113   //
114   // Options.GetDispatcherLimits() determines the maximum number of jobs that
115   // the resolver will run at once. This upper-bounds the total number of
116   // outstanding DNS transactions (not counting retransmissions and retries).
117   //
118   // |net_log| and |system_dns_config_notifier|, if non-null, must remain valid
119   // for the life of the HostResolverManager.
120   HostResolverManager(const HostResolver::ManagerOptions& options,
121                       SystemDnsConfigChangeNotifier* system_dns_config_notifier,
122                       NetLog* net_log);
123 
124   HostResolverManager(const HostResolverManager&) = delete;
125   HostResolverManager& operator=(const HostResolverManager&) = delete;
126 
127   // If any completion callbacks are pending when the resolver is destroyed,
128   // the host resolutions are cancelled, and the completion callbacks will not
129   // be called.
130   ~HostResolverManager() override;
131 
132   // Same as constructor above, but binds the HostResolverManager to
133   // `target_network`: all DNS requests will be performed for `target_network`
134   // only, requests will fail if `target_network` disconnects. Only
135   // HostResolvers bound to the same network will be able to use this.
136   // Only implemented for Android.
137   static std::unique_ptr<HostResolverManager>
138   CreateNetworkBoundHostResolverManager(
139       const HostResolver::ManagerOptions& options,
140       handles::NetworkHandle target_network,
141       NetLog* net_log);
142 
143   // |resolve_context| must have already been added (via
144   // RegisterResolveContext()). If |optional_parameters| specifies any cache
145   // usage other than LOCAL_ONLY, there must be a 1:1 correspondence between
146   // |resolve_context| and |host_cache|, and both should come from the same
147   // ContextHostResolver.
148   //
149   // TODO(crbug.com/1022059): Use the HostCache out of the ResolveContext
150   // instead of passing it separately.
151   std::unique_ptr<HostResolver::ResolveHostRequest> CreateRequest(
152       absl::variant<url::SchemeHostPort, HostPortPair> host,
153       NetworkAnonymizationKey network_anonymization_key,
154       NetLogWithSource net_log,
155       absl::optional<ResolveHostParameters> optional_parameters,
156       ResolveContext* resolve_context,
157       HostCache* host_cache);
158   std::unique_ptr<HostResolver::ResolveHostRequest> CreateRequest(
159       HostResolver::Host host,
160       NetworkAnonymizationKey network_anonymization_key,
161       NetLogWithSource net_log,
162       absl::optional<ResolveHostParameters> optional_parameters,
163       ResolveContext* resolve_context,
164       HostCache* host_cache);
165   // |resolve_context| is the context to use for the probes, and it is expected
166   // to be the context of the calling ContextHostResolver.
167   std::unique_ptr<HostResolver::ProbeRequest> CreateDohProbeRequest(
168       ResolveContext* resolve_context);
169   std::unique_ptr<MdnsListener> CreateMdnsListener(const HostPortPair& host,
170                                                    DnsQueryType query_type);
171 
172   // Enables or disables the built-in asynchronous DnsClient. If enabled, by
173   // default (when no |ResolveHostParameters::source| is specified), the
174   // DnsClient will be used for resolves and, in case of failure, resolution
175   // will fallback to the system resolver (in tests, HostResolverProc from
176   // HostResolverSystemTask::Params). If the DnsClient is not pre-configured
177   // with a valid DnsConfig, a new config is fetched from NetworkChangeNotifier.
178   //
179   // Setting to |true| has no effect if |ENABLE_BUILT_IN_DNS| not defined.
180   virtual void SetInsecureDnsClientEnabled(bool enabled,
181                                            bool additional_dns_types_enabled);
182 
183   base::Value::Dict GetDnsConfigAsValue() const;
184 
185   // Sets overriding configuration that will replace or add to configuration
186   // read from the system for DnsClient resolution.
187   void SetDnsConfigOverrides(DnsConfigOverrides overrides);
188 
189   // Support for invalidating cached per-context data on changes to network or
190   // DNS configuration. ContextHostResolvers should register/deregister
191   // themselves here rather than attempting to listen for relevant network
192   // change signals themselves because HostResolverManager needs to coordinate
193   // invalidations with in-progress resolves and because some invalidations are
194   // triggered by changes to manager properties/configuration rather than pure
195   // network changes.
196   //
197   // Note: Invalidation handling must not call back into HostResolverManager as
198   // the invalidation is expected to be handled atomically with other clearing
199   // and aborting actions.
200   void RegisterResolveContext(ResolveContext* context);
201   void DeregisterResolveContext(const ResolveContext* context);
202 
set_host_resolver_system_params_for_test(const HostResolverSystemTask::Params & host_resolver_system_params)203   void set_host_resolver_system_params_for_test(
204       const HostResolverSystemTask::Params& host_resolver_system_params) {
205     host_resolver_system_params_ = host_resolver_system_params;
206   }
207 
InvalidateCachesForTesting()208   void InvalidateCachesForTesting() { InvalidateCaches(); }
209 
210   void SetTickClockForTesting(const base::TickClock* tick_clock);
211 
212   // Configures maximum number of Jobs in the queue. Exposed for testing.
213   // Only allowed when the queue is empty.
214   void SetMaxQueuedJobsForTesting(size_t value);
215 
216   void SetMdnsSocketFactoryForTesting(
217       std::unique_ptr<MDnsSocketFactory> socket_factory);
218   void SetMdnsClientForTesting(std::unique_ptr<MDnsClient> client);
219 
220   // To simulate modifications it would have received if |dns_client| had been
221   // in place before calling this, DnsConfig will be set with the configuration
222   // from the previous DnsClient being replaced (including system config if
223   // |dns_client| does not already contain a system config). This means tests do
224   // not normally need to worry about ordering between setting a test client and
225   // setting DnsConfig.
226   void SetDnsClientForTesting(std::unique_ptr<DnsClient> dns_client);
227 
228   // Explicitly disable the system resolver even if tests have set a catch-all
229   // DNS block. See `ForceSystemResolverDueToTestOverride`.
DisableSystemResolverForTesting()230   void DisableSystemResolverForTesting() {
231     system_resolver_disabled_for_testing_ = true;
232   }
233 
234   // Sets the last IPv6 probe result for testing. Uses the standard timeout
235   // duration, so it's up to the test fixture to ensure it doesn't expire by
236   // mocking time, if expiration would pose a problem.
237   void SetLastIPv6ProbeResultForTesting(bool last_ipv6_probe_result);
238 
ResetIPv6ProbeTimeForTesting()239   void ResetIPv6ProbeTimeForTesting() {
240     last_ipv6_probe_time_ = base::TimeTicks();
241   }
242 
243   // Allows the tests to catch slots leaking out of the dispatcher.  One
244   // HostResolverManager::Job could occupy multiple PrioritizedDispatcher job
245   // slots.
num_running_dispatcher_jobs_for_tests()246   size_t num_running_dispatcher_jobs_for_tests() const {
247     return dispatcher_->num_running_jobs();
248   }
249 
num_jobs_for_testing()250   size_t num_jobs_for_testing() const { return jobs_.size(); }
251 
check_ipv6_on_wifi_for_testing()252   bool check_ipv6_on_wifi_for_testing() const { return check_ipv6_on_wifi_; }
253 
target_network_for_testing()254   handles::NetworkHandle target_network_for_testing() const {
255     return target_network_;
256   }
257 
https_svcb_options_for_testing()258   const HostResolver::HttpsSvcbOptions& https_svcb_options_for_testing() const {
259     return https_svcb_options_;
260   }
261 
262   // Public to be called from std::make_unique. Not to be called directly.
263   HostResolverManager(base::PassKey<HostResolverManager>,
264                       const HostResolver::ManagerOptions& options,
265                       SystemDnsConfigChangeNotifier* system_dns_config_notifier,
266                       handles::NetworkHandle target_network,
267                       NetLog* net_log);
268 
269  protected:
270   // Callback from HaveOnlyLoopbackAddresses probe.
271   void SetHaveOnlyLoopbackAddresses(bool result);
272 
273  private:
274   friend class HostResolverManagerTest;
275   friend class HostResolverManagerDnsTest;
276   class Job;
277   struct JobKey;
278   class LoopbackProbeJob;
279   class DnsTask;
280   class RequestImpl;
281   class ProbeRequestImpl;
282   using JobMap = std::map<JobKey, std::unique_ptr<Job>>;
283 
284   // Task types that a Job might run.
285   // These values are persisted to logs. Entries should not be renumbered and
286   // numeric values should never be reused
287   enum class TaskType {
288     SYSTEM = 0,
289     DNS = 1,
290     SECURE_DNS = 2,
291     MDNS = 3,
292     CACHE_LOOKUP = 4,
293     INSECURE_CACHE_LOOKUP = 5,
294     SECURE_CACHE_LOOKUP = 6,
295     CONFIG_PRESET = 7,
296     NAT64 = 8,
297     HOSTS = 9,
298 
299     kMaxValue = HOSTS,
300   };
301 
302   // Returns true if the task is local, synchronous, and instantaneous.
303   static bool IsLocalTask(TaskType task);
304 
305   // Attempts host resolution using fast local sources: IP literal resolution,
306   // cache lookup, HOSTS lookup (if enabled), and localhost. Returns results
307   // with error() OK if successful, ERR_NAME_NOT_RESOLVED if input is invalid,
308   // or ERR_DNS_CACHE_MISS if the host could not be resolved using local
309   // sources.
310   //
311   // On ERR_DNS_CACHE_MISS and OK, |out_tasks| contains the tentative
312   // sequence of tasks that a future job should run.
313   //
314   // If results are returned from the host cache, |out_stale_info| will be
315   // filled in with information on how stale or fresh the result is. Otherwise,
316   // |out_stale_info| will be set to |absl::nullopt|.
317   //
318   // If |cache_usage == ResolveHostParameters::CacheUsage::STALE_ALLOWED|, then
319   // stale cache entries can be returned.
320   HostCache::Entry ResolveLocally(
321       bool only_ipv6_reachable,
322       const JobKey& job_key,
323       const IPAddress& ip_address,
324       ResolveHostParameters::CacheUsage cache_usage,
325       SecureDnsPolicy secure_dns_policy,
326       HostResolverSource source,
327       const NetLogWithSource& source_net_log,
328       HostCache* cache,
329       std::deque<TaskType>* out_tasks,
330       absl::optional<HostCache::EntryStaleness>* out_stale_info);
331 
332   // Creates and starts a Job to asynchronously attempt to resolve
333   // |request|.
334   void CreateAndStartJob(JobKey key,
335                          std::deque<TaskType> tasks,
336                          RequestImpl* request);
337 
338   HostResolverManager::Job* AddJobWithoutRequest(
339       JobKey key,
340       ResolveHostParameters::CacheUsage cache_usage,
341       HostCache* host_cache,
342       std::deque<TaskType> tasks,
343       RequestPriority priority,
344       const NetLogWithSource& source_net_log);
345 
346   // Resolves the IP literal hostname represented by `ip_address`.
347   HostCache::Entry ResolveAsIP(DnsQueryTypeSet query_types,
348                                bool resolve_canonname,
349                                const IPAddress& ip_address);
350 
351   // Returns the result iff |cache_usage| permits cache lookups and a positive
352   // match is found for |key| in |cache|. |out_stale_info| must be non-null, and
353   // will be filled in with details of the entry's staleness if an entry is
354   // returned, otherwise it will be set to |absl::nullopt|.
355   absl::optional<HostCache::Entry> MaybeServeFromCache(
356       HostCache* cache,
357       const HostCache::Key& key,
358       ResolveHostParameters::CacheUsage cache_usage,
359       bool ignore_secure,
360       const NetLogWithSource& source_net_log,
361       absl::optional<HostCache::EntryStaleness>* out_stale_info);
362 
363   // Returns any preset resolution result from the active DoH configuration that
364   // matches |key.host|.
365   absl::optional<HostCache::Entry> MaybeReadFromConfig(const JobKey& key);
366 
367   // Populates the secure cache with an optimal entry that supersedes the
368   // bootstrap result.
369   void StartBootstrapFollowup(JobKey key,
370                               HostCache* host_cache,
371                               const NetLogWithSource& source_net_log);
372 
373   // Iff we have a DnsClient with a valid DnsConfig and we're not about to
374   // attempt a system lookup, then try to resolve the query using the HOSTS
375   // file.
376   absl::optional<HostCache::Entry> ServeFromHosts(
377       base::StringPiece hostname,
378       DnsQueryTypeSet query_types,
379       bool default_family_due_to_no_ipv6,
380       const std::deque<TaskType>& tasks);
381 
382   // Iff |key| is for a localhost name (RFC 6761) and address DNS query type,
383   // returns a results entry with the loopback IP.
384   absl::optional<HostCache::Entry> ServeLocalhost(
385       base::StringPiece hostname,
386       DnsQueryTypeSet query_types,
387       bool default_family_due_to_no_ipv6);
388 
389   // Returns the secure dns mode to use for a job, taking into account the
390   // global DnsConfig mode and any per-request policy.
391   SecureDnsMode GetEffectiveSecureDnsMode(SecureDnsPolicy secure_dns_policy);
392 
393   // Returns true when a catch-all DNS block has been set for tests, unless
394   // `SetDisableSystemResolverForTesting` has been called to explicitly disable
395   // that safety net. DnsTasks should never be issued when this returns true.
396   bool ShouldForceSystemResolverDueToTestOverride() const;
397 
398   // Helper method to add DnsTasks and related tasks based on the SecureDnsMode
399   // and fallback parameters. If |prioritize_local_lookups| is true, then we
400   // may push an insecure cache lookup ahead of a secure DnsTask.
401   void PushDnsTasks(bool system_task_allowed,
402                     SecureDnsMode secure_dns_mode,
403                     bool insecure_tasks_allowed,
404                     bool allow_cache,
405                     bool prioritize_local_lookups,
406                     ResolveContext* resolve_context,
407                     std::deque<TaskType>* out_tasks);
408 
409   // Initialized the sequence of tasks to run to resolve a request. The sequence
410   // may be adjusted later and not all tasks need to be run.
411   void CreateTaskSequence(const JobKey& job_key,
412                           ResolveHostParameters::CacheUsage cache_usage,
413                           SecureDnsPolicy secure_dns_policy,
414                           std::deque<TaskType>* out_tasks);
415 
416   // Determines "effective" request parameters using manager properties and IPv6
417   // reachability.
418   void GetEffectiveParametersForRequest(
419       const absl::variant<url::SchemeHostPort, std::string>& host,
420       DnsQueryType dns_query_type,
421       HostResolverFlags flags,
422       SecureDnsPolicy secure_dns_policy,
423       bool is_ip,
424       const NetLogWithSource& net_log,
425       DnsQueryTypeSet* out_effective_types,
426       HostResolverFlags* out_effective_flags,
427       SecureDnsMode* out_effective_secure_dns_mode);
428 
429   // Schedules probes to check IPv6 support. Returns OK if probe results are
430   // already cached, and ERR_IO_PENDING when a probe is scheduled to be
431   // completed asynchronously. When called repeatedly this method returns OK to
432   // confirm that results have been cached.
433   int StartIPv6ReachabilityCheck(const NetLogWithSource& net_log,
434                                  CompletionOnceCallback callback);
435 
436   void FinishIPv6ReachabilityCheck(CompletionOnceCallback callback, int rv);
437 
438   // Sets |last_ipv6_probe_result_| and updates |last_ipv6_probe_time_|.
439   void SetLastIPv6ProbeResult(bool last_ipv6_probe_result);
440 
441   // Attempts to connect a UDP socket to |dest|:53. Virtual for testing. Returns
442   // the value of the attempted socket connection and the reachability check. If
443   // the return value from the connection is not ERR_IO_PENDING, callers must
444   // handle the results of the reachability check themselves. Otherwise the
445   // result of the reachability check will be set when `callback` is run.
446   // Returns OK if the reachability check succeeded, ERR_FAILED if it failed,
447   // ERR_IO_PENDING if it will be asynchronous.
448   virtual int StartGloballyReachableCheck(const IPAddress& dest,
449                                           const NetLogWithSource& net_log,
450                                           CompletionOnceCallback callback);
451 
452   bool FinishGloballyReachableCheck(DatagramClientSocket* socket, int rv);
453 
454   void RunFinishGloballyReachableCheck(
455       scoped_refptr<base::RefCountedData<std::unique_ptr<DatagramClientSocket>>>
456           socket,
457       CompletionOnceCallback callback,
458       int rv);
459 
460   // Asynchronously checks if only loopback IPs are available.
461   virtual void RunLoopbackProbeJob();
462 
463   // Records the result in cache if cache is present.
464   void CacheResult(HostCache* cache,
465                    const HostCache::Key& key,
466                    const HostCache::Entry& entry,
467                    base::TimeDelta ttl);
468 
469   // Removes |job_it| from |jobs_| and return.
470   std::unique_ptr<Job> RemoveJob(JobMap::iterator job_it);
471 
472   // Removes Jobs for this context.
473   void RemoveAllJobs(const ResolveContext* context);
474 
475   // Aborts all jobs (both scheduled and running) which are not targeting a
476   // specific network with ERR_NETWORK_CHANGED and notifies their requests.
477   // Aborts only running jobs if `in_progress_only` is true. Might start new
478   // jobs.
479   void AbortJobsWithoutTargetNetwork(bool in_progress_only);
480 
481   // Aborts all in progress insecure DnsTasks. In-progress jobs will fall back
482   // to HostResolverSystemTasks if able and otherwise abort with |error|. Might
483   // start new jobs, if any jobs were taking up two dispatcher slots.
484   //
485   // If |fallback_only|, insecure DnsTasks will only abort if they can fallback
486   // to HostResolverSystemTasks.
487   void AbortInsecureDnsTasks(int error, bool fallback_only);
488 
489   // Attempts to serve each Job in |jobs_| from the HOSTS file if we have
490   // a DnsClient with a valid DnsConfig.
491   void TryServingAllJobsFromHosts();
492 
493   // NetworkChangeNotifier::IPAddressObserver:
494   void OnIPAddressChanged() override;
495 
496   // NetworkChangeNotifier::ConnectionTypeObserver:
497   void OnConnectionTypeChanged(
498       NetworkChangeNotifier::ConnectionType type) override;
499 
500   // SystemDnsConfigChangeNotifier::Observer:
501   void OnSystemDnsConfigChanged(absl::optional<DnsConfig> config) override;
502 
503   void UpdateJobsForChangedConfig();
504 
505   // Called on successful resolve after falling back to HostResolverSystemTask
506   // after a failed DnsTask resolve.
507   void OnFallbackResolve(int dns_task_error);
508 
509   int GetOrCreateMdnsClient(MDnsClient** out_client);
510 
511   // |network_change| indicates whether or not the invalidation was triggered
512   // by a network connection change.
513   void InvalidateCaches(bool network_change = false);
514 
515   void UpdateConnectionType(NetworkChangeNotifier::ConnectionType type);
516 
IsBoundToNetwork()517   bool IsBoundToNetwork() const {
518     return target_network_ != handles::kInvalidNetworkHandle;
519   }
520 
521   // Returns |nullptr| if DoH probes are currently not allowed (due to
522   // configuration or current connection state).
523   std::unique_ptr<DnsProbeRunner> CreateDohProbeRunner(
524       ResolveContext* resolve_context);
525 
526   // Used for multicast DNS tasks. Created on first use using
527   // GetOrCreateMndsClient().
528   std::unique_ptr<MDnsSocketFactory> mdns_socket_factory_;
529   std::unique_ptr<MDnsClient> mdns_client_;
530 
531   // Map from HostCache::Key to a Job.
532   JobMap jobs_;
533 
534   // Starts Jobs according to their priority and the configured limits.
535   std::unique_ptr<PrioritizedDispatcher> dispatcher_;
536 
537   // Limit on the maximum number of jobs queued in |dispatcher_|.
538   size_t max_queued_jobs_ = 0;
539 
540   // Parameters for HostResolverSystemTask.
541   HostResolverSystemTask::Params host_resolver_system_params_;
542 
543   raw_ptr<NetLog> net_log_;
544 
545   // If present, used by DnsTask and ServeFromHosts to resolve requests.
546   std::unique_ptr<DnsClient> dns_client_;
547 
548   raw_ptr<SystemDnsConfigChangeNotifier> system_dns_config_notifier_;
549 
550   handles::NetworkHandle target_network_;
551 
552   // False if IPv6 should not be attempted and assumed unreachable when on a
553   // WiFi connection. See https://crbug.com/696569 for further context.
554   bool check_ipv6_on_wifi_;
555 
556   base::TimeTicks last_ipv6_probe_time_;
557   bool last_ipv6_probe_result_ = true;
558   bool probing_ipv6_ = false;
559 
560   // Any resolver flags that should be added to a request by default.
561   HostResolverFlags additional_resolver_flags_ = 0;
562 
563   // Allow fallback to HostResolverSystemTask if DnsTask fails.
564   bool allow_fallback_to_systemtask_ = true;
565 
566   // Shared tick clock, overridden for testing.
567   raw_ptr<const base::TickClock> tick_clock_;
568 
569   // When true, ignore the catch-all DNS block if it exists.
570   bool system_resolver_disabled_for_testing_ = false;
571 
572   // For per-context cache invalidation notifications.
573   base::ObserverList<ResolveContext,
574                      true /* check_empty */,
575                      false /* allow_reentrancy */>
576       registered_contexts_;
577   bool invalidation_in_progress_ = false;
578 
579   // An experimental flag for features::kUseDnsHttpsSvcb.
580   HostResolver::HttpsSvcbOptions https_svcb_options_;
581 
582   std::vector<CompletionOnceCallback> ipv6_request_callbacks_;
583 
584   THREAD_CHECKER(thread_checker_);
585 
586   base::WeakPtrFactory<HostResolverManager> weak_ptr_factory_{this};
587 
588   base::WeakPtrFactory<HostResolverManager> probe_weak_ptr_factory_{this};
589 };
590 
591 // Resolves a local hostname (such as "localhost" or "vhost.localhost") into
592 // IP endpoints (with port 0). Returns true if |host| is a local
593 // hostname and false otherwise. Names will resolve to both IPv4 and IPv6.
594 // This function is only exposed so it can be unit-tested.
595 // TODO(tfarina): It would be better to change the tests so this function
596 // gets exercised indirectly through HostResolverManager.
597 NET_EXPORT_PRIVATE bool ResolveLocalHostname(
598     base::StringPiece host,
599     std::vector<IPEndPoint>* address_list);
600 
601 }  // namespace net
602 
603 #endif  // NET_DNS_HOST_RESOLVER_MANAGER_H_
604