Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: net/socket/socks_client_socket_pool.cc

Issue 10026024: Attempting to re-land a small portion of this change... Simply add links from (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix willchan's nit Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/socks_client_socket_pool.h ('k') | net/socket/ssl_client_socket_pool.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 9 #include "base/time.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_(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.
203 if (transport_pool_)
204 transport_pool_->AddLayeredPool(this);
202 } 205 }
203 206
204 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 }
205 212
206 int SOCKSClientSocketPool::RequestSocket( 213 int SOCKSClientSocketPool::RequestSocket(
207 const std::string& group_name, const void* socket_params, 214 const std::string& group_name, const void* socket_params,
208 RequestPriority priority, ClientSocketHandle* handle, 215 RequestPriority priority, ClientSocketHandle* handle,
209 const CompletionCallback& callback, const BoundNetLog& net_log) { 216 const CompletionCallback& callback, const BoundNetLog& net_log) {
210 const scoped_refptr<SOCKSSocketParams>* casted_socket_params = 217 const scoped_refptr<SOCKSSocketParams>* casted_socket_params =
211 static_cast<const scoped_refptr<SOCKSSocketParams>*>(socket_params); 218 static_cast<const scoped_refptr<SOCKSSocketParams>*>(socket_params);
212 219
213 return base_.RequestSocket(group_name, *casted_socket_params, priority, 220 return base_.RequestSocket(group_name, *casted_socket_params, priority,
214 handle, callback, net_log); 221 handle, callback, net_log);
(...skipping 17 matching lines...) Expand all
232 239
233 void SOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, 240 void SOCKSClientSocketPool::ReleaseSocket(const std::string& group_name,
234 StreamSocket* socket, int id) { 241 StreamSocket* socket, int id) {
235 base_.ReleaseSocket(group_name, socket, id); 242 base_.ReleaseSocket(group_name, socket, id);
236 } 243 }
237 244
238 void SOCKSClientSocketPool::Flush() { 245 void SOCKSClientSocketPool::Flush() {
239 base_.Flush(); 246 base_.Flush();
240 } 247 }
241 248
249 bool SOCKSClientSocketPool::IsStalled() const {
250 return base_.IsStalled() || transport_pool_->IsStalled();
251 }
252
242 void SOCKSClientSocketPool::CloseIdleSockets() { 253 void SOCKSClientSocketPool::CloseIdleSockets() {
243 base_.CloseIdleSockets(); 254 base_.CloseIdleSockets();
244 } 255 }
245 256
246 int SOCKSClientSocketPool::IdleSocketCount() const { 257 int SOCKSClientSocketPool::IdleSocketCount() const {
247 return base_.idle_socket_count(); 258 return base_.idle_socket_count();
248 } 259 }
249 260
250 int SOCKSClientSocketPool::IdleSocketCountInGroup( 261 int SOCKSClientSocketPool::IdleSocketCountInGroup(
251 const std::string& group_name) const { 262 const std::string& group_name) const {
252 return base_.IdleSocketCountInGroup(group_name); 263 return base_.IdleSocketCountInGroup(group_name);
253 } 264 }
254 265
255 LoadState SOCKSClientSocketPool::GetLoadState( 266 LoadState SOCKSClientSocketPool::GetLoadState(
256 const std::string& group_name, const ClientSocketHandle* handle) const { 267 const std::string& group_name, const ClientSocketHandle* handle) const {
257 return base_.GetLoadState(group_name, handle); 268 return base_.GetLoadState(group_name, handle);
258 } 269 }
259 270
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
260 DictionaryValue* SOCKSClientSocketPool::GetInfoAsValue( 279 DictionaryValue* SOCKSClientSocketPool::GetInfoAsValue(
261 const std::string& name, 280 const std::string& name,
262 const std::string& type, 281 const std::string& type,
263 bool include_nested_pools) const { 282 bool include_nested_pools) const {
264 DictionaryValue* dict = base_.GetInfoAsValue(name, type); 283 DictionaryValue* dict = base_.GetInfoAsValue(name, type);
265 if (include_nested_pools) { 284 if (include_nested_pools) {
266 ListValue* list = new ListValue(); 285 ListValue* list = new ListValue();
267 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", 286 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool",
268 "transport_socket_pool", 287 "transport_socket_pool",
269 false)); 288 false));
270 dict->Set("nested_pools", list); 289 dict->Set("nested_pools", list);
271 } 290 }
272 return dict; 291 return dict;
273 } 292 }
274 293
275 base::TimeDelta SOCKSClientSocketPool::ConnectionTimeout() const { 294 base::TimeDelta SOCKSClientSocketPool::ConnectionTimeout() const {
276 return base_.ConnectionTimeout(); 295 return base_.ConnectionTimeout();
277 } 296 }
278 297
279 ClientSocketPoolHistograms* SOCKSClientSocketPool::histograms() const { 298 ClientSocketPoolHistograms* SOCKSClientSocketPool::histograms() const {
280 return base_.histograms(); 299 return base_.histograms();
281 }; 300 };
282 301
302 bool SOCKSClientSocketPool::CloseOneIdleConnection() {
303 if (base_.CloseOneIdleSocket())
304 return true;
305 return base_.CloseOneIdleConnectionInLayeredPool();
306 }
307
283 } // namespace net 308 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socks_client_socket_pool.h ('k') | net/socket/ssl_client_socket_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698