| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 292 |
| 293 void UpdateDNSConfig(bool config_changed); | 293 void UpdateDNSConfig(bool config_changed); |
| 294 | 294 |
| 295 // True if have a DnsClient with a valid DnsConfig. | 295 // True if have a DnsClient with a valid DnsConfig. |
| 296 bool HaveDnsConfig() const; | 296 bool HaveDnsConfig() const; |
| 297 | 297 |
| 298 // Called when a host name is successfully resolved and DnsTask was run on it | 298 // Called when a host name is successfully resolved and DnsTask was run on it |
| 299 // and resulted in |net_error|. | 299 // and resulted in |net_error|. |
| 300 void OnDnsTaskResolve(int net_error); | 300 void OnDnsTaskResolve(int net_error); |
| 301 | 301 |
| 302 void OnCacheEntryEvicted(const HostCache::Key& key, |
| 303 const HostCache::Entry& entry); |
| 304 void ClearCacheHitCallbacks(const HostCache::Key& key); |
| 305 void MaybeAddCacheHitCallback(const HostCache::Key& key, |
| 306 const RequestInfo& info); |
| 307 void RunCacheHitCallbacks(const HostCache::Key& key, const RequestInfo& info); |
| 308 |
| 309 void ApplyPersistentData(std::unique_ptr<const base::Value>); |
| 310 std::unique_ptr<const base::Value> GetPersistentData(); |
| 311 |
| 302 void SchedulePersist(); | 312 void SchedulePersist(); |
| 303 void DoPersist(); | 313 void DoPersist(); |
| 304 | 314 |
| 305 void ApplyPersistentData(std::unique_ptr<const base::Value>); | |
| 306 std::unique_ptr<const base::Value> GetPersistentData(); | |
| 307 | |
| 308 // Allows the tests to catch slots leaking out of the dispatcher. One | 315 // Allows the tests to catch slots leaking out of the dispatcher. One |
| 309 // HostResolverImpl::Job could occupy multiple PrioritizedDispatcher job | 316 // HostResolverImpl::Job could occupy multiple PrioritizedDispatcher job |
| 310 // slots. | 317 // slots. |
| 311 size_t num_running_dispatcher_jobs_for_tests() const { | 318 size_t num_running_dispatcher_jobs_for_tests() const { |
| 312 return dispatcher_->num_running_jobs(); | 319 return dispatcher_->num_running_jobs(); |
| 313 } | 320 } |
| 314 | 321 |
| 315 // Cache of host resolution results. | 322 // Cache of host resolution results. |
| 316 std::unique_ptr<HostCache> cache_; | 323 std::unique_ptr<HostCache> cache_; |
| 317 | 324 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 HostResolverFlags additional_resolver_flags_; | 361 HostResolverFlags additional_resolver_flags_; |
| 355 | 362 |
| 356 // Allow fallback to ProcTask if DnsTask fails. | 363 // Allow fallback to ProcTask if DnsTask fails. |
| 357 bool fallback_to_proctask_; | 364 bool fallback_to_proctask_; |
| 358 | 365 |
| 359 // Task runner used for DNS lookups using the platform resolver, and other | 366 // Task runner used for DNS lookups using the platform resolver, and other |
| 360 // blocking operations. Usually just the WorkerPool's task runner for slow | 367 // blocking operations. Usually just the WorkerPool's task runner for slow |
| 361 // tasks, but can be overridden for tests. | 368 // tasks, but can be overridden for tests. |
| 362 scoped_refptr<base::TaskRunner> worker_task_runner_; | 369 scoped_refptr<base::TaskRunner> worker_task_runner_; |
| 363 | 370 |
| 371 std::map<const HostCache::Key, std::vector<RequestInfo::CacheHitCallback>> |
| 372 cache_hit_callbacks_; |
| 373 |
| 364 bool persist_initialized_; | 374 bool persist_initialized_; |
| 365 PersistCallback persist_callback_; | 375 PersistCallback persist_callback_; |
| 366 base::OneShotTimer persist_timer_; | 376 base::OneShotTimer persist_timer_; |
| 367 | 377 |
| 368 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; | 378 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; |
| 369 | 379 |
| 370 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; | 380 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; |
| 371 | 381 |
| 372 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 382 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
| 373 }; | 383 }; |
| 374 | 384 |
| 375 // Resolves a local hostname (such as "localhost" or "localhost6") into | 385 // Resolves a local hostname (such as "localhost" or "localhost6") into |
| 376 // IP endpoints with the given port. Returns true if |host| is a local | 386 // IP endpoints with the given port. Returns true if |host| is a local |
| 377 // hostname and false otherwise. Special IPv6 names (e.g. "localhost6") | 387 // hostname and false otherwise. Special IPv6 names (e.g. "localhost6") |
| 378 // will resolve to an IPv6 address only, whereas other names will | 388 // will resolve to an IPv6 address only, whereas other names will |
| 379 // resolve to both IPv4 and IPv6. | 389 // resolve to both IPv4 and IPv6. |
| 380 // This function is only exposed so it can be unit-tested. | 390 // This function is only exposed so it can be unit-tested. |
| 381 // 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 |
| 382 // gets exercised indirectly through HostResolverImpl. | 392 // gets exercised indirectly through HostResolverImpl. |
| 383 NET_EXPORT_PRIVATE bool ResolveLocalHostname(base::StringPiece host, | 393 NET_EXPORT_PRIVATE bool ResolveLocalHostname(base::StringPiece host, |
| 384 uint16_t port, | 394 uint16_t port, |
| 385 AddressList* address_list); | 395 AddressList* address_list); |
| 386 | 396 |
| 387 } // namespace net | 397 } // namespace net |
| 388 | 398 |
| 389 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ | 399 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ |
| OLD | NEW |