| 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 14 matching lines...) Expand all Loading... |
| 25 #include "net/spdy/spdy_session_pool.h" | 25 #include "net/spdy/spdy_session_pool.h" |
| 26 #include "net/spdy/spdy_stream.h" | 26 #include "net/spdy/spdy_stream.h" |
| 27 #include "net/ssl/ssl_cert_request_info.h" | 27 #include "net/ssl/ssl_cert_request_info.h" |
| 28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 29 | 29 |
| 30 namespace net { | 30 namespace net { |
| 31 | 31 |
| 32 HttpProxySocketParams::HttpProxySocketParams( | 32 HttpProxySocketParams::HttpProxySocketParams( |
| 33 const scoped_refptr<TransportSocketParams>& transport_params, | 33 const scoped_refptr<TransportSocketParams>& transport_params, |
| 34 const scoped_refptr<SSLSocketParams>& ssl_params, | 34 const scoped_refptr<SSLSocketParams>& ssl_params, |
| 35 const GURL& request_url, | |
| 36 const std::string& user_agent, | 35 const std::string& user_agent, |
| 37 const HostPortPair& endpoint, | 36 const HostPortPair& endpoint, |
| 38 HttpAuthCache* http_auth_cache, | 37 HttpAuthCache* http_auth_cache, |
| 39 HttpAuthHandlerFactory* http_auth_handler_factory, | 38 HttpAuthHandlerFactory* http_auth_handler_factory, |
| 40 SpdySessionPool* spdy_session_pool, | 39 SpdySessionPool* spdy_session_pool, |
| 41 bool tunnel, | 40 bool tunnel, |
| 42 ProxyDelegate* proxy_delegate) | 41 ProxyDelegate* proxy_delegate) |
| 43 : transport_params_(transport_params), | 42 : transport_params_(transport_params), |
| 44 ssl_params_(ssl_params), | 43 ssl_params_(ssl_params), |
| 45 spdy_session_pool_(spdy_session_pool), | 44 spdy_session_pool_(spdy_session_pool), |
| 46 request_url_(request_url), | |
| 47 user_agent_(user_agent), | 45 user_agent_(user_agent), |
| 48 endpoint_(endpoint), | 46 endpoint_(endpoint), |
| 49 http_auth_cache_(tunnel ? http_auth_cache : NULL), | 47 http_auth_cache_(tunnel ? http_auth_cache : NULL), |
| 50 http_auth_handler_factory_(tunnel ? http_auth_handler_factory : NULL), | 48 http_auth_handler_factory_(tunnel ? http_auth_handler_factory : NULL), |
| 51 tunnel_(tunnel), | 49 tunnel_(tunnel), |
| 52 proxy_delegate_(proxy_delegate) { | 50 proxy_delegate_(proxy_delegate) { |
| 53 DCHECK((transport_params.get() == NULL && ssl_params.get() != NULL) || | 51 DCHECK((transport_params.get() == NULL && ssl_params.get() != NULL) || |
| 54 (transport_params.get() != NULL && ssl_params.get() == NULL)); | 52 (transport_params.get() != NULL && ssl_params.get() == NULL)); |
| 55 if (transport_params_.get()) { | 53 if (transport_params_.get()) { |
| 56 ignore_limits_ = transport_params->ignore_limits(); | 54 ignore_limits_ = transport_params->ignore_limits(); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 277 } |
| 280 | 278 |
| 281 int HttpProxyConnectJob::DoHttpProxyConnect() { | 279 int HttpProxyConnectJob::DoHttpProxyConnect() { |
| 282 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; | 280 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; |
| 283 const HostResolver::RequestInfo& tcp_destination = params_->destination(); | 281 const HostResolver::RequestInfo& tcp_destination = params_->destination(); |
| 284 const HostPortPair& proxy_server = tcp_destination.host_port_pair(); | 282 const HostPortPair& proxy_server = tcp_destination.host_port_pair(); |
| 285 | 283 |
| 286 // Add a HttpProxy connection on top of the tcp socket. | 284 // Add a HttpProxy connection on top of the tcp socket. |
| 287 transport_socket_.reset( | 285 transport_socket_.reset( |
| 288 new HttpProxyClientSocket(transport_socket_handle_.release(), | 286 new HttpProxyClientSocket(transport_socket_handle_.release(), |
| 289 params_->request_url(), | |
| 290 params_->user_agent(), | 287 params_->user_agent(), |
| 291 params_->endpoint(), | 288 params_->endpoint(), |
| 292 proxy_server, | 289 proxy_server, |
| 293 params_->http_auth_cache(), | 290 params_->http_auth_cache(), |
| 294 params_->http_auth_handler_factory(), | 291 params_->http_auth_handler_factory(), |
| 295 params_->tunnel(), | 292 params_->tunnel(), |
| 296 using_spdy_, | 293 using_spdy_, |
| 297 protocol_negotiated_, | 294 protocol_negotiated_, |
| 298 params_->proxy_delegate(), | 295 params_->proxy_delegate(), |
| 299 params_->ssl_params().get() != NULL)); | 296 params_->ssl_params().get() != NULL)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 } else { | 328 } else { |
| 332 // Create a session direct to the proxy itself | 329 // Create a session direct to the proxy itself |
| 333 spdy_session = | 330 spdy_session = |
| 334 spdy_pool->CreateAvailableSessionFromSocket( | 331 spdy_pool->CreateAvailableSessionFromSocket( |
| 335 key, transport_socket_handle_.Pass(), | 332 key, transport_socket_handle_.Pass(), |
| 336 net_log(), OK, /*using_ssl_*/ true); | 333 net_log(), OK, /*using_ssl_*/ true); |
| 337 DCHECK(spdy_session); | 334 DCHECK(spdy_session); |
| 338 } | 335 } |
| 339 | 336 |
| 340 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE; | 337 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE; |
| 341 return spdy_stream_request_.StartRequest(SPDY_BIDIRECTIONAL_STREAM, | 338 return spdy_stream_request_.StartRequest( |
| 342 spdy_session, | 339 SPDY_BIDIRECTIONAL_STREAM, spdy_session, |
| 343 params_->request_url(), | 340 GURL("https://" + params_->endpoint().ToString()), priority(), |
| 344 priority(), | 341 spdy_session->net_log(), callback_); |
| 345 spdy_session->net_log(), | |
| 346 callback_); | |
| 347 } | 342 } |
| 348 | 343 |
| 349 int HttpProxyConnectJob::DoSpdyProxyCreateStreamComplete(int result) { | 344 int HttpProxyConnectJob::DoSpdyProxyCreateStreamComplete(int result) { |
| 350 if (result < 0) | 345 if (result < 0) |
| 351 return result; | 346 return result; |
| 352 | 347 |
| 353 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; | 348 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; |
| 354 base::WeakPtr<SpdyStream> stream = spdy_stream_request_.ReleaseStream(); | 349 base::WeakPtr<SpdyStream> stream = spdy_stream_request_.ReleaseStream(); |
| 355 DCHECK(stream.get()); | 350 DCHECK(stream.get()); |
| 356 // |transport_socket_| will set itself as |stream|'s delegate. | 351 // |transport_socket_| will set itself as |stream|'s delegate. |
| 357 transport_socket_.reset( | 352 transport_socket_.reset( |
| 358 new SpdyProxyClientSocket(stream, | 353 new SpdyProxyClientSocket(stream, |
| 359 params_->user_agent(), | 354 params_->user_agent(), |
| 360 params_->endpoint(), | 355 params_->endpoint(), |
| 361 params_->request_url(), | |
| 362 params_->destination().host_port_pair(), | 356 params_->destination().host_port_pair(), |
| 363 net_log(), | 357 net_log(), |
| 364 params_->http_auth_cache(), | 358 params_->http_auth_cache(), |
| 365 params_->http_auth_handler_factory())); | 359 params_->http_auth_handler_factory())); |
| 366 return transport_socket_->Connect(callback_); | 360 return transport_socket_->Connect(callback_); |
| 367 } | 361 } |
| 368 | 362 |
| 369 void HttpProxyConnectJob::NotifyProxyDelegateOfCompletion(int result) { | 363 void HttpProxyConnectJob::NotifyProxyDelegateOfCompletion(int result) { |
| 370 if (!params_->proxy_delegate()) | 364 if (!params_->proxy_delegate()) |
| 371 return; | 365 return; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 base_.RemoveHigherLayeredPool(higher_pool); | 551 base_.RemoveHigherLayeredPool(higher_pool); |
| 558 } | 552 } |
| 559 | 553 |
| 560 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { | 554 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { |
| 561 if (base_.CloseOneIdleSocket()) | 555 if (base_.CloseOneIdleSocket()) |
| 562 return true; | 556 return true; |
| 563 return base_.CloseOneIdleConnectionInHigherLayeredPool(); | 557 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
| 564 } | 558 } |
| 565 | 559 |
| 566 } // namespace net | 560 } // namespace net |
| OLD | NEW |