| 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/bind_helpers.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 11 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "net/base/connection_type_histograms.h" | 15 #include "net/base/connection_type_histograms.h" |
| 15 #include "net/base/net_log.h" | 16 #include "net/base/net_log.h" |
| 16 #include "net/base/net_util.h" | 17 #include "net/base/net_util.h" |
| 17 #include "net/base/ssl_cert_request_info.h" | 18 #include "net/base/ssl_cert_request_info.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 const HttpRequestInfo& request_info, | 108 const HttpRequestInfo& request_info, |
| 108 const SSLConfig& server_ssl_config, | 109 const SSLConfig& server_ssl_config, |
| 109 const SSLConfig& proxy_ssl_config, | 110 const SSLConfig& proxy_ssl_config, |
| 110 const BoundNetLog& net_log) | 111 const BoundNetLog& net_log) |
| 111 : request_(NULL), | 112 : request_(NULL), |
| 112 request_info_(request_info), | 113 request_info_(request_info), |
| 113 server_ssl_config_(server_ssl_config), | 114 server_ssl_config_(server_ssl_config), |
| 114 proxy_ssl_config_(proxy_ssl_config), | 115 proxy_ssl_config_(proxy_ssl_config), |
| 115 net_log_(BoundNetLog::Make(net_log.net_log(), | 116 net_log_(BoundNetLog::Make(net_log.net_log(), |
| 116 NetLog::SOURCE_HTTP_STREAM_JOB)), | 117 NetLog::SOURCE_HTTP_STREAM_JOB)), |
| 117 ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_(this, &Job::OnIOComplete)), | 118 ALLOW_THIS_IN_INITIALIZER_LIST(old_io_callback_( |
| 119 this, &Job::OnIOComplete)), |
| 120 ALLOW_THIS_IN_INITIALIZER_LIST(io_callback_( |
| 121 base::Bind(&Job::OnIOComplete, base::Unretained(this)))), |
| 118 connection_(new ClientSocketHandle), | 122 connection_(new ClientSocketHandle), |
| 119 session_(session), | 123 session_(session), |
| 120 stream_factory_(stream_factory), | 124 stream_factory_(stream_factory), |
| 121 next_state_(STATE_NONE), | 125 next_state_(STATE_NONE), |
| 122 pac_request_(NULL), | 126 pac_request_(NULL), |
| 123 blocking_job_(NULL), | 127 blocking_job_(NULL), |
| 124 dependent_job_(NULL), | 128 dependent_job_(NULL), |
| 125 using_ssl_(false), | 129 using_ssl_(false), |
| 126 using_spdy_(false), | 130 using_spdy_(false), |
| 127 force_spdy_always_(HttpStreamFactory::force_spdy_always()), | 131 force_spdy_always_(HttpStreamFactory::force_spdy_always()), |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 DCHECK(!pac_request_); | 569 DCHECK(!pac_request_); |
| 566 | 570 |
| 567 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 571 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
| 568 | 572 |
| 569 if (request_info_.load_flags & LOAD_BYPASS_PROXY) { | 573 if (request_info_.load_flags & LOAD_BYPASS_PROXY) { |
| 570 proxy_info_.UseDirect(); | 574 proxy_info_.UseDirect(); |
| 571 return OK; | 575 return OK; |
| 572 } | 576 } |
| 573 | 577 |
| 574 return session_->proxy_service()->ResolveProxy( | 578 return session_->proxy_service()->ResolveProxy( |
| 575 request_info_.url, &proxy_info_, &io_callback_, &pac_request_, | 579 request_info_.url, &proxy_info_, io_callback_, &pac_request_, net_log_); |
| 576 net_log_); | |
| 577 } | 580 } |
| 578 | 581 |
| 579 int HttpStreamFactoryImpl::Job::DoResolveProxyComplete(int result) { | 582 int HttpStreamFactoryImpl::Job::DoResolveProxyComplete(int result) { |
| 580 pac_request_ = NULL; | 583 pac_request_ = NULL; |
| 581 | 584 |
| 582 if (result == OK) { | 585 if (result == OK) { |
| 583 // Remove unsupported proxies from the list. | 586 // Remove unsupported proxies from the list. |
| 584 proxy_info_.RemoveProxiesWithoutScheme( | 587 proxy_info_.RemoveProxiesWithoutScheme( |
| 585 ProxyServer::SCHEME_DIRECT | | 588 ProxyServer::SCHEME_DIRECT | |
| 586 ProxyServer::SCHEME_HTTP | ProxyServer::SCHEME_HTTPS | | 589 ProxyServer::SCHEME_HTTP | ProxyServer::SCHEME_HTTPS | |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 session_, | 711 session_, |
| 709 proxy_info_, | 712 proxy_info_, |
| 710 ShouldForceSpdySSL(), | 713 ShouldForceSpdySSL(), |
| 711 want_spdy_over_npn, | 714 want_spdy_over_npn, |
| 712 server_ssl_config_, | 715 server_ssl_config_, |
| 713 proxy_ssl_config_, | 716 proxy_ssl_config_, |
| 714 net_log_, | 717 net_log_, |
| 715 num_streams_); | 718 num_streams_); |
| 716 } else { | 719 } else { |
| 717 return InitSocketHandleForHttpRequest( | 720 return InitSocketHandleForHttpRequest( |
| 718 origin_url_, | 721 origin_url_, request_info_.extra_headers, request_info_.load_flags, |
| 719 request_info_.extra_headers, | 722 request_info_.priority, session_, proxy_info_, ShouldForceSpdySSL(), |
| 720 request_info_.load_flags, | 723 want_spdy_over_npn, server_ssl_config_, proxy_ssl_config_, net_log_, |
| 721 request_info_.priority, | 724 connection_.get(), io_callback_); |
| 722 session_, | |
| 723 proxy_info_, | |
| 724 ShouldForceSpdySSL(), | |
| 725 want_spdy_over_npn, | |
| 726 server_ssl_config_, | |
| 727 proxy_ssl_config_, | |
| 728 net_log_, | |
| 729 connection_.get(), | |
| 730 &io_callback_); | |
| 731 } | 725 } |
| 732 } | 726 } |
| 733 | 727 |
| 734 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { | 728 int HttpStreamFactoryImpl::Job::DoInitConnectionComplete(int result) { |
| 735 if (IsPreconnecting()) { | 729 if (IsPreconnecting()) { |
| 736 DCHECK_EQ(OK, result); | 730 DCHECK_EQ(OK, result); |
| 737 return OK; | 731 return OK; |
| 738 } | 732 } |
| 739 | 733 |
| 740 // TODO(willchan): Make this a bit more exact. Maybe there are recoverable | 734 // TODO(willchan): Make this a bit more exact. Maybe there are recoverable |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 | 943 |
| 950 session_->proxy_service()->ReportSuccess(proxy_info_); | 944 session_->proxy_service()->ReportSuccess(proxy_info_); |
| 951 next_state_ = STATE_NONE; | 945 next_state_ = STATE_NONE; |
| 952 return OK; | 946 return OK; |
| 953 } | 947 } |
| 954 | 948 |
| 955 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuth() { | 949 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuth() { |
| 956 next_state_ = STATE_RESTART_TUNNEL_AUTH_COMPLETE; | 950 next_state_ = STATE_RESTART_TUNNEL_AUTH_COMPLETE; |
| 957 HttpProxyClientSocket* http_proxy_socket = | 951 HttpProxyClientSocket* http_proxy_socket = |
| 958 static_cast<HttpProxyClientSocket*>(connection_->socket()); | 952 static_cast<HttpProxyClientSocket*>(connection_->socket()); |
| 959 return http_proxy_socket->RestartWithAuth(&io_callback_); | 953 return http_proxy_socket->RestartWithAuth(&old_io_callback_); |
| 960 } | 954 } |
| 961 | 955 |
| 962 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuthComplete(int result) { | 956 int HttpStreamFactoryImpl::Job::DoRestartTunnelAuthComplete(int result) { |
| 963 if (result == ERR_PROXY_AUTH_REQUESTED) | 957 if (result == ERR_PROXY_AUTH_REQUESTED) |
| 964 return result; | 958 return result; |
| 965 | 959 |
| 966 if (result == OK) { | 960 if (result == OK) { |
| 967 // Now that we've got the HttpProxyClientSocket connected. We have | 961 // Now that we've got the HttpProxyClientSocket connected. We have |
| 968 // to release it as an idle socket into the pool and start the connection | 962 // to release it as an idle socket into the pool and start the connection |
| 969 // process from the beginning. Trying to pass it in with the | 963 // process from the beginning. Trying to pass it in with the |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 if (request_info_.load_flags & LOAD_BYPASS_PROXY) { | 1077 if (request_info_.load_flags & LOAD_BYPASS_PROXY) { |
| 1084 return error; | 1078 return error; |
| 1085 } | 1079 } |
| 1086 | 1080 |
| 1087 if (proxy_info_.is_https() && proxy_ssl_config_.send_client_cert) { | 1081 if (proxy_info_.is_https() && proxy_ssl_config_.send_client_cert) { |
| 1088 session_->ssl_client_auth_cache()->Remove( | 1082 session_->ssl_client_auth_cache()->Remove( |
| 1089 proxy_info_.proxy_server().host_port_pair().ToString()); | 1083 proxy_info_.proxy_server().host_port_pair().ToString()); |
| 1090 } | 1084 } |
| 1091 | 1085 |
| 1092 int rv = session_->proxy_service()->ReconsiderProxyAfterError( | 1086 int rv = session_->proxy_service()->ReconsiderProxyAfterError( |
| 1093 request_info_.url, &proxy_info_, &io_callback_, &pac_request_, | 1087 request_info_.url, &proxy_info_, io_callback_, &pac_request_, net_log_); |
| 1094 net_log_); | |
| 1095 if (rv == OK || rv == ERR_IO_PENDING) { | 1088 if (rv == OK || rv == ERR_IO_PENDING) { |
| 1096 // If the error was during connection setup, there is no socket to | 1089 // If the error was during connection setup, there is no socket to |
| 1097 // disconnect. | 1090 // disconnect. |
| 1098 if (connection_->socket()) | 1091 if (connection_->socket()) |
| 1099 connection_->socket()->Disconnect(); | 1092 connection_->socket()->Disconnect(); |
| 1100 connection_->Reset(); | 1093 connection_->Reset(); |
| 1101 if (request_) | 1094 if (request_) |
| 1102 request_->RemoveRequestFromSpdySessionRequestMap(); | 1095 request_->RemoveRequestFromSpdySessionRequestMap(); |
| 1103 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; | 1096 next_state_ = STATE_RESOLVE_PROXY_COMPLETE; |
| 1104 } else { | 1097 } else { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 return false; | 1197 return false; |
| 1205 } | 1198 } |
| 1206 if (request_info_.method != "GET" && request_info_.method != "HEAD") { | 1199 if (request_info_.method != "GET" && request_info_.method != "HEAD") { |
| 1207 return false; | 1200 return false; |
| 1208 } | 1201 } |
| 1209 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining( | 1202 return stream_factory_->http_pipelined_host_pool_.IsHostEligibleForPipelining( |
| 1210 origin_); | 1203 origin_); |
| 1211 } | 1204 } |
| 1212 | 1205 |
| 1213 } // namespace net | 1206 } // namespace net |
| OLD | NEW |