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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 // HostResolver methods: | 129 // HostResolver methods: |
130 virtual int Resolve(const RequestInfo& info, | 130 virtual int Resolve(const RequestInfo& info, |
131 AddressList* addresses, | 131 AddressList* addresses, |
132 OldCompletionCallback* callback, | 132 OldCompletionCallback* callback, |
133 RequestHandle* out_req, | 133 RequestHandle* out_req, |
134 const BoundNetLog& source_net_log) OVERRIDE; | 134 const BoundNetLog& source_net_log) OVERRIDE; |
135 virtual int ResolveFromCache(const RequestInfo& info, | 135 virtual int ResolveFromCache(const RequestInfo& info, |
136 AddressList* addresses, | 136 AddressList* addresses, |
137 const BoundNetLog& source_net_log) OVERRIDE; | 137 const BoundNetLog& source_net_log) OVERRIDE; |
138 virtual void CancelRequest(RequestHandle req) OVERRIDE; | 138 virtual void CancelRequest(RequestHandle req) OVERRIDE; |
139 virtual void AddObserver(HostResolver::Observer* observer) OVERRIDE; | |
140 virtual void RemoveObserver(HostResolver::Observer* observer) OVERRIDE; | |
141 virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE; | 139 virtual void SetDefaultAddressFamily(AddressFamily address_family) OVERRIDE; |
142 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; | 140 virtual AddressFamily GetDefaultAddressFamily() const OVERRIDE; |
143 virtual void ProbeIPv6Support() OVERRIDE; | 141 virtual void ProbeIPv6Support() OVERRIDE; |
144 virtual HostCache* GetHostCache() OVERRIDE; | 142 virtual HostCache* GetHostCache() OVERRIDE; |
145 | 143 |
146 private: | 144 private: |
147 // Allow tests to access our innards for testing purposes. | 145 // Allow tests to access our innards for testing purposes. |
148 friend class LookupAttemptHostResolverProc; | 146 friend class LookupAttemptHostResolverProc; |
149 | 147 |
150 // Allow tests to access our innards for testing purposes. | 148 // Allow tests to access our innards for testing purposes. |
151 FRIEND_TEST_ALL_PREFIXES(HostResolverImplTest, MultipleAttempts); | 149 FRIEND_TEST_ALL_PREFIXES(HostResolverImplTest, MultipleAttempts); |
152 | 150 |
153 class Job; | 151 class Job; |
154 class JobPool; | 152 class JobPool; |
155 class IPv6ProbeJob; | 153 class IPv6ProbeJob; |
156 class Request; | 154 class Request; |
157 typedef std::vector<Request*> RequestsList; | 155 typedef std::vector<Request*> RequestsList; |
158 typedef HostCache::Key Key; | 156 typedef HostCache::Key Key; |
159 typedef std::map<Key, scoped_refptr<Job> > JobMap; | 157 typedef std::map<Key, scoped_refptr<Job> > JobMap; |
160 typedef std::vector<HostResolver::Observer*> ObserversList; | |
161 | 158 |
162 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP | 159 // Helper used by |Resolve()| and |ResolveFromCache()|. Performs IP |
163 // literal and cache lookup, returns OK if successful, | 160 // literal and cache lookup, returns OK if successful, |
164 // 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 |
165 // 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. |
166 int ResolveHelper(int request_id, | 163 int ResolveHelper(int request_id, |
167 const Key& key, | 164 const Key& key, |
168 const RequestInfo& info, | 165 const RequestInfo& info, |
169 AddressList* addresses, | 166 AddressList* addresses, |
170 const BoundNetLog& request_net_log); | 167 const BoundNetLog& request_net_log); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 uint32 retry_factor_; | 318 uint32 retry_factor_; |
322 | 319 |
323 // The information to track pending requests for a JobPool, as well as | 320 // The information to track pending requests for a JobPool, as well as |
324 // how many outstanding jobs the pool already has, and its constraints. | 321 // how many outstanding jobs the pool already has, and its constraints. |
325 JobPool* job_pools_[POOL_COUNT]; | 322 JobPool* job_pools_[POOL_COUNT]; |
326 | 323 |
327 // The job that OnJobComplete() is currently processing (needed in case | 324 // The job that OnJobComplete() is currently processing (needed in case |
328 // HostResolver gets deleted from within the callback). | 325 // HostResolver gets deleted from within the callback). |
329 scoped_refptr<Job> cur_completing_job_; | 326 scoped_refptr<Job> cur_completing_job_; |
330 | 327 |
331 // The observers to notify when a request starts/ends. | |
332 ObserversList observers_; | |
333 | |
334 // Monotonically increasing ID number to assign to the next request. | 328 // Monotonically increasing ID number to assign to the next request. |
335 // Observers are the only consumers of this ID number. | 329 // Observers are the only consumers of this ID number. |
336 int next_request_id_; | 330 int next_request_id_; |
eroman
2011/11/14 20:01:39
Can you delete this too? Or maybe it is still used
szym
2011/11/14 23:50:17
Currently HostResolverImpl does not use it, so I r
cbentzel
2011/11/15 10:49:01
You could always maintain a std::set<Request*> in
| |
337 | 331 |
338 // Monotonically increasing ID number to assign to the next job. | 332 // Monotonically increasing ID number to assign to the next job. |
339 // The only consumer of this ID is the requests tracing code. | 333 // The only consumer of this ID is the requests tracing code. |
340 int next_job_id_; | 334 int next_job_id_; |
341 | 335 |
342 // The procedure to use for resolving host names. This will be NULL, except | 336 // The procedure to use for resolving host names. This will be NULL, except |
343 // in the case of unit-tests which inject custom host resolving behaviors. | 337 // in the case of unit-tests which inject custom host resolving behaviors. |
344 scoped_refptr<HostResolverProc> resolver_proc_; | 338 scoped_refptr<HostResolverProc> resolver_proc_; |
345 | 339 |
346 // Address family to use when the request doesn't specify one. | 340 // Address family to use when the request doesn't specify one. |
(...skipping 11 matching lines...) Expand all Loading... | |
358 HostResolverFlags additional_resolver_flags_; | 352 HostResolverFlags additional_resolver_flags_; |
359 | 353 |
360 NetLog* net_log_; | 354 NetLog* net_log_; |
361 | 355 |
362 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 356 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
363 }; | 357 }; |
364 | 358 |
365 } // namespace net | 359 } // namespace net |
366 | 360 |
367 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 361 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
OLD | NEW |