| 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_H_ | 5 #ifndef NET_BASE_HOST_RESOLVER_H_ |
| 6 #define NET_BASE_HOST_RESOLVER_H_ | 6 #define NET_BASE_HOST_RESOLVER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 #include "net/base/address_family.h" | 13 #include "net/base/address_family.h" |
| 14 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
| 15 #include "net/base/host_port_pair.h" | 15 #include "net/base/host_port_pair.h" |
| 16 #include "net/base/net_api.h" | 16 #include "net/base/net_export.h" |
| 17 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 18 #include "net/base/request_priority.h" | 18 #include "net/base/request_priority.h" |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 | 21 |
| 22 class AddressList; | 22 class AddressList; |
| 23 class BoundNetLog; | 23 class BoundNetLog; |
| 24 class HostResolverImpl; | 24 class HostResolverImpl; |
| 25 class HostResolverProc; | 25 class HostResolverProc; |
| 26 class NetLog; | 26 class NetLog; |
| 27 | 27 |
| 28 // This class represents the task of resolving hostnames (or IP address | 28 // This class represents the task of resolving hostnames (or IP address |
| 29 // literal) to an AddressList object. | 29 // literal) to an AddressList object. |
| 30 // | 30 // |
| 31 // HostResolver can handle multiple requests at a time, so when cancelling a | 31 // HostResolver can handle multiple requests at a time, so when cancelling a |
| 32 // request the RequestHandle that was returned by Resolve() needs to be | 32 // request the RequestHandle that was returned by Resolve() needs to be |
| 33 // given. A simpler alternative for consumers that only have 1 outstanding | 33 // given. A simpler alternative for consumers that only have 1 outstanding |
| 34 // request at a time is to create a SingleRequestHostResolver wrapper around | 34 // request at a time is to create a SingleRequestHostResolver wrapper around |
| 35 // HostResolver (which will automatically cancel the single request when it | 35 // HostResolver (which will automatically cancel the single request when it |
| 36 // goes out of scope). | 36 // goes out of scope). |
| 37 class NET_API HostResolver { | 37 class NET_EXPORT HostResolver { |
| 38 public: | 38 public: |
| 39 // The parameters for doing a Resolve(). A hostname and port are required, | 39 // The parameters for doing a Resolve(). A hostname and port are required, |
| 40 // the rest are optional (and have reasonable defaults). | 40 // the rest are optional (and have reasonable defaults). |
| 41 class NET_API RequestInfo { | 41 class NET_EXPORT RequestInfo { |
| 42 public: | 42 public: |
| 43 explicit RequestInfo(const HostPortPair& host_port_pair); | 43 explicit RequestInfo(const HostPortPair& host_port_pair); |
| 44 | 44 |
| 45 const HostPortPair& host_port_pair() const { return host_port_pair_; } | 45 const HostPortPair& host_port_pair() const { return host_port_pair_; } |
| 46 void set_host_port_pair(const HostPortPair& host_port_pair) { | 46 void set_host_port_pair(const HostPortPair& host_port_pair) { |
| 47 host_port_pair_ = host_port_pair; | 47 host_port_pair_ = host_port_pair; |
| 48 } | 48 } |
| 49 | 49 |
| 50 int port() const { return host_port_pair_.port(); } | 50 int port() const { return host_port_pair_.port(); } |
| 51 const std::string& hostname() const { return host_port_pair_.host(); } | 51 const std::string& hostname() const { return host_port_pair_.host(); } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 // Creates a HostResolver implementation that queries the underlying system. | 203 // Creates a HostResolver implementation that queries the underlying system. |
| 204 // (Except if a unit-test has changed the global HostResolverProc using | 204 // (Except if a unit-test has changed the global HostResolverProc using |
| 205 // ScopedHostResolverProc to intercept requests to the system). | 205 // ScopedHostResolverProc to intercept requests to the system). |
| 206 // |max_concurrent_resolves| is how many resolve requests will be allowed to | 206 // |max_concurrent_resolves| is how many resolve requests will be allowed to |
| 207 // run in parallel. Pass HostResolver::kDefaultParallelism to choose a | 207 // run in parallel. Pass HostResolver::kDefaultParallelism to choose a |
| 208 // default value. | 208 // default value. |
| 209 // |max_retry_attempts| is the maximum number of times we will retry for host | 209 // |max_retry_attempts| is the maximum number of times we will retry for host |
| 210 // resolution. Pass HostResolver::kDefaultRetryAttempts to choose a default | 210 // resolution. Pass HostResolver::kDefaultRetryAttempts to choose a default |
| 211 // value. | 211 // value. |
| 212 NET_API HostResolver* CreateSystemHostResolver(size_t max_concurrent_resolves, | 212 NET_EXPORT HostResolver* CreateSystemHostResolver( |
| 213 size_t max_retry_attempts, | 213 size_t max_concurrent_resolves, |
| 214 NetLog* net_log); | 214 size_t max_retry_attempts, |
| 215 NetLog* net_log); |
| 215 | 216 |
| 216 // Creates a HostResolver implementation that sends actual DNS queries to | 217 // Creates a HostResolver implementation that sends actual DNS queries to |
| 217 // the specified DNS server and parses response and returns results. | 218 // the specified DNS server and parses response and returns results. |
| 218 NET_API HostResolver* CreateAsyncHostResolver(size_t max_concurrent_resolves, | 219 NET_EXPORT HostResolver* CreateAsyncHostResolver(size_t max_concurrent_resolves, |
| 219 const IPAddressNumber& dns_ip, | 220 const IPAddressNumber& dns_ip, |
| 220 NetLog* net_log); | 221 NetLog* net_log); |
| 221 } // namespace net | 222 } // namespace net |
| 222 | 223 |
| 223 #endif // NET_BASE_HOST_RESOLVER_H_ | 224 #endif // NET_BASE_HOST_RESOLVER_H_ |
| OLD | NEW |