Eric Orth | dc35748e | 2018-08-23 22:41:48 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 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_SOURCE_H_ |
| 6 | #define NET_DNS_HOST_RESOLVER_SOURCE_H_ |
| 7 | |
Eric Orth | 50d4b20 | 2019-01-14 18:38:28 | [diff] [blame] | 8 | #include "base/stl_util.h" |
| 9 | |
Eric Orth | 12c4725 | 2018-09-05 17:04:07 | [diff] [blame] | 10 | namespace net { |
| 11 | |
Eric Orth | dc35748e | 2018-08-23 22:41:48 | [diff] [blame] | 12 | // Enumeration to specify the allowed results source for HostResolver |
| 13 | // requests. |
| 14 | enum class HostResolverSource { |
| 15 | // Resolver will pick an appropriate source. Results could come from DNS, |
| 16 | // MulticastDNS, HOSTS file, etc. |
| 17 | ANY, |
| 18 | |
| 19 | // Results will only be retrieved from the system or OS, eg via the |
| 20 | // getaddrinfo() system call. |
| 21 | SYSTEM, |
| 22 | |
| 23 | // Results will only come from DNS queries. |
| 24 | DNS, |
| 25 | |
Eric Orth | 9871aafa | 2018-10-02 19:59:18 | [diff] [blame] | 26 | // Results will only come from Multicast DNS queries. |
| 27 | MULTICAST_DNS, |
Eric Orth | 50d4b20 | 2019-01-14 18:38:28 | [diff] [blame] | 28 | |
Eric Orth | eb33286 | 2019-01-26 00:52:38 | [diff] [blame] | 29 | // No external sources will be used. Results will only come from fast local |
| 30 | // sources that are available no matter the source setting, e.g. cache, hosts |
| 31 | // file, IP literal resolution, etc. Resolves with this setting are guaranteed |
| 32 | // to finish synchronously. |
| 33 | LOCAL_ONLY, |
| 34 | |
| 35 | MAX = LOCAL_ONLY |
Eric Orth | dc35748e | 2018-08-23 22:41:48 | [diff] [blame] | 36 | }; |
| 37 | |
Eric Orth | 50d4b20 | 2019-01-14 18:38:28 | [diff] [blame] | 38 | const HostResolverSource kHostResolverSources[] = { |
| 39 | HostResolverSource::ANY, HostResolverSource::SYSTEM, |
Eric Orth | eb33286 | 2019-01-26 00:52:38 | [diff] [blame] | 40 | HostResolverSource::DNS, HostResolverSource::MULTICAST_DNS, |
| 41 | HostResolverSource::LOCAL_ONLY}; |
Eric Orth | 50d4b20 | 2019-01-14 18:38:28 | [diff] [blame] | 42 | |
| 43 | static_assert( |
| 44 | base::size(kHostResolverSources) == |
| 45 | static_cast<unsigned>(HostResolverSource::MAX) + 1, |
| 46 | "All HostResolverSource values should be in kHostResolverSources."); |
| 47 | |
Eric Orth | 12c4725 | 2018-09-05 17:04:07 | [diff] [blame] | 48 | } // namespace net |
| 49 | |
Eric Orth | dc35748e | 2018-08-23 22:41:48 | [diff] [blame] | 50 | #endif // NET_DNS_HOST_RESOLVER_SOURCE_H_ |