| 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/transport_client_socket_pool.h" | 5 #include "net/socket/transport_client_socket_pool.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 ++iter) { | 42 ++iter) { |
| 43 if (iter->GetFamily() != ADDRESS_FAMILY_IPV6) | 43 if (iter->GetFamily() != ADDRESS_FAMILY_IPV6) |
| 44 return false; | 44 return false; |
| 45 } | 45 } |
| 46 return true; | 46 return true; |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 // This lock protects |g_last_connect_time|. | 51 // This lock protects |g_last_connect_time|. |
| 52 static base::LazyInstance<base::Lock>::Leaky | 52 static base::LazyInstance<base::Lock>::Leaky g_last_connect_time_lock = |
| 53 g_last_connect_time_lock = LAZY_INSTANCE_INITIALIZER; | 53 LAZY_INSTANCE_INITIALIZER; |
| 54 | 54 |
| 55 // |g_last_connect_time| has the last time a connect() call is made. | 55 // |g_last_connect_time| has the last time a connect() call is made. |
| 56 static base::LazyInstance<base::TimeTicks>::Leaky | 56 static base::LazyInstance<base::TimeTicks>::Leaky g_last_connect_time = |
| 57 g_last_connect_time = LAZY_INSTANCE_INITIALIZER; | 57 LAZY_INSTANCE_INITIALIZER; |
| 58 | 58 |
| 59 TransportSocketParams::TransportSocketParams( | 59 TransportSocketParams::TransportSocketParams( |
| 60 const HostPortPair& host_port_pair, | 60 const HostPortPair& host_port_pair, |
| 61 bool disable_resolver_cache, | 61 bool disable_resolver_cache, |
| 62 bool ignore_limits, | 62 bool ignore_limits, |
| 63 const OnHostResolutionCallback& host_resolution_callback) | 63 const OnHostResolutionCallback& host_resolution_callback) |
| 64 : destination_(host_port_pair), | 64 : destination_(host_port_pair), |
| 65 ignore_limits_(ignore_limits), | 65 ignore_limits_(ignore_limits), |
| 66 host_resolution_callback_(host_resolution_callback) { | 66 host_resolution_callback_(host_resolution_callback) { |
| 67 if (disable_resolver_cache) | 67 if (disable_resolver_cache) |
| 68 destination_.set_allow_cached_response(false); | 68 destination_.set_allow_cached_response(false); |
| 69 } | 69 } |
| 70 | 70 |
| 71 TransportSocketParams::~TransportSocketParams() {} | 71 TransportSocketParams::~TransportSocketParams() { |
| 72 } |
| 72 | 73 |
| 73 // TransportConnectJobs will time out after this many seconds. Note this is | 74 // TransportConnectJobs will time out after this many seconds. Note this is |
| 74 // the total time, including both host resolution and TCP connect() times. | 75 // the total time, including both host resolution and TCP connect() times. |
| 75 // | 76 // |
| 76 // TODO(eroman): The use of this constant needs to be re-evaluated. The time | 77 // TODO(eroman): The use of this constant needs to be re-evaluated. The time |
| 77 // needed for TCPClientSocketXXX::Connect() can be arbitrarily long, since | 78 // needed for TCPClientSocketXXX::Connect() can be arbitrarily long, since |
| 78 // the address list may contain many alternatives, and most of those may | 79 // the address list may contain many alternatives, and most of those may |
| 79 // timeout. Even worse, the per-connect timeout threshold varies greatly | 80 // timeout. Even worse, the per-connect timeout threshold varies greatly |
| 80 // between systems (anywhere from 20 seconds to 190 seconds). | 81 // between systems (anywhere from 20 seconds to 190 seconds). |
| 81 // See comment #12 at http://crbug.com/23364 for specifics. | 82 // See comment #12 at http://crbug.com/23364 for specifics. |
| 82 static const int kTransportConnectJobTimeoutInSeconds = 240; // 4 minutes. | 83 static const int kTransportConnectJobTimeoutInSeconds = 240; // 4 minutes. |
| 83 | 84 |
| 84 TransportConnectJob::TransportConnectJob( | 85 TransportConnectJob::TransportConnectJob( |
| 85 const std::string& group_name, | 86 const std::string& group_name, |
| 86 RequestPriority priority, | 87 RequestPriority priority, |
| 87 const scoped_refptr<TransportSocketParams>& params, | 88 const scoped_refptr<TransportSocketParams>& params, |
| 88 base::TimeDelta timeout_duration, | 89 base::TimeDelta timeout_duration, |
| 89 ClientSocketFactory* client_socket_factory, | 90 ClientSocketFactory* client_socket_factory, |
| 90 HostResolver* host_resolver, | 91 HostResolver* host_resolver, |
| 91 Delegate* delegate, | 92 Delegate* delegate, |
| 92 NetLog* net_log) | 93 NetLog* net_log) |
| 93 : ConnectJob(group_name, timeout_duration, priority, delegate, | 94 : ConnectJob(group_name, |
| 95 timeout_duration, |
| 96 priority, |
| 97 delegate, |
| 94 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), | 98 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), |
| 95 params_(params), | 99 params_(params), |
| 96 client_socket_factory_(client_socket_factory), | 100 client_socket_factory_(client_socket_factory), |
| 97 resolver_(host_resolver), | 101 resolver_(host_resolver), |
| 98 next_state_(STATE_NONE), | 102 next_state_(STATE_NONE), |
| 99 interval_between_connects_(CONNECT_INTERVAL_GT_20MS) { | 103 interval_between_connects_(CONNECT_INTERVAL_GT_20MS) { |
| 100 } | 104 } |
| 101 | 105 |
| 102 TransportConnectJob::~TransportConnectJob() { | 106 TransportConnectJob::~TransportConnectJob() { |
| 103 // We don't worry about cancelling the host resolution and TCP connect, since | 107 // We don't worry about cancelling the host resolution and TCP connect, since |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 if (interval <= 10) | 215 if (interval <= 10) |
| 212 interval_between_connects_ = CONNECT_INTERVAL_LE_10MS; | 216 interval_between_connects_ = CONNECT_INTERVAL_LE_10MS; |
| 213 else if (interval <= 20) | 217 else if (interval <= 20) |
| 214 interval_between_connects_ = CONNECT_INTERVAL_LE_20MS; | 218 interval_between_connects_ = CONNECT_INTERVAL_LE_20MS; |
| 215 else | 219 else |
| 216 interval_between_connects_ = CONNECT_INTERVAL_GT_20MS; | 220 interval_between_connects_ = CONNECT_INTERVAL_GT_20MS; |
| 217 } | 221 } |
| 218 | 222 |
| 219 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; | 223 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; |
| 220 transport_socket_ = client_socket_factory_->CreateTransportClientSocket( | 224 transport_socket_ = client_socket_factory_->CreateTransportClientSocket( |
| 221 addresses_, net_log().net_log(), net_log().source()); | 225 addresses_, net_log().net_log(), net_log().source()); |
| 222 int rv = transport_socket_->Connect( | 226 int rv = transport_socket_->Connect( |
| 223 base::Bind(&TransportConnectJob::OnIOComplete, base::Unretained(this))); | 227 base::Bind(&TransportConnectJob::OnIOComplete, base::Unretained(this))); |
| 224 if (rv == ERR_IO_PENDING && | 228 if (rv == ERR_IO_PENDING && |
| 225 addresses_.front().GetFamily() == ADDRESS_FAMILY_IPV6 && | 229 addresses_.front().GetFamily() == ADDRESS_FAMILY_IPV6 && |
| 226 !AddressListOnlyContainsIPv6(addresses_)) { | 230 !AddressListOnlyContainsIPv6(addresses_)) { |
| 227 fallback_timer_.Start(FROM_HERE, | 231 fallback_timer_.Start( |
| 232 FROM_HERE, |
| 228 base::TimeDelta::FromMilliseconds(kIPv6FallbackTimerInMs), | 233 base::TimeDelta::FromMilliseconds(kIPv6FallbackTimerInMs), |
| 229 this, &TransportConnectJob::DoIPv6FallbackTransportConnect); | 234 this, |
| 235 &TransportConnectJob::DoIPv6FallbackTransportConnect); |
| 230 } | 236 } |
| 231 return rv; | 237 return rv; |
| 232 } | 238 } |
| 233 | 239 |
| 234 int TransportConnectJob::DoTransportConnectComplete(int result) { | 240 int TransportConnectJob::DoTransportConnectComplete(int result) { |
| 235 if (result == OK) { | 241 if (result == OK) { |
| 236 bool is_ipv4 = addresses_.front().GetFamily() == ADDRESS_FAMILY_IPV4; | 242 bool is_ipv4 = addresses_.front().GetFamily() == ADDRESS_FAMILY_IPV4; |
| 237 DCHECK(!connect_timing_.connect_start.is_null()); | 243 DCHECK(!connect_timing_.connect_start.is_null()); |
| 238 DCHECK(!connect_timing_.dns_start.is_null()); | 244 DCHECK(!connect_timing_.dns_start.is_null()); |
| 239 base::TimeTicks now = base::TimeTicks::Now(); | 245 base::TimeTicks now = base::TimeTicks::Now(); |
| 240 base::TimeDelta total_duration = now - connect_timing_.dns_start; | 246 base::TimeDelta total_duration = now - connect_timing_.dns_start; |
| 241 UMA_HISTOGRAM_CUSTOM_TIMES( | 247 UMA_HISTOGRAM_CUSTOM_TIMES("Net.DNS_Resolution_And_TCP_Connection_Latency2", |
| 242 "Net.DNS_Resolution_And_TCP_Connection_Latency2", | 248 total_duration, |
| 243 total_duration, | 249 base::TimeDelta::FromMilliseconds(1), |
| 244 base::TimeDelta::FromMilliseconds(1), | 250 base::TimeDelta::FromMinutes(10), |
| 245 base::TimeDelta::FromMinutes(10), | 251 100); |
| 246 100); | |
| 247 | 252 |
| 248 base::TimeDelta connect_duration = now - connect_timing_.connect_start; | 253 base::TimeDelta connect_duration = now - connect_timing_.connect_start; |
| 249 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TCP_Connection_Latency", | 254 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TCP_Connection_Latency", |
| 250 connect_duration, | 255 connect_duration, |
| 251 base::TimeDelta::FromMilliseconds(1), | 256 base::TimeDelta::FromMilliseconds(1), |
| 252 base::TimeDelta::FromMinutes(10), | 257 base::TimeDelta::FromMinutes(10), |
| 253 100); | 258 100); |
| 254 | 259 |
| 255 switch (interval_between_connects_) { | 260 switch (interval_between_connects_) { |
| 256 case CONNECT_INTERVAL_LE_10MS: | 261 case CONNECT_INTERVAL_LE_10MS: |
| 257 UMA_HISTOGRAM_CUSTOM_TIMES( | 262 UMA_HISTOGRAM_CUSTOM_TIMES( |
| 258 "Net.TCP_Connection_Latency_Interval_LessThanOrEqual_10ms", | 263 "Net.TCP_Connection_Latency_Interval_LessThanOrEqual_10ms", |
| 259 connect_duration, | 264 connect_duration, |
| 260 base::TimeDelta::FromMilliseconds(1), | 265 base::TimeDelta::FromMilliseconds(1), |
| 261 base::TimeDelta::FromMinutes(10), | 266 base::TimeDelta::FromMinutes(10), |
| 262 100); | 267 100); |
| 263 break; | 268 break; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 DCHECK(!fallback_transport_socket_.get()); | 330 DCHECK(!fallback_transport_socket_.get()); |
| 326 DCHECK(!fallback_addresses_.get()); | 331 DCHECK(!fallback_addresses_.get()); |
| 327 | 332 |
| 328 fallback_addresses_.reset(new AddressList(addresses_)); | 333 fallback_addresses_.reset(new AddressList(addresses_)); |
| 329 MakeAddressListStartWithIPv4(fallback_addresses_.get()); | 334 MakeAddressListStartWithIPv4(fallback_addresses_.get()); |
| 330 fallback_transport_socket_ = | 335 fallback_transport_socket_ = |
| 331 client_socket_factory_->CreateTransportClientSocket( | 336 client_socket_factory_->CreateTransportClientSocket( |
| 332 *fallback_addresses_, net_log().net_log(), net_log().source()); | 337 *fallback_addresses_, net_log().net_log(), net_log().source()); |
| 333 fallback_connect_start_time_ = base::TimeTicks::Now(); | 338 fallback_connect_start_time_ = base::TimeTicks::Now(); |
| 334 int rv = fallback_transport_socket_->Connect( | 339 int rv = fallback_transport_socket_->Connect( |
| 335 base::Bind( | 340 base::Bind(&TransportConnectJob::DoIPv6FallbackTransportConnectComplete, |
| 336 &TransportConnectJob::DoIPv6FallbackTransportConnectComplete, | 341 base::Unretained(this))); |
| 337 base::Unretained(this))); | |
| 338 if (rv != ERR_IO_PENDING) | 342 if (rv != ERR_IO_PENDING) |
| 339 DoIPv6FallbackTransportConnectComplete(rv); | 343 DoIPv6FallbackTransportConnectComplete(rv); |
| 340 } | 344 } |
| 341 | 345 |
| 342 void TransportConnectJob::DoIPv6FallbackTransportConnectComplete(int result) { | 346 void TransportConnectJob::DoIPv6FallbackTransportConnectComplete(int result) { |
| 343 // This should only happen when we're waiting for the main connect to succeed. | 347 // This should only happen when we're waiting for the main connect to succeed. |
| 344 if (next_state_ != STATE_TRANSPORT_CONNECT_COMPLETE) { | 348 if (next_state_ != STATE_TRANSPORT_CONNECT_COMPLETE) { |
| 345 NOTREACHED(); | 349 NOTREACHED(); |
| 346 return; | 350 return; |
| 347 } | 351 } |
| 348 | 352 |
| 349 DCHECK_NE(ERR_IO_PENDING, result); | 353 DCHECK_NE(ERR_IO_PENDING, result); |
| 350 DCHECK(fallback_transport_socket_.get()); | 354 DCHECK(fallback_transport_socket_.get()); |
| 351 DCHECK(fallback_addresses_.get()); | 355 DCHECK(fallback_addresses_.get()); |
| 352 | 356 |
| 353 if (result == OK) { | 357 if (result == OK) { |
| 354 DCHECK(!fallback_connect_start_time_.is_null()); | 358 DCHECK(!fallback_connect_start_time_.is_null()); |
| 355 DCHECK(!connect_timing_.dns_start.is_null()); | 359 DCHECK(!connect_timing_.dns_start.is_null()); |
| 356 base::TimeTicks now = base::TimeTicks::Now(); | 360 base::TimeTicks now = base::TimeTicks::Now(); |
| 357 base::TimeDelta total_duration = now - connect_timing_.dns_start; | 361 base::TimeDelta total_duration = now - connect_timing_.dns_start; |
| 358 UMA_HISTOGRAM_CUSTOM_TIMES( | 362 UMA_HISTOGRAM_CUSTOM_TIMES("Net.DNS_Resolution_And_TCP_Connection_Latency2", |
| 359 "Net.DNS_Resolution_And_TCP_Connection_Latency2", | 363 total_duration, |
| 360 total_duration, | 364 base::TimeDelta::FromMilliseconds(1), |
| 361 base::TimeDelta::FromMilliseconds(1), | 365 base::TimeDelta::FromMinutes(10), |
| 362 base::TimeDelta::FromMinutes(10), | 366 100); |
| 363 100); | |
| 364 | 367 |
| 365 base::TimeDelta connect_duration = now - fallback_connect_start_time_; | 368 base::TimeDelta connect_duration = now - fallback_connect_start_time_; |
| 366 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TCP_Connection_Latency", | 369 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TCP_Connection_Latency", |
| 367 connect_duration, | 370 connect_duration, |
| 368 base::TimeDelta::FromMilliseconds(1), | 371 base::TimeDelta::FromMilliseconds(1), |
| 369 base::TimeDelta::FromMinutes(10), | 372 base::TimeDelta::FromMinutes(10), |
| 370 100); | 373 100); |
| 371 | 374 |
| 372 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TCP_Connection_Latency_IPv4_Wins_Race", | 375 UMA_HISTOGRAM_CUSTOM_TIMES("Net.TCP_Connection_Latency_IPv4_Wins_Race", |
| 373 connect_duration, | 376 connect_duration, |
| 374 base::TimeDelta::FromMilliseconds(1), | 377 base::TimeDelta::FromMilliseconds(1), |
| 375 base::TimeDelta::FromMinutes(10), | 378 base::TimeDelta::FromMinutes(10), |
| 376 100); | 379 100); |
| 377 SetSocket(fallback_transport_socket_.Pass()); | 380 SetSocket(fallback_transport_socket_.Pass()); |
| 378 next_state_ = STATE_NONE; | 381 next_state_ = STATE_NONE; |
| 379 transport_socket_.reset(); | 382 transport_socket_.reset(); |
| 380 } else { | 383 } else { |
| 381 // Be a bit paranoid and kill off the fallback members to prevent reuse. | 384 // Be a bit paranoid and kill off the fallback members to prevent reuse. |
| 382 fallback_transport_socket_.reset(); | 385 fallback_transport_socket_.reset(); |
| 383 fallback_addresses_.reset(); | 386 fallback_addresses_.reset(); |
| 384 } | 387 } |
| 385 NotifyDelegateOfCompletion(result); // Deletes |this| | 388 NotifyDelegateOfCompletion(result); // Deletes |this| |
| 386 } | 389 } |
| 387 | 390 |
| 388 int TransportConnectJob::ConnectInternal() { | 391 int TransportConnectJob::ConnectInternal() { |
| 389 next_state_ = STATE_RESOLVE_HOST; | 392 next_state_ = STATE_RESOLVE_HOST; |
| 390 return DoLoop(OK); | 393 return DoLoop(OK); |
| 391 } | 394 } |
| 392 | 395 |
| 393 scoped_ptr<ConnectJob> | 396 scoped_ptr<ConnectJob> |
| 394 TransportClientSocketPool::TransportConnectJobFactory::NewConnectJob( | 397 TransportClientSocketPool::TransportConnectJobFactory::NewConnectJob( |
| 395 const std::string& group_name, | 398 const std::string& group_name, |
| 396 const PoolBase::Request& request, | 399 const PoolBase::Request& request, |
| 397 ConnectJob::Delegate* delegate) const { | 400 ConnectJob::Delegate* delegate) const { |
| 398 return scoped_ptr<ConnectJob>( | 401 return scoped_ptr<ConnectJob>(new TransportConnectJob(group_name, |
| 399 new TransportConnectJob(group_name, | 402 request.priority(), |
| 400 request.priority(), | 403 request.params(), |
| 401 request.params(), | 404 ConnectionTimeout(), |
| 402 ConnectionTimeout(), | 405 client_socket_factory_, |
| 403 client_socket_factory_, | 406 host_resolver_, |
| 404 host_resolver_, | 407 delegate, |
| 405 delegate, | 408 net_log_)); |
| 406 net_log_)); | |
| 407 } | 409 } |
| 408 | 410 |
| 409 base::TimeDelta | 411 base::TimeDelta |
| 410 TransportClientSocketPool::TransportConnectJobFactory::ConnectionTimeout() | 412 TransportClientSocketPool::TransportConnectJobFactory::ConnectionTimeout() |
| 411 const { | 413 const { |
| 412 return base::TimeDelta::FromSeconds(kTransportConnectJobTimeoutInSeconds); | 414 return base::TimeDelta::FromSeconds(kTransportConnectJobTimeoutInSeconds); |
| 413 } | 415 } |
| 414 | 416 |
| 415 TransportClientSocketPool::TransportClientSocketPool( | 417 TransportClientSocketPool::TransportClientSocketPool( |
| 416 int max_sockets, | 418 int max_sockets, |
| 417 int max_sockets_per_group, | 419 int max_sockets_per_group, |
| 418 ClientSocketPoolHistograms* histograms, | 420 ClientSocketPoolHistograms* histograms, |
| 419 HostResolver* host_resolver, | 421 HostResolver* host_resolver, |
| 420 ClientSocketFactory* client_socket_factory, | 422 ClientSocketFactory* client_socket_factory, |
| 421 NetLog* net_log) | 423 NetLog* net_log) |
| 422 : base_(NULL, max_sockets, max_sockets_per_group, histograms, | 424 : base_(NULL, |
| 425 max_sockets, |
| 426 max_sockets_per_group, |
| 427 histograms, |
| 423 ClientSocketPool::unused_idle_socket_timeout(), | 428 ClientSocketPool::unused_idle_socket_timeout(), |
| 424 ClientSocketPool::used_idle_socket_timeout(), | 429 ClientSocketPool::used_idle_socket_timeout(), |
| 425 new TransportConnectJobFactory(client_socket_factory, | 430 new TransportConnectJobFactory(client_socket_factory, |
| 426 host_resolver, net_log)) { | 431 host_resolver, |
| 432 net_log)) { |
| 427 base_.EnableConnectBackupJobs(); | 433 base_.EnableConnectBackupJobs(); |
| 428 } | 434 } |
| 429 | 435 |
| 430 TransportClientSocketPool::~TransportClientSocketPool() {} | 436 TransportClientSocketPool::~TransportClientSocketPool() { |
| 437 } |
| 431 | 438 |
| 432 int TransportClientSocketPool::RequestSocket( | 439 int TransportClientSocketPool::RequestSocket(const std::string& group_name, |
| 433 const std::string& group_name, | 440 const void* params, |
| 434 const void* params, | 441 RequestPriority priority, |
| 435 RequestPriority priority, | 442 ClientSocketHandle* handle, |
| 436 ClientSocketHandle* handle, | 443 const CompletionCallback& callback, |
| 437 const CompletionCallback& callback, | 444 const BoundNetLog& net_log) { |
| 438 const BoundNetLog& net_log) { | |
| 439 const scoped_refptr<TransportSocketParams>* casted_params = | 445 const scoped_refptr<TransportSocketParams>* casted_params = |
| 440 static_cast<const scoped_refptr<TransportSocketParams>*>(params); | 446 static_cast<const scoped_refptr<TransportSocketParams>*>(params); |
| 441 | 447 |
| 442 if (net_log.IsLogging()) { | 448 if (net_log.IsLogging()) { |
| 443 // TODO(eroman): Split out the host and port parameters. | 449 // TODO(eroman): Split out the host and port parameters. |
| 444 net_log.AddEvent( | 450 net_log.AddEvent( |
| 445 NetLog::TYPE_TCP_CLIENT_SOCKET_POOL_REQUESTED_SOCKET, | 451 NetLog::TYPE_TCP_CLIENT_SOCKET_POOL_REQUESTED_SOCKET, |
| 446 CreateNetLogHostPortPairCallback( | 452 CreateNetLogHostPortPairCallback( |
| 447 &casted_params->get()->destination().host_port_pair())); | 453 &casted_params->get()->destination().host_port_pair())); |
| 448 } | 454 } |
| 449 | 455 |
| 450 return base_.RequestSocket(group_name, *casted_params, priority, handle, | 456 return base_.RequestSocket( |
| 451 callback, net_log); | 457 group_name, *casted_params, priority, handle, callback, net_log); |
| 452 } | 458 } |
| 453 | 459 |
| 454 void TransportClientSocketPool::RequestSockets( | 460 void TransportClientSocketPool::RequestSockets(const std::string& group_name, |
| 455 const std::string& group_name, | 461 const void* params, |
| 456 const void* params, | 462 int num_sockets, |
| 457 int num_sockets, | 463 const BoundNetLog& net_log) { |
| 458 const BoundNetLog& net_log) { | |
| 459 const scoped_refptr<TransportSocketParams>* casted_params = | 464 const scoped_refptr<TransportSocketParams>* casted_params = |
| 460 static_cast<const scoped_refptr<TransportSocketParams>*>(params); | 465 static_cast<const scoped_refptr<TransportSocketParams>*>(params); |
| 461 | 466 |
| 462 if (net_log.IsLogging()) { | 467 if (net_log.IsLogging()) { |
| 463 // TODO(eroman): Split out the host and port parameters. | 468 // TODO(eroman): Split out the host and port parameters. |
| 464 net_log.AddEvent( | 469 net_log.AddEvent( |
| 465 NetLog::TYPE_TCP_CLIENT_SOCKET_POOL_REQUESTED_SOCKETS, | 470 NetLog::TYPE_TCP_CLIENT_SOCKET_POOL_REQUESTED_SOCKETS, |
| 466 CreateNetLogHostPortPairCallback( | 471 CreateNetLogHostPortPairCallback( |
| 467 &casted_params->get()->destination().host_port_pair())); | 472 &casted_params->get()->destination().host_port_pair())); |
| 468 } | 473 } |
| 469 | 474 |
| 470 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log); | 475 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log); |
| 471 } | 476 } |
| 472 | 477 |
| 473 void TransportClientSocketPool::CancelRequest( | 478 void TransportClientSocketPool::CancelRequest(const std::string& group_name, |
| 474 const std::string& group_name, | 479 ClientSocketHandle* handle) { |
| 475 ClientSocketHandle* handle) { | |
| 476 base_.CancelRequest(group_name, handle); | 480 base_.CancelRequest(group_name, handle); |
| 477 } | 481 } |
| 478 | 482 |
| 479 void TransportClientSocketPool::ReleaseSocket( | 483 void TransportClientSocketPool::ReleaseSocket(const std::string& group_name, |
| 480 const std::string& group_name, | 484 scoped_ptr<StreamSocket> socket, |
| 481 scoped_ptr<StreamSocket> socket, | 485 int id) { |
| 482 int id) { | |
| 483 base_.ReleaseSocket(group_name, socket.Pass(), id); | 486 base_.ReleaseSocket(group_name, socket.Pass(), id); |
| 484 } | 487 } |
| 485 | 488 |
| 486 void TransportClientSocketPool::FlushWithError(int error) { | 489 void TransportClientSocketPool::FlushWithError(int error) { |
| 487 base_.FlushWithError(error); | 490 base_.FlushWithError(error); |
| 488 } | 491 } |
| 489 | 492 |
| 490 void TransportClientSocketPool::CloseIdleSockets() { | 493 void TransportClientSocketPool::CloseIdleSockets() { |
| 491 base_.CloseIdleSockets(); | 494 base_.CloseIdleSockets(); |
| 492 } | 495 } |
| 493 | 496 |
| 494 int TransportClientSocketPool::IdleSocketCount() const { | 497 int TransportClientSocketPool::IdleSocketCount() const { |
| 495 return base_.idle_socket_count(); | 498 return base_.idle_socket_count(); |
| 496 } | 499 } |
| 497 | 500 |
| 498 int TransportClientSocketPool::IdleSocketCountInGroup( | 501 int TransportClientSocketPool::IdleSocketCountInGroup( |
| 499 const std::string& group_name) const { | 502 const std::string& group_name) const { |
| 500 return base_.IdleSocketCountInGroup(group_name); | 503 return base_.IdleSocketCountInGroup(group_name); |
| 501 } | 504 } |
| 502 | 505 |
| 503 LoadState TransportClientSocketPool::GetLoadState( | 506 LoadState TransportClientSocketPool::GetLoadState( |
| 504 const std::string& group_name, const ClientSocketHandle* handle) const { | 507 const std::string& group_name, |
| 508 const ClientSocketHandle* handle) const { |
| 505 return base_.GetLoadState(group_name, handle); | 509 return base_.GetLoadState(group_name, handle); |
| 506 } | 510 } |
| 507 | 511 |
| 508 base::DictionaryValue* TransportClientSocketPool::GetInfoAsValue( | 512 base::DictionaryValue* TransportClientSocketPool::GetInfoAsValue( |
| 509 const std::string& name, | 513 const std::string& name, |
| 510 const std::string& type, | 514 const std::string& type, |
| 511 bool include_nested_pools) const { | 515 bool include_nested_pools) const { |
| 512 return base_.GetInfoAsValue(name, type); | 516 return base_.GetInfoAsValue(name, type); |
| 513 } | 517 } |
| 514 | 518 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 528 HigherLayeredPool* higher_pool) { | 532 HigherLayeredPool* higher_pool) { |
| 529 base_.AddHigherLayeredPool(higher_pool); | 533 base_.AddHigherLayeredPool(higher_pool); |
| 530 } | 534 } |
| 531 | 535 |
| 532 void TransportClientSocketPool::RemoveHigherLayeredPool( | 536 void TransportClientSocketPool::RemoveHigherLayeredPool( |
| 533 HigherLayeredPool* higher_pool) { | 537 HigherLayeredPool* higher_pool) { |
| 534 base_.RemoveHigherLayeredPool(higher_pool); | 538 base_.RemoveHigherLayeredPool(higher_pool); |
| 535 } | 539 } |
| 536 | 540 |
| 537 } // namespace net | 541 } // namespace net |
| OLD | NEW |