OLD | NEW |
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_H_ | 5 #ifndef NET_DNS_HOST_RESOLVER_H_ |
6 #define NET_DNS_HOST_RESOLVER_H_ | 6 #define NET_DNS_HOST_RESOLVER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "net/base/address_family.h" | 15 #include "net/base/address_family.h" |
16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
17 #include "net/base/host_port_pair.h" | 17 #include "net/base/host_port_pair.h" |
18 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
19 #include "net/base/prioritized_dispatcher.h" | 19 #include "net/base/prioritized_dispatcher.h" |
20 #include "net/base/request_priority.h" | 20 #include "net/base/request_priority.h" |
| 21 #include "net/dns/host_cache.h" |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 class Value; | 24 class Value; |
24 } | 25 } |
25 | 26 |
26 namespace net { | 27 namespace net { |
27 | 28 |
28 class AddressList; | 29 class AddressList; |
29 class BoundNetLog; | 30 class BoundNetLog; |
30 class HostCache; | |
31 class HostResolverProc; | 31 class HostResolverProc; |
32 class NetLog; | 32 class NetLog; |
33 | 33 |
34 // This class represents the task of resolving hostnames (or IP address | 34 // This class represents the task of resolving hostnames (or IP address |
35 // literal) to an AddressList object. | 35 // literal) to an AddressList object. |
36 // | 36 // |
37 // HostResolver can handle multiple requests at a time, so when cancelling a | 37 // HostResolver can handle multiple requests at a time, so when cancelling a |
38 // request the RequestHandle that was returned by Resolve() needs to be | 38 // request the RequestHandle that was returned by Resolve() needs to be |
39 // given. A simpler alternative for consumers that only have 1 outstanding | 39 // given. A simpler alternative for consumers that only have 1 outstanding |
40 // request at a time is to create a SingleRequestHostResolver wrapper around | 40 // request at a time is to create a SingleRequestHostResolver wrapper around |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // completed. | 148 // completed. |
149 // | 149 // |
150 // Profiling information for the request is saved to |net_log| if non-NULL. | 150 // Profiling information for the request is saved to |net_log| if non-NULL. |
151 virtual int Resolve(const RequestInfo& info, | 151 virtual int Resolve(const RequestInfo& info, |
152 RequestPriority priority, | 152 RequestPriority priority, |
153 AddressList* addresses, | 153 AddressList* addresses, |
154 const CompletionCallback& callback, | 154 const CompletionCallback& callback, |
155 RequestHandle* out_req, | 155 RequestHandle* out_req, |
156 const BoundNetLog& net_log) = 0; | 156 const BoundNetLog& net_log) = 0; |
157 | 157 |
158 // Resolves the given hostname (or IP address literal) out of cache or HOSTS | |
159 // file (if enabled) only. This is guaranteed to complete synchronously. | |
160 // This acts like |Resolve()| if the hostname is IP literal, or cached value | |
161 // or HOSTS entry exists. Otherwise, ERR_DNS_CACHE_MISS is returned. | |
162 virtual int ResolveFromCache(const RequestInfo& info, | |
163 AddressList* addresses, | |
164 const BoundNetLog& net_log) = 0; | |
165 | |
166 // Changes the priority of the specified request. |req| is the handle returned | 158 // Changes the priority of the specified request. |req| is the handle returned |
167 // by Resolve(). ChangeRequestPriority must NOT be called after the request's | 159 // by Resolve(). ChangeRequestPriority must NOT be called after the request's |
168 // completion callback has already run or the request was canceled. | 160 // completion callback has already run or the request was canceled. |
169 virtual void ChangeRequestPriority(RequestHandle req, | 161 virtual void ChangeRequestPriority(RequestHandle req, |
170 RequestPriority priority); | 162 RequestPriority priority); |
171 | 163 |
172 // Cancels the specified request. |req| is the handle returned by Resolve(). | 164 // Cancels the specified request. |req| is the handle returned by Resolve(). |
173 // After a request is canceled, its completion callback will not be called. | 165 // After a request is canceled, its completion callback will not be called. |
174 // CancelRequest must NOT be called after the request's completion callback | 166 // CancelRequest must NOT be called after the request's completion callback |
175 // has already run or the request was canceled. | 167 // has already run or the request was canceled. |
176 virtual void CancelRequest(RequestHandle req) = 0; | 168 virtual void CancelRequest(RequestHandle req) = 0; |
177 | 169 |
| 170 // Resolves the given hostname (or IP address literal) out of cache or HOSTS |
| 171 // file (if enabled) only. This is guaranteed to complete synchronously. |
| 172 // This acts like |Resolve()| if the hostname is IP literal, or cached value |
| 173 // or HOSTS entry exists. Otherwise, ERR_DNS_CACHE_MISS is returned. |
| 174 virtual int ResolveFromCache(const RequestInfo& info, |
| 175 AddressList* addresses, |
| 176 const BoundNetLog& net_log) = 0; |
| 177 |
178 // Enable or disable the built-in asynchronous DnsClient. | 178 // Enable or disable the built-in asynchronous DnsClient. |
179 virtual void SetDnsClientEnabled(bool enabled); | 179 virtual void SetDnsClientEnabled(bool enabled); |
180 | 180 |
181 // Returns the HostResolverCache |this| uses, or NULL if there isn't one. | 181 // Returns the HostResolverCache |this| uses, or NULL if there isn't one. |
182 // Used primarily to clear the cache and for getting debug information. | 182 // Used primarily to clear the cache and for getting debug information. |
183 virtual HostCache* GetHostCache(); | 183 virtual HostCache* GetHostCache(); |
184 | 184 |
185 // Returns the current DNS configuration |this| is using, as a Value, or | 185 // Returns the current DNS configuration |this| is using, as a Value, or |
186 // nullptr if it's configured to always use the system host resolver. | 186 // nullptr if it's configured to always use the system host resolver. |
187 virtual std::unique_ptr<base::Value> GetDnsConfigAsValue() const; | 187 virtual std::unique_ptr<base::Value> GetDnsConfigAsValue() const; |
(...skipping 11 matching lines...) Expand all Loading... |
199 protected: | 199 protected: |
200 HostResolver(); | 200 HostResolver(); |
201 | 201 |
202 private: | 202 private: |
203 DISALLOW_COPY_AND_ASSIGN(HostResolver); | 203 DISALLOW_COPY_AND_ASSIGN(HostResolver); |
204 }; | 204 }; |
205 | 205 |
206 } // namespace net | 206 } // namespace net |
207 | 207 |
208 #endif // NET_DNS_HOST_RESOLVER_H_ | 208 #endif // NET_DNS_HOST_RESOLVER_H_ |
OLD | NEW |