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_BASE_HOST_RESOLVER_IMPL_H_ | 5 #ifndef NET_BASE_HOST_RESOLVER_IMPL_H_ |
6 #define NET_BASE_HOST_RESOLVER_IMPL_H_ | 6 #define NET_BASE_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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // |job_limits| specifies the maximum number of jobs that the resolver will | 107 // |job_limits| specifies the maximum number of jobs that the resolver will |
108 // run at once. This upper-bounds the total number of outstanding | 108 // run at once. This upper-bounds the total number of outstanding |
109 // DNS transactions (not counting retransmissions and retries). | 109 // DNS transactions (not counting retransmissions and retries). |
110 // | 110 // |
111 // |dns_config_service| will be used to detect changes to DNS configuration | 111 // |dns_config_service| will be used to detect changes to DNS configuration |
112 // and obtain DnsConfig for DnsClient. | 112 // and obtain DnsConfig for DnsClient. |
113 // | 113 // |
114 // |dns_client|, if set, will be used to resolve requests. | 114 // |dns_client|, if set, will be used to resolve requests. |
115 // | 115 // |
116 // |net_log| must remain valid for the life of the HostResolverImpl. | 116 // |net_log| must remain valid for the life of the HostResolverImpl. |
117 // TODO(szym): change to scoped_ptr<HostCache>. | |
118 HostResolverImpl(scoped_ptr<HostCache> cache, | 117 HostResolverImpl(scoped_ptr<HostCache> cache, |
119 const PrioritizedDispatcher::Limits& job_limits, | 118 const PrioritizedDispatcher::Limits& job_limits, |
120 const ProcTaskParams& proc_params, | 119 const ProcTaskParams& proc_params, |
121 scoped_ptr<DnsClient> dns_client, | 120 scoped_ptr<DnsClient> dns_client, |
122 NetLog* net_log); | 121 NetLog* net_log); |
123 | 122 |
124 // If any completion callbacks are pending when the resolver is destroyed, | 123 // If any completion callbacks are pending when the resolver is destroyed, |
125 // the host resolutions are cancelled, and the completion callbacks will not | 124 // the host resolutions are cancelled, and the completion callbacks will not |
126 // be called. | 125 // be called. |
127 virtual ~HostResolverImpl(); | 126 virtual ~HostResolverImpl(); |
(...skipping 16 matching lines...) Expand all Loading... |
144 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; | 143 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; |
145 virtual void ProbeIPv6Support() OVERRIDE; | 144 virtual void ProbeIPv6Support() 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; | 152 class IPv6ProbeJob; |
| 153 class LoopbackProbeJob; |
154 class DnsTask; | 154 class DnsTask; |
155 class Request; | 155 class Request; |
156 typedef HostCache::Key Key; | 156 typedef HostCache::Key Key; |
157 typedef std::map<Key, Job*> JobMap; | 157 typedef std::map<Key, Job*> JobMap; |
158 typedef ScopedVector<Request> RequestsList; | 158 typedef ScopedVector<Request> RequestsList; |
159 | 159 |
160 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP | 160 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP |
161 // literal, cache and HOSTS lookup (if enabled), returns OK if successful, | 161 // literal, cache and HOSTS lookup (if enabled), returns OK if successful, |
162 // ERR_NAME_NOT_RESOLVED if either hostname is invalid or IP literal is | 162 // ERR_NAME_NOT_RESOLVED if either hostname is invalid or IP literal is |
163 // incompatible, ERR_DNS_CACHE_MISS if entry was not found in cache and HOSTS. | 163 // incompatible, ERR_DNS_CACHE_MISS if entry was not found in cache and HOSTS. |
(...skipping 16 matching lines...) Expand all Loading... |
180 const RequestInfo& info, | 180 const RequestInfo& info, |
181 int* net_error, | 181 int* net_error, |
182 AddressList* addresses); | 182 AddressList* addresses); |
183 | 183 |
184 // If we have a DnsClient with a valid DnsConfig, and |key| is found in the | 184 // If we have a DnsClient with a valid DnsConfig, and |key| is found in the |
185 // HOSTS file, returns true and fills |addresses|. Otherwise returns false. | 185 // HOSTS file, returns true and fills |addresses|. Otherwise returns false. |
186 bool ServeFromHosts(const Key& key, | 186 bool ServeFromHosts(const Key& key, |
187 const RequestInfo& info, | 187 const RequestInfo& info, |
188 AddressList* addresses); | 188 AddressList* addresses); |
189 | 189 |
190 // Notifies IPv6ProbeJob not to call back, and discard reference to the job. | |
191 void DiscardIPv6ProbeJob(); | |
192 | |
193 // Callback from IPv6 probe activity. | 190 // Callback from IPv6 probe activity. |
194 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); | 191 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); |
195 | 192 |
196 // Callback from HaveOnlyLoopbackAddresses probe. | 193 // Callback from HaveOnlyLoopbackAddresses probe. |
197 void SetHaveOnlyLoopbackAddresses(bool result); | 194 void SetHaveOnlyLoopbackAddresses(bool result); |
198 | 195 |
199 // 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 |
200 // "effective" address family by inheriting the resolver's default address | 197 // "effective" address family by inheriting the resolver's default address |
201 // family when the request leaves it unspecified. | 198 // family when the request leaves it unspecified. |
202 Key GetEffectiveKeyForRequest(const RequestInfo& info) const; | 199 Key GetEffectiveKeyForRequest(const RequestInfo& info) const; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 size_t max_queued_jobs_; | 241 size_t max_queued_jobs_; |
245 | 242 |
246 // Parameters for ProcTask. | 243 // Parameters for ProcTask. |
247 ProcTaskParams proc_params_; | 244 ProcTaskParams proc_params_; |
248 | 245 |
249 // Address family to use when the request doesn't specify one. | 246 // Address family to use when the request doesn't specify one. |
250 AddressFamily default_address_family_; | 247 AddressFamily default_address_family_; |
251 | 248 |
252 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; | 249 base::WeakPtrFactory<HostResolverImpl> weak_ptr_factory_; |
253 | 250 |
| 251 base::WeakPtrFactory<HostResolverImpl> probe_weak_ptr_factory_; |
| 252 |
254 // If present, used by DnsTask and ServeFromHosts to resolve requests. | 253 // If present, used by DnsTask and ServeFromHosts to resolve requests. |
255 scoped_ptr<DnsClient> dns_client_; | 254 scoped_ptr<DnsClient> dns_client_; |
256 | 255 |
257 // True if received valid config from |dns_config_service_|. Temporary, used | 256 // True if received valid config from |dns_config_service_|. Temporary, used |
258 // to measure performance of DnsConfigService: http://crbug.com/125599 | 257 // to measure performance of DnsConfigService: http://crbug.com/125599 |
259 bool received_dns_config_; | 258 bool received_dns_config_; |
260 | 259 |
261 // Indicate if probing is done after each network change event to set address | 260 // Indicate if probing is done after each network change event to set address |
262 // family. When false, explicit setting of address family is used. | 261 // family. When false, explicit setting of address family is used and results |
| 262 // of the IPv6 probe job are ignored. |
263 bool ipv6_probe_monitoring_; | 263 bool ipv6_probe_monitoring_; |
264 | 264 |
265 // The last un-cancelled IPv6ProbeJob (if any). | |
266 scoped_refptr<IPv6ProbeJob> ipv6_probe_job_; | |
267 | |
268 // Any resolver flags that should be added to a request by default. | 265 // Any resolver flags that should be added to a request by default. |
269 HostResolverFlags additional_resolver_flags_; | 266 HostResolverFlags additional_resolver_flags_; |
270 | 267 |
271 NetLog* net_log_; | 268 NetLog* net_log_; |
272 | 269 |
273 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 270 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
274 }; | 271 }; |
275 | 272 |
276 } // namespace net | 273 } // namespace net |
277 | 274 |
278 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 275 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
OLD | NEW |