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 <map> | |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
14 #include "base/threading/non_thread_safe.h" | 15 #include "base/threading/non_thread_safe.h" |
15 #include "base/time.h" | 16 #include "base/time.h" |
16 #include "net/base/capturing_net_log.h" | 17 #include "net/base/capturing_net_log.h" |
17 #include "net/base/host_cache.h" | 18 #include "net/base/host_cache.h" |
18 #include "net/base/host_resolver.h" | 19 #include "net/base/host_resolver.h" |
19 #include "net/base/host_resolver_proc.h" | 20 #include "net/base/host_resolver_proc.h" |
20 #include "net/base/net_export.h" | 21 #include "net/base/net_export.h" |
21 #include "net/base/net_log.h" | 22 #include "net/base/net_log.h" |
22 #include "net/base/network_change_notifier.h" | 23 #include "net/base/network_change_notifier.h" |
24 #include "net/base/priority_dispatch.h" | |
23 | 25 |
24 namespace net { | 26 namespace net { |
25 | 27 |
26 // For each hostname that is requested, HostResolver creates a | 28 // For each hostname that is requested, HostResolver creates a |
27 // HostResolverImpl::Job. This job gets dispatched to a thread in the global | 29 // HostResolverImpl::Job. When this job gets dispatched it creates a ProcJob |
28 // WorkerPool, where it runs SystemHostResolverProc(). If requests for that same | 30 // which runs the given HostResolverProc on a WorkerPool thread. If requests for |
29 // host are made while the job is already outstanding, then they are attached | 31 // that same host are made during the jobs lifetime, they are attached to the |
mmenke
2011/12/21 16:22:58
nit: job's lifetime
szym
2011/12/28 01:24:10
Done.
| |
30 // to the existing job rather than creating a new one. This avoids doing | 32 // existing job rather than creating a new one. This avoids doing parallel |
31 // parallel resolves for the same host. | 33 // resolves for the same host. |
32 // | 34 // |
33 // The way these classes fit together is illustrated by: | 35 // The way these classes fit together is illustrated by: |
34 // | 36 // |
35 // | 37 // |
36 // +----------- HostResolverImpl -------------+ | 38 // +----------- HostResolverImpl -------------+ |
37 // | | | | 39 // | | | |
38 // Job Job Job | 40 // Job Job Job |
39 // (for host1, fam1) (for host2, fam2) (for hostx, famx) | 41 // (for host1, fam1) (for host2, fam2) (for hostx, famx) |
40 // / | | / | | / | | | 42 // / | | / | | / | | |
41 // Request ... Request Request ... Request Request ... Request | 43 // Request ... Request Request ... Request Request ... Request |
(...skipping 14 matching lines...) Expand all Loading... | |
56 // Whenever we try to resolve the host, we post a delayed task to check if host | 58 // Whenever we try to resolve the host, we post a delayed task to check if host |
57 // resolution (OnLookupComplete) is completed or not. If the original attempt | 59 // resolution (OnLookupComplete) is completed or not. If the original attempt |
58 // hasn't completed, then we start another attempt for host resolution. We take | 60 // hasn't completed, then we start another attempt for host resolution. We take |
59 // the results from the first attempt that finishes and ignore the results from | 61 // the results from the first attempt that finishes and ignore the results from |
60 // all other attempts. | 62 // all other attempts. |
61 | 63 |
62 class NET_EXPORT HostResolverImpl | 64 class NET_EXPORT HostResolverImpl |
63 : public HostResolver, | 65 : public HostResolver, |
64 NON_EXPORTED_BASE(public base::NonThreadSafe), | 66 NON_EXPORTED_BASE(public base::NonThreadSafe), |
65 public NetworkChangeNotifier::IPAddressObserver, | 67 public NetworkChangeNotifier::IPAddressObserver, |
66 public NetworkChangeNotifier::DNSObserver { | 68 public NetworkChangeNotifier::DNSObserver, |
69 public base::SupportsWeakPtr<HostResolverImpl> { | |
67 public: | 70 public: |
68 // The index into |job_pools_| for the various job pools. Pools with a higher | 71 // Parameters for ProcJob which resolves hostnames using HostResolveProc. |
69 // index have lower priority. | |
70 // | |
71 // Note: This is currently unused, since there is a single pool | |
72 // for all requests. | |
73 enum JobPoolIndex { | |
74 POOL_NORMAL = 0, | |
75 POOL_COUNT, | |
76 }; | |
77 | |
78 // Creates a HostResolver that first uses the local cache |cache|, and then | |
79 // falls back to |resolver_proc|. | |
80 // | |
81 // If |cache| is NULL, then no caching is used. Otherwise we take | |
82 // ownership of the |cache| pointer, and will free it during destructor. | |
83 // | 72 // |
84 // |resolver_proc| is used to perform the actual resolves; it must be | 73 // |resolver_proc| is used to perform the actual resolves; it must be |
85 // thread-safe since it is run from multiple worker threads. If | 74 // thread-safe since it is run from multiple worker threads. If |
86 // |resolver_proc| is NULL then the default host resolver procedure is | 75 // |resolver_proc| is NULL then the default host resolver procedure is |
87 // used (which is SystemHostResolverProc except if overridden). | 76 // used (which is SystemHostResolverProc except if overridden). |
88 // |max_jobs| specifies the maximum number of threads that the host resolver | |
89 // will use (not counting potential duplicate attempts). Use | |
90 // SetPoolConstraints() to specify finer-grain settings. | |
91 // |max_retry_attempts| is the maximum number of times we will retry for host | |
92 // resolution. Pass HostResolver::kDefaultRetryAttempts to choose a default | |
93 // value. | |
94 // | 77 // |
95 // For each attempt, we could start another attempt if host is not resolved | 78 // For each attempt, we could start another attempt if host is not resolved |
96 // within unresponsive_delay_ time. We keep attempting to resolve the host | 79 // within unresponsive_delay_ time. We keep attempting to resolve the host |
mmenke
2011/12/21 16:22:58
While you're here, could you surround the variable
szym
2011/12/28 01:24:10
Done.
| |
97 // for max_retry_attempts. For every retry attempt, we grow the | 80 // for max_retry_attempts. For every retry attempt, we grow the |
98 // unresponsive_delay_ by the retry_factor_ amount (that is retry interval is | 81 // unresponsive_delay_ by the retry_factor_ amount (that is retry interval is |
99 // multiplied by the retry factor each time). Once we have retried | 82 // multiplied by the retry factor each time). Once we have retried |
100 // max_retry_attempts, we give up on additional attempts. | 83 // max_retry_attempts, we give up on additional attempts. |
101 // | 84 // |
85 struct NET_EXPORT_PRIVATE ProcJobParams { | |
86 // Sets up defaults. | |
87 ProcJobParams(HostResolverProc* resolver_proc, size_t max_retry_attempts); | |
88 | |
89 ~ProcJobParams(); | |
90 | |
91 // The procedure to use for resolving host names. This will be NULL, except | |
92 // in the case of unit-tests which inject custom host resolving behaviors. | |
93 scoped_refptr<HostResolverProc> resolver_proc_; | |
mmenke
2011/12/21 16:22:58
The style guide doesn't allow the terminating unde
szym
2011/12/28 01:24:10
Done.
| |
94 | |
95 // Maximum number retry attempts to resolve the hostname. | |
96 // Pass HostResolver::kDefaultRetryAttempts to choose a default | |
97 // value. | |
98 size_t max_retry_attempts_; | |
99 | |
100 // This is the limit after which we make another attempt to resolve the host | |
101 // if the worker thread has not responded yet. | |
102 base::TimeDelta unresponsive_delay_; | |
103 | |
104 // Factor to grow unresponsive_delay_ when we re-re-try. | |
105 uint32 retry_factor_; | |
106 }; | |
107 | |
108 // Creates a HostResolver that first uses the local cache |cache|, and then | |
109 // falls back to |proc_params.resolver_proc_|. | |
110 // | |
111 // If |cache| is NULL, then no caching is used. Otherwise we take | |
112 // ownership of the |cache| pointer, and will free it during destructor. | |
mmenke
2011/12/21 16:22:58
nit: "during destruction" or "in the destructor"
szym
2011/12/28 01:24:10
Done.
| |
113 // | |
114 // |job_limits| specifies the maximum number of threads that the host resolver | |
115 // will use (not counting potential duplicate attempts). | |
mmenke
2011/12/21 16:22:58
Should clarify it's the number of active jobs, rat
szym
2011/12/28 01:24:10
Done.
| |
116 // | |
102 // |net_log| must remain valid for the life of the HostResolverImpl. | 117 // |net_log| must remain valid for the life of the HostResolverImpl. |
103 HostResolverImpl(HostResolverProc* resolver_proc, | 118 HostResolverImpl(HostCache* cache, |
104 HostCache* cache, | 119 const PriorityDispatch::Limits& job_limits, |
105 size_t max_jobs, | 120 const ProcJobParams& proc_params, |
106 size_t max_retry_attempts, | |
107 NetLog* net_log); | 121 NetLog* net_log); |
108 | 122 |
109 // If any completion callbacks are pending when the resolver is destroyed, | 123 // If any completion callbacks are pending when the resolver is destroyed, |
110 // the host resolutions are cancelled, and the completion callbacks will not | 124 // the host resolutions are cancelled, and the completion callbacks will not |
111 // be called. | 125 // be called. |
112 virtual ~HostResolverImpl(); | 126 virtual ~HostResolverImpl(); |
113 | 127 |
114 // Applies a set of constraints for requests that belong to the specified | 128 // Configures maximum number of Jobs in the queue. Exposed for testing. |
115 // pool. NOTE: Don't call this after requests have been already been started. | 129 // Only allowed when the queue is empty. |
116 // | 130 void SetMaxQueuedJobs(size_t max_queued); |
mmenke
2011/12/21 16:22:58
Since this is only used in one test, could just go
mmenke
2011/12/21 16:22:58
nit: Also, think either |max| or |max_queued_jobs
szym
2011/12/28 01:24:10
Done.
| |
117 // |pool_index| -- Specifies which pool these constraints should be applied | |
118 // to. | |
119 // |max_outstanding_jobs| -- How many concurrent jobs are allowed for this | |
120 // pool. | |
121 // |max_pending_requests| -- How many requests can be enqueued for this pool | |
122 // before we start dropping requests. Dropped | |
123 // requests fail with | |
124 // ERR_HOST_RESOLVER_QUEUE_TOO_LARGE. | |
125 void SetPoolConstraints(JobPoolIndex pool_index, | |
126 size_t max_outstanding_jobs, | |
127 size_t max_pending_requests); | |
128 | 131 |
129 // HostResolver methods: | 132 // HostResolver methods: |
130 virtual int Resolve(const RequestInfo& info, | 133 virtual int Resolve(const RequestInfo& info, |
131 AddressList* addresses, | 134 AddressList* addresses, |
132 const CompletionCallback& callback, | 135 const CompletionCallback& callback, |
133 RequestHandle* out_req, | 136 RequestHandle* out_req, |
134 const BoundNetLog& source_net_log) OVERRIDE; | 137 const BoundNetLog& source_net_log) OVERRIDE; |
135 virtual int ResolveFromCache(const RequestInfo& info, | 138 virtual int ResolveFromCache(const RequestInfo& info, |
136 AddressList* addresses, | 139 AddressList* addresses, |
137 const BoundNetLog& source_net_log) OVERRIDE; | 140 const BoundNetLog& source_net_log) OVERRIDE; |
138 virtual void CancelRequest(RequestHandle req) OVERRIDE; | 141 virtual void CancelRequest(RequestHandle req) OVERRIDE; |
139 virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE; | 142 virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE; |
140 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; | 143 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; |
141 virtual void ProbeIPv6Support() OVERRIDE; | 144 virtual void ProbeIPv6Support() OVERRIDE; |
142 virtual HostCache* GetHostCache() OVERRIDE; | 145 virtual HostCache* GetHostCache() OVERRIDE; |
143 | 146 |
144 private: | 147 private: |
145 // Allow tests to access our innards for testing purposes. | 148 // Allow tests to access our innards for testing purposes. |
146 friend class LookupAttemptHostResolverProc; | |
147 | |
148 // Allow tests to access our innards for testing purposes. | |
149 FRIEND_TEST_ALL_PREFIXES(HostResolverImplTest, MultipleAttempts); | 149 FRIEND_TEST_ALL_PREFIXES(HostResolverImplTest, MultipleAttempts); |
150 | 150 |
151 class Job; | 151 class Job; |
152 class JobPool; | 152 class ProcJob; |
153 class IPv6ProbeJob; | 153 class IPv6ProbeJob; |
154 class Request; | 154 class Request; |
155 typedef HostCache::Key Key; | |
156 typedef std::map<Key, Job*> JobMap; | |
155 typedef std::vector<Request*> RequestsList; | 157 typedef std::vector<Request*> RequestsList; |
156 typedef HostCache::Key Key; | |
157 typedef std::map<Key, scoped_refptr<Job> > JobMap; | |
158 | 158 |
159 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP | 159 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP |
160 // literal and cache lookup, returns OK if successful, | 160 // literal and cache lookup, returns OK if successful, |
161 // 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 |
162 // incompatible, ERR_DNS_CACHE_MISS if entry was not found in cache. | 162 // incompatible, ERR_DNS_CACHE_MISS if entry was not found in cache. |
163 int ResolveHelper(const Key& key, | 163 int ResolveHelper(const Key& key, |
164 const RequestInfo& info, | 164 const RequestInfo& info, |
165 AddressList* addresses, | 165 AddressList* addresses, |
166 const BoundNetLog& request_net_log); | 166 const BoundNetLog& request_net_log); |
167 | 167 |
168 // Tries to resolve |key| as an IP, returns true and sets |net_error| if | 168 // Tries to resolve |key| as an IP, returns true and sets |net_error| if |
169 // succeeds, returns false otherwise. | 169 // succeeds, returns false otherwise. |
170 bool ResolveAsIP(const Key& key, | 170 bool ResolveAsIP(const Key& key, |
171 const RequestInfo& info, | 171 const RequestInfo& info, |
172 int* net_error, | 172 int* net_error, |
173 AddressList* addresses); | 173 AddressList* addresses); |
174 | 174 |
175 // If |key| is not found in cache returns false, otherwise returns | 175 // If |key| is not found in cache returns false, otherwise returns |
176 // true, sets |net_error| to the cached error code and fills |addresses| | 176 // true, sets |net_error| to the cached error code and fills |addresses| |
177 // if it is a positive entry. | 177 // if it is a positive entry. |
178 bool ServeFromCache(const Key& key, | 178 bool ServeFromCache(const Key& key, |
179 const RequestInfo& info, | 179 const RequestInfo& info, |
180 const BoundNetLog& request_net_log, | 180 const BoundNetLog& request_net_log, |
181 int* net_error, | 181 int* net_error, |
182 AddressList* addresses); | 182 AddressList* addresses); |
183 | 183 |
184 // Returns the HostResolverProc to use for this instance. | 184 // The logging routines are defined here because some requests are resolved |
185 HostResolverProc* effective_resolver_proc() const { | 185 // without a Request object. |
186 return resolver_proc_ ? | |
187 resolver_proc_.get() : HostResolverProc::GetDefault(); | |
188 } | |
189 | 186 |
190 // Adds a job to outstanding jobs list. | 187 // Logs when a request has just been started. |
191 void AddOutstandingJob(Job* job); | 188 static void LogStartRequest(const BoundNetLog& source_net_log, |
189 const BoundNetLog& request_net_log, | |
190 const RequestInfo& info); | |
192 | 191 |
193 // Returns the outstanding job for |key|, or NULL if there is none. | 192 // Logs when a request has just completed (before its callback is run). |
194 Job* FindOutstandingJob(const Key& key); | 193 static void LogFinishRequest(const BoundNetLog& source_net_log, |
194 const BoundNetLog& request_net_log, | |
195 const RequestInfo& info, | |
196 int net_error, | |
197 int os_error); | |
195 | 198 |
196 // Removes |job| from the outstanding jobs list. | 199 // Logs when a request has been cancelled. |
197 void RemoveOutstandingJob(Job* job); | 200 static void LogCancelRequest(const BoundNetLog& source_net_log, |
201 const BoundNetLog& request_net_log, | |
202 const RequestInfo& info); | |
198 | 203 |
199 // Callback for when |job| has completed with |net_error| and |addrlist|. | 204 // Notifies IPv6ProbeJob not to call back, and discard reference to the job. |
200 void OnJobComplete(Job* job, int net_error, int os_error, | |
201 const AddressList& addrlist); | |
202 | |
203 // Aborts |job|. Same as OnJobComplete() except does not remove |job| | |
204 // from |jobs_| and does not cache the result (ERR_ABORTED). | |
205 void AbortJob(Job* job); | |
206 | |
207 // Used by both OnJobComplete() and AbortJob(); | |
208 void OnJobCompleteInternal(Job* job, int net_error, int os_error, | |
209 const AddressList& addrlist); | |
210 | |
211 // Called when a request has just been started. | |
212 void OnStartRequest(const BoundNetLog& source_net_log, | |
213 const BoundNetLog& request_net_log, | |
214 const RequestInfo& info); | |
215 | |
216 // Called when a request has just completed (before its callback is run). | |
217 void OnFinishRequest(const BoundNetLog& source_net_log, | |
218 const BoundNetLog& request_net_log, | |
219 const RequestInfo& info, | |
220 int net_error, | |
221 int os_error); | |
222 | |
223 // Called when a request has been cancelled. | |
224 void OnCancelRequest(const BoundNetLog& source_net_log, | |
225 const BoundNetLog& request_net_log, | |
226 const RequestInfo& info); | |
227 | |
228 // Notify IPv6ProbeJob not to call back, and discard reference to the job. | |
229 void DiscardIPv6ProbeJob(); | 205 void DiscardIPv6ProbeJob(); |
230 | 206 |
231 // Callback from IPv6 probe activity. | 207 // Callback from IPv6 probe activity. |
232 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); | 208 void IPv6ProbeSetDefaultAddressFamily(AddressFamily address_family); |
233 | 209 |
234 // Returns true if the constraints for |pool| are met, and a new job can be | |
235 // created for this pool. | |
236 bool CanCreateJobForPool(const JobPool& pool) const; | |
237 | |
238 // Returns the index of the pool that request |req| maps to. | |
239 static JobPoolIndex GetJobPoolIndexForRequest(const Request* req); | |
240 | |
241 JobPool* GetPoolForRequest(const Request* req) { | |
242 return job_pools_[GetJobPoolIndexForRequest(req)]; | |
243 } | |
244 | |
245 // Starts up to 1 job given the current pool constraints. This job | |
246 // may have multiple requests attached to it. | |
247 void ProcessQueuedRequests(); | |
248 | |
249 // Returns the (hostname, address_family) key to use for |info|, choosing an | 210 // Returns the (hostname, address_family) key to use for |info|, choosing an |
250 // "effective" address family by inheriting the resolver's default address | 211 // "effective" address family by inheriting the resolver's default address |
251 // family when the request leaves it unspecified. | 212 // family when the request leaves it unspecified. |
252 Key GetEffectiveKeyForRequest(const RequestInfo& info) const; | 213 Key GetEffectiveKeyForRequest(const RequestInfo& info) const; |
253 | 214 |
254 // Attaches |req| to a new job, and starts it. Returns that job. | 215 // Called by |job| when it has finished running with result. |
255 Job* CreateAndStartJob(Request* req); | 216 void OnJobFinished(Job* job, const AddressList& addrlist); |
256 | 217 |
257 // Adds a pending request |req| to |pool|. | 218 // Called by |job| when it is ready to be destroyed. Returns true if |job| was |
258 int EnqueueRequest(JobPool* pool, Request* req); | 219 // removed from |jobs_|, which means the caller should delete it. |
220 // Otherwise, the previous caller will delete it. | |
mmenke
2011/12/21 16:22:58
Previous caller?
szym
2011/12/21 22:19:34
Whoever was the first to call RemoveJob and receiv
szym
2011/12/28 01:24:10
This part of the logic removed.
| |
221 bool RemoveJob(Job* job); | |
259 | 222 |
260 // Cancels all jobs. | 223 // Cancels all jobs. Drops all requests. |
261 void CancelAllJobs(); | 224 void CancelAllJobs(); |
mmenke
2011/12/22 16:18:49
Mind renaming this to Shutdown() or ShutdownAllJob
szym
2011/12/28 01:24:10
Removed.
| |
262 | 225 |
263 // Aborts all in progress jobs (but might start new ones). | 226 // Aborts all in progress jobs and notifies their requests. |
227 // Might start new jobs. | |
264 void AbortAllInProgressJobs(); | 228 void AbortAllInProgressJobs(); |
265 | 229 |
266 // NetworkChangeNotifier::IPAddressObserver methods: | 230 // NetworkChangeNotifier::IPAddressObserver methods: |
267 virtual void OnIPAddressChanged() OVERRIDE; | 231 virtual void OnIPAddressChanged() OVERRIDE; |
268 | 232 |
269 // Helper methods to get and set max_retry_attempts_. | |
270 size_t max_retry_attempts() const { | |
271 return max_retry_attempts_; | |
272 } | |
273 void set_max_retry_attempts(const size_t max_retry_attempts) { | |
274 max_retry_attempts_ = max_retry_attempts; | |
275 } | |
276 | |
277 // Helper methods for unit tests to get and set unresponsive_delay_. | |
278 base::TimeDelta unresponsive_delay() const { return unresponsive_delay_; } | |
279 void set_unresponsive_delay(const base::TimeDelta& unresponsive_delay) { | |
280 unresponsive_delay_ = unresponsive_delay; | |
281 } | |
282 | |
283 // Helper methods to get and set retry_factor_. | |
284 uint32 retry_factor() const { | |
285 return retry_factor_; | |
286 } | |
287 void set_retry_factor(const uint32 retry_factor) { | |
288 retry_factor_ = retry_factor; | |
289 } | |
290 | |
291 // NetworkChangeNotifier::OnDNSChanged methods: | 233 // NetworkChangeNotifier::OnDNSChanged methods: |
292 virtual void OnDNSChanged() OVERRIDE; | 234 virtual void OnDNSChanged() OVERRIDE; |
293 | 235 |
294 // Cache of host resolution results. | 236 // Cache of host resolution results. |
295 scoped_ptr<HostCache> cache_; | 237 scoped_ptr<HostCache> cache_; |
296 | 238 |
297 // Map from hostname to outstanding job. | 239 // Map from cache key to outstanding job. |
298 JobMap jobs_; | 240 JobMap jobs_; |
299 | 241 |
300 // Maximum number of concurrent jobs allowed, across all pools. Each job may | 242 // Starts Jobs according to their priority and the configured limits. |
301 // create multiple concurrent resolve attempts for the hostname. | 243 PriorityDispatch dispatch_; |
302 size_t max_jobs_; | |
303 | 244 |
304 // Maximum number retry attempts to resolve the hostname. | 245 // Parameters for ProcJob. |
305 size_t max_retry_attempts_; | 246 ProcJobParams proc_params_; |
306 | |
307 // This is the limit after which we make another attempt to resolve the host | |
308 // if the worker thread has not responded yet. Allow unit tests to change the | |
309 // value. | |
310 base::TimeDelta unresponsive_delay_; | |
311 | |
312 // Factor to grow unresponsive_delay_ when we re-re-try. Allow unit tests to | |
313 // change the value. | |
314 uint32 retry_factor_; | |
315 | |
316 // The information to track pending requests for a JobPool, as well as | |
317 // how many outstanding jobs the pool already has, and its constraints. | |
318 JobPool* job_pools_[POOL_COUNT]; | |
319 | |
320 // The job that OnJobComplete() is currently processing (needed in case | |
321 // HostResolver gets deleted from within the callback). | |
322 scoped_refptr<Job> cur_completing_job_; | |
323 | |
324 // Monotonically increasing ID number to assign to the next job. | |
325 // The only consumer of this ID is the requests tracing code. | |
326 int next_job_id_; | |
327 | |
328 // The procedure to use for resolving host names. This will be NULL, except | |
329 // in the case of unit-tests which inject custom host resolving behaviors. | |
330 scoped_refptr<HostResolverProc> resolver_proc_; | |
331 | 247 |
332 // Address family to use when the request doesn't specify one. | 248 // Address family to use when the request doesn't specify one. |
333 AddressFamily default_address_family_; | 249 AddressFamily default_address_family_; |
334 | 250 |
335 // Indicate if probing is done after each network change event to set address | 251 // Indicate if probing is done after each network change event to set address |
336 // family. | 252 // family. |
337 // When false, explicit setting of address family is used. | 253 // When false, explicit setting of address family is used. |
338 bool ipv6_probe_monitoring_; | 254 bool ipv6_probe_monitoring_; |
339 | 255 |
340 // The last un-cancelled IPv6ProbeJob (if any). | 256 // The last un-cancelled IPv6ProbeJob (if any). |
341 scoped_refptr<IPv6ProbeJob> ipv6_probe_job_; | 257 scoped_refptr<IPv6ProbeJob> ipv6_probe_job_; |
342 | 258 |
343 // Any resolver flags that should be added to a request by default. | 259 // Any resolver flags that should be added to a request by default. |
344 HostResolverFlags additional_resolver_flags_; | 260 HostResolverFlags additional_resolver_flags_; |
345 | 261 |
346 NetLog* net_log_; | 262 NetLog* net_log_; |
347 | 263 |
348 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 264 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
349 }; | 265 }; |
350 | 266 |
351 } // namespace net | 267 } // namespace net |
352 | 268 |
353 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 269 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
OLD | NEW |