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_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 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 // HostResolver methods: | 80 // HostResolver methods: |
81 virtual int Resolve(const RequestInfo& info, | 81 virtual int Resolve(const RequestInfo& info, |
82 AddressList* addresses, | 82 AddressList* addresses, |
83 CompletionCallback* callback, | 83 CompletionCallback* callback, |
84 RequestHandle* out_req, | 84 RequestHandle* out_req, |
85 LoadLog* load_log); | 85 LoadLog* load_log); |
86 virtual void CancelRequest(RequestHandle req); | 86 virtual void CancelRequest(RequestHandle req); |
87 virtual void AddObserver(HostResolver::Observer* observer); | 87 virtual void AddObserver(HostResolver::Observer* observer); |
88 virtual void RemoveObserver(HostResolver::Observer* observer); | 88 virtual void RemoveObserver(HostResolver::Observer* observer); |
89 virtual HostCache* GetHostCache(); | |
90 | 89 |
91 // TODO(eroman): temp hack for http://crbug.com/15513 | 90 // TODO(eroman): temp hack for http://crbug.com/15513 |
92 virtual void Shutdown(); | 91 virtual void Shutdown(); |
93 | 92 |
94 virtual void SetDefaultAddressFamily(AddressFamily address_family) { | 93 virtual void SetDefaultAddressFamily(AddressFamily address_family) { |
95 default_address_family_ = address_family; | 94 default_address_family_ = address_family; |
96 } | 95 } |
97 | 96 |
| 97 virtual bool IsHostResolverImpl() { return true; } |
| 98 |
| 99 // Returns the cache this resolver uses, or NULL if caching is disabled. |
| 100 HostCache* cache() { return cache_.get(); } |
| 101 |
| 102 // Clears the request trace log. |
| 103 void ClearRequestsTrace(); |
| 104 |
| 105 // Starts/ends capturing requests to a trace log. |
| 106 void EnableRequestsTracing(bool enable); |
| 107 |
| 108 bool IsRequestsTracingEnabled() const; |
| 109 |
| 110 // Returns a copy of the requests trace log, or NULL if there is none. |
| 111 scoped_refptr<LoadLog> GetRequestsTrace(); |
| 112 |
98 // Applies a set of constraints for requests that belong to the specified | 113 // Applies a set of constraints for requests that belong to the specified |
99 // pool. NOTE: Don't call this after requests have been already been started. | 114 // pool. NOTE: Don't call this after requests have been already been started. |
100 // | 115 // |
101 // |pool_index| -- Specifies which pool these constraints should be applied | 116 // |pool_index| -- Specifies which pool these constraints should be applied |
102 // to. | 117 // to. |
103 // |max_outstanding_jobs| -- How many concurrent jobs are allowed for this | 118 // |max_outstanding_jobs| -- How many concurrent jobs are allowed for this |
104 // pool. | 119 // pool. |
105 // |max_pending_requests| -- How many requests can be enqueued for this pool | 120 // |max_pending_requests| -- How many requests can be enqueued for this pool |
106 // before we start dropping requests. Dropped | 121 // before we start dropping requests. Dropped |
107 // requests fail with | 122 // requests fail with |
108 // ERR_HOST_RESOLVER_QUEUE_TOO_LARGE. | 123 // ERR_HOST_RESOLVER_QUEUE_TOO_LARGE. |
109 void SetPoolConstraints(JobPoolIndex pool_index, | 124 void SetPoolConstraints(JobPoolIndex pool_index, |
110 size_t max_outstanding_jobs, | 125 size_t max_outstanding_jobs, |
111 size_t max_pending_requests); | 126 size_t max_pending_requests); |
112 | 127 |
113 private: | 128 private: |
114 class Job; | 129 class Job; |
115 class JobPool; | 130 class JobPool; |
116 class Request; | 131 class Request; |
| 132 class RequestsTrace; |
117 typedef std::vector<Request*> RequestsList; | 133 typedef std::vector<Request*> RequestsList; |
118 typedef HostCache::Key Key; | 134 typedef HostCache::Key Key; |
119 typedef std::map<Key, scoped_refptr<Job> > JobMap; | 135 typedef std::map<Key, scoped_refptr<Job> > JobMap; |
120 typedef std::vector<HostResolver::Observer*> ObserversList; | 136 typedef std::vector<HostResolver::Observer*> ObserversList; |
121 | 137 |
122 // If any completion callbacks are pending when the resolver is destroyed, | 138 // If any completion callbacks are pending when the resolver is destroyed, |
123 // the host resolutions are cancelled, and the completion callbacks will not | 139 // the host resolutions are cancelled, and the completion callbacks will not |
124 // be called. | 140 // be called. |
125 virtual ~HostResolverImpl(); | 141 virtual ~HostResolverImpl(); |
126 | 142 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // HostResolver gets deleted from within the callback). | 215 // HostResolver gets deleted from within the callback). |
200 scoped_refptr<Job> cur_completing_job_; | 216 scoped_refptr<Job> cur_completing_job_; |
201 | 217 |
202 // The observers to notify when a request starts/ends. | 218 // The observers to notify when a request starts/ends. |
203 ObserversList observers_; | 219 ObserversList observers_; |
204 | 220 |
205 // Monotonically increasing ID number to assign to the next request. | 221 // Monotonically increasing ID number to assign to the next request. |
206 // Observers are the only consumers of this ID number. | 222 // Observers are the only consumers of this ID number. |
207 int next_request_id_; | 223 int next_request_id_; |
208 | 224 |
| 225 // Monotonically increasing ID number to assign to the next job. |
| 226 // The only consumer of this ID is the requests tracing code. |
| 227 int next_job_id_; |
| 228 |
209 // The procedure to use for resolving host names. This will be NULL, except | 229 // The procedure to use for resolving host names. This will be NULL, except |
210 // in the case of unit-tests which inject custom host resolving behaviors. | 230 // in the case of unit-tests which inject custom host resolving behaviors. |
211 scoped_refptr<HostResolverProc> resolver_proc_; | 231 scoped_refptr<HostResolverProc> resolver_proc_; |
212 | 232 |
213 // Address family to use when the request doesn't specify one. | 233 // Address family to use when the request doesn't specify one. |
214 AddressFamily default_address_family_; | 234 AddressFamily default_address_family_; |
215 | 235 |
216 // TODO(eroman): temp hack for http://crbug.com/15513 | 236 // TODO(eroman): temp hack for http://crbug.com/15513 |
217 bool shutdown_; | 237 bool shutdown_; |
218 | 238 |
219 const scoped_refptr<NetworkChangeNotifier> network_change_notifier_; | 239 const scoped_refptr<NetworkChangeNotifier> network_change_notifier_; |
220 | 240 |
| 241 scoped_refptr<RequestsTrace> requests_trace_; |
| 242 |
221 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); | 243 DISALLOW_COPY_AND_ASSIGN(HostResolverImpl); |
222 }; | 244 }; |
223 | 245 |
224 } // namespace net | 246 } // namespace net |
225 | 247 |
226 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ | 248 #endif // NET_BASE_HOST_RESOLVER_IMPL_H_ |
OLD | NEW |