Chromium Code Reviews| 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 |
| 146 protected: | |
| 147 // Probes IPv6 support and returns true if IPv6 support is enabled. | |
| 148 // Results are cached, i.e. when called repeatedly this method returns result | |
| 149 // from the first probe for some time before probing again. | |
| 150 virtual bool IsIPv6Reachable(const BoundNetLog& net_log); | |
|
mmenke
2015/06/03 13:31:03
Drive-by nit: This doesn't have to be protected f
cbentzel
2015/06/03 15:43:19
Done.
| |
| 151 | |
| 148 private: | 152 private: |
| 149 friend class HostResolverImplTest; | 153 friend class HostResolverImplTest; |
| 150 class Job; | 154 class Job; |
| 151 class ProcTask; | 155 class ProcTask; |
| 152 class LoopbackProbeJob; | 156 class LoopbackProbeJob; |
| 153 class DnsTask; | 157 class DnsTask; |
| 154 class Request; | 158 class Request; |
| 155 typedef HostCache::Key Key; | 159 typedef HostCache::Key Key; |
| 156 typedef std::map<Key, Job*> JobMap; | 160 typedef std::map<Key, Job*> JobMap; |
| 157 typedef ScopedVector<Request> RequestsList; | 161 typedef ScopedVector<Request> RequestsList; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 // Callback from HaveOnlyLoopbackAddresses probe. | 199 // Callback from HaveOnlyLoopbackAddresses probe. |
| 196 void SetHaveOnlyLoopbackAddresses(bool result); | 200 void SetHaveOnlyLoopbackAddresses(bool result); |
| 197 | 201 |
| 198 // Returns the (hostname, address_family) key to use for |info|, choosing an | 202 // Returns the (hostname, address_family) key to use for |info|, choosing an |
| 199 // "effective" address family by inheriting the resolver's default address | 203 // "effective" address family by inheriting the resolver's default address |
| 200 // family when the request leaves it unspecified. | 204 // family when the request leaves it unspecified. |
| 201 Key GetEffectiveKeyForRequest(const RequestInfo& info, | 205 Key GetEffectiveKeyForRequest(const RequestInfo& info, |
| 202 const IPAddressNumber* ip_number, | 206 const IPAddressNumber* ip_number, |
| 203 const BoundNetLog& net_log); | 207 const BoundNetLog& net_log); |
| 204 | 208 |
| 205 // Probes IPv6 support and returns true if IPv6 support is enabled. | |
| 206 // Results are cached, i.e. when called repeatedly this method returns result | |
| 207 // from the first probe for some time before probing again. | |
| 208 bool IsIPv6Reachable(const BoundNetLog& net_log); | |
| 209 | |
| 210 // Records the result in cache if cache is present. | 209 // Records the result in cache if cache is present. |
| 211 void CacheResult(const Key& key, | 210 void CacheResult(const Key& key, |
| 212 const HostCache::Entry& entry, | 211 const HostCache::Entry& entry, |
| 213 base::TimeDelta ttl); | 212 base::TimeDelta ttl); |
| 214 | 213 |
| 215 // Removes |job| from |jobs_|, only if it exists. | 214 // Removes |job| from |jobs_|, only if it exists. |
| 216 void RemoveJob(Job* job); | 215 void RemoveJob(Job* job); |
| 217 | 216 |
| 218 // Aborts all in progress jobs with ERR_NETWORK_CHANGED and notifies their | 217 // Aborts all in progress jobs with ERR_NETWORK_CHANGED and notifies their |
| 219 // requests. Might start new jobs. | 218 // requests. Might start new jobs. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 scoped_ptr<PrioritizedDispatcher> dispatcher_; | 260 scoped_ptr<PrioritizedDispatcher> dispatcher_; |
| 262 | 261 |
| 263 // Limit on the maximum number of jobs queued in |dispatcher_|. | 262 // Limit on the maximum number of jobs queued in |dispatcher_|. |
| 264 size_t max_queued_jobs_; | 263 size_t max_queued_jobs_; |
| 265 | 264 |
| 266 // Parameters for ProcTask. | 265 // Parameters for ProcTask. |
| 267 ProcTaskParams proc_params_; | 266 ProcTaskParams proc_params_; |
| 268 | 267 |
| 269 NetLog* net_log_; | 268 NetLog* net_log_; |
| 270 | 269 |
| 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. | 270 // If present, used by DnsTask and ServeFromHosts to resolve requests. |
| 275 scoped_ptr<DnsClient> dns_client_; | 271 scoped_ptr<DnsClient> dns_client_; |
| 276 | 272 |
| 277 // True if received valid config from |dns_config_service_|. Temporary, used | 273 // True if received valid config from |dns_config_service_|. Temporary, used |
| 278 // to measure performance of DnsConfigService: http://crbug.com/125599 | 274 // to measure performance of DnsConfigService: http://crbug.com/125599 |
| 279 bool received_dns_config_; | 275 bool received_dns_config_; |
| 280 | 276 |
| 281 // Number of consecutive failures of DnsTask, counted when fallback succeeds. | 277 // Number of consecutive failures of DnsTask, counted when fallback succeeds. |
| 282 unsigned num_dns_failures_; | 278 unsigned num_dns_failures_; |
| 283 | 279 |
| 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 | 280 // True if DnsConfigService detected that system configuration depends on |
| 289 // local IPv6 connectivity. Disables probing. | 281 // local IPv6 connectivity. Disables probing. |
| 290 bool use_local_ipv6_; | 282 bool use_local_ipv6_; |
| 291 | 283 |
| 292 base::TimeTicks last_ipv6_probe_time_; | 284 base::TimeTicks last_ipv6_probe_time_; |
| 293 bool last_ipv6_probe_result_; | 285 bool last_ipv6_probe_result_; |
| 294 | 286 |
| 295 // True iff ProcTask has successfully resolved a hostname known to have IPv6 | 287 // True iff ProcTask has successfully resolved a hostname known to have IPv6 |
| 296 // addresses using ADDRESS_FAMILY_UNSPECIFIED. Reset on IP address change. | 288 // addresses using ADDRESS_FAMILY_UNSPECIFIED. Reset on IP address change. |
| 297 bool resolved_known_ipv6_hostname_; | 289 bool resolved_known_ipv6_hostname_; |
| 298 | 290 |
| 299 // Any resolver flags that should be added to a request by default. | 291 // Any resolver flags that should be added to a request by default. |
| 300 HostResolverFlags additional_resolver_flags_; | 292 HostResolverFlags additional_resolver_flags_; |
| 301 | 293 |
| 302 // Allow fallback to ProcTask if DnsTask fails. | 294 // Allow fallback to ProcTask if DnsTask fails. |
| 303 bool fallback_to_proctask_; | 295 bool fallback_to_proctask_; |
| 304 | 296 |
| 305 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; | 297 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; |
| 306 | 298 |
| 307 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; | 299 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; |
| 308 | 300 |
| 309 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 301 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
| 310 }; | 302 }; |
| 311 | 303 |
| 312 } // namespace net | 304 } // namespace net |
| 313 | 305 |
| 314 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ | 306 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ |
| OLD | NEW |