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 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 size_t max_concurrent_resolves; | 57 size_t max_concurrent_resolves; |
58 size_t max_retry_attempts; | 58 size_t max_retry_attempts; |
59 bool enable_caching; | 59 bool enable_caching; |
60 }; | 60 }; |
61 | 61 |
62 // The parameters for doing a Resolve(). A hostname and port are | 62 // The parameters for doing a Resolve(). A hostname and port are |
63 // required; the rest are optional (and have reasonable defaults). | 63 // required; the rest are optional (and have reasonable defaults). |
64 class NET_EXPORT RequestInfo { | 64 class NET_EXPORT RequestInfo { |
65 public: | 65 public: |
66 explicit RequestInfo(const HostPortPair& host_port_pair); | 66 explicit RequestInfo(const HostPortPair& host_port_pair); |
| 67 RequestInfo(const RequestInfo& request_info); |
| 68 ~RequestInfo(); |
67 | 69 |
68 const HostPortPair& host_port_pair() const { return host_port_pair_; } | 70 const HostPortPair& host_port_pair() const { return host_port_pair_; } |
69 void set_host_port_pair(const HostPortPair& host_port_pair) { | 71 void set_host_port_pair(const HostPortPair& host_port_pair) { |
70 host_port_pair_ = host_port_pair; | 72 host_port_pair_ = host_port_pair; |
71 } | 73 } |
72 | 74 |
73 uint16_t port() const { return host_port_pair_.port(); } | 75 uint16_t port() const { return host_port_pair_.port(); } |
74 const std::string& hostname() const { return host_port_pair_.host(); } | 76 const std::string& hostname() const { return host_port_pair_.host(); } |
75 | 77 |
76 AddressFamily address_family() const { return address_family_; } | 78 AddressFamily address_family() const { return address_family_; } |
(...skipping 10 matching lines...) Expand all Loading... |
87 | 89 |
88 bool allow_cached_response() const { return allow_cached_response_; } | 90 bool allow_cached_response() const { return allow_cached_response_; } |
89 void set_allow_cached_response(bool b) { allow_cached_response_ = b; } | 91 void set_allow_cached_response(bool b) { allow_cached_response_ = b; } |
90 | 92 |
91 bool is_speculative() const { return is_speculative_; } | 93 bool is_speculative() const { return is_speculative_; } |
92 void set_is_speculative(bool b) { is_speculative_ = b; } | 94 void set_is_speculative(bool b) { is_speculative_ = b; } |
93 | 95 |
94 bool is_my_ip_address() const { return is_my_ip_address_; } | 96 bool is_my_ip_address() const { return is_my_ip_address_; } |
95 void set_is_my_ip_address(bool b) { is_my_ip_address_ = b; } | 97 void set_is_my_ip_address(bool b) { is_my_ip_address_ = b; } |
96 | 98 |
| 99 using CacheHitCallback = base::Callback<void(const RequestInfo&)>; |
| 100 const CacheHitCallback& cache_hit_callback() const { |
| 101 return cache_hit_callback_; |
| 102 } |
| 103 void set_cache_hit_callback(const CacheHitCallback& callback) { |
| 104 cache_hit_callback_ = callback; |
| 105 } |
| 106 |
97 private: | 107 private: |
| 108 RequestInfo(); |
| 109 |
98 // The hostname to resolve, and the port to use in resulting sockaddrs. | 110 // The hostname to resolve, and the port to use in resulting sockaddrs. |
99 HostPortPair host_port_pair_; | 111 HostPortPair host_port_pair_; |
100 | 112 |
101 // The address family to restrict results to. | 113 // The address family to restrict results to. |
102 AddressFamily address_family_; | 114 AddressFamily address_family_; |
103 | 115 |
104 // Flags to use when resolving this request. | 116 // Flags to use when resolving this request. |
105 HostResolverFlags host_resolver_flags_; | 117 HostResolverFlags host_resolver_flags_; |
106 | 118 |
107 // Whether it is ok to return a result from the host cache. | 119 // Whether it is ok to return a result from the host cache. |
108 bool allow_cached_response_; | 120 bool allow_cached_response_; |
109 | 121 |
110 // Whether this request was started by the DNS prefetcher. | 122 // Whether this request was started by the DNS prefetcher. |
111 bool is_speculative_; | 123 bool is_speculative_; |
112 | 124 |
113 // Indicates a request for myIpAddress (to differentiate from other requests | 125 // Indicates a request for myIpAddress (to differentiate from other requests |
114 // for localhost, currently used by Chrome OS). | 126 // for localhost, currently used by Chrome OS). |
115 bool is_my_ip_address_; | 127 bool is_my_ip_address_; |
| 128 |
| 129 // A callback that will be called when another request reads the cache data |
| 130 // returned (and possibly written) by this request. |
| 131 CacheHitCallback cache_hit_callback_; |
116 }; | 132 }; |
117 | 133 |
118 // Opaque type used to cancel a request. | 134 // Opaque type used to cancel a request. |
119 typedef void* RequestHandle; | 135 typedef void* RequestHandle; |
120 | 136 |
121 // Set Options.max_concurrent_resolves to this to select a default level | 137 // Set Options.max_concurrent_resolves to this to select a default level |
122 // of concurrency. | 138 // of concurrency. |
123 static const size_t kDefaultParallelism = 0; | 139 static const size_t kDefaultParallelism = 0; |
124 | 140 |
125 // Set Options.max_retry_attempts to this to select a default retry value. | 141 // Set Options.max_retry_attempts to this to select a default retry value. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 protected: | 215 protected: |
200 HostResolver(); | 216 HostResolver(); |
201 | 217 |
202 private: | 218 private: |
203 DISALLOW_COPY_AND_ASSIGN(HostResolver); | 219 DISALLOW_COPY_AND_ASSIGN(HostResolver); |
204 }; | 220 }; |
205 | 221 |
206 } // namespace net | 222 } // namespace net |
207 | 223 |
208 #endif // NET_DNS_HOST_RESOLVER_H_ | 224 #endif // NET_DNS_HOST_RESOLVER_H_ |
OLD | NEW |