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