Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: net/base/host_resolver_impl.h

Issue 7011044: Add a command line option to turn off retry attempts to resolve host (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 // until retry interval reaches maximum_unresponsive_delay_ time. For every
92 // retry attempt, we grow the unresponsive_delay_ by the retry_factor_ amount 95 // retry attempt, we grow the unresponsive_delay_ by the retry_factor_ amount
93 // (that is retry interval is multiplied by the retry factor each time). Once 96 // (that is retry interval is multiplied by the retry factor each time). Once
94 // retry interval exceeds maximum_unresponsive_delay_ time, we give up on 97 // retry interval exceeds maximum_unresponsive_delay_ time, we give up on
95 // additional attempts. 98 // additional attempts.
96 // 99 //
97 // |net_log| must remain valid for the life of the HostResolverImpl. 100 // |net_log| must remain valid for the life of the HostResolverImpl.
98 HostResolverImpl(HostResolverProc* resolver_proc, 101 HostResolverImpl(HostResolverProc* resolver_proc,
99 HostCache* cache, 102 HostCache* cache,
100 size_t max_jobs, 103 size_t max_jobs,
104 size_t max_retry_attempts,
101 NetLog* net_log); 105 NetLog* net_log);
102 106
103 // If any completion callbacks are pending when the resolver is destroyed, 107 // If any completion callbacks are pending when the resolver is destroyed,
104 // the host resolutions are cancelled, and the completion callbacks will not 108 // the host resolutions are cancelled, and the completion callbacks will not
105 // be called. 109 // be called.
106 virtual ~HostResolverImpl(); 110 virtual ~HostResolverImpl();
107 111
108 // Continuously observe whether IPv6 is supported, and set the allowable 112 // Continuously observe whether IPv6 is supported, and set the allowable
109 // address family to IPv4 iff IPv6 is not supported. 113 // address family to IPv4 iff IPv6 is not supported.
110 void ProbeIPv6Support(); 114 void ProbeIPv6Support();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 247
244 // Cancels all jobs. 248 // Cancels all jobs.
245 void CancelAllJobs(); 249 void CancelAllJobs();
246 250
247 // Aborts all in progress jobs (but might start new ones). 251 // Aborts all in progress jobs (but might start new ones).
248 void AbortAllInProgressJobs(); 252 void AbortAllInProgressJobs();
249 253
250 // NetworkChangeNotifier::IPAddressObserver methods: 254 // NetworkChangeNotifier::IPAddressObserver methods:
251 virtual void OnIPAddressChanged(); 255 virtual void OnIPAddressChanged();
252 256
257 // Helper methods to get and set max_retry_attempts_.
258 size_t max_retry_attempts() const {
259 return max_retry_attempts_;
260 }
261 void set_max_retry_attempts(const size_t max_retry_attempts) {
262 max_retry_attempts_ = max_retry_attempts;
263 }
264
253 // Helper methods for unit tests to get and set unresponsive_delay_. 265 // Helper methods for unit tests to get and set unresponsive_delay_.
254 base::TimeDelta unresponsive_delay() const { return unresponsive_delay_; } 266 base::TimeDelta unresponsive_delay() const { return unresponsive_delay_; }
255 void set_unresponsive_delay(const base::TimeDelta& unresponsive_delay) { 267 void set_unresponsive_delay(const base::TimeDelta& unresponsive_delay) {
256 unresponsive_delay_ = unresponsive_delay; 268 unresponsive_delay_ = unresponsive_delay;
257 } 269 }
258 270
259 // Helper methods to get and set retry_factor. 271 // Helper methods to get and set retry_factor_.
260 uint32 retry_factor() const { 272 uint32 retry_factor() const {
261 return retry_factor_; 273 return retry_factor_;
262 } 274 }
263 void set_retry_factor(const uint32 retry_factor) { 275 void set_retry_factor(const uint32 retry_factor) {
264 retry_factor_ = retry_factor; 276 retry_factor_ = retry_factor;
265 } 277 }
266 278
267 // Helper methods for unit tests to get and set maximum_unresponsive_delay_. 279 // Helper methods for unit tests to get and set maximum_unresponsive_delay_.
268 base::TimeDelta maximum_unresponsive_delay() const { 280 base::TimeDelta maximum_unresponsive_delay() const {
269 return maximum_unresponsive_delay_; 281 return maximum_unresponsive_delay_;
270 } 282 }
271 void set_maximum_unresponsive_delay( 283 void set_maximum_unresponsive_delay(
272 const base::TimeDelta& maximum_unresponsive_delay) { 284 const base::TimeDelta& maximum_unresponsive_delay) {
273 maximum_unresponsive_delay_ = maximum_unresponsive_delay; 285 maximum_unresponsive_delay_ = maximum_unresponsive_delay;
274 } 286 }
275 287
276 // Cache of host resolution results. 288 // Cache of host resolution results.
277 scoped_ptr<HostCache> cache_; 289 scoped_ptr<HostCache> cache_;
278 290
279 // Map from hostname to outstanding job. 291 // Map from hostname to outstanding job.
280 JobMap jobs_; 292 JobMap jobs_;
281 293
282 // Maximum number of concurrent jobs allowed, across all pools. Each job may 294 // Maximum number of concurrent jobs allowed, across all pools. Each job may
283 // create multiple concurrent resolve attempts for the hostname. 295 // create multiple concurrent resolve attempts for the hostname.
284 size_t max_jobs_; 296 size_t max_jobs_;
285 297
298 // Maximum number retry attempts to resolve the hostname.
299 size_t max_retry_attempts_;
300
286 // This is the limit after which we make another attempt to resolve the host 301 // 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 302 // if the worker thread has not responded yet. Allow unit tests to change the
288 // value. 303 // value.
289 base::TimeDelta unresponsive_delay_; 304 base::TimeDelta unresponsive_delay_;
290 305
291 // Factor to grow unresponsive_delay_ when we re-re-try. Allow unit tests to 306 // Factor to grow unresponsive_delay_ when we re-re-try. Allow unit tests to
292 // change the value. 307 // change the value.
293 uint32 retry_factor_; 308 uint32 retry_factor_;
294 309
295 // This is the limit on how large we grow the retry interval. Once it exceeds 310 // This is the limit on how large we grow the retry interval. Once it exceeds
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 HostResolverFlags additional_resolver_flags_; 353 HostResolverFlags additional_resolver_flags_;
339 354
340 NetLog* net_log_; 355 NetLog* net_log_;
341 356
342 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); 357 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl);
343 }; 358 };
344 359
345 } // namespace net 360 } // namespace net
346 361
347 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ 362 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698