OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_BASE_HOST_RESOLVER_PROC_H_ | 5 #ifndef NET_BASE_HOST_RESOLVER_PROC_H_ |
6 #define NET_BASE_HOST_RESOLVER_PROC_H_ | 6 #define NET_BASE_HOST_RESOLVER_PROC_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
11 #include "net/base/address_family.h" | 11 #include "net/base/address_family.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 | 14 |
15 class AddressList; | 15 class AddressList; |
16 | 16 |
17 // Interface for a getaddrinfo()-like procedure. This is used by unit-tests | 17 // Interface for a getaddrinfo()-like procedure. This is used by unit-tests |
18 // to control the underlying resolutions in HostResolverImpl. HostResolverProcs | 18 // to control the underlying resolutions in HostResolverImpl. HostResolverProcs |
19 // can be chained together; they fallback to the next procedure in the chain | 19 // can be chained together; they fallback to the next procedure in the chain |
20 // by calling ResolveUsingPrevious(). | 20 // by calling ResolveUsingPrevious(). |
21 // | 21 // |
22 // Note that implementations of HostResolverProc *MUST BE THREADSAFE*, since | 22 // Note that implementations of HostResolverProc *MUST BE THREADSAFE*, since |
23 // the HostResolver implementation using them can be multi-threaded. | 23 // the HostResolver implementation using them can be multi-threaded. |
24 class HostResolverProc : public base::RefCountedThreadSafe<HostResolverProc> { | 24 class HostResolverProc : public base::RefCountedThreadSafe<HostResolverProc> { |
25 public: | 25 public: |
26 explicit HostResolverProc(HostResolverProc* previous); | 26 explicit HostResolverProc(HostResolverProc* previous); |
27 virtual ~HostResolverProc() {} | |
28 | 27 |
29 // Resolves |host| to an address list, restricting the results to addresses | 28 // Resolves |host| to an address list, restricting the results to addresses |
30 // in |address_family|. If successful returns OK and fills |addrlist| with | 29 // in |address_family|. If successful returns OK and fills |addrlist| with |
31 // a list of socket addresses. Otherwise returns a network error code. | 30 // a list of socket addresses. Otherwise returns a network error code. |
32 virtual int Resolve(const std::string& host, | 31 virtual int Resolve(const std::string& host, |
33 AddressFamily address_family, | 32 AddressFamily address_family, |
34 AddressList* addrlist) = 0; | 33 AddressList* addrlist) = 0; |
35 | 34 |
36 protected: | 35 protected: |
| 36 friend class base::RefCountedThreadSafe<HostResolverProc>; |
| 37 |
| 38 virtual ~HostResolverProc() {} |
| 39 |
37 // Asks the fallback procedure (if set) to do the resolve. | 40 // Asks the fallback procedure (if set) to do the resolve. |
38 int ResolveUsingPrevious(const std::string& host, | 41 int ResolveUsingPrevious(const std::string& host, |
39 AddressFamily address_family, | 42 AddressFamily address_family, |
40 AddressList* addrlist); | 43 AddressList* addrlist); |
41 | 44 |
42 private: | 45 private: |
43 friend class HostResolverImpl; | 46 friend class HostResolverImpl; |
44 friend class MockHostResolverBase; | 47 friend class MockHostResolverBase; |
45 friend class ScopedDefaultHostResolverProc; | 48 friend class ScopedDefaultHostResolverProc; |
46 | 49 |
(...skipping 20 matching lines...) Expand all Loading... |
67 // (i.e. this calls out to getaddrinfo()). If successful returns OK and fills | 70 // (i.e. this calls out to getaddrinfo()). If successful returns OK and fills |
68 // |addrlist| with a list of socket addresses. Otherwise returns a | 71 // |addrlist| with a list of socket addresses. Otherwise returns a |
69 // network error code. | 72 // network error code. |
70 int SystemHostResolverProc(const std::string& host, | 73 int SystemHostResolverProc(const std::string& host, |
71 AddressFamily address_family, | 74 AddressFamily address_family, |
72 AddressList* addrlist); | 75 AddressList* addrlist); |
73 | 76 |
74 } // namespace net | 77 } // namespace net |
75 | 78 |
76 #endif // NET_BASE_HOST_RESOLVER_PROC_H_ | 79 #endif // NET_BASE_HOST_RESOLVER_PROC_H_ |
OLD | NEW |