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

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

Issue 2910473005: Deprecate NonThreadSafe in net/ in favor of SequenceChecker/ThreadChecker. (Closed)
Patch Set: rebase on r476634 Created 3 years, 6 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
« no previous file with comments | « net/dns/host_cache.cc ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/strings/string_piece.h" 16 #include "base/strings/string_piece.h"
17 #include "base/threading/non_thread_safe.h" 17 #include "base/threading/thread_checker.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "base/timer/timer.h" 19 #include "base/timer/timer.h"
20 #include "net/base/net_export.h" 20 #include "net/base/net_export.h"
21 #include "net/base/network_change_notifier.h" 21 #include "net/base/network_change_notifier.h"
22 #include "net/dns/host_cache.h" 22 #include "net/dns/host_cache.h"
23 #include "net/dns/host_resolver.h" 23 #include "net/dns/host_resolver.h"
24 #include "net/dns/host_resolver_proc.h" 24 #include "net/dns/host_resolver_proc.h"
25 25
26 namespace net { 26 namespace net {
27 27
(...skipping 26 matching lines...) Expand all
54 // 54 //
55 // Thread safety: This class is not threadsafe, and must only be called 55 // Thread safety: This class is not threadsafe, and must only be called
56 // from one thread! 56 // from one thread!
57 // 57 //
58 // The HostResolverImpl enforces limits on the maximum number of concurrent 58 // The HostResolverImpl enforces limits on the maximum number of concurrent
59 // threads using PrioritizedDispatcher::Limits. 59 // threads using PrioritizedDispatcher::Limits.
60 // 60 //
61 // Jobs are ordered in the queue based on their priority and order of arrival. 61 // Jobs are ordered in the queue based on their priority and order of arrival.
62 class NET_EXPORT HostResolverImpl 62 class NET_EXPORT HostResolverImpl
63 : public HostResolver, 63 : public HostResolver,
64 NON_EXPORTED_BASE(public base::NonThreadSafe),
65 public NetworkChangeNotifier::IPAddressObserver, 64 public NetworkChangeNotifier::IPAddressObserver,
66 public NetworkChangeNotifier::ConnectionTypeObserver, 65 public NetworkChangeNotifier::ConnectionTypeObserver,
67 public NetworkChangeNotifier::DNSObserver { 66 public NetworkChangeNotifier::DNSObserver {
68 public: 67 public:
69 // Parameters for ProcTask which resolves hostnames using HostResolveProc. 68 // Parameters for ProcTask which resolves hostnames using HostResolveProc.
70 // 69 //
71 // |resolver_proc| is used to perform the actual resolves; it must be 70 // |resolver_proc| is used to perform the actual resolves; it must be
72 // thread-safe since it may be run from multiple worker threads. If 71 // thread-safe since it may be run from multiple worker threads. If
73 // |resolver_proc| is NULL then the default host resolver procedure is 72 // |resolver_proc| is NULL then the default host resolver procedure is
74 // used (which is SystemHostResolverProc except if overridden). 73 // used (which is SystemHostResolverProc except if overridden).
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // tasks, but can be overridden for tests. 374 // tasks, but can be overridden for tests.
376 scoped_refptr<base::TaskRunner> worker_task_runner_; 375 scoped_refptr<base::TaskRunner> worker_task_runner_;
377 376
378 std::map<const HostCache::Key, std::vector<RequestInfo::CacheHitCallback>> 377 std::map<const HostCache::Key, std::vector<RequestInfo::CacheHitCallback>>
379 cache_hit_callbacks_; 378 cache_hit_callbacks_;
380 379
381 bool persist_initialized_; 380 bool persist_initialized_;
382 PersistCallback persist_callback_; 381 PersistCallback persist_callback_;
383 base::OneShotTimer persist_timer_; 382 base::OneShotTimer persist_timer_;
384 383
384 THREAD_CHECKER(thread_checker_);
385
385 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; 386 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_;
386 387
387 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; 388 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_;
388 389
389 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); 390 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl);
390 }; 391 };
391 392
392 // Resolves a local hostname (such as "localhost" or "localhost6") into 393 // Resolves a local hostname (such as "localhost" or "localhost6") into
393 // IP endpoints with the given port. Returns true if |host| is a local 394 // IP endpoints with the given port. Returns true if |host| is a local
394 // hostname and false otherwise. Special IPv6 names (e.g. "localhost6") 395 // hostname and false otherwise. Special IPv6 names (e.g. "localhost6")
395 // will resolve to an IPv6 address only, whereas other names will 396 // will resolve to an IPv6 address only, whereas other names will
396 // resolve to both IPv4 and IPv6. 397 // resolve to both IPv4 and IPv6.
397 // This function is only exposed so it can be unit-tested. 398 // This function is only exposed so it can be unit-tested.
398 // TODO(tfarina): It would be better to change the tests so this function 399 // TODO(tfarina): It would be better to change the tests so this function
399 // gets exercised indirectly through HostResolverImpl. 400 // gets exercised indirectly through HostResolverImpl.
400 NET_EXPORT_PRIVATE bool ResolveLocalHostname(base::StringPiece host, 401 NET_EXPORT_PRIVATE bool ResolveLocalHostname(base::StringPiece host,
401 uint16_t port, 402 uint16_t port,
402 AddressList* address_list); 403 AddressList* address_list);
403 404
404 } // namespace net 405 } // namespace net
405 406
406 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ 407 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_
OLDNEW
« no previous file with comments | « net/dns/host_cache.cc ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698