OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 case STATE_HTTP_PROXY_CONNECT_COMPLETE: | 98 case STATE_HTTP_PROXY_CONNECT_COMPLETE: |
99 case STATE_SPDY_PROXY_CREATE_STREAM: | 99 case STATE_SPDY_PROXY_CREATE_STREAM: |
100 case STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE: | 100 case STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE: |
101 return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL; | 101 return LOAD_STATE_ESTABLISHING_PROXY_TUNNEL; |
102 default: | 102 default: |
103 NOTREACHED(); | 103 NOTREACHED(); |
104 return LOAD_STATE_IDLE; | 104 return LOAD_STATE_IDLE; |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 int HttpProxyConnectJob::ConnectInternal() { | 108 void HttpProxyConnectJob::GetAdditionalErrorState(ClientSocketHandle * handle) { |
109 if (params_->tcp_params()) | 109 if (error_response_info_.cert_request_info) { |
110 next_state_ = STATE_TCP_CONNECT; | 110 handle->set_ssl_error_response_info(error_response_info_); |
111 else | 111 handle->set_is_ssl_error(true); |
112 next_state_ = STATE_SSL_CONNECT; | 112 } |
113 return DoLoop(OK); | |
114 } | 113 } |
115 | 114 |
116 void HttpProxyConnectJob::OnIOComplete(int result) { | 115 void HttpProxyConnectJob::OnIOComplete(int result) { |
117 int rv = DoLoop(result); | 116 int rv = DoLoop(result); |
118 if (rv != ERR_IO_PENDING) | 117 if (rv != ERR_IO_PENDING) |
119 NotifyDelegateOfCompletion(rv); // Deletes |this| | 118 NotifyDelegateOfCompletion(rv); // Deletes |this| |
120 } | 119 } |
121 | 120 |
122 int HttpProxyConnectJob::DoLoop(int result) { | 121 int HttpProxyConnectJob::DoLoop(int result) { |
123 DCHECK_NE(next_state_, STATE_NONE); | 122 DCHECK_NE(next_state_, STATE_NONE); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 // need to add a predicate to this if statement so we fall through | 240 // need to add a predicate to this if statement so we fall through |
242 // to the else case. (HttpProxyClientSocket currently acts as | 241 // to the else case. (HttpProxyClientSocket currently acts as |
243 // a "trusted" SPDY proxy). | 242 // a "trusted" SPDY proxy). |
244 if (using_spdy_ && params_->tunnel()) | 243 if (using_spdy_ && params_->tunnel()) |
245 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM; | 244 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM; |
246 else | 245 else |
247 next_state_ = STATE_HTTP_PROXY_CONNECT; | 246 next_state_ = STATE_HTTP_PROXY_CONNECT; |
248 return result; | 247 return result; |
249 } | 248 } |
250 | 249 |
251 void HttpProxyConnectJob::GetAdditionalErrorState(ClientSocketHandle * handle) { | 250 int HttpProxyConnectJob::DoHttpProxyConnect() { |
252 if (error_response_info_.cert_request_info) { | 251 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; |
253 handle->set_ssl_error_response_info(error_response_info_); | 252 const HostResolver::RequestInfo& tcp_destination = params_->destination(); |
254 handle->set_is_ssl_error(true); | 253 const HostPortPair& proxy_server = tcp_destination.host_port_pair(); |
| 254 |
| 255 // Add a HttpProxy connection on top of the tcp socket. |
| 256 transport_socket_.reset( |
| 257 new HttpProxyClientSocket(transport_socket_handle_.release(), |
| 258 params_->request_url(), |
| 259 params_->user_agent(), |
| 260 params_->endpoint(), |
| 261 proxy_server, |
| 262 params_->http_auth_cache(), |
| 263 params_->http_auth_handler_factory(), |
| 264 params_->tunnel(), |
| 265 using_spdy_, |
| 266 params_->ssl_params() != NULL)); |
| 267 return transport_socket_->Connect(&callback_); |
| 268 } |
| 269 |
| 270 int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) { |
| 271 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED || |
| 272 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { |
| 273 set_socket(transport_socket_.release()); |
255 } | 274 } |
| 275 |
| 276 return result; |
256 } | 277 } |
257 | 278 |
258 int HttpProxyConnectJob::DoSpdyProxyCreateStream() { | 279 int HttpProxyConnectJob::DoSpdyProxyCreateStream() { |
259 DCHECK(using_spdy_); | 280 DCHECK(using_spdy_); |
260 DCHECK(params_->tunnel()); | 281 DCHECK(params_->tunnel()); |
261 | 282 |
262 HostPortProxyPair pair(params_->destination().host_port_pair(), | 283 HostPortProxyPair pair(params_->destination().host_port_pair(), |
263 ProxyServer::Direct()); | 284 ProxyServer::Direct()); |
264 SpdySessionPool* spdy_pool = params_->spdy_session_pool(); | 285 SpdySessionPool* spdy_pool = params_->spdy_session_pool(); |
265 scoped_refptr<SpdySession> spdy_session; | 286 scoped_refptr<SpdySession> spdy_session; |
(...skipping 30 matching lines...) Expand all Loading... |
296 new SpdyProxyClientSocket(spdy_stream_, | 317 new SpdyProxyClientSocket(spdy_stream_, |
297 params_->user_agent(), | 318 params_->user_agent(), |
298 params_->endpoint(), | 319 params_->endpoint(), |
299 params_->request_url(), | 320 params_->request_url(), |
300 params_->destination().host_port_pair(), | 321 params_->destination().host_port_pair(), |
301 params_->http_auth_cache(), | 322 params_->http_auth_cache(), |
302 params_->http_auth_handler_factory())); | 323 params_->http_auth_handler_factory())); |
303 return transport_socket_->Connect(&callback_); | 324 return transport_socket_->Connect(&callback_); |
304 } | 325 } |
305 | 326 |
306 int HttpProxyConnectJob::DoHttpProxyConnect() { | 327 int HttpProxyConnectJob::ConnectInternal() { |
307 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; | 328 if (params_->tcp_params()) |
308 const HostResolver::RequestInfo& tcp_destination = params_->destination(); | 329 next_state_ = STATE_TCP_CONNECT; |
309 const HostPortPair& proxy_server = tcp_destination.host_port_pair(); | 330 else |
310 | 331 next_state_ = STATE_SSL_CONNECT; |
311 // Add a HttpProxy connection on top of the tcp socket. | 332 return DoLoop(OK); |
312 transport_socket_.reset( | |
313 new HttpProxyClientSocket(transport_socket_handle_.release(), | |
314 params_->request_url(), | |
315 params_->user_agent(), | |
316 params_->endpoint(), | |
317 proxy_server, | |
318 params_->http_auth_cache(), | |
319 params_->http_auth_handler_factory(), | |
320 params_->tunnel(), | |
321 using_spdy_, | |
322 params_->ssl_params() != NULL)); | |
323 return transport_socket_->Connect(&callback_); | |
324 } | |
325 | |
326 int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) { | |
327 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED || | |
328 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { | |
329 set_socket(transport_socket_.release()); | |
330 } | |
331 | |
332 return result; | |
333 } | 333 } |
334 | 334 |
335 HttpProxyClientSocketPool:: | 335 HttpProxyClientSocketPool:: |
336 HttpProxyConnectJobFactory::HttpProxyConnectJobFactory( | 336 HttpProxyConnectJobFactory::HttpProxyConnectJobFactory( |
337 TCPClientSocketPool* tcp_pool, | 337 TCPClientSocketPool* tcp_pool, |
338 SSLClientSocketPool* ssl_pool, | 338 SSLClientSocketPool* ssl_pool, |
339 HostResolver* host_resolver, | 339 HostResolver* host_resolver, |
340 NetLog* net_log) | 340 NetLog* net_log) |
341 : tcp_pool_(tcp_pool), | 341 : tcp_pool_(tcp_pool), |
342 ssl_pool_(ssl_pool), | 342 ssl_pool_(ssl_pool), |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 463 |
464 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { | 464 base::TimeDelta HttpProxyClientSocketPool::ConnectionTimeout() const { |
465 return base_.ConnectionTimeout(); | 465 return base_.ConnectionTimeout(); |
466 } | 466 } |
467 | 467 |
468 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const { | 468 ClientSocketPoolHistograms* HttpProxyClientSocketPool::histograms() const { |
469 return base_.histograms(); | 469 return base_.histograms(); |
470 } | 470 } |
471 | 471 |
472 } // namespace net | 472 } // namespace net |
OLD | NEW |