OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "net/base/address_family.h" | 12 #include "net/base/address_family.h" |
| 13 #include "net/base/net_api.h" |
13 | 14 |
14 namespace net { | 15 namespace net { |
15 | 16 |
16 class AddressList; | 17 class AddressList; |
17 | 18 |
18 // Interface for a getaddrinfo()-like procedure. This is used by unit-tests | 19 // Interface for a getaddrinfo()-like procedure. This is used by unit-tests |
19 // to control the underlying resolutions in HostResolverImpl. HostResolverProcs | 20 // to control the underlying resolutions in HostResolverImpl. HostResolverProcs |
20 // can be chained together; they fallback to the next procedure in the chain | 21 // can be chained together; they fallback to the next procedure in the chain |
21 // by calling ResolveUsingPrevious(). | 22 // by calling ResolveUsingPrevious(). |
22 // | 23 // |
23 // Note that implementations of HostResolverProc *MUST BE THREADSAFE*, since | 24 // Note that implementations of HostResolverProc *MUST BE THREADSAFE*, since |
24 // the HostResolver implementation using them can be multi-threaded. | 25 // the HostResolver implementation using them can be multi-threaded. |
25 class HostResolverProc : public base::RefCountedThreadSafe<HostResolverProc> { | 26 class NET_API HostResolverProc |
| 27 : public base::RefCountedThreadSafe<HostResolverProc> { |
26 public: | 28 public: |
27 explicit HostResolverProc(HostResolverProc* previous); | 29 explicit HostResolverProc(HostResolverProc* previous); |
28 | 30 |
29 // Resolves |host| to an address list, restricting the results to addresses | 31 // Resolves |host| to an address list, restricting the results to addresses |
30 // in |address_family|. If successful returns OK and fills |addrlist| with | 32 // in |address_family|. If successful returns OK and fills |addrlist| with |
31 // a list of socket addresses. Otherwise returns a network error code, and | 33 // a list of socket addresses. Otherwise returns a network error code, and |
32 // fills |os_error| with a more specific error if it was non-NULL. | 34 // fills |os_error| with a more specific error if it was non-NULL. |
33 virtual int Resolve(const std::string& host, | 35 virtual int Resolve(const std::string& host, |
34 AddressFamily address_family, | 36 AddressFamily address_family, |
35 HostResolverFlags host_resolver_flags, | 37 HostResolverFlags host_resolver_flags, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 static HostResolverProc* default_proc_; | 78 static HostResolverProc* default_proc_; |
77 | 79 |
78 DISALLOW_COPY_AND_ASSIGN(HostResolverProc); | 80 DISALLOW_COPY_AND_ASSIGN(HostResolverProc); |
79 }; | 81 }; |
80 | 82 |
81 // Resolves |host| to an address list, using the system's default host resolver. | 83 // Resolves |host| to an address list, using the system's default host resolver. |
82 // (i.e. this calls out to getaddrinfo()). If successful returns OK and fills | 84 // (i.e. this calls out to getaddrinfo()). If successful returns OK and fills |
83 // |addrlist| with a list of socket addresses. Otherwise returns a | 85 // |addrlist| with a list of socket addresses. Otherwise returns a |
84 // network error code, and fills |os_error| with a more specific errir if it | 86 // network error code, and fills |os_error| with a more specific errir if it |
85 // was non-NULL. | 87 // was non-NULL. |
86 int SystemHostResolverProc(const std::string& host, | 88 NET_TEST int SystemHostResolverProc(const std::string& host, |
87 AddressFamily address_family, | 89 AddressFamily address_family, |
88 HostResolverFlags host_resolver_flags, | 90 HostResolverFlags host_resolver_flags, |
89 AddressList* addrlist, | 91 AddressList* addrlist, |
90 int* os_error); | 92 int* os_error); |
91 | 93 |
92 } // namespace net | 94 } // namespace net |
93 | 95 |
94 #endif // NET_BASE_HOST_RESOLVER_PROC_H_ | 96 #endif // NET_BASE_HOST_RESOLVER_PROC_H_ |
OLD | NEW |