| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 AddressList* addresses, | 134 AddressList* addresses, |
| 135 const CompletionCallback& callback, | 135 const CompletionCallback& callback, |
| 136 RequestHandle* out_req, | 136 RequestHandle* out_req, |
| 137 const BoundNetLog& source_net_log) OVERRIDE; | 137 const BoundNetLog& source_net_log) OVERRIDE; |
| 138 virtual int ResolveFromCache(const RequestInfo& info, | 138 virtual int ResolveFromCache(const RequestInfo& info, |
| 139 AddressList* addresses, | 139 AddressList* addresses, |
| 140 const BoundNetLog& source_net_log) OVERRIDE; | 140 const BoundNetLog& source_net_log) OVERRIDE; |
| 141 virtual void CancelRequest(RequestHandle req) OVERRIDE; | 141 virtual void CancelRequest(RequestHandle req) OVERRIDE; |
| 142 virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE; | 142 virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE; |
| 143 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; | 143 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; |
| 144 virtual void ProbeIPv6Support() OVERRIDE; | |
| 145 virtual void SetDnsClientEnabled(bool enabled) OVERRIDE; | 144 virtual void SetDnsClientEnabled(bool enabled) OVERRIDE; |
| 146 virtual HostCache* GetHostCache() OVERRIDE; | 145 virtual HostCache* GetHostCache() OVERRIDE; |
| 147 virtual base::Value* GetDnsConfigAsValue() const OVERRIDE; | 146 virtual base::Value* GetDnsConfigAsValue() const OVERRIDE; |
| 148 | 147 |
| 149 private: | 148 private: |
| 150 friend class HostResolverImplTest; | 149 friend class HostResolverImplTest; |
| 151 class Job; | 150 class Job; |
| 152 class ProcTask; | 151 class ProcTask; |
| 153 class IPv6ProbeJob; | |
| 154 class LoopbackProbeJob; | 152 class LoopbackProbeJob; |
| 155 class DnsTask; | 153 class DnsTask; |
| 156 class Request; | 154 class Request; |
| 157 typedef HostCache::Key Key; | 155 typedef HostCache::Key Key; |
| 158 typedef std::map<Key, Job*> JobMap; | 156 typedef std::map<Key, Job*> JobMap; |
| 159 typedef ScopedVector<Request> RequestsList; | 157 typedef ScopedVector<Request> RequestsList; |
| 160 | 158 |
| 161 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP | 159 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP |
| 162 // literal, cache and HOSTS lookup (if enabled), returns OK if successful, | 160 // literal, cache and HOSTS lookup (if enabled), returns OK if successful, |
| 163 // ERR_NAME_NOT_RESOLVED if either hostname is invalid or IP literal is | 161 // ERR_NAME_NOT_RESOLVED if either hostname is invalid or IP literal is |
| (...skipping 17 matching lines...) Expand all Loading... |
| 181 const RequestInfo& info, | 179 const RequestInfo& info, |
| 182 int* net_error, | 180 int* net_error, |
| 183 AddressList* addresses); | 181 AddressList* addresses); |
| 184 | 182 |
| 185 // If we have a DnsClient with a valid DnsConfig, and |key| is found in the | 183 // If we have a DnsClient with a valid DnsConfig, and |key| is found in the |
| 186 // HOSTS file, returns true and fills |addresses|. Otherwise returns false. | 184 // HOSTS file, returns true and fills |addresses|. Otherwise returns false. |
| 187 bool ServeFromHosts(const Key& key, | 185 bool ServeFromHosts(const Key& key, |
| 188 const RequestInfo& info, | 186 const RequestInfo& info, |
| 189 AddressList* addresses); | 187 AddressList* addresses); |
| 190 | 188 |
| 191 // Callback from IPv6 probe activity. | |
| 192 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); | |
| 193 | |
| 194 // Callback from HaveOnlyLoopbackAddresses probe. | 189 // Callback from HaveOnlyLoopbackAddresses probe. |
| 195 void SetHaveOnlyLoopbackAddresses(bool result); | 190 void SetHaveOnlyLoopbackAddresses(bool result); |
| 196 | 191 |
| 197 // Returns the (hostname, address_family) key to use for |info|, choosing an | 192 // Returns the (hostname, address_family) key to use for |info|, choosing an |
| 198 // "effective" address family by inheriting the resolver's default address | 193 // "effective" address family by inheriting the resolver's default address |
| 199 // family when the request leaves it unspecified. | 194 // family when the request leaves it unspecified. |
| 200 Key GetEffectiveKeyForRequest(const RequestInfo& info) const; | 195 Key GetEffectiveKeyForRequest(const RequestInfo& info) const; |
| 201 | 196 |
| 202 // Records the result in cache if cache is present. | 197 // Records the result in cache if cache is present. |
| 203 void CacheResult(const Key& key, | 198 void CacheResult(const Key& key, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // If present, used by DnsTask and ServeFromHosts to resolve requests. | 255 // If present, used by DnsTask and ServeFromHosts to resolve requests. |
| 261 scoped_ptr<DnsClient> dns_client_; | 256 scoped_ptr<DnsClient> dns_client_; |
| 262 | 257 |
| 263 // True if received valid config from |dns_config_service_|. Temporary, used | 258 // True if received valid config from |dns_config_service_|. Temporary, used |
| 264 // to measure performance of DnsConfigService: http://crbug.com/125599 | 259 // to measure performance of DnsConfigService: http://crbug.com/125599 |
| 265 bool received_dns_config_; | 260 bool received_dns_config_; |
| 266 | 261 |
| 267 // Number of consecutive failures of DnsTask, counted when fallback succeeds. | 262 // Number of consecutive failures of DnsTask, counted when fallback succeeds. |
| 268 unsigned num_dns_failures_; | 263 unsigned num_dns_failures_; |
| 269 | 264 |
| 270 // Indicate if probing is done after each network change event to set address | 265 // True if probing is done for each Request to set address family. When false, |
| 271 // family. When false, explicit setting of address family is used and results | 266 // explicit setting in |default_address_family_| is used. |
| 272 // of the IPv6 probe job are ignored. | 267 bool probe_ipv6_support_; |
| 273 bool ipv6_probe_monitoring_; | |
| 274 | 268 |
| 275 // True iff ProcTask has successfully resolved a hostname known to have IPv6 | 269 // True iff ProcTask has successfully resolved a hostname known to have IPv6 |
| 276 // addresses using ADDRESS_FAMILY_UNSPECIFIED. Reset on IP address change. | 270 // addresses using ADDRESS_FAMILY_UNSPECIFIED. Reset on IP address change. |
| 277 bool resolved_known_ipv6_hostname_; | 271 bool resolved_known_ipv6_hostname_; |
| 278 | 272 |
| 279 // Any resolver flags that should be added to a request by default. | 273 // Any resolver flags that should be added to a request by default. |
| 280 HostResolverFlags additional_resolver_flags_; | 274 HostResolverFlags additional_resolver_flags_; |
| 281 | 275 |
| 282 // Allow fallback to ProcTask if DnsTask fails. | 276 // Allow fallback to ProcTask if DnsTask fails. |
| 283 bool fallback_to_proctask_; | 277 bool fallback_to_proctask_; |
| 284 | 278 |
| 285 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 279 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
| 286 }; | 280 }; |
| 287 | 281 |
| 288 } // namespace net | 282 } // namespace net |
| 289 | 283 |
| 290 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ | 284 #endif // NET_DNS_HOST_RESOLVER_IMPL_H_ |
| OLD | NEW |