| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_H_ | 5 #ifndef NET_BASE_HOST_RESOLVER_H_ |
| 6 #define NET_BASE_HOST_RESOLVER_H_ | 6 #define NET_BASE_HOST_RESOLVER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 void CancelRequest(Request* req); | 155 void CancelRequest(Request* req); |
| 156 | 156 |
| 157 // Adds an observer to this resolver. The observer will be notified of the | 157 // Adds an observer to this resolver. The observer will be notified of the |
| 158 // start and completion of all requests (excluding cancellation). |observer| | 158 // start and completion of all requests (excluding cancellation). |observer| |
| 159 // must remain valid for the duration of this HostResolver's lifetime. | 159 // must remain valid for the duration of this HostResolver's lifetime. |
| 160 void AddObserver(Observer* observer); | 160 void AddObserver(Observer* observer); |
| 161 | 161 |
| 162 // Unregisters an observer previously added by AddObserver(). | 162 // Unregisters an observer previously added by AddObserver(). |
| 163 void RemoveObserver(Observer* observer); | 163 void RemoveObserver(Observer* observer); |
| 164 | 164 |
| 165 // TODO(eroman): temp hack for http://crbug.com/15513 |
| 166 void Shutdown(); |
| 167 |
| 165 private: | 168 private: |
| 166 class Job; | 169 class Job; |
| 167 typedef std::vector<Request*> RequestsList; | 170 typedef std::vector<Request*> RequestsList; |
| 168 typedef base::hash_map<std::string, scoped_refptr<Job> > JobMap; | 171 typedef base::hash_map<std::string, scoped_refptr<Job> > JobMap; |
| 169 typedef std::vector<Observer*> ObserversList; | 172 typedef std::vector<Observer*> ObserversList; |
| 170 | 173 |
| 171 // Adds a job to outstanding jobs list. | 174 // Adds a job to outstanding jobs list. |
| 172 void AddOutstandingJob(Job* job); | 175 void AddOutstandingJob(Job* job); |
| 173 | 176 |
| 174 // Returns the outstanding job for |hostname|, or NULL if there is none. | 177 // Returns the outstanding job for |hostname|, or NULL if there is none. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 203 // HostResolver gets deleted from within the callback). | 206 // HostResolver gets deleted from within the callback). |
| 204 scoped_refptr<Job> cur_completing_job_; | 207 scoped_refptr<Job> cur_completing_job_; |
| 205 | 208 |
| 206 // The observers to notify when a request starts/ends. | 209 // The observers to notify when a request starts/ends. |
| 207 ObserversList observers_; | 210 ObserversList observers_; |
| 208 | 211 |
| 209 // Monotonically increasing ID number to assign to the next request. | 212 // Monotonically increasing ID number to assign to the next request. |
| 210 // Observers are the only consumers of this ID number. | 213 // Observers are the only consumers of this ID number. |
| 211 int next_request_id_; | 214 int next_request_id_; |
| 212 | 215 |
| 216 // TODO(eroman): temp hack for http://crbug.com/15513 |
| 217 bool shutdown_; |
| 218 |
| 213 DISALLOW_COPY_AND_ASSIGN(HostResolver); | 219 DISALLOW_COPY_AND_ASSIGN(HostResolver); |
| 214 }; | 220 }; |
| 215 | 221 |
| 216 // This class represents the task of resolving a hostname (or IP address | 222 // This class represents the task of resolving a hostname (or IP address |
| 217 // literal) to an AddressList object. It wraps HostResolver to resolve only a | 223 // literal) to an AddressList object. It wraps HostResolver to resolve only a |
| 218 // single hostname at a time and cancels this request when going out of scope. | 224 // single hostname at a time and cancels this request when going out of scope. |
| 219 class SingleRequestHostResolver { | 225 class SingleRequestHostResolver { |
| 220 public: | 226 public: |
| 221 explicit SingleRequestHostResolver(HostResolver* resolver); | 227 explicit SingleRequestHostResolver(HostResolver* resolver); |
| 222 | 228 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // | 291 // |
| 286 // NOTE: In most cases, you should use ScopedHostMapper instead, which is | 292 // NOTE: In most cases, you should use ScopedHostMapper instead, which is |
| 287 // defined in host_resolver_unittest.h | 293 // defined in host_resolver_unittest.h |
| 288 // | 294 // |
| 289 HostMapper* SetHostMapper(HostMapper* host_mapper); | 295 HostMapper* SetHostMapper(HostMapper* host_mapper); |
| 290 #endif | 296 #endif |
| 291 | 297 |
| 292 } // namespace net | 298 } // namespace net |
| 293 | 299 |
| 294 #endif // NET_BASE_HOST_RESOLVER_H_ | 300 #endif // NET_BASE_HOST_RESOLVER_H_ |
| OLD | NEW |