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