OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 // If |cache| is NULL, then no caching is used. Otherwise we take | 78 // If |cache| is NULL, then no caching is used. Otherwise we take |
79 // ownership of the |cache| pointer, and will free it during destructor. | 79 // ownership of the |cache| pointer, and will free it during destructor. |
80 // | 80 // |
81 // |resolver_proc| is used to perform the actual resolves; it must be | 81 // |resolver_proc| is used to perform the actual resolves; it must be |
82 // thread-safe since it is run from multiple worker threads. If | 82 // thread-safe since it is run from multiple worker threads. If |
83 // |resolver_proc| is NULL then the default host resolver procedure is | 83 // |resolver_proc| is NULL then the default host resolver procedure is |
84 // used (which is SystemHostResolverProc except if overridden). | 84 // used (which is SystemHostResolverProc except if overridden). |
85 // |max_jobs| specifies the maximum number of threads that the host resolver | 85 // |max_jobs| specifies the maximum number of threads that the host resolver |
86 // will use (not counting potential duplicate attempts). Use | 86 // will use (not counting potential duplicate attempts). Use |
87 // SetPoolConstraints() to specify finer-grain settings. | 87 // SetPoolConstraints() to specify finer-grain settings. |
88 // |max_retry_attempts| is the maximum number of times we will retry for host | |
89 // resolution. Pass HostResolver::kDefaultRetryAttempts to choose a default | |
eroman
2011/05/17 22:53:26
Note that this does not work as described.
ramant (doing other things)
2011/05/17 23:27:25
Fixed.
Done.
| |
90 // value. | |
88 // | 91 // |
89 // For each attempt, we could start another attempt if host is not resolved | 92 // For each attempt, we could start another attempt if host is not resolved |
90 // within unresponsive_delay_ time. We keep attempting to resolve the host | 93 // within unresponsive_delay_ time. We keep attempting to resolve the host |
91 // until retry interval reaches maximum_unresponsive_delay_ time. For every | 94 // for max_retry_attempts. For every retry attempt, we grow the |
92 // retry attempt, we grow the unresponsive_delay_ by the retry_factor_ amount | 95 // unresponsive_delay_ by the retry_factor_ amount (that is retry interval is |
93 // (that is retry interval is multiplied by the retry factor each time). Once | 96 // multiplied by the retry factor each time). Once we have retried |
94 // retry interval exceeds maximum_unresponsive_delay_ time, we give up on | 97 // max_retry_attempts, we give up on additional attempts. |
95 // additional attempts. | |
96 // | 98 // |
97 // |net_log| must remain valid for the life of the HostResolverImpl. | 99 // |net_log| must remain valid for the life of the HostResolverImpl. |
98 HostResolverImpl(HostResolverProc* resolver_proc, | 100 HostResolverImpl(HostResolverProc* resolver_proc, |
99 HostCache* cache, | 101 HostCache* cache, |
100 size_t max_jobs, | 102 size_t max_jobs, |
103 size_t max_retry_attempts, | |
101 NetLog* net_log); | 104 NetLog* net_log); |
102 | 105 |
103 // If any completion callbacks are pending when the resolver is destroyed, | 106 // If any completion callbacks are pending when the resolver is destroyed, |
104 // the host resolutions are cancelled, and the completion callbacks will not | 107 // the host resolutions are cancelled, and the completion callbacks will not |
105 // be called. | 108 // be called. |
106 virtual ~HostResolverImpl(); | 109 virtual ~HostResolverImpl(); |
107 | 110 |
108 // Continuously observe whether IPv6 is supported, and set the allowable | 111 // Continuously observe whether IPv6 is supported, and set the allowable |
109 // address family to IPv4 iff IPv6 is not supported. | 112 // address family to IPv4 iff IPv6 is not supported. |
110 void ProbeIPv6Support(); | 113 void ProbeIPv6Support(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 | 246 |
244 // Cancels all jobs. | 247 // Cancels all jobs. |
245 void CancelAllJobs(); | 248 void CancelAllJobs(); |
246 | 249 |
247 // Aborts all in progress jobs (but might start new ones). | 250 // Aborts all in progress jobs (but might start new ones). |
248 void AbortAllInProgressJobs(); | 251 void AbortAllInProgressJobs(); |
249 | 252 |
250 // NetworkChangeNotifier::IPAddressObserver methods: | 253 // NetworkChangeNotifier::IPAddressObserver methods: |
251 virtual void OnIPAddressChanged(); | 254 virtual void OnIPAddressChanged(); |
252 | 255 |
256 // Helper methods to get and set max_retry_attempts_. | |
257 size_t max_retry_attempts() const { | |
258 return max_retry_attempts_; | |
259 } | |
260 void set_max_retry_attempts(const size_t max_retry_attempts) { | |
261 max_retry_attempts_ = max_retry_attempts; | |
262 } | |
263 | |
253 // Helper methods for unit tests to get and set unresponsive_delay_. | 264 // Helper methods for unit tests to get and set unresponsive_delay_. |
254 base::TimeDelta unresponsive_delay() const { return unresponsive_delay_; } | 265 base::TimeDelta unresponsive_delay() const { return unresponsive_delay_; } |
255 void set_unresponsive_delay(const base::TimeDelta& unresponsive_delay) { | 266 void set_unresponsive_delay(const base::TimeDelta& unresponsive_delay) { |
256 unresponsive_delay_ = unresponsive_delay; | 267 unresponsive_delay_ = unresponsive_delay; |
257 } | 268 } |
258 | 269 |
259 // Helper methods to get and set retry_factor. | 270 // Helper methods to get and set retry_factor_. |
260 uint32 retry_factor() const { | 271 uint32 retry_factor() const { |
261 return retry_factor_; | 272 return retry_factor_; |
262 } | 273 } |
263 void set_retry_factor(const uint32 retry_factor) { | 274 void set_retry_factor(const uint32 retry_factor) { |
264 retry_factor_ = retry_factor; | 275 retry_factor_ = retry_factor; |
265 } | 276 } |
266 | 277 |
267 // Helper methods for unit tests to get and set maximum_unresponsive_delay_. | |
268 base::TimeDelta maximum_unresponsive_delay() const { | |
269 return maximum_unresponsive_delay_; | |
270 } | |
271 void set_maximum_unresponsive_delay( | |
272 const base::TimeDelta& maximum_unresponsive_delay) { | |
273 maximum_unresponsive_delay_ = maximum_unresponsive_delay; | |
274 } | |
275 | |
276 // Cache of host resolution results. | 278 // Cache of host resolution results. |
277 scoped_ptr<HostCache> cache_; | 279 scoped_ptr<HostCache> cache_; |
278 | 280 |
279 // Map from hostname to outstanding job. | 281 // Map from hostname to outstanding job. |
280 JobMap jobs_; | 282 JobMap jobs_; |
281 | 283 |
282 // Maximum number of concurrent jobs allowed, across all pools. Each job may | 284 // Maximum number of concurrent jobs allowed, across all pools. Each job may |
283 // create multiple concurrent resolve attempts for the hostname. | 285 // create multiple concurrent resolve attempts for the hostname. |
284 size_t max_jobs_; | 286 size_t max_jobs_; |
285 | 287 |
288 // Maximum number retry attempts to resolve the hostname. | |
289 size_t max_retry_attempts_; | |
290 | |
286 // This is the limit after which we make another attempt to resolve the host | 291 // This is the limit after which we make another attempt to resolve the host |
287 // if the worker thread has not responded yet. Allow unit tests to change the | 292 // if the worker thread has not responded yet. Allow unit tests to change the |
288 // value. | 293 // value. |
289 base::TimeDelta unresponsive_delay_; | 294 base::TimeDelta unresponsive_delay_; |
290 | 295 |
291 // Factor to grow unresponsive_delay_ when we re-re-try. Allow unit tests to | 296 // Factor to grow unresponsive_delay_ when we re-re-try. Allow unit tests to |
292 // change the value. | 297 // change the value. |
293 uint32 retry_factor_; | 298 uint32 retry_factor_; |
294 | 299 |
295 // This is the limit on how large we grow the retry interval. Once it exceeds | |
296 // this, we give up on additional attempts. Allow unit tests to change the | |
297 // value. | |
298 base::TimeDelta maximum_unresponsive_delay_; | |
299 | |
300 // The information to track pending requests for a JobPool, as well as | 300 // The information to track pending requests for a JobPool, as well as |
301 // how many outstanding jobs the pool already has, and its constraints. | 301 // how many outstanding jobs the pool already has, and its constraints. |
302 JobPool* job_pools_[POOL_COUNT]; | 302 JobPool* job_pools_[POOL_COUNT]; |
303 | 303 |
304 // The job that OnJobComplete() is currently processing (needed in case | 304 // The job that OnJobComplete() is currently processing (needed in case |
305 // HostResolver gets deleted from within the callback). | 305 // HostResolver gets deleted from within the callback). |
306 scoped_refptr<Job> cur_completing_job_; | 306 scoped_refptr<Job> cur_completing_job_; |
307 | 307 |
308 // The observers to notify when a request starts/ends. | 308 // The observers to notify when a request starts/ends. |
309 ObserversList observers_; | 309 ObserversList observers_; |
(...skipping 28 matching lines...) Expand all Loading... | |
338 HostResolverFlags additional_resolver_flags_; | 338 HostResolverFlags additional_resolver_flags_; |
339 | 339 |
340 NetLog* net_log_; | 340 NetLog* net_log_; |
341 | 341 |
342 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 342 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
343 }; | 343 }; |
344 | 344 |
345 } // namespace net | 345 } // namespace net |
346 | 346 |
347 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 347 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
OLD | NEW |