| 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/http/http_proxy_client_socket_pool.h" | 5 #include "net/http/http_proxy_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/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 | 58 |
| 59 const HostResolver::RequestInfo& HttpProxySocketParams::destination() const { | 59 const HostResolver::RequestInfo& HttpProxySocketParams::destination() const { |
| 60 if (transport_params_.get() == NULL) { | 60 if (transport_params_.get() == NULL) { |
| 61 return ssl_params_->GetDirectConnectionParams()->destination(); | 61 return ssl_params_->GetDirectConnectionParams()->destination(); |
| 62 } else { | 62 } else { |
| 63 return transport_params_->destination(); | 63 return transport_params_->destination(); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 HttpProxySocketParams::~HttpProxySocketParams() {} | 67 HttpProxySocketParams::~HttpProxySocketParams() { |
| 68 } |
| 68 | 69 |
| 69 // HttpProxyConnectJobs will time out after this many seconds. Note this is on | 70 // HttpProxyConnectJobs will time out after this many seconds. Note this is on |
| 70 // top of the timeout for the transport socket. | 71 // top of the timeout for the transport socket. |
| 71 #if (defined(OS_ANDROID) || defined(OS_IOS)) && defined(SPDY_PROXY_AUTH_ORIGIN) | 72 #if (defined(OS_ANDROID) || defined(OS_IOS)) && defined(SPDY_PROXY_AUTH_ORIGIN) |
| 72 static const int kHttpProxyConnectJobTimeoutInSeconds = 10; | 73 static const int kHttpProxyConnectJobTimeoutInSeconds = 10; |
| 73 #else | 74 #else |
| 74 static const int kHttpProxyConnectJobTimeoutInSeconds = 30; | 75 static const int kHttpProxyConnectJobTimeoutInSeconds = 30; |
| 75 #endif | 76 #endif |
| 76 | 77 |
| 77 | |
| 78 HttpProxyConnectJob::HttpProxyConnectJob( | 78 HttpProxyConnectJob::HttpProxyConnectJob( |
| 79 const std::string& group_name, | 79 const std::string& group_name, |
| 80 RequestPriority priority, | 80 RequestPriority priority, |
| 81 const scoped_refptr<HttpProxySocketParams>& params, | 81 const scoped_refptr<HttpProxySocketParams>& params, |
| 82 const base::TimeDelta& timeout_duration, | 82 const base::TimeDelta& timeout_duration, |
| 83 TransportClientSocketPool* transport_pool, | 83 TransportClientSocketPool* transport_pool, |
| 84 SSLClientSocketPool* ssl_pool, | 84 SSLClientSocketPool* ssl_pool, |
| 85 HostResolver* host_resolver, | 85 HostResolver* host_resolver, |
| 86 Delegate* delegate, | 86 Delegate* delegate, |
| 87 NetLog* net_log) | 87 NetLog* net_log) |
| 88 : ConnectJob(group_name, timeout_duration, priority, delegate, | 88 : ConnectJob(group_name, |
| 89 timeout_duration, |
| 90 priority, |
| 91 delegate, |
| 89 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), | 92 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), |
| 90 weak_ptr_factory_(this), | 93 weak_ptr_factory_(this), |
| 91 params_(params), | 94 params_(params), |
| 92 transport_pool_(transport_pool), | 95 transport_pool_(transport_pool), |
| 93 ssl_pool_(ssl_pool), | 96 ssl_pool_(ssl_pool), |
| 94 resolver_(host_resolver), | 97 resolver_(host_resolver), |
| 95 callback_(base::Bind(&HttpProxyConnectJob::OnIOComplete, | 98 callback_(base::Bind(&HttpProxyConnectJob::OnIOComplete, |
| 96 weak_ptr_factory_.GetWeakPtr())), | 99 weak_ptr_factory_.GetWeakPtr())), |
| 97 using_spdy_(false), | 100 using_spdy_(false), |
| 98 protocol_negotiated_(kProtoUnknown) { | 101 protocol_negotiated_(kProtoUnknown) { |
| 99 } | 102 } |
| 100 | 103 |
| 101 HttpProxyConnectJob::~HttpProxyConnectJob() {} | 104 HttpProxyConnectJob::~HttpProxyConnectJob() { |
| 105 } |
| 102 | 106 |
| 103 LoadState HttpProxyConnectJob::GetLoadState() const { | 107 LoadState HttpProxyConnectJob::GetLoadState() const { |
| 104 switch (next_state_) { | 108 switch (next_state_) { |
| 105 case STATE_TCP_CONNECT: | 109 case STATE_TCP_CONNECT: |
| 106 case STATE_TCP_CONNECT_COMPLETE: | 110 case STATE_TCP_CONNECT_COMPLETE: |
| 107 case STATE_SSL_CONNECT: | 111 case STATE_SSL_CONNECT: |
| 108 case STATE_SSL_CONNECT_COMPLETE: | 112 case STATE_SSL_CONNECT_COMPLETE: |
| 109 return transport_socket_handle_->GetLoadState(); | 113 return transport_socket_handle_->GetLoadState(); |
| 110 case STATE_HTTP_PROXY_CONNECT: | 114 case STATE_HTTP_PROXY_CONNECT: |
| 111 case STATE_HTTP_PROXY_CONNECT_COMPLETE: | 115 case STATE_HTTP_PROXY_CONNECT_COMPLETE: |
| 112 case STATE_SPDY_PROXY_CREATE_STREAM: | 116 case STATE_SPDY_PROXY_CREATE_STREAM: |
| 113 case STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE: | 117 case STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE: |
| 114 return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL; | 118 return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL; |
| 115 default: | 119 default: |
| 116 NOTREACHED(); | 120 NOTREACHED(); |
| 117 return LOAD_STATE_IDLE; | 121 return LOAD_STATE_IDLE; |
| 118 } | 122 } |
| 119 } | 123 } |
| 120 | 124 |
| 121 void HttpProxyConnectJob::GetAdditionalErrorState(ClientSocketHandle * handle) { | 125 void HttpProxyConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) { |
| 122 if (error_response_info_.cert_request_info.get()) { | 126 if (error_response_info_.cert_request_info.get()) { |
| 123 handle->set_ssl_error_response_info(error_response_info_); | 127 handle->set_ssl_error_response_info(error_response_info_); |
| 124 handle->set_is_ssl_error(true); | 128 handle->set_is_ssl_error(true); |
| 125 } | 129 } |
| 126 } | 130 } |
| 127 | 131 |
| 128 void HttpProxyConnectJob::OnIOComplete(int result) { | 132 void HttpProxyConnectJob::OnIOComplete(int result) { |
| 129 int rv = DoLoop(result); | 133 int rv = DoLoop(result); |
| 130 if (rv != ERR_IO_PENDING) | 134 if (rv != ERR_IO_PENDING) |
| 131 NotifyDelegateOfCompletion(rv); // Deletes |this| | 135 NotifyDelegateOfCompletion(rv); // Deletes |this| |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 net_log()); | 192 net_log()); |
| 189 } | 193 } |
| 190 | 194 |
| 191 int HttpProxyConnectJob::DoTransportConnectComplete(int result) { | 195 int HttpProxyConnectJob::DoTransportConnectComplete(int result) { |
| 192 if (result != OK) | 196 if (result != OK) |
| 193 return ERR_PROXY_CONNECTION_FAILED; | 197 return ERR_PROXY_CONNECTION_FAILED; |
| 194 | 198 |
| 195 // Reset the timer to just the length of time allowed for HttpProxy handshake | 199 // Reset the timer to just the length of time allowed for HttpProxy handshake |
| 196 // so that a fast TCP connection plus a slow HttpProxy failure doesn't take | 200 // so that a fast TCP connection plus a slow HttpProxy failure doesn't take |
| 197 // longer to timeout than it should. | 201 // longer to timeout than it should. |
| 198 ResetTimer(base::TimeDelta::FromSeconds( | 202 ResetTimer( |
| 199 kHttpProxyConnectJobTimeoutInSeconds)); | 203 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds)); |
| 200 | 204 |
| 201 next_state_ = STATE_HTTP_PROXY_CONNECT; | 205 next_state_ = STATE_HTTP_PROXY_CONNECT; |
| 202 return result; | 206 return result; |
| 203 } | 207 } |
| 204 | 208 |
| 205 int HttpProxyConnectJob::DoSSLConnect() { | 209 int HttpProxyConnectJob::DoSSLConnect() { |
| 206 if (params_->tunnel()) { | 210 if (params_->tunnel()) { |
| 207 SpdySessionKey key(params_->destination().host_port_pair(), | 211 SpdySessionKey key(params_->destination().host_port_pair(), |
| 208 ProxyServer::Direct(), | 212 ProxyServer::Direct(), |
| 209 PRIVACY_MODE_DISABLED); | 213 PRIVACY_MODE_DISABLED); |
| 210 if (params_->spdy_session_pool()->FindAvailableSession(key, net_log())) { | 214 if (params_->spdy_session_pool()->FindAvailableSession(key, net_log())) { |
| 211 using_spdy_ = true; | 215 using_spdy_ = true; |
| 212 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM; | 216 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM; |
| 213 return OK; | 217 return OK; |
| 214 } | 218 } |
| 215 } | 219 } |
| 216 next_state_ = STATE_SSL_CONNECT_COMPLETE; | 220 next_state_ = STATE_SSL_CONNECT_COMPLETE; |
| 217 transport_socket_handle_.reset(new ClientSocketHandle()); | 221 transport_socket_handle_.reset(new ClientSocketHandle()); |
| 218 return transport_socket_handle_->Init( | 222 return transport_socket_handle_->Init(group_name(), |
| 219 group_name(), params_->ssl_params(), priority(), callback_, | 223 params_->ssl_params(), |
| 220 ssl_pool_, net_log()); | 224 priority(), |
| 225 callback_, |
| 226 ssl_pool_, |
| 227 net_log()); |
| 221 } | 228 } |
| 222 | 229 |
| 223 int HttpProxyConnectJob::DoSSLConnectComplete(int result) { | 230 int HttpProxyConnectJob::DoSSLConnectComplete(int result) { |
| 224 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { | 231 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { |
| 225 error_response_info_ = transport_socket_handle_->ssl_error_response_info(); | 232 error_response_info_ = transport_socket_handle_->ssl_error_response_info(); |
| 226 DCHECK(error_response_info_.cert_request_info.get()); | 233 DCHECK(error_response_info_.cert_request_info.get()); |
| 227 error_response_info_.cert_request_info->is_proxy = true; | 234 error_response_info_.cert_request_info->is_proxy = true; |
| 228 return result; | 235 return result; |
| 229 } | 236 } |
| 230 if (IsCertificateError(result)) { | 237 if (IsCertificateError(result)) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 244 } | 251 } |
| 245 | 252 |
| 246 SSLClientSocket* ssl = | 253 SSLClientSocket* ssl = |
| 247 static_cast<SSLClientSocket*>(transport_socket_handle_->socket()); | 254 static_cast<SSLClientSocket*>(transport_socket_handle_->socket()); |
| 248 using_spdy_ = ssl->was_spdy_negotiated(); | 255 using_spdy_ = ssl->was_spdy_negotiated(); |
| 249 protocol_negotiated_ = ssl->GetNegotiatedProtocol(); | 256 protocol_negotiated_ = ssl->GetNegotiatedProtocol(); |
| 250 | 257 |
| 251 // Reset the timer to just the length of time allowed for HttpProxy handshake | 258 // Reset the timer to just the length of time allowed for HttpProxy handshake |
| 252 // so that a fast SSL connection plus a slow HttpProxy failure doesn't take | 259 // so that a fast SSL connection plus a slow HttpProxy failure doesn't take |
| 253 // longer to timeout than it should. | 260 // longer to timeout than it should. |
| 254 ResetTimer(base::TimeDelta::FromSeconds( | 261 ResetTimer( |
| 255 kHttpProxyConnectJobTimeoutInSeconds)); | 262 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds)); |
| 256 // TODO(rch): If we ever decide to implement a "trusted" SPDY proxy | 263 // TODO(rch): If we ever decide to implement a "trusted" SPDY proxy |
| 257 // (one that we speak SPDY over SSL to, but to which we send HTTPS | 264 // (one that we speak SPDY over SSL to, but to which we send HTTPS |
| 258 // request directly instead of through CONNECT tunnels, then we | 265 // request directly instead of through CONNECT tunnels, then we |
| 259 // need to add a predicate to this if statement so we fall through | 266 // need to add a predicate to this if statement so we fall through |
| 260 // to the else case. (HttpProxyClientSocket currently acts as | 267 // to the else case. (HttpProxyClientSocket currently acts as |
| 261 // a "trusted" SPDY proxy). | 268 // a "trusted" SPDY proxy). |
| 262 if (using_spdy_ && params_->tunnel()) { | 269 if (using_spdy_ && params_->tunnel()) { |
| 263 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM; | 270 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM; |
| 264 } else { | 271 } else { |
| 265 next_state_ = STATE_HTTP_PROXY_CONNECT; | 272 next_state_ = STATE_HTTP_PROXY_CONNECT; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 spdy_pool->FindAvailableSession(key, net_log()); | 315 spdy_pool->FindAvailableSession(key, net_log()); |
| 309 // It's possible that a session to the proxy has recently been created | 316 // It's possible that a session to the proxy has recently been created |
| 310 if (spdy_session) { | 317 if (spdy_session) { |
| 311 if (transport_socket_handle_.get()) { | 318 if (transport_socket_handle_.get()) { |
| 312 if (transport_socket_handle_->socket()) | 319 if (transport_socket_handle_->socket()) |
| 313 transport_socket_handle_->socket()->Disconnect(); | 320 transport_socket_handle_->socket()->Disconnect(); |
| 314 transport_socket_handle_->Reset(); | 321 transport_socket_handle_->Reset(); |
| 315 } | 322 } |
| 316 } else { | 323 } else { |
| 317 // Create a session direct to the proxy itself | 324 // Create a session direct to the proxy itself |
| 318 spdy_session = | 325 spdy_session = spdy_pool->CreateAvailableSessionFromSocket( |
| 319 spdy_pool->CreateAvailableSessionFromSocket( | 326 key, |
| 320 key, transport_socket_handle_.Pass(), | 327 transport_socket_handle_.Pass(), |
| 321 net_log(), OK, /*using_ssl_*/ true); | 328 net_log(), |
| 329 OK, |
| 330 /*using_ssl_*/ true); |
| 322 DCHECK(spdy_session); | 331 DCHECK(spdy_session); |
| 323 } | 332 } |
| 324 | 333 |
| 325 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE; | 334 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE; |
| 326 return spdy_stream_request_.StartRequest(SPDY_BIDIRECTIONAL_STREAM, | 335 return spdy_stream_request_.StartRequest(SPDY_BIDIRECTIONAL_STREAM, |
| 327 spdy_session, | 336 spdy_session, |
| 328 params_->request_url(), | 337 params_->request_url(), |
| 329 priority(), | 338 priority(), |
| 330 spdy_session->net_log(), | 339 spdy_session->net_log(), |
| 331 callback_); | 340 callback_); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 353 | 362 |
| 354 int HttpProxyConnectJob::ConnectInternal() { | 363 int HttpProxyConnectJob::ConnectInternal() { |
| 355 if (params_->transport_params().get()) { | 364 if (params_->transport_params().get()) { |
| 356 next_state_ = STATE_TCP_CONNECT; | 365 next_state_ = STATE_TCP_CONNECT; |
| 357 } else { | 366 } else { |
| 358 next_state_ = STATE_SSL_CONNECT; | 367 next_state_ = STATE_SSL_CONNECT; |
| 359 } | 368 } |
| 360 return DoLoop(OK); | 369 return DoLoop(OK); |
| 361 } | 370 } |
| 362 | 371 |
| 363 HttpProxyClientSocketPool:: | 372 HttpProxyClientSocketPool::HttpProxyConnectJobFactory:: |
| 364 HttpProxyConnectJobFactory::HttpProxyConnectJobFactory( | 373 HttpProxyConnectJobFactory(TransportClientSocketPool* transport_pool, |
| 365 TransportClientSocketPool* transport_pool, | 374 SSLClientSocketPool* ssl_pool, |
| 366 SSLClientSocketPool* ssl_pool, | 375 HostResolver* host_resolver, |
| 367 HostResolver* host_resolver, | 376 NetLog* net_log) |
| 368 NetLog* net_log) | |
| 369 : transport_pool_(transport_pool), | 377 : transport_pool_(transport_pool), |
| 370 ssl_pool_(ssl_pool), | 378 ssl_pool_(ssl_pool), |
| 371 host_resolver_(host_resolver), | 379 host_resolver_(host_resolver), |
| 372 net_log_(net_log) { | 380 net_log_(net_log) { |
| 373 base::TimeDelta max_pool_timeout = base::TimeDelta(); | 381 base::TimeDelta max_pool_timeout = base::TimeDelta(); |
| 374 | 382 |
| 375 #if (defined(OS_ANDROID) || defined(OS_IOS)) && defined(SPDY_PROXY_AUTH_ORIGIN) | 383 #if (defined(OS_ANDROID) || defined(OS_IOS)) && defined(SPDY_PROXY_AUTH_ORIGIN) |
| 376 #else | 384 #else |
| 377 if (transport_pool_) | 385 if (transport_pool_) |
| 378 max_pool_timeout = transport_pool_->ConnectionTimeout(); | 386 max_pool_timeout = transport_pool_->ConnectionTimeout(); |
| 379 if (ssl_pool_) | 387 if (ssl_pool_) |
| 380 max_pool_timeout = std::max(max_pool_timeout, | 388 max_pool_timeout = |
| 381 ssl_pool_->ConnectionTimeout()); | 389 std::max(max_pool_timeout, ssl_pool_->ConnectionTimeout()); |
| 382 #endif | 390 #endif |
| 383 timeout_ = max_pool_timeout + | 391 timeout_ = max_pool_timeout + |
| 384 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds); | 392 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds); |
| 385 } | 393 } |
| 386 | 394 |
| 387 | |
| 388 scoped_ptr<ConnectJob> | 395 scoped_ptr<ConnectJob> |
| 389 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( | 396 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( |
| 390 const std::string& group_name, | 397 const std::string& group_name, |
| 391 const PoolBase::Request& request, | 398 const PoolBase::Request& request, |
| 392 ConnectJob::Delegate* delegate) const { | 399 ConnectJob::Delegate* delegate) const { |
| 393 return scoped_ptr<ConnectJob>(new HttpProxyConnectJob(group_name, | 400 return scoped_ptr<ConnectJob>(new HttpProxyConnectJob(group_name, |
| 394 request.priority(), | 401 request.priority(), |
| 395 request.params(), | 402 request.params(), |
| 396 ConnectionTimeout(), | 403 ConnectionTimeout(), |
| 397 transport_pool_, | 404 transport_pool_, |
| 398 ssl_pool_, | 405 ssl_pool_, |
| 399 host_resolver_, | 406 host_resolver_, |
| 400 delegate, | 407 delegate, |
| 401 net_log_)); | 408 net_log_)); |
| 402 } | 409 } |
| 403 | 410 |
| 404 base::TimeDelta | 411 base::TimeDelta |
| 405 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout( | 412 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout() |
| 406 ) const { | 413 const { |
| 407 return timeout_; | 414 return timeout_; |
| 408 } | 415 } |
| 409 | 416 |
| 410 HttpProxyClientSocketPool::HttpProxyClientSocketPool( | 417 HttpProxyClientSocketPool::HttpProxyClientSocketPool( |
| 411 int max_sockets, | 418 int max_sockets, |
| 412 int max_sockets_per_group, | 419 int max_sockets_per_group, |
| 413 ClientSocketPoolHistograms* histograms, | 420 ClientSocketPoolHistograms* histograms, |
| 414 HostResolver* host_resolver, | 421 HostResolver* host_resolver, |
| 415 TransportClientSocketPool* transport_pool, | 422 TransportClientSocketPool* transport_pool, |
| 416 SSLClientSocketPool* ssl_pool, | 423 SSLClientSocketPool* ssl_pool, |
| 417 NetLog* net_log) | 424 NetLog* net_log) |
| 418 : transport_pool_(transport_pool), | 425 : transport_pool_(transport_pool), |
| 419 ssl_pool_(ssl_pool), | 426 ssl_pool_(ssl_pool), |
| 420 base_(this, max_sockets, max_sockets_per_group, histograms, | 427 base_(this, |
| 428 max_sockets, |
| 429 max_sockets_per_group, |
| 430 histograms, |
| 421 ClientSocketPool::unused_idle_socket_timeout(), | 431 ClientSocketPool::unused_idle_socket_timeout(), |
| 422 ClientSocketPool::used_idle_socket_timeout(), | 432 ClientSocketPool::used_idle_socket_timeout(), |
| 423 new HttpProxyConnectJobFactory(transport_pool, | 433 new HttpProxyConnectJobFactory(transport_pool, |
| 424 ssl_pool, | 434 ssl_pool, |
| 425 host_resolver, | 435 host_resolver, |
| 426 net_log)) { | 436 net_log)) { |
| 427 // We should always have a |transport_pool_| except in unit tests. | 437 // We should always have a |transport_pool_| except in unit tests. |
| 428 if (transport_pool_) | 438 if (transport_pool_) |
| 429 base_.AddLowerLayeredPool(transport_pool_); | 439 base_.AddLowerLayeredPool(transport_pool_); |
| 430 if (ssl_pool_) | 440 if (ssl_pool_) |
| 431 base_.AddLowerLayeredPool(ssl_pool_); | 441 base_.AddLowerLayeredPool(ssl_pool_); |
| 432 } | 442 } |
| 433 | 443 |
| 434 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { | 444 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { |
| 435 } | 445 } |
| 436 | 446 |
| 437 int HttpProxyClientSocketPool::RequestSocket( | 447 int HttpProxyClientSocketPool::RequestSocket(const std::string& group_name, |
| 438 const std::string& group_name, const void* socket_params, | 448 const void* socket_params, |
| 439 RequestPriority priority, ClientSocketHandle* handle, | 449 RequestPriority priority, |
| 440 const CompletionCallback& callback, const BoundNetLog& net_log) { | 450 ClientSocketHandle* handle, |
| 451 const CompletionCallback& callback, |
| 452 const BoundNetLog& net_log) { |
| 441 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = | 453 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = |
| 442 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); | 454 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); |
| 443 | 455 |
| 444 return base_.RequestSocket(group_name, *casted_socket_params, priority, | 456 return base_.RequestSocket( |
| 445 handle, callback, net_log); | 457 group_name, *casted_socket_params, priority, handle, callback, net_log); |
| 446 } | 458 } |
| 447 | 459 |
| 448 void HttpProxyClientSocketPool::RequestSockets( | 460 void HttpProxyClientSocketPool::RequestSockets(const std::string& group_name, |
| 449 const std::string& group_name, | 461 const void* params, |
| 450 const void* params, | 462 int num_sockets, |
| 451 int num_sockets, | 463 const BoundNetLog& net_log) { |
| 452 const BoundNetLog& net_log) { | |
| 453 const scoped_refptr<HttpProxySocketParams>* casted_params = | 464 const scoped_refptr<HttpProxySocketParams>* casted_params = |
| 454 static_cast<const scoped_refptr<HttpProxySocketParams>*>(params); | 465 static_cast<const scoped_refptr<HttpProxySocketParams>*>(params); |
| 455 | 466 |
| 456 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log); | 467 base_.RequestSockets(group_name, *casted_params, num_sockets, net_log); |
| 457 } | 468 } |
| 458 | 469 |
| 459 void HttpProxyClientSocketPool::CancelRequest( | 470 void HttpProxyClientSocketPool::CancelRequest(const std::string& group_name, |
| 460 const std::string& group_name, | 471 ClientSocketHandle* handle) { |
| 461 ClientSocketHandle* handle) { | |
| 462 base_.CancelRequest(group_name, handle); | 472 base_.CancelRequest(group_name, handle); |
| 463 } | 473 } |
| 464 | 474 |
| 465 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name, | 475 void HttpProxyClientSocketPool::ReleaseSocket(const std::string& group_name, |
| 466 scoped_ptr<StreamSocket> socket, | 476 scoped_ptr<StreamSocket> socket, |
| 467 int id) { | 477 int id) { |
| 468 base_.ReleaseSocket(group_name, socket.Pass(), id); | 478 base_.ReleaseSocket(group_name, socket.Pass(), id); |
| 469 } | 479 } |
| 470 | 480 |
| 471 void HttpProxyClientSocketPool::FlushWithError(int error) { | 481 void HttpProxyClientSocketPool::FlushWithError(int error) { |
| 472 base_.FlushWithError(error); | 482 base_.FlushWithError(error); |
| 473 } | 483 } |
| 474 | 484 |
| 475 void HttpProxyClientSocketPool::CloseIdleSockets() { | 485 void HttpProxyClientSocketPool::CloseIdleSockets() { |
| 476 base_.CloseIdleSockets(); | 486 base_.CloseIdleSockets(); |
| 477 } | 487 } |
| 478 | 488 |
| 479 int HttpProxyClientSocketPool::IdleSocketCount() const { | 489 int HttpProxyClientSocketPool::IdleSocketCount() const { |
| 480 return base_.idle_socket_count(); | 490 return base_.idle_socket_count(); |
| 481 } | 491 } |
| 482 | 492 |
| 483 int HttpProxyClientSocketPool::IdleSocketCountInGroup( | 493 int HttpProxyClientSocketPool::IdleSocketCountInGroup( |
| 484 const std::string& group_name) const { | 494 const std::string& group_name) const { |
| 485 return base_.IdleSocketCountInGroup(group_name); | 495 return base_.IdleSocketCountInGroup(group_name); |
| 486 } | 496 } |
| 487 | 497 |
| 488 LoadState HttpProxyClientSocketPool::GetLoadState( | 498 LoadState HttpProxyClientSocketPool::GetLoadState( |
| 489 const std::string& group_name, const ClientSocketHandle* handle) const { | 499 const std::string& group_name, |
| 500 const ClientSocketHandle* handle) const { |
| 490 return base_.GetLoadState(group_name, handle); | 501 return base_.GetLoadState(group_name, handle); |
| 491 } | 502 } |
| 492 | 503 |
| 493 base::DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( | 504 base::DictionaryValue* HttpProxyClientSocketPool::GetInfoAsValue( |
| 494 const std::string& name, | 505 const std::string& name, |
| 495 const std::string& type, | 506 const std::string& type, |
| 496 bool include_nested_pools) const { | 507 bool include_nested_pools) const { |
| 497 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type); | 508 base::DictionaryValue* dict = base_.GetInfoAsValue(name, type); |
| 498 if (include_nested_pools) { | 509 if (include_nested_pools) { |
| 499 base::ListValue* list = new base::ListValue(); | 510 base::ListValue* list = new base::ListValue(); |
| 500 if (transport_pool_) { | 511 if (transport_pool_) { |
| 501 list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", | 512 list->Append(transport_pool_->GetInfoAsValue( |
| 502 "transport_socket_pool", | 513 "transport_socket_pool", "transport_socket_pool", true)); |
| 503 true)); | |
| 504 } | 514 } |
| 505 if (ssl_pool_) { | 515 if (ssl_pool_) { |
| 506 list->Append(ssl_pool_->GetInfoAsValue("ssl_socket_pool", | 516 list->Append(ssl_pool_->GetInfoAsValue( |
| 507 "ssl_socket_pool", | 517 "ssl_socket_pool", "ssl_socket_pool", true)); |
| 508 true)); | |
| 509 } | 518 } |
| 510 dict->Set("nested_pools", list); | 519 dict->Set("nested_pools", list); |
| 511 } | 520 } |
| 512 return dict; | 521 return dict; |
| 513 } | 522 } |
| 514 | 523 |
| 515 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { | 524 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { |
| 516 return base_.ConnectionTimeout(); | 525 return base_.ConnectionTimeout(); |
| 517 } | 526 } |
| 518 | 527 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 534 base_.RemoveHigherLayeredPool(higher_pool); | 543 base_.RemoveHigherLayeredPool(higher_pool); |
| 535 } | 544 } |
| 536 | 545 |
| 537 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { | 546 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { |
| 538 if (base_.CloseOneIdleSocket()) | 547 if (base_.CloseOneIdleSocket()) |
| 539 return true; | 548 return true; |
| 540 return base_.CloseOneIdleConnectionInHigherLayeredPool(); | 549 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
| 541 } | 550 } |
| 542 | 551 |
| 543 } // namespace net | 552 } // namespace net |
| OLD | NEW |