| 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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 #include "net/base/proxy_delegate.h" |
| 14 #include "net/http/http_network_session.h" | 15 #include "net/http/http_network_session.h" |
| 15 #include "net/http/http_proxy_client_socket.h" | 16 #include "net/http/http_proxy_client_socket.h" |
| 16 #include "net/socket/client_socket_factory.h" | 17 #include "net/socket/client_socket_factory.h" |
| 17 #include "net/socket/client_socket_handle.h" | 18 #include "net/socket/client_socket_handle.h" |
| 18 #include "net/socket/client_socket_pool_base.h" | 19 #include "net/socket/client_socket_pool_base.h" |
| 19 #include "net/socket/ssl_client_socket.h" | 20 #include "net/socket/ssl_client_socket.h" |
| 20 #include "net/socket/ssl_client_socket_pool.h" | 21 #include "net/socket/ssl_client_socket_pool.h" |
| 21 #include "net/socket/transport_client_socket_pool.h" | 22 #include "net/socket/transport_client_socket_pool.h" |
| 22 #include "net/spdy/spdy_proxy_client_socket.h" | 23 #include "net/spdy/spdy_proxy_client_socket.h" |
| 23 #include "net/spdy/spdy_session.h" | 24 #include "net/spdy/spdy_session.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 124 |
| 124 void HttpProxyConnectJob::GetAdditionalErrorState(ClientSocketHandle * handle) { | 125 void HttpProxyConnectJob::GetAdditionalErrorState(ClientSocketHandle * handle) { |
| 125 if (error_response_info_.cert_request_info.get()) { | 126 if (error_response_info_.cert_request_info.get()) { |
| 126 handle->set_ssl_error_response_info(error_response_info_); | 127 handle->set_ssl_error_response_info(error_response_info_); |
| 127 handle->set_is_ssl_error(true); | 128 handle->set_is_ssl_error(true); |
| 128 } | 129 } |
| 129 } | 130 } |
| 130 | 131 |
| 131 void HttpProxyConnectJob::OnIOComplete(int result) { | 132 void HttpProxyConnectJob::OnIOComplete(int result) { |
| 132 int rv = DoLoop(result); | 133 int rv = DoLoop(result); |
| 133 if (rv != ERR_IO_PENDING) | 134 if (rv != ERR_IO_PENDING) { |
| 135 NotifyProxyDelegateOfCompletion(rv); |
| 134 NotifyDelegateOfCompletion(rv); // Deletes |this| | 136 NotifyDelegateOfCompletion(rv); // Deletes |this| |
| 137 } |
| 135 } | 138 } |
| 136 | 139 |
| 137 int HttpProxyConnectJob::DoLoop(int result) { | 140 int HttpProxyConnectJob::DoLoop(int result) { |
| 138 DCHECK_NE(next_state_, STATE_NONE); | 141 DCHECK_NE(next_state_, STATE_NONE); |
| 139 | 142 |
| 140 int rv = result; | 143 int rv = result; |
| 141 do { | 144 do { |
| 142 State state = next_state_; | 145 State state = next_state_; |
| 143 next_state_ = STATE_NONE; | 146 next_state_ = STATE_NONE; |
| 144 switch (state) { | 147 switch (state) { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 params_->user_agent(), | 358 params_->user_agent(), |
| 356 params_->endpoint(), | 359 params_->endpoint(), |
| 357 params_->request_url(), | 360 params_->request_url(), |
| 358 params_->destination().host_port_pair(), | 361 params_->destination().host_port_pair(), |
| 359 net_log(), | 362 net_log(), |
| 360 params_->http_auth_cache(), | 363 params_->http_auth_cache(), |
| 361 params_->http_auth_handler_factory())); | 364 params_->http_auth_handler_factory())); |
| 362 return transport_socket_->Connect(callback_); | 365 return transport_socket_->Connect(callback_); |
| 363 } | 366 } |
| 364 | 367 |
| 368 void HttpProxyConnectJob::NotifyProxyDelegateOfCompletion(int result) { |
| 369 if (!params_->proxy_delegate()) |
| 370 return; |
| 371 |
| 372 const HostPortPair& proxy_server = params_->destination().host_port_pair(); |
| 373 params_->proxy_delegate()->OnTunnelConnectCompleted(params_->endpoint(), |
| 374 proxy_server, |
| 375 result); |
| 376 } |
| 377 |
| 365 int HttpProxyConnectJob::ConnectInternal() { | 378 int HttpProxyConnectJob::ConnectInternal() { |
| 366 if (params_->transport_params().get()) { | 379 if (params_->transport_params().get()) { |
| 367 next_state_ = STATE_TCP_CONNECT; | 380 next_state_ = STATE_TCP_CONNECT; |
| 368 } else { | 381 } else { |
| 369 next_state_ = STATE_SSL_CONNECT; | 382 next_state_ = STATE_SSL_CONNECT; |
| 370 } | 383 } |
| 371 return DoLoop(OK); | 384 |
| 385 int rv = DoLoop(OK); |
| 386 if (rv != ERR_IO_PENDING) { |
| 387 NotifyProxyDelegateOfCompletion(rv); |
| 388 } |
| 389 |
| 390 return rv; |
| 372 } | 391 } |
| 373 | 392 |
| 374 HttpProxyClientSocketPool:: | 393 HttpProxyClientSocketPool:: |
| 375 HttpProxyConnectJobFactory::HttpProxyConnectJobFactory( | 394 HttpProxyConnectJobFactory::HttpProxyConnectJobFactory( |
| 376 TransportClientSocketPool* transport_pool, | 395 TransportClientSocketPool* transport_pool, |
| 377 SSLClientSocketPool* ssl_pool, | 396 SSLClientSocketPool* ssl_pool, |
| 378 HostResolver* host_resolver, | 397 HostResolver* host_resolver, |
| 379 const ProxyDelegate* proxy_delegate, | 398 const ProxyDelegate* proxy_delegate, |
| 380 NetLog* net_log) | 399 NetLog* net_log) |
| 381 : transport_pool_(transport_pool), | 400 : transport_pool_(transport_pool), |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 base_.RemoveHigherLayeredPool(higher_pool); | 570 base_.RemoveHigherLayeredPool(higher_pool); |
| 552 } | 571 } |
| 553 | 572 |
| 554 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { | 573 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { |
| 555 if (base_.CloseOneIdleSocket()) | 574 if (base_.CloseOneIdleSocket()) |
| 556 return true; | 575 return true; |
| 557 return base_.CloseOneIdleConnectionInHigherLayeredPool(); | 576 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
| 558 } | 577 } |
| 559 | 578 |
| 560 } // namespace net | 579 } // namespace net |
| OLD | NEW |