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