OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "net/socket/socks_client_socket_pool.h" | 5 #include "net/socket/socks_client_socket_pool.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 186 } |
187 | 187 |
188 SOCKSClientSocketPool::SOCKSClientSocketPool( | 188 SOCKSClientSocketPool::SOCKSClientSocketPool( |
189 int max_sockets, | 189 int max_sockets, |
190 int max_sockets_per_group, | 190 int max_sockets_per_group, |
191 ClientSocketPoolHistograms* histograms, | 191 ClientSocketPoolHistograms* histograms, |
192 HostResolver* host_resolver, | 192 HostResolver* host_resolver, |
193 TransportClientSocketPool* transport_pool, | 193 TransportClientSocketPool* transport_pool, |
194 NetLog* net_log) | 194 NetLog* net_log) |
195 : transport_pool_(transport_pool), | 195 : transport_pool_(transport_pool), |
196 base_(max_sockets, max_sockets_per_group, histograms, | 196 base_(this, max_sockets, max_sockets_per_group, histograms, |
197 ClientSocketPool::unused_idle_socket_timeout(), | 197 ClientSocketPool::unused_idle_socket_timeout(), |
198 ClientSocketPool::used_idle_socket_timeout(), | 198 ClientSocketPool::used_idle_socket_timeout(), |
199 new SOCKSConnectJobFactory(transport_pool, | 199 new SOCKSConnectJobFactory(transport_pool, |
200 host_resolver, | 200 host_resolver, |
201 net_log)) { | 201 net_log)) { |
202 // We should always have a |transport_pool_| except in unit tests. | 202 // We should always have a |transport_pool_| except in unit tests. |
203 if (transport_pool_) | 203 if (transport_pool_) |
204 transport_pool_->AddLayeredPool(this); | 204 base_.AddLowerLayeredPool(transport_pool_); |
205 } | 205 } |
206 | 206 |
207 SOCKSClientSocketPool::~SOCKSClientSocketPool() { | 207 SOCKSClientSocketPool::~SOCKSClientSocketPool() { |
208 // We should always have a |transport_pool_| except in unit tests. | |
209 if (transport_pool_) | |
210 transport_pool_->RemoveLayeredPool(this); | |
211 } | 208 } |
212 | 209 |
213 int SOCKSClientSocketPool::RequestSocket( | 210 int SOCKSClientSocketPool::RequestSocket( |
214 const std::string& group_name, const void* socket_params, | 211 const std::string& group_name, const void* socket_params, |
215 RequestPriority priority, ClientSocketHandle* handle, | 212 RequestPriority priority, ClientSocketHandle* handle, |
216 const CompletionCallback& callback, const BoundNetLog& net_log) { | 213 const CompletionCallback& callback, const BoundNetLog& net_log) { |
217 const scoped_refptr<SOCKSSocketParams>* casted_socket_params = | 214 const scoped_refptr<SOCKSSocketParams>* casted_socket_params = |
218 static_cast<const scoped_refptr<SOCKSSocketParams>*>(socket_params); | 215 static_cast<const scoped_refptr<SOCKSSocketParams>*>(socket_params); |
219 | 216 |
220 return base_.RequestSocket(group_name, *casted_socket_params, priority, | 217 return base_.RequestSocket(group_name, *casted_socket_params, priority, |
(...skipping 18 matching lines...) Expand all Loading... |
239 | 236 |
240 void SOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, | 237 void SOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, |
241 StreamSocket* socket, int id) { | 238 StreamSocket* socket, int id) { |
242 base_.ReleaseSocket(group_name, socket, id); | 239 base_.ReleaseSocket(group_name, socket, id); |
243 } | 240 } |
244 | 241 |
245 void SOCKSClientSocketPool::FlushWithError(int error) { | 242 void SOCKSClientSocketPool::FlushWithError(int error) { |
246 base_.FlushWithError(error); | 243 base_.FlushWithError(error); |
247 } | 244 } |
248 | 245 |
249 bool SOCKSClientSocketPool::IsStalled() const { | |
250 return base_.IsStalled() || transport_pool_->IsStalled(); | |
251 } | |
252 | |
253 void SOCKSClientSocketPool::CloseIdleSockets() { | 246 void SOCKSClientSocketPool::CloseIdleSockets() { |
254 base_.CloseIdleSockets(); | 247 base_.CloseIdleSockets(); |
255 } | 248 } |
256 | 249 |
257 int SOCKSClientSocketPool::IdleSocketCount() const { | 250 int SOCKSClientSocketPool::IdleSocketCount() const { |
258 return base_.idle_socket_count(); | 251 return base_.idle_socket_count(); |
259 } | 252 } |
260 | 253 |
261 int SOCKSClientSocketPool::IdleSocketCountInGroup( | 254 int SOCKSClientSocketPool::IdleSocketCountInGroup( |
262 const std::string& group_name) const { | 255 const std::string& group_name) const { |
263 return base_.IdleSocketCountInGroup(group_name); | 256 return base_.IdleSocketCountInGroup(group_name); |
264 } | 257 } |
265 | 258 |
266 LoadState SOCKSClientSocketPool::GetLoadState( | 259 LoadState SOCKSClientSocketPool::GetLoadState( |
267 const std::string& group_name, const ClientSocketHandle* handle) const { | 260 const std::string& group_name, const ClientSocketHandle* handle) const { |
268 return base_.GetLoadState(group_name, handle); | 261 return base_.GetLoadState(group_name, handle); |
269 } | 262 } |
270 | 263 |
271 void SOCKSClientSocketPool::AddLayeredPool(LayeredPool* layered_pool) { | |
272 base_.AddLayeredPool(layered_pool); | |
273 } | |
274 | |
275 void SOCKSClientSocketPool::RemoveLayeredPool(LayeredPool* layered_pool) { | |
276 base_.RemoveLayeredPool(layered_pool); | |
277 } | |
278 | |
279 base::DictionaryValue* SOCKSClientSocketPool::GetInfoAsValue( | 264 base::DictionaryValue* SOCKSClientSocketPool::GetInfoAsValue( |
280 const std::string& name, | 265 const std::string& name, |
281 const std::string& type, | 266 const std::string& type, |
282 bool include_nested_pools) const { | 267 bool include_nested_pools) const { |
283 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type); | 268 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type); |
284 if (include_nested_pools) { | 269 if (include_nested_pools) { |
285 base::ListValue* list = new base::ListValue(); | 270 base::ListValue* list = new base::ListValue(); |
286 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", | 271 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", |
287 "transport_socket_pool", | 272 "transport_socket_pool", |
288 false)); | 273 false)); |
289 dict->Set("nested_pools", list); | 274 dict->Set("nested_pools", list); |
290 } | 275 } |
291 return dict; | 276 return dict; |
292 } | 277 } |
293 | 278 |
294 base::TimeDelta SOCKSClientSocketPool::ConnectionTimeout() const { | 279 base::TimeDelta SOCKSClientSocketPool::ConnectionTimeout() const { |
295 return base_.ConnectionTimeout(); | 280 return base_.ConnectionTimeout(); |
296 } | 281 } |
297 | 282 |
298 ClientSocketPoolHistograms* SOCKSClientSocketPool::histograms() const { | 283 ClientSocketPoolHistograms* SOCKSClientSocketPool::histograms() const { |
299 return base_.histograms(); | 284 return base_.histograms(); |
300 }; | 285 }; |
301 | 286 |
| 287 bool SOCKSClientSocketPool::IsStalled() const { |
| 288 return base_.IsStalled(); |
| 289 } |
| 290 |
| 291 void SOCKSClientSocketPool::AddHigherLayeredPool( |
| 292 HigherLayeredPool* higher_pool) { |
| 293 base_.AddHigherLayeredPool(higher_pool); |
| 294 } |
| 295 |
| 296 void SOCKSClientSocketPool::RemoveHigherLayeredPool( |
| 297 HigherLayeredPool* higher_pool) { |
| 298 base_.RemoveHigherLayeredPool(higher_pool); |
| 299 } |
| 300 |
302 bool SOCKSClientSocketPool::CloseOneIdleConnection() { | 301 bool SOCKSClientSocketPool::CloseOneIdleConnection() { |
303 if (base_.CloseOneIdleSocket()) | 302 if (base_.CloseOneIdleSocket()) |
304 return true; | 303 return true; |
305 return base_.CloseOneIdleConnectionInLayeredPool(); | 304 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
306 } | 305 } |
307 | 306 |
308 } // namespace net | 307 } // namespace net |
OLD | NEW |