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 #include "net/base/net_export.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 class AddressList; | 17 class AddressList; |
18 | 18 |
19 // 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 |
20 // to control the underlying resolutions in HostResolverImpl. HostResolverProcs | 20 // to control the underlying resolutions in HostResolverImpl. HostResolverProcs |
21 // 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 |
22 // by calling ResolveUsingPrevious(). | 22 // by calling ResolveUsingPrevious(). |
23 // | 23 // |
24 // Note that implementations of HostResolverProc *MUST BE THREADSAFE*, since | 24 // Note that implementations of HostResolverProc *MUST BE THREADSAFE*, since |
25 // the HostResolver implementation using them can be multi-threaded. | 25 // the HostResolver implementation using them can be multi-threaded. |
26 class NET_API HostResolverProc | 26 class NET_EXPORT HostResolverProc |
27 : public base::RefCountedThreadSafe<HostResolverProc> { | 27 : public base::RefCountedThreadSafe<HostResolverProc> { |
28 public: | 28 public: |
29 explicit HostResolverProc(HostResolverProc* previous); | 29 explicit HostResolverProc(HostResolverProc* previous); |
30 | 30 |
31 // Resolves |host| to an address list, restricting the results to addresses | 31 // Resolves |host| to an address list, restricting the results to addresses |
32 // in |address_family|. If successful returns OK and fills |addrlist| with | 32 // in |address_family|. If successful returns OK and fills |addrlist| with |
33 // 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 |
34 // 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. |
35 virtual int Resolve(const std::string& host, | 35 virtual int Resolve(const std::string& host, |
36 AddressFamily address_family, | 36 AddressFamily address_family, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 static HostResolverProc* default_proc_; | 78 static HostResolverProc* default_proc_; |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(HostResolverProc); | 80 DISALLOW_COPY_AND_ASSIGN(HostResolverProc); |
81 }; | 81 }; |
82 | 82 |
83 // 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. |
84 // (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 |
85 // |addrlist| with a list of socket addresses. Otherwise returns a | 85 // |addrlist| with a list of socket addresses. Otherwise returns a |
86 // 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 |
87 // was non-NULL. | 87 // was non-NULL. |
88 NET_TEST int SystemHostResolverProc(const std::string& host, | 88 NET_EXPORT_PRIVATE int SystemHostResolverProc( |
89 AddressFamily address_family, | 89 const std::string& host, |
90 HostResolverFlags host_resolver_flags, | 90 AddressFamily address_family, |
91 AddressList* addrlist, | 91 HostResolverFlags host_resolver_flags, |
92 int* os_error); | 92 AddressList* addrlist, |
| 93 int* os_error); |
93 | 94 |
94 } // namespace net | 95 } // namespace net |
95 | 96 |
96 #endif // NET_BASE_HOST_RESOLVER_PROC_H_ | 97 #endif // NET_BASE_HOST_RESOLVER_PROC_H_ |
OLD | NEW |