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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 size_t max_concurrent_resolves; | 69 size_t max_concurrent_resolves; |
70 size_t max_retry_attempts; | 70 size_t max_retry_attempts; |
71 bool enable_caching; | 71 bool enable_caching; |
72 }; | 72 }; |
73 | 73 |
74 // The parameters for doing a Resolve(). A hostname and port are | 74 // The parameters for doing a Resolve(). A hostname and port are |
75 // required; the rest are optional (and have reasonable defaults). | 75 // required; the rest are optional (and have reasonable defaults). |
76 class NET_EXPORT RequestInfo { | 76 class NET_EXPORT RequestInfo { |
77 public: | 77 public: |
78 explicit RequestInfo(const HostPortPair& host_port_pair); | 78 explicit RequestInfo(const HostPortPair& host_port_pair); |
| 79 RequestInfo(const RequestInfo& request_info); |
| 80 ~RequestInfo(); |
79 | 81 |
80 const HostPortPair& host_port_pair() const { return host_port_pair_; } | 82 const HostPortPair& host_port_pair() const { return host_port_pair_; } |
81 void set_host_port_pair(const HostPortPair& host_port_pair) { | 83 void set_host_port_pair(const HostPortPair& host_port_pair) { |
82 host_port_pair_ = host_port_pair; | 84 host_port_pair_ = host_port_pair; |
83 } | 85 } |
84 | 86 |
85 uint16_t port() const { return host_port_pair_.port(); } | 87 uint16_t port() const { return host_port_pair_.port(); } |
86 const std::string& hostname() const { return host_port_pair_.host(); } | 88 const std::string& hostname() const { return host_port_pair_.host(); } |
87 | 89 |
88 AddressFamily address_family() const { return address_family_; } | 90 AddressFamily address_family() const { return address_family_; } |
(...skipping 10 matching lines...) Expand all Loading... |
99 | 101 |
100 bool allow_cached_response() const { return allow_cached_response_; } | 102 bool allow_cached_response() const { return allow_cached_response_; } |
101 void set_allow_cached_response(bool b) { allow_cached_response_ = b; } | 103 void set_allow_cached_response(bool b) { allow_cached_response_ = b; } |
102 | 104 |
103 bool is_speculative() const { return is_speculative_; } | 105 bool is_speculative() const { return is_speculative_; } |
104 void set_is_speculative(bool b) { is_speculative_ = b; } | 106 void set_is_speculative(bool b) { is_speculative_ = b; } |
105 | 107 |
106 bool is_my_ip_address() const { return is_my_ip_address_; } | 108 bool is_my_ip_address() const { return is_my_ip_address_; } |
107 void set_is_my_ip_address(bool b) { is_my_ip_address_ = b; } | 109 void set_is_my_ip_address(bool b) { is_my_ip_address_ = b; } |
108 | 110 |
| 111 using CacheHitCallback = base::Callback<void(const RequestInfo&)>; |
| 112 const CacheHitCallback& cache_hit_callback() const { |
| 113 return cache_hit_callback_; |
| 114 } |
| 115 void set_cache_hit_callback(const CacheHitCallback& callback) { |
| 116 cache_hit_callback_ = callback; |
| 117 } |
| 118 |
109 private: | 119 private: |
| 120 RequestInfo(); |
| 121 |
110 // The hostname to resolve, and the port to use in resulting sockaddrs. | 122 // The hostname to resolve, and the port to use in resulting sockaddrs. |
111 HostPortPair host_port_pair_; | 123 HostPortPair host_port_pair_; |
112 | 124 |
113 // The address family to restrict results to. | 125 // The address family to restrict results to. |
114 AddressFamily address_family_; | 126 AddressFamily address_family_; |
115 | 127 |
116 // Flags to use when resolving this request. | 128 // Flags to use when resolving this request. |
117 HostResolverFlags host_resolver_flags_; | 129 HostResolverFlags host_resolver_flags_; |
118 | 130 |
119 // Whether it is ok to return a result from the host cache. | 131 // Whether it is ok to return a result from the host cache. |
120 bool allow_cached_response_; | 132 bool allow_cached_response_; |
121 | 133 |
122 // Whether this request was started by the DNS prefetcher. | 134 // Whether this request was started by the DNS prefetcher. |
123 bool is_speculative_; | 135 bool is_speculative_; |
124 | 136 |
125 // Indicates a request for myIpAddress (to differentiate from other requests | 137 // Indicates a request for myIpAddress (to differentiate from other requests |
126 // for localhost, currently used by Chrome OS). | 138 // for localhost, currently used by Chrome OS). |
127 bool is_my_ip_address_; | 139 bool is_my_ip_address_; |
| 140 |
| 141 // A callback that will be called when another request reads the cache data |
| 142 // returned (and possibly written) by this request. |
| 143 CacheHitCallback cache_hit_callback_; |
128 }; | 144 }; |
129 | 145 |
130 // Set Options.max_concurrent_resolves to this to select a default level | 146 // Set Options.max_concurrent_resolves to this to select a default level |
131 // of concurrency. | 147 // of concurrency. |
132 static const size_t kDefaultParallelism = 0; | 148 static const size_t kDefaultParallelism = 0; |
133 | 149 |
134 // Set Options.max_retry_attempts to this to select a default retry value. | 150 // Set Options.max_retry_attempts to this to select a default retry value. |
135 static const size_t kDefaultRetryAttempts = static_cast<size_t>(-1); | 151 static const size_t kDefaultRetryAttempts = static_cast<size_t>(-1); |
136 | 152 |
137 // If any completion callbacks are pending when the resolver is destroyed, | 153 // If any completion callbacks are pending when the resolver is destroyed, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 protected: | 225 protected: |
210 HostResolver(); | 226 HostResolver(); |
211 | 227 |
212 private: | 228 private: |
213 DISALLOW_COPY_AND_ASSIGN(HostResolver); | 229 DISALLOW_COPY_AND_ASSIGN(HostResolver); |
214 }; | 230 }; |
215 | 231 |
216 } // namespace net | 232 } // namespace net |
217 | 233 |
218 #endif // NET_DNS_HOST_RESOLVER_H_ | 234 #endif // NET_DNS_HOST_RESOLVER_H_ |
OLD | NEW |