Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: net/dns/host_resolver_impl.h

Issue 2083643003: DNS: Let requests specify a callback for future cache hits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 290
291 void UpdateDNSConfig(bool config_changed); 291 void UpdateDNSConfig(bool config_changed);
292 292
293 // True if have a DnsClient with a valid DnsConfig. 293 // True if have a DnsClient with a valid DnsConfig.
294 bool HaveDnsConfig() const; 294 bool HaveDnsConfig() const;
295 295
296 // Called when a host name is successfully resolved and DnsTask was run on it 296 // Called when a host name is successfully resolved and DnsTask was run on it
297 // and resulted in |net_error|. 297 // and resulted in |net_error|.
298 void OnDnsTaskResolve(int net_error); 298 void OnDnsTaskResolve(int net_error);
299 299
300 void OnCacheEntryEvicted(const HostCache::Key& key,
301 const HostCache::Entry& entry);
302 void ClearCacheHitCallbacks(const HostCache::Key& key);
303 void MaybeAddCacheHitCallback(const HostCache::Key& key,
304 const RequestInfo& info);
305 void RunCacheHitCallbacks(const HostCache::Key& key, const RequestInfo& info);
306
300 // Allows the tests to catch slots leaking out of the dispatcher. One 307 // Allows the tests to catch slots leaking out of the dispatcher. One
301 // HostResolverImpl::Job could occupy multiple PrioritizedDispatcher job 308 // HostResolverImpl::Job could occupy multiple PrioritizedDispatcher job
302 // slots. 309 // slots.
303 size_t num_running_dispatcher_jobs_for_tests() const { 310 size_t num_running_dispatcher_jobs_for_tests() const {
304 return dispatcher_->num_running_jobs(); 311 return dispatcher_->num_running_jobs();
305 } 312 }
306 313
307 // Cache of host resolution results. 314 // Cache of host resolution results.
308 std::unique_ptr<HostCache> cache_; 315 std::unique_ptr<HostCache> cache_;
309 316
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 HostResolverFlags additional_resolver_flags_; 353 HostResolverFlags additional_resolver_flags_;
347 354
348 // Allow fallback to ProcTask if DnsTask fails. 355 // Allow fallback to ProcTask if DnsTask fails.
349 bool fallback_to_proctask_; 356 bool fallback_to_proctask_;
350 357
351 // Task runner used for DNS lookups using the platform resolver, and other 358 // Task runner used for DNS lookups using the platform resolver, and other
352 // blocking operations. Usually just the WorkerPool's task runner for slow 359 // blocking operations. Usually just the WorkerPool's task runner for slow
353 // tasks, but can be overridden for tests. 360 // tasks, but can be overridden for tests.
354 scoped_refptr<base::TaskRunner> worker_task_runner_; 361 scoped_refptr<base::TaskRunner> worker_task_runner_;
355 362
363 std::map<const HostCache::Key, std::vector<RequestInfo::CacheHitCallback>>
364 cache_hit_callbacks_;
365
356 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; 366 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_;
357 367
358 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; 368 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_;
359 369
360 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); 370 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl);
361 }; 371 };
362 372
363 // Resolves a local hostname (such as "localhost" or "localhost6") into 373 // Resolves a local hostname (such as "localhost" or "localhost6") into
364 // IP endpoints with the given port. Returns true if |host| is a local 374 // IP endpoints with the given port. Returns true if |host| is a local
365 // hostname and false otherwise. Special IPv6 names (e.g. "localhost6") 375 // hostname and false otherwise. Special IPv6 names (e.g. "localhost6")
366 // will resolve to an IPv6 address only, whereas other names will 376 // will resolve to an IPv6 address only, whereas other names will
367 // resolve to both IPv4 and IPv6. 377 // resolve to both IPv4 and IPv6.
368 // This function is only exposed so it can be unit-tested. 378 // This function is only exposed so it can be unit-tested.
369 // TODO(tfarina): It would be better to change the tests so this function 379 // TODO(tfarina): It would be better to change the tests so this function
370 // gets exercised indirectly through HostResolverImpl. 380 // gets exercised indirectly through HostResolverImpl.
371 NET_EXPORT_PRIVATE bool ResolveLocalHostname(base::StringPiece host, 381 NET_EXPORT_PRIVATE bool ResolveLocalHostname(base::StringPiece host,
372 uint16_t port, 382 uint16_t port,
373 AddressList* address_list); 383 AddressList* address_list);
374 384
375 } // namespace net 385 } // namespace net
376 386
377 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ 387 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698