| 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/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/time.h" | 9 #include "base/time.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 NetLog* net_log) | 79 NetLog* net_log) |
| 80 : ConnectJob(group_name, timeout_duration, delegate, | 80 : ConnectJob(group_name, timeout_duration, delegate, |
| 81 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), | 81 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), |
| 82 params_(params), | 82 params_(params), |
| 83 transport_pool_(transport_pool), | 83 transport_pool_(transport_pool), |
| 84 ssl_pool_(ssl_pool), | 84 ssl_pool_(ssl_pool), |
| 85 resolver_(host_resolver), | 85 resolver_(host_resolver), |
| 86 ALLOW_THIS_IN_INITIALIZER_LIST( | 86 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 87 callback_(base::Bind(&HttpProxyConnectJob::OnIOComplete, | 87 callback_(base::Bind(&HttpProxyConnectJob::OnIOComplete, |
| 88 base::Unretained(this)))), | 88 base::Unretained(this)))), |
| 89 ALLOW_THIS_IN_INITIALIZER_LIST( | |
| 90 callback_old_(this, &HttpProxyConnectJob::OnIOComplete)), | |
| 91 using_spdy_(false) { | 89 using_spdy_(false) { |
| 92 } | 90 } |
| 93 | 91 |
| 94 HttpProxyConnectJob::~HttpProxyConnectJob() {} | 92 HttpProxyConnectJob::~HttpProxyConnectJob() {} |
| 95 | 93 |
| 96 LoadState HttpProxyConnectJob::GetLoadState() const { | 94 LoadState HttpProxyConnectJob::GetLoadState() const { |
| 97 switch (next_state_) { | 95 switch (next_state_) { |
| 98 case STATE_TCP_CONNECT: | 96 case STATE_TCP_CONNECT: |
| 99 case STATE_TCP_CONNECT_COMPLETE: | 97 case STATE_TCP_CONNECT_COMPLETE: |
| 100 case STATE_SSL_CONNECT: | 98 case STATE_SSL_CONNECT: |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } else { | 300 } else { |
| 303 // Create a session direct to the proxy itself | 301 // Create a session direct to the proxy itself |
| 304 int rv = spdy_pool->GetSpdySessionFromSocket( | 302 int rv = spdy_pool->GetSpdySessionFromSocket( |
| 305 pair, transport_socket_handle_.release(), | 303 pair, transport_socket_handle_.release(), |
| 306 net_log(), OK, &spdy_session, /*using_ssl_*/ true); | 304 net_log(), OK, &spdy_session, /*using_ssl_*/ true); |
| 307 if (rv < 0) | 305 if (rv < 0) |
| 308 return rv; | 306 return rv; |
| 309 } | 307 } |
| 310 | 308 |
| 311 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE; | 309 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE; |
| 312 return spdy_session->CreateStream(params_->request_url(), | 310 return spdy_session->CreateStream( |
| 313 params_->destination().priority(), | 311 params_->request_url(), params_->destination().priority(), |
| 314 &spdy_stream_, spdy_session->net_log(), | 312 &spdy_stream_, spdy_session->net_log(), callback_); |
| 315 &callback_old_); | |
| 316 } | 313 } |
| 317 | 314 |
| 318 int HttpProxyConnectJob::DoSpdyProxyCreateStreamComplete(int result) { | 315 int HttpProxyConnectJob::DoSpdyProxyCreateStreamComplete(int result) { |
| 319 if (result < 0) | 316 if (result < 0) |
| 320 return result; | 317 return result; |
| 321 | 318 |
| 322 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; | 319 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; |
| 323 transport_socket_.reset( | 320 transport_socket_.reset( |
| 324 new SpdyProxyClientSocket(spdy_stream_, | 321 new SpdyProxyClientSocket(spdy_stream_, |
| 325 params_->user_agent(), | 322 params_->user_agent(), |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 397 } |
| 401 | 398 |
| 402 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { | 399 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { |
| 403 if (ssl_pool_) | 400 if (ssl_pool_) |
| 404 ssl_pool_->RemoveLayeredPool(this); | 401 ssl_pool_->RemoveLayeredPool(this); |
| 405 // We should always have a |transport_pool_| except in unit tests. | 402 // We should always have a |transport_pool_| except in unit tests. |
| 406 if (transport_pool_) | 403 if (transport_pool_) |
| 407 transport_pool_->RemoveLayeredPool(this); | 404 transport_pool_->RemoveLayeredPool(this); |
| 408 } | 405 } |
| 409 | 406 |
| 410 int HttpProxyClientSocketPool::RequestSocket(const std::string& group_name, | 407 int HttpProxyClientSocketPool::RequestSocket( |
| 411 const void* socket_params, | 408 const std::string& group_name, const void* socket_params, |
| 412 RequestPriority priority, | 409 RequestPriority priority, ClientSocketHandle* handle, |
| 413 ClientSocketHandle* handle, | 410 const CompletionCallback& callback, const BoundNetLog& net_log) { |
| 414 OldCompletionCallback* callback, | |
| 415 const BoundNetLog& net_log) { | |
| 416 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = | 411 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = |
| 417 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); | 412 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); |
| 418 | 413 |
| 419 return base_.RequestSocket(group_name, *casted_socket_params, priority, | 414 return base_.RequestSocket(group_name, *casted_socket_params, priority, |
| 420 handle, callback, net_log); | 415 handle, callback, net_log); |
| 421 } | 416 } |
| 422 | 417 |
| 423 void HttpProxyClientSocketPool::RequestSockets( | 418 void HttpProxyClientSocketPool::RequestSockets( |
| 424 const std::string& group_name, | 419 const std::string& group_name, |
| 425 const void* params, | 420 const void* params, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 return base_.histograms(); | 503 return base_.histograms(); |
| 509 } | 504 } |
| 510 | 505 |
| 511 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { | 506 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { |
| 512 if (base_.CloseOneIdleSocket()) | 507 if (base_.CloseOneIdleSocket()) |
| 513 return true; | 508 return true; |
| 514 return base_.CloseOneIdleConnectionInLayeredPool(); | 509 return base_.CloseOneIdleConnectionInLayeredPool(); |
| 515 } | 510 } |
| 516 | 511 |
| 517 } // namespace net | 512 } // namespace net |
| OLD | NEW |