| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_DNS_HOST_RESOLVER_IMPL_H_ | 5 #ifndef NET_DNS_HOST_RESOLVER_IMPL_H_ |
| 6 #define NET_DNS_HOST_RESOLVER_IMPL_H_ | 6 #define NET_DNS_HOST_RESOLVER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // Callback from HaveOnlyLoopbackAddresses probe. | 172 // Callback from HaveOnlyLoopbackAddresses probe. |
| 173 void SetHaveOnlyLoopbackAddresses(bool result); | 173 void SetHaveOnlyLoopbackAddresses(bool result); |
| 174 | 174 |
| 175 private: | 175 private: |
| 176 friend class HostResolverImplTest; | 176 friend class HostResolverImplTest; |
| 177 class Job; | 177 class Job; |
| 178 class ProcTask; | 178 class ProcTask; |
| 179 class LoopbackProbeJob; | 179 class LoopbackProbeJob; |
| 180 class DnsTask; | 180 class DnsTask; |
| 181 class RequestImpl; | 181 class RequestImpl; |
| 182 typedef HostCache::Key Key; | 182 using Key = HostCache::Key; |
| 183 typedef std::map<Key, Job*> JobMap; | 183 using JobMap = std::map<Key, std::unique_ptr<Job>>; |
| 184 | 184 |
| 185 // Number of consecutive failures of DnsTask (with successful fallback to | 185 // Number of consecutive failures of DnsTask (with successful fallback to |
| 186 // ProcTask) before the DnsClient is disabled until the next DNS change. | 186 // ProcTask) before the DnsClient is disabled until the next DNS change. |
| 187 static const unsigned kMaximumDnsFailures; | 187 static const unsigned kMaximumDnsFailures; |
| 188 | 188 |
| 189 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP | 189 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP |
| 190 // literal, cache and HOSTS lookup (if enabled), returns OK if successful, | 190 // literal, cache and HOSTS lookup (if enabled), returns OK if successful, |
| 191 // ERR_NAME_NOT_RESOLVED if either hostname is invalid or IP literal is | 191 // ERR_NAME_NOT_RESOLVED if either hostname is invalid or IP literal is |
| 192 // incompatible, ERR_DNS_CACHE_MISS if entry was not found in cache and | 192 // incompatible, ERR_DNS_CACHE_MISS if entry was not found in cache and |
| 193 // HOSTS and is not localhost. | 193 // HOSTS and is not localhost. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 virtual bool IsIPv6Reachable(const NetLogWithSource& net_log); | 256 virtual bool IsIPv6Reachable(const NetLogWithSource& net_log); |
| 257 | 257 |
| 258 // Asynchronously checks if only loopback IPs are available. | 258 // Asynchronously checks if only loopback IPs are available. |
| 259 virtual void RunLoopbackProbeJob(); | 259 virtual void RunLoopbackProbeJob(); |
| 260 | 260 |
| 261 // Records the result in cache if cache is present. | 261 // Records the result in cache if cache is present. |
| 262 void CacheResult(const Key& key, | 262 void CacheResult(const Key& key, |
| 263 const HostCache::Entry& entry, | 263 const HostCache::Entry& entry, |
| 264 base::TimeDelta ttl); | 264 base::TimeDelta ttl); |
| 265 | 265 |
| 266 // Removes |job| from |jobs_|, only if it exists. | 266 // Removes |job| from |jobs_| and returns ownership. |
| 267 void RemoveJob(Job* job); | 267 std::unique_ptr<Job> RemoveJob(Job* job); |
| 268 | 268 |
| 269 // Aborts all in progress jobs with ERR_NETWORK_CHANGED and notifies their | 269 // Aborts all in progress jobs with ERR_NETWORK_CHANGED and notifies their |
| 270 // requests. Might start new jobs. | 270 // requests. Might start new jobs. |
| 271 void AbortAllInProgressJobs(); | 271 void AbortAllInProgressJobs(); |
| 272 | 272 |
| 273 // Aborts all in progress DnsTasks. In-progress jobs will fall back to | 273 // Aborts all in progress DnsTasks. In-progress jobs will fall back to |
| 274 // ProcTasks. Might start new jobs, if any jobs were taking up two dispatcher | 274 // ProcTasks. Might start new jobs, if any jobs were taking up two dispatcher |
| 275 // slots. | 275 // slots. |
| 276 void AbortDnsTasks(); | 276 void AbortDnsTasks(); |
| 277 | 277 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 // This function is only exposed so it can be unit-tested. | 390 // This function is only exposed so it can be unit-tested. |
| 391 // TODO(tfarina): It would be better to change the tests so this function | 391 // TODO(tfarina): It would be better to change the tests so this function |
| 392 // gets exercised indirectly through HostResolverImpl. | 392 // gets exercised indirectly through HostResolverImpl. |
| 393 NET_EXPORT_PRIVATE bool ResolveLocalHostname(base::StringPiece host, | 393 NET_EXPORT_PRIVATE bool ResolveLocalHostname(base::StringPiece host, |
| 394 uint16_t port, | 394 uint16_t port, |
| 395 AddressList* address_list); | 395 AddressList* address_list); |
| 396 | 396 |
| 397 } // namespace net | 397 } // namespace net |
| 398 | 398 |
| 399 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ | 399 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ |
| OLD | NEW |