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