| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 HostResolver* host_resolver, | 77 HostResolver* host_resolver, |
| 78 Delegate* delegate, | 78 Delegate* delegate, |
| 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_(this, &HttpProxyConnectJob::OnIOComplete)), | 87 callback_(base::Bind(&HttpProxyConnectJob::OnIOComplete, |
| 88 base::Unretained(this)))), |
| 89 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 90 callback_old_(this, &HttpProxyConnectJob::OnIOComplete)), |
| 88 using_spdy_(false) { | 91 using_spdy_(false) { |
| 89 } | 92 } |
| 90 | 93 |
| 91 HttpProxyConnectJob::~HttpProxyConnectJob() {} | 94 HttpProxyConnectJob::~HttpProxyConnectJob() {} |
| 92 | 95 |
| 93 LoadState HttpProxyConnectJob::GetLoadState() const { | 96 LoadState HttpProxyConnectJob::GetLoadState() const { |
| 94 switch (next_state_) { | 97 switch (next_state_) { |
| 95 case STATE_TCP_CONNECT: | 98 case STATE_TCP_CONNECT: |
| 96 case STATE_TCP_CONNECT_COMPLETE: | 99 case STATE_TCP_CONNECT_COMPLETE: |
| 97 case STATE_SSL_CONNECT: | 100 case STATE_SSL_CONNECT: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 return rv; | 170 return rv; |
| 168 } | 171 } |
| 169 | 172 |
| 170 int HttpProxyConnectJob::DoTransportConnect() { | 173 int HttpProxyConnectJob::DoTransportConnect() { |
| 171 next_state_ = STATE_TCP_CONNECT_COMPLETE; | 174 next_state_ = STATE_TCP_CONNECT_COMPLETE; |
| 172 transport_socket_handle_.reset(new ClientSocketHandle()); | 175 transport_socket_handle_.reset(new ClientSocketHandle()); |
| 173 return transport_socket_handle_->Init( | 176 return transport_socket_handle_->Init( |
| 174 group_name(), | 177 group_name(), |
| 175 params_->transport_params(), | 178 params_->transport_params(), |
| 176 params_->transport_params()->destination().priority(), | 179 params_->transport_params()->destination().priority(), |
| 177 &callback_, | 180 &callback_old_, |
| 178 transport_pool_, | 181 transport_pool_, |
| 179 net_log()); | 182 net_log()); |
| 180 } | 183 } |
| 181 | 184 |
| 182 int HttpProxyConnectJob::DoTransportConnectComplete(int result) { | 185 int HttpProxyConnectJob::DoTransportConnectComplete(int result) { |
| 183 if (result != OK) | 186 if (result != OK) |
| 184 return ERR_PROXY_CONNECTION_FAILED; | 187 return ERR_PROXY_CONNECTION_FAILED; |
| 185 | 188 |
| 186 // Reset the timer to just the length of time allowed for HttpProxy handshake | 189 // Reset the timer to just the length of time allowed for HttpProxy handshake |
| 187 // so that a fast TCP connection plus a slow HttpProxy failure doesn't take | 190 // so that a fast TCP connection plus a slow HttpProxy failure doesn't take |
| (...skipping 13 matching lines...) Expand all Loading... |
| 201 using_spdy_ = true; | 204 using_spdy_ = true; |
| 202 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM; | 205 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM; |
| 203 return OK; | 206 return OK; |
| 204 } | 207 } |
| 205 } | 208 } |
| 206 next_state_ = STATE_SSL_CONNECT_COMPLETE; | 209 next_state_ = STATE_SSL_CONNECT_COMPLETE; |
| 207 transport_socket_handle_.reset(new ClientSocketHandle()); | 210 transport_socket_handle_.reset(new ClientSocketHandle()); |
| 208 return transport_socket_handle_->Init( | 211 return transport_socket_handle_->Init( |
| 209 group_name(), params_->ssl_params(), | 212 group_name(), params_->ssl_params(), |
| 210 params_->ssl_params()->transport_params()->destination().priority(), | 213 params_->ssl_params()->transport_params()->destination().priority(), |
| 211 &callback_, ssl_pool_, net_log()); | 214 &callback_old_, ssl_pool_, net_log()); |
| 212 } | 215 } |
| 213 | 216 |
| 214 int HttpProxyConnectJob::DoSSLConnectComplete(int result) { | 217 int HttpProxyConnectJob::DoSSLConnectComplete(int result) { |
| 215 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { | 218 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) { |
| 216 error_response_info_ = transport_socket_handle_->ssl_error_response_info(); | 219 error_response_info_ = transport_socket_handle_->ssl_error_response_info(); |
| 217 DCHECK(error_response_info_.cert_request_info.get()); | 220 DCHECK(error_response_info_.cert_request_info.get()); |
| 218 error_response_info_.cert_request_info->is_proxy = true; | 221 error_response_info_.cert_request_info->is_proxy = true; |
| 219 return result; | 222 return result; |
| 220 } | 223 } |
| 221 if (IsCertificateError(result)) { | 224 if (IsCertificateError(result)) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 new HttpProxyClientSocket(transport_socket_handle_.release(), | 267 new HttpProxyClientSocket(transport_socket_handle_.release(), |
| 265 params_->request_url(), | 268 params_->request_url(), |
| 266 params_->user_agent(), | 269 params_->user_agent(), |
| 267 params_->endpoint(), | 270 params_->endpoint(), |
| 268 proxy_server, | 271 proxy_server, |
| 269 params_->http_auth_cache(), | 272 params_->http_auth_cache(), |
| 270 params_->http_auth_handler_factory(), | 273 params_->http_auth_handler_factory(), |
| 271 params_->tunnel(), | 274 params_->tunnel(), |
| 272 using_spdy_, | 275 using_spdy_, |
| 273 params_->ssl_params() != NULL)); | 276 params_->ssl_params() != NULL)); |
| 274 return transport_socket_->Connect(&callback_); | 277 return transport_socket_->Connect(callback_); |
| 275 } | 278 } |
| 276 | 279 |
| 277 int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) { | 280 int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) { |
| 278 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED || | 281 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED || |
| 279 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { | 282 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { |
| 280 set_socket(transport_socket_.release()); | 283 set_socket(transport_socket_.release()); |
| 281 } | 284 } |
| 282 | 285 |
| 283 return result; | 286 return result; |
| 284 } | 287 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 305 pair, transport_socket_handle_.release(), | 308 pair, transport_socket_handle_.release(), |
| 306 net_log(), OK, &spdy_session, /*using_ssl_*/ true); | 309 net_log(), OK, &spdy_session, /*using_ssl_*/ true); |
| 307 if (rv < 0) | 310 if (rv < 0) |
| 308 return rv; | 311 return rv; |
| 309 } | 312 } |
| 310 | 313 |
| 311 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE; | 314 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM_COMPLETE; |
| 312 return spdy_session->CreateStream(params_->request_url(), | 315 return spdy_session->CreateStream(params_->request_url(), |
| 313 params_->destination().priority(), | 316 params_->destination().priority(), |
| 314 &spdy_stream_, spdy_session->net_log(), | 317 &spdy_stream_, spdy_session->net_log(), |
| 315 &callback_); | 318 &callback_old_); |
| 316 } | 319 } |
| 317 | 320 |
| 318 int HttpProxyConnectJob::DoSpdyProxyCreateStreamComplete(int result) { | 321 int HttpProxyConnectJob::DoSpdyProxyCreateStreamComplete(int result) { |
| 319 if (result < 0) | 322 if (result < 0) |
| 320 return result; | 323 return result; |
| 321 | 324 |
| 322 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; | 325 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; |
| 323 transport_socket_.reset( | 326 transport_socket_.reset( |
| 324 new SpdyProxyClientSocket(spdy_stream_, | 327 new SpdyProxyClientSocket(spdy_stream_, |
| 325 params_->user_agent(), | 328 params_->user_agent(), |
| 326 params_->endpoint(), | 329 params_->endpoint(), |
| 327 params_->request_url(), | 330 params_->request_url(), |
| 328 params_->destination().host_port_pair(), | 331 params_->destination().host_port_pair(), |
| 329 params_->http_auth_cache(), | 332 params_->http_auth_cache(), |
| 330 params_->http_auth_handler_factory())); | 333 params_->http_auth_handler_factory())); |
| 331 return transport_socket_->Connect(&callback_); | 334 return transport_socket_->Connect(callback_); |
| 332 } | 335 } |
| 333 | 336 |
| 334 int HttpProxyConnectJob::ConnectInternal() { | 337 int HttpProxyConnectJob::ConnectInternal() { |
| 335 if (params_->transport_params()) | 338 if (params_->transport_params()) |
| 336 next_state_ = STATE_TCP_CONNECT; | 339 next_state_ = STATE_TCP_CONNECT; |
| 337 else | 340 else |
| 338 next_state_ = STATE_SSL_CONNECT; | 341 next_state_ = STATE_SSL_CONNECT; |
| 339 return DoLoop(OK); | 342 return DoLoop(OK); |
| 340 } | 343 } |
| 341 | 344 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 return base_.histograms(); | 511 return base_.histograms(); |
| 509 } | 512 } |
| 510 | 513 |
| 511 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { | 514 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { |
| 512 if (base_.CloseOneIdleSocket()) | 515 if (base_.CloseOneIdleSocket()) |
| 513 return true; | 516 return true; |
| 514 return base_.CloseOneIdleConnectionInLayeredPool(); | 517 return base_.CloseOneIdleConnectionInLayeredPool(); |
| 515 } | 518 } |
| 516 | 519 |
| 517 } // namespace net | 520 } // namespace net |
| OLD | NEW |