| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "net/base/address_family.h" | 11 #include "net/base/address_family.h" |
| 12 #include "net/base/completion_callback.h" | 12 #include "net/base/completion_callback.h" |
| 13 #include "net/base/host_port_pair.h" | 13 #include "net/base/host_port_pair.h" |
| 14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
| 15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
| 16 #include "net/base/prioritized_dispatcher.h" |
| 16 #include "net/base/request_priority.h" | 17 #include "net/base/request_priority.h" |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class Value; | 20 class Value; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace net { | 23 namespace net { |
| 23 | 24 |
| 24 class AddressList; | 25 class AddressList; |
| 25 class BoundNetLog; | 26 class BoundNetLog; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 41 // |max_concurrent_resolves| is how many resolve requests will be allowed to | 42 // |max_concurrent_resolves| is how many resolve requests will be allowed to |
| 42 // run in parallel. Pass HostResolver::kDefaultParallelism to choose a | 43 // run in parallel. Pass HostResolver::kDefaultParallelism to choose a |
| 43 // default value. | 44 // default value. |
| 44 // |max_retry_attempts| is the maximum number of times we will retry for host | 45 // |max_retry_attempts| is the maximum number of times we will retry for host |
| 45 // resolution. Pass HostResolver::kDefaultRetryAttempts to choose a default | 46 // resolution. Pass HostResolver::kDefaultRetryAttempts to choose a default |
| 46 // value. | 47 // value. |
| 47 // |enable_caching| controls whether a HostCache is used. | 48 // |enable_caching| controls whether a HostCache is used. |
| 48 struct NET_EXPORT Options { | 49 struct NET_EXPORT Options { |
| 49 Options(); | 50 Options(); |
| 50 | 51 |
| 52 PrioritizedDispatcher::Limits GetDispatcherLimits() const; |
| 53 |
| 51 size_t max_concurrent_resolves; | 54 size_t max_concurrent_resolves; |
| 52 size_t max_retry_attempts; | 55 size_t max_retry_attempts; |
| 53 bool enable_caching; | 56 bool enable_caching; |
| 54 }; | 57 }; |
| 55 | 58 |
| 56 // The parameters for doing a Resolve(). A hostname and port are | 59 // The parameters for doing a Resolve(). A hostname and port are |
| 57 // required; the rest are optional (and have reasonable defaults). | 60 // required; the rest are optional (and have reasonable defaults). |
| 58 class NET_EXPORT RequestInfo { | 61 class NET_EXPORT RequestInfo { |
| 59 public: | 62 public: |
| 60 explicit RequestInfo(const HostPortPair& host_port_pair); | 63 explicit RequestInfo(const HostPortPair& host_port_pair); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Whether it is ok to return a result from the host cache. | 101 // Whether it is ok to return a result from the host cache. |
| 99 bool allow_cached_response_; | 102 bool allow_cached_response_; |
| 100 | 103 |
| 101 // Whether this request was started by the DNS prefetcher. | 104 // Whether this request was started by the DNS prefetcher. |
| 102 bool is_speculative_; | 105 bool is_speculative_; |
| 103 }; | 106 }; |
| 104 | 107 |
| 105 // Opaque type used to cancel a request. | 108 // Opaque type used to cancel a request. |
| 106 typedef void* RequestHandle; | 109 typedef void* RequestHandle; |
| 107 | 110 |
| 108 // This value can be passed into CreateSystemResolver as the | 111 // Set Options.max_concurrent_resolves to this to select a default level |
| 109 // |max_concurrent_resolves| parameter. It will select a default level of | 112 // of concurrency. |
| 110 // concurrency. | |
| 111 static const size_t kDefaultParallelism = 0; | 113 static const size_t kDefaultParallelism = 0; |
| 112 | 114 |
| 113 // This value can be passed into CreateSystemResolver as the | 115 // Set Options.max_retry_attempts to this to select a default retry value. |
| 114 // |max_retry_attempts| parameter. | |
| 115 static const size_t kDefaultRetryAttempts = -1; | 116 static const size_t kDefaultRetryAttempts = -1; |
| 116 | 117 |
| 117 // If any completion callbacks are pending when the resolver is destroyed, | 118 // If any completion callbacks are pending when the resolver is destroyed, |
| 118 // the host resolutions are cancelled, and the completion callbacks will not | 119 // the host resolutions are cancelled, and the completion callbacks will not |
| 119 // be called. | 120 // be called. |
| 120 virtual ~HostResolver(); | 121 virtual ~HostResolver(); |
| 121 | 122 |
| 122 // Resolves the given hostname (or IP address literal), filling out the | 123 // Resolves the given hostname (or IP address literal), filling out the |
| 123 // |addresses| object upon success. The |info.port| parameter will be set as | 124 // |addresses| object upon success. The |info.port| parameter will be set as |
| 124 // the sin(6)_port field of the sockaddr_in{6} struct. Returns OK if | 125 // the sin(6)_port field of the sockaddr_in{6} struct. Returns OK if |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 protected: | 191 protected: |
| 191 HostResolver(); | 192 HostResolver(); |
| 192 | 193 |
| 193 private: | 194 private: |
| 194 DISALLOW_COPY_AND_ASSIGN(HostResolver); | 195 DISALLOW_COPY_AND_ASSIGN(HostResolver); |
| 195 }; | 196 }; |
| 196 | 197 |
| 197 } // namespace net | 198 } // namespace net |
| 198 | 199 |
| 199 #endif // NET_DNS_HOST_RESOLVER_H_ | 200 #endif // NET_DNS_HOST_RESOLVER_H_ |
| OLD | NEW |