| 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_stream_factory_impl_job.h" | 5 #include "net/http/http_stream_factory_impl_job.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 return ERR_IO_PENDING; | 399 return ERR_IO_PENDING; |
| 400 } | 400 } |
| 401 | 401 |
| 402 switch (result) { | 402 switch (result) { |
| 403 case ERR_PROXY_AUTH_REQUESTED: | 403 case ERR_PROXY_AUTH_REQUESTED: |
| 404 { | 404 { |
| 405 DCHECK(connection_.get()); | 405 DCHECK(connection_.get()); |
| 406 DCHECK(connection_->socket()); | 406 DCHECK(connection_->socket()); |
| 407 DCHECK(establishing_tunnel_); | 407 DCHECK(establishing_tunnel_); |
| 408 | 408 |
| 409 ProxyClientSocket* proxy_socket = | 409 HttpProxyClientSocket* http_proxy_socket = |
| 410 static_cast<ProxyClientSocket*>(connection_->socket()); | 410 static_cast<HttpProxyClientSocket*>(connection_->socket()); |
| 411 const HttpResponseInfo* tunnel_auth_response = | 411 const HttpResponseInfo* tunnel_auth_response = |
| 412 proxy_socket->GetConnectResponseInfo(); | 412 http_proxy_socket->GetConnectResponseInfo(); |
| 413 | 413 |
| 414 next_state_ = STATE_WAITING_USER_ACTION; | 414 next_state_ = STATE_WAITING_USER_ACTION; |
| 415 MessageLoop::current()->PostTask( | 415 MessageLoop::current()->PostTask( |
| 416 FROM_HERE, | 416 FROM_HERE, |
| 417 base::Bind( | 417 base::Bind( |
| 418 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback, | 418 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback, |
| 419 ptr_factory_.GetWeakPtr(), | 419 ptr_factory_.GetWeakPtr(), |
| 420 *tunnel_auth_response, | 420 *tunnel_auth_response, |
| 421 proxy_socket->auth_controller())); | 421 http_proxy_socket->auth_controller())); |
| 422 } | 422 } |
| 423 return ERR_IO_PENDING; | 423 return ERR_IO_PENDING; |
| 424 | 424 |
| 425 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: | 425 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: |
| 426 MessageLoop::current()->PostTask( | 426 MessageLoop::current()->PostTask( |
| 427 FROM_HERE, | 427 FROM_HERE, |
| 428 base::Bind( | 428 base::Bind( |
| 429 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback, | 429 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback, |
| 430 ptr_factory_.GetWeakPtr(), | 430 ptr_factory_.GetWeakPtr(), |
| 431 connection_->ssl_error_response_info().cert_request_info)); | 431 connection_->ssl_error_response_info().cert_request_info)); |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 if (result < 0) | 935 if (result < 0) |
| 936 return result; | 936 return result; |
| 937 | 937 |
| 938 session_->proxy_service()->ReportSuccess(proxy_info_); | 938 session_->proxy_service()->ReportSuccess(proxy_info_); |
| 939 next_state_ = STATE_NONE; | 939 next_state_ = STATE_NONE; |
| 940 return OK; | 940 return OK; |
| 941 } | 941 } |
| 942 | 942 |
| 943 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuth() { | 943 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuth() { |
| 944 next_state_ = STATE_RESTART_TUNNEL_AUTH_COMPLETE; | 944 next_state_ = STATE_RESTART_TUNNEL_AUTH_COMPLETE; |
| 945 ProxyClientSocket* proxy_socket = | 945 HttpProxyClientSocket* http_proxy_socket = |
| 946 static_cast<ProxyClientSocket*>(connection_->socket()); | 946 static_cast<HttpProxyClientSocket*>(connection_->socket()); |
| 947 return proxy_socket->RestartWithAuth(&io_callback_); | 947 return http_proxy_socket->RestartWithAuth(&io_callback_); |
| 948 } | 948 } |
| 949 | 949 |
| 950 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuthComplete(int result) { | 950 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuthComplete(int result) { |
| 951 if (result == ERR_PROXY_AUTH_REQUESTED) | 951 if (result == ERR_PROXY_AUTH_REQUESTED) |
| 952 return result; | 952 return result; |
| 953 | 953 |
| 954 if (result == OK) { | 954 if (result == OK) { |
| 955 // Now that we've got the ProxyClientSocket prepared to restart. We have | 955 // Now that we've got the HttpProxyClientSocket connected. We have |
| 956 // to release it as an idle socket into the pool and start the connection | 956 // to release it as an idle socket into the pool and start the connection |
| 957 // process from the beginning. Trying to pass it in with the | 957 // process from the beginning. Trying to pass it in with the |
| 958 // SSLSocketParams might cause a deadlock since params are dispatched | 958 // SSLSocketParams might cause a deadlock since params are dispatched |
| 959 // interchangeably. This request won't necessarily get this http proxy | 959 // interchangeably. This request won't necessarily get this http proxy |
| 960 // socket, but there will be forward progress. | 960 // socket, but there will be forward progress. |
| 961 establishing_tunnel_ = false; | 961 establishing_tunnel_ = false; |
| 962 ReturnToStateInitConnection(!connection_->socket()->IsConnectedAndIdle()); | 962 ReturnToStateInitConnection(false /* do not close connection */); |
| 963 return OK; | 963 return OK; |
| 964 } | 964 } |
| 965 | 965 |
| 966 return ReconsiderProxyAfterError(result); | 966 return ReconsiderProxyAfterError(result); |
| 967 } | 967 } |
| 968 | 968 |
| 969 void HttpStreamFactoryImpl::Job::ReturnToStateInitConnection( | 969 void HttpStreamFactoryImpl::Job::ReturnToStateInitConnection( |
| 970 bool close_connection) { | 970 bool close_connection) { |
| 971 if (close_connection && connection_->socket()) | 971 if (close_connection && connection_->socket()) |
| 972 connection_->socket()->Disconnect(); | 972 connection_->socket()->Disconnect(); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 return false; | 1192 return false; |
| 1193 } | 1193 } |
| 1194 if (request_info_.method != "GET" && request_info_.method != "HEAD") { | 1194 if (request_info_.method != "GET" && request_info_.method != "HEAD") { |
| 1195 return false; | 1195 return false; |
| 1196 } | 1196 } |
| 1197 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining( | 1197 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining( |
| 1198 origin_); | 1198 origin_); |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 } // namespace net | 1201 } // namespace net |
| OLD | NEW |