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_IMPL_H_ | 5 #ifndef NET_DNS_HOST_RESOLVER_IMPL_H_ |
6 #define NET_DNS_HOST_RESOLVER_IMPL_H_ | 6 #define NET_DNS_HOST_RESOLVER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 int Resolve(const RequestInfo& info, | 128 int Resolve(const RequestInfo& info, |
129 RequestPriority priority, | 129 RequestPriority priority, |
130 AddressList* addresses, | 130 AddressList* addresses, |
131 const CompletionCallback& callback, | 131 const CompletionCallback& callback, |
132 RequestHandle* out_req, | 132 RequestHandle* out_req, |
133 const BoundNetLog& source_net_log) override; | 133 const BoundNetLog& source_net_log) override; |
134 int ResolveFromCache(const RequestInfo& info, | 134 int ResolveFromCache(const RequestInfo& info, |
135 AddressList* addresses, | 135 AddressList* addresses, |
136 const BoundNetLog& source_net_log) override; | 136 const BoundNetLog& source_net_log) override; |
137 void CancelRequest(RequestHandle req) override; | 137 void CancelRequest(RequestHandle req) override; |
138 void SetDefaultAddressFamily(AddressFamily address_family) override; | |
139 AddressFamily GetDefaultAddressFamily() const override; | |
140 void SetDnsClientEnabled(bool enabled) override; | 138 void SetDnsClientEnabled(bool enabled) override; |
141 HostCache* GetHostCache() override; | 139 HostCache* GetHostCache() override; |
142 base::Value* GetDnsConfigAsValue() const override; | 140 base::Value* GetDnsConfigAsValue() const override; |
143 | 141 |
144 void set_proc_params_for_test(const ProcTaskParams& proc_params) { | 142 void set_proc_params_for_test(const ProcTaskParams& proc_params) { |
145 proc_params_ = proc_params; | 143 proc_params_ = proc_params; |
146 } | 144 } |
147 | 145 |
148 private: | 146 private: |
149 friend class HostResolverImplTest; | 147 friend class HostResolverImplTest; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // Returns the (hostname, address_family) key to use for |info|, choosing an | 196 // Returns the (hostname, address_family) key to use for |info|, choosing an |
199 // "effective" address family by inheriting the resolver's default address | 197 // "effective" address family by inheriting the resolver's default address |
200 // family when the request leaves it unspecified. | 198 // family when the request leaves it unspecified. |
201 Key GetEffectiveKeyForRequest(const RequestInfo& info, | 199 Key GetEffectiveKeyForRequest(const RequestInfo& info, |
202 const IPAddressNumber* ip_number, | 200 const IPAddressNumber* ip_number, |
203 const BoundNetLog& net_log); | 201 const BoundNetLog& net_log); |
204 | 202 |
205 // Probes IPv6 support and returns true if IPv6 support is enabled. | 203 // Probes IPv6 support and returns true if IPv6 support is enabled. |
206 // Results are cached, i.e. when called repeatedly this method returns result | 204 // Results are cached, i.e. when called repeatedly this method returns result |
207 // from the first probe for some time before probing again. | 205 // from the first probe for some time before probing again. |
208 bool IsIPv6Reachable(const BoundNetLog& net_log); | 206 virtual bool IsIPv6Reachable(const BoundNetLog& net_log); |
209 | 207 |
210 // Records the result in cache if cache is present. | 208 // Records the result in cache if cache is present. |
211 void CacheResult(const Key& key, | 209 void CacheResult(const Key& key, |
212 const HostCache::Entry& entry, | 210 const HostCache::Entry& entry, |
213 base::TimeDelta ttl); | 211 base::TimeDelta ttl); |
214 | 212 |
215 // Removes |job| from |jobs_|, only if it exists. | 213 // Removes |job| from |jobs_|, only if it exists. |
216 void RemoveJob(Job* job); | 214 void RemoveJob(Job* job); |
217 | 215 |
218 // Aborts all in progress jobs with ERR_NETWORK_CHANGED and notifies their | 216 // Aborts all in progress jobs with ERR_NETWORK_CHANGED and notifies their |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 scoped_ptr<PrioritizedDispatcher> dispatcher_; | 259 scoped_ptr<PrioritizedDispatcher> dispatcher_; |
262 | 260 |
263 // Limit on the maximum number of jobs queued in |dispatcher_|. | 261 // Limit on the maximum number of jobs queued in |dispatcher_|. |
264 size_t max_queued_jobs_; | 262 size_t max_queued_jobs_; |
265 | 263 |
266 // Parameters for ProcTask. | 264 // Parameters for ProcTask. |
267 ProcTaskParams proc_params_; | 265 ProcTaskParams proc_params_; |
268 | 266 |
269 NetLog* net_log_; | 267 NetLog* net_log_; |
270 | 268 |
271 // Address family to use when the request doesn't specify one. | |
272 AddressFamily default_address_family_; | |
273 | |
274 // If present, used by DnsTask and ServeFromHosts to resolve requests. | 269 // If present, used by DnsTask and ServeFromHosts to resolve requests. |
275 scoped_ptr<DnsClient> dns_client_; | 270 scoped_ptr<DnsClient> dns_client_; |
276 | 271 |
277 // True if received valid config from |dns_config_service_|. Temporary, used | 272 // True if received valid config from |dns_config_service_|. Temporary, used |
278 // to measure performance of DnsConfigService: http://crbug.com/125599 | 273 // to measure performance of DnsConfigService: http://crbug.com/125599 |
279 bool received_dns_config_; | 274 bool received_dns_config_; |
280 | 275 |
281 // Number of consecutive failures of DnsTask, counted when fallback succeeds. | 276 // Number of consecutive failures of DnsTask, counted when fallback succeeds. |
282 unsigned num_dns_failures_; | 277 unsigned num_dns_failures_; |
283 | 278 |
284 // True if probing is done for each Request to set address family. When false, | |
285 // explicit setting in |default_address_family_| is used. | |
286 bool probe_ipv6_support_; | |
287 | |
288 // True if DnsConfigService detected that system configuration depends on | 279 // True if DnsConfigService detected that system configuration depends on |
289 // local IPv6 connectivity. Disables probing. | 280 // local IPv6 connectivity. Disables probing. |
290 bool use_local_ipv6_; | 281 bool use_local_ipv6_; |
291 | 282 |
292 base::TimeTicks last_ipv6_probe_time_; | 283 base::TimeTicks last_ipv6_probe_time_; |
293 bool last_ipv6_probe_result_; | 284 bool last_ipv6_probe_result_; |
294 | 285 |
295 // True iff ProcTask has successfully resolved a hostname known to have IPv6 | 286 // True iff ProcTask has successfully resolved a hostname known to have IPv6 |
296 // addresses using ADDRESS_FAMILY_UNSPECIFIED. Reset on IP address change. | 287 // addresses using ADDRESS_FAMILY_UNSPECIFIED. Reset on IP address change. |
297 bool resolved_known_ipv6_hostname_; | 288 bool resolved_known_ipv6_hostname_; |
298 | 289 |
299 // Any resolver flags that should be added to a request by default. | 290 // Any resolver flags that should be added to a request by default. |
300 HostResolverFlags additional_resolver_flags_; | 291 HostResolverFlags additional_resolver_flags_; |
301 | 292 |
302 // Allow fallback to ProcTask if DnsTask fails. | 293 // Allow fallback to ProcTask if DnsTask fails. |
303 bool fallback_to_proctask_; | 294 bool fallback_to_proctask_; |
304 | 295 |
305 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; | 296 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; |
306 | 297 |
307 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; | 298 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; |
308 | 299 |
309 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 300 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
310 }; | 301 }; |
311 | 302 |
312 } // namespace net | 303 } // namespace net |
313 | 304 |
314 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ | 305 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ |
OLD | NEW |