| 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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 return ERR_IO_PENDING; | 362 return ERR_IO_PENDING; |
| 363 } | 363 } |
| 364 | 364 |
| 365 switch (result) { | 365 switch (result) { |
| 366 case ERR_PROXY_AUTH_REQUESTED: | 366 case ERR_PROXY_AUTH_REQUESTED: |
| 367 { | 367 { |
| 368 DCHECK(connection_.get()); | 368 DCHECK(connection_.get()); |
| 369 DCHECK(connection_->socket()); | 369 DCHECK(connection_->socket()); |
| 370 DCHECK(establishing_tunnel_); | 370 DCHECK(establishing_tunnel_); |
| 371 | 371 |
| 372 ProxyClientSocket* proxy_socket = | 372 HttpProxyClientSocket* http_proxy_socket = |
| 373 static_cast<ProxyClientSocket*>(connection_->socket()); | 373 static_cast<HttpProxyClientSocket*>(connection_->socket()); |
| 374 const HttpResponseInfo* tunnel_auth_response = | 374 const HttpResponseInfo* tunnel_auth_response = |
| 375 proxy_socket->GetConnectResponseInfo(); | 375 http_proxy_socket->GetConnectResponseInfo(); |
| 376 | 376 |
| 377 next_state_ = STATE_WAITING_USER_ACTION; | 377 next_state_ = STATE_WAITING_USER_ACTION; |
| 378 MessageLoop::current()->PostTask( | 378 MessageLoop::current()->PostTask( |
| 379 FROM_HERE, | 379 FROM_HERE, |
| 380 base::Bind( | 380 base::Bind( |
| 381 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback, | 381 &HttpStreamFactoryImpl::Job::OnNeedsProxyAuthCallback, |
| 382 ptr_factory_.GetWeakPtr(), | 382 ptr_factory_.GetWeakPtr(), |
| 383 *tunnel_auth_response, | 383 *tunnel_auth_response, |
| 384 proxy_socket->auth_controller())); | 384 http_proxy_socket->auth_controller())); |
| 385 } | 385 } |
| 386 return ERR_IO_PENDING; | 386 return ERR_IO_PENDING; |
| 387 | 387 |
| 388 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: | 388 case ERR_SSL_CLIENT_AUTH_CERT_NEEDED: |
| 389 MessageLoop::current()->PostTask( | 389 MessageLoop::current()->PostTask( |
| 390 FROM_HERE, | 390 FROM_HERE, |
| 391 base::Bind( | 391 base::Bind( |
| 392 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback, | 392 &HttpStreamFactoryImpl::Job::OnNeedsClientAuthCallback, |
| 393 ptr_factory_.GetWeakPtr(), | 393 ptr_factory_.GetWeakPtr(), |
| 394 connection_->ssl_error_response_info().cert_request_info)); | 394 connection_->ssl_error_response_info().cert_request_info)); |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 if (result < 0) | 891 if (result < 0) |
| 892 return result; | 892 return result; |
| 893 | 893 |
| 894 session_->proxy_service()->ReportSuccess(proxy_info_); | 894 session_->proxy_service()->ReportSuccess(proxy_info_); |
| 895 next_state_ = STATE_NONE; | 895 next_state_ = STATE_NONE; |
| 896 return OK; | 896 return OK; |
| 897 } | 897 } |
| 898 | 898 |
| 899 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuth() { | 899 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuth() { |
| 900 next_state_ = STATE_RESTART_TUNNEL_AUTH_COMPLETE; | 900 next_state_ = STATE_RESTART_TUNNEL_AUTH_COMPLETE; |
| 901 ProxyClientSocket* proxy_socket = | 901 HttpProxyClientSocket* http_proxy_socket = |
| 902 static_cast<ProxyClientSocket*>(connection_->socket()); | 902 static_cast<HttpProxyClientSocket*>(connection_->socket()); |
| 903 return proxy_socket->RestartWithAuth(&io_callback_); | 903 return http_proxy_socket->RestartWithAuth(&io_callback_); |
| 904 } | 904 } |
| 905 | 905 |
| 906 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuthComplete(int result) { | 906 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuthComplete(int result) { |
| 907 if (result == ERR_PROXY_AUTH_REQUESTED) | 907 if (result == ERR_PROXY_AUTH_REQUESTED) |
| 908 return result; | 908 return result; |
| 909 | 909 |
| 910 if (result == OK) { | 910 if (result == OK) { |
| 911 // Now that we've got the ProxyClientSocket prepared to restart. We have | 911 // Now that we've got the HttpProxyClientSocket connected. We have |
| 912 // to release it as an idle socket into the pool and start the connection | 912 // to release it as an idle socket into the pool and start the connection |
| 913 // process from the beginning. Trying to pass it in with the | 913 // process from the beginning. Trying to pass it in with the |
| 914 // SSLSocketParams might cause a deadlock since params are dispatched | 914 // SSLSocketParams might cause a deadlock since params are dispatched |
| 915 // interchangeably. This request won't necessarily get this http proxy | 915 // interchangeably. This request won't necessarily get this http proxy |
| 916 // socket, but there will be forward progress. | 916 // socket, but there will be forward progress. |
| 917 establishing_tunnel_ = false; | 917 establishing_tunnel_ = false; |
| 918 ReturnToStateInitConnection(!connection_->socket()->IsConnectedAndIdle()); | 918 ReturnToStateInitConnection(false /* do not close connection */); |
| 919 return OK; | 919 return OK; |
| 920 } | 920 } |
| 921 | 921 |
| 922 return ReconsiderProxyAfterError(result); | 922 return ReconsiderProxyAfterError(result); |
| 923 } | 923 } |
| 924 | 924 |
| 925 void HttpStreamFactoryImpl::Job::ReturnToStateInitConnection( | 925 void HttpStreamFactoryImpl::Job::ReturnToStateInitConnection( |
| 926 bool close_connection) { | 926 bool close_connection) { |
| 927 if (close_connection && connection_->socket()) | 927 if (close_connection && connection_->socket()) |
| 928 connection_->socket()->Disconnect(); | 928 connection_->socket()->Disconnect(); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 if (IsPreconnecting() || !request_) { | 1144 if (IsPreconnecting() || !request_) { |
| 1145 return false; | 1145 return false; |
| 1146 } | 1146 } |
| 1147 if (using_ssl_) { | 1147 if (using_ssl_) { |
| 1148 return false; | 1148 return false; |
| 1149 } | 1149 } |
| 1150 return request_info_.method == "GET" || request_info_.method == "HEAD"; | 1150 return request_info_.method == "GET" || request_info_.method == "HEAD"; |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 } // namespace net | 1153 } // namespace net |
| OLD | NEW |