Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: net/http/http_stream_factory_impl_job.cc

Issue 2814633003: Extract Proxy Resolution out of HttpStreamFactoryImpl::Job (Closed)
Patch Set: rebased Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // stream. 141 // stream.
142 std::unique_ptr<base::Value> NetLogHttpStreamProtoCallback( 142 std::unique_ptr<base::Value> NetLogHttpStreamProtoCallback(
143 NextProto negotiated_protocol, 143 NextProto negotiated_protocol,
144 NetLogCaptureMode /* capture_mode */) { 144 NetLogCaptureMode /* capture_mode */) {
145 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 145 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
146 146
147 dict->SetString("proto", NextProtoToString(negotiated_protocol)); 147 dict->SetString("proto", NextProtoToString(negotiated_protocol));
148 return std::move(dict); 148 return std::move(dict);
149 } 149 }
150 150
151 // Returns parameters associated with the proxy resolution.
152 std::unique_ptr<base::Value> NetLogHttpStreamJobProxyServerResolved(
153 const ProxyServer& proxy_server,
154 NetLogCaptureMode /* capture_mode */) {
155 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
156
157 dict->SetString("proxy_server", proxy_server.is_valid()
158 ? proxy_server.ToPacString()
159 : std::string());
160 return std::move(dict);
161 }
162
163 HttpStreamFactoryImpl::Job::Job(Delegate* delegate, 151 HttpStreamFactoryImpl::Job::Job(Delegate* delegate,
164 JobType job_type, 152 JobType job_type,
165 HttpNetworkSession* session, 153 HttpNetworkSession* session,
166 const HttpRequestInfo& request_info, 154 const HttpRequestInfo& request_info,
167 RequestPriority priority, 155 RequestPriority priority,
156 const ProxyInfo& proxy_info,
168 const SSLConfig& server_ssl_config, 157 const SSLConfig& server_ssl_config,
169 const SSLConfig& proxy_ssl_config, 158 const SSLConfig& proxy_ssl_config,
170 HostPortPair destination, 159 HostPortPair destination,
171 GURL origin_url, 160 GURL origin_url,
172 bool enable_ip_based_pooling, 161 bool enable_ip_based_pooling,
173 NetLog* net_log) 162 NetLog* net_log)
174 : Job(delegate, 163 : Job(delegate,
175 job_type, 164 job_type,
176 session, 165 session,
177 request_info, 166 request_info,
178 priority, 167 priority,
168 proxy_info,
179 server_ssl_config, 169 server_ssl_config,
180 proxy_ssl_config, 170 proxy_ssl_config,
181 destination, 171 destination,
182 origin_url, 172 origin_url,
183 AlternativeService(), 173 AlternativeService(),
184 ProxyServer(), 174 ProxyServer(),
185 enable_ip_based_pooling, 175 enable_ip_based_pooling,
186 net_log) {} 176 net_log) {}
187 177
188 HttpStreamFactoryImpl::Job::Job(Delegate* delegate, 178 HttpStreamFactoryImpl::Job::Job(Delegate* delegate,
189 JobType job_type, 179 JobType job_type,
190 HttpNetworkSession* session, 180 HttpNetworkSession* session,
191 const HttpRequestInfo& request_info, 181 const HttpRequestInfo& request_info,
192 RequestPriority priority, 182 RequestPriority priority,
183 const ProxyInfo& proxy_info,
193 const SSLConfig& server_ssl_config, 184 const SSLConfig& server_ssl_config,
194 const SSLConfig& proxy_ssl_config, 185 const SSLConfig& proxy_ssl_config,
195 HostPortPair destination, 186 HostPortPair destination,
196 GURL origin_url, 187 GURL origin_url,
197 AlternativeService alternative_service, 188 AlternativeService alternative_service,
198 const ProxyServer& alternative_proxy_server, 189 const ProxyServer& alternative_proxy_server,
199 bool enable_ip_based_pooling, 190 bool enable_ip_based_pooling,
200 NetLog* net_log) 191 NetLog* net_log)
201 : request_info_(request_info), 192 : request_info_(request_info),
202 priority_(priority), 193 priority_(priority),
194 proxy_info_(proxy_info),
203 server_ssl_config_(server_ssl_config), 195 server_ssl_config_(server_ssl_config),
204 proxy_ssl_config_(proxy_ssl_config), 196 proxy_ssl_config_(proxy_ssl_config),
205 net_log_( 197 net_log_(
206 NetLogWithSource::Make(net_log, NetLogSourceType::HTTP_STREAM_JOB)), 198 NetLogWithSource::Make(net_log, NetLogSourceType::HTTP_STREAM_JOB)),
207 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))), 199 io_callback_(base::Bind(&Job::OnIOComplete, base::Unretained(this))),
208 connection_(new ClientSocketHandle), 200 connection_(new ClientSocketHandle),
209 session_(session), 201 session_(session),
210 state_(STATE_NONE), 202 state_(STATE_NONE),
211 next_state_(STATE_NONE), 203 next_state_(STATE_NONE),
212 pac_request_(NULL),
213 destination_(destination), 204 destination_(destination),
214 origin_url_(origin_url), 205 origin_url_(origin_url),
215 alternative_service_(alternative_service), 206 alternative_service_(alternative_service),
216 alternative_proxy_server_(alternative_proxy_server), 207 alternative_proxy_server_(alternative_proxy_server),
217 enable_ip_based_pooling_(enable_ip_based_pooling), 208 enable_ip_based_pooling_(enable_ip_based_pooling),
218 delegate_(delegate), 209 delegate_(delegate),
219 job_type_(job_type), 210 job_type_(job_type),
220 using_ssl_(origin_url_.SchemeIs(url::kHttpsScheme) || 211 using_ssl_(origin_url_.SchemeIs(url::kHttpsScheme) ||
221 origin_url_.SchemeIs(url::kWssScheme)), 212 origin_url_.SchemeIs(url::kWssScheme)),
222 using_spdy_(false), 213 using_spdy_(false),
223 using_quic_(false), 214 using_quic_(false),
215 should_reconsider_proxy_(false),
224 quic_request_(session_->quic_stream_factory(), 216 quic_request_(session_->quic_stream_factory(),
225 session_->http_server_properties()), 217 session_->http_server_properties()),
226 using_existing_quic_session_(false), 218 using_existing_quic_session_(false),
227 establishing_tunnel_(false), 219 establishing_tunnel_(false),
228 was_alpn_negotiated_(false), 220 was_alpn_negotiated_(false),
229 negotiated_protocol_(kProtoUnknown), 221 negotiated_protocol_(kProtoUnknown),
230 num_streams_(0), 222 num_streams_(0),
231 spdy_session_direct_(false), 223 spdy_session_direct_(false),
232 stream_type_(HttpStreamRequest::BIDIRECTIONAL_STREAM), 224 stream_type_(HttpStreamRequest::BIDIRECTIONAL_STREAM),
233 ptr_factory_(this) { 225 ptr_factory_(this) {
(...skipping 29 matching lines...) Expand all
263 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB); 255 net_log_.EndEvent(NetLogEventType::HTTP_STREAM_JOB);
264 256
265 // When we're in a partially constructed state, waiting for the user to 257 // When we're in a partially constructed state, waiting for the user to
266 // provide certificate handling information or authentication, we can't reuse 258 // provide certificate handling information or authentication, we can't reuse
267 // this stream at all. 259 // this stream at all.
268 if (next_state_ == STATE_WAITING_USER_ACTION) { 260 if (next_state_ == STATE_WAITING_USER_ACTION) {
269 connection_->socket()->Disconnect(); 261 connection_->socket()->Disconnect();
270 connection_.reset(); 262 connection_.reset();
271 } 263 }
272 264
273 if (pac_request_)
274 session_->proxy_service()->CancelPacRequest(pac_request_);
275
276 // The stream could be in a partial state. It is not reusable. 265 // The stream could be in a partial state. It is not reusable.
277 if (stream_.get() && next_state_ != STATE_DONE) 266 if (stream_.get() && next_state_ != STATE_DONE)
278 stream_->Close(true /* not reusable */); 267 stream_->Close(true /* not reusable */);
279 } 268 }
280 269
281 void HttpStreamFactoryImpl::Job::Start( 270 void HttpStreamFactoryImpl::Job::Start(
282 HttpStreamRequest::StreamType stream_type) { 271 HttpStreamRequest::StreamType stream_type) {
283 stream_type_ = stream_type; 272 stream_type_ = stream_type;
284 StartInternal(); 273 StartInternal();
285 } 274 }
(...skipping 24 matching lines...) Expand all
310 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth() { 299 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth() {
311 DCHECK(establishing_tunnel_); 300 DCHECK(establishing_tunnel_);
312 next_state_ = STATE_RESTART_TUNNEL_AUTH; 301 next_state_ = STATE_RESTART_TUNNEL_AUTH;
313 stream_.reset(); 302 stream_.reset();
314 RunLoop(OK); 303 RunLoop(OK);
315 return ERR_IO_PENDING; 304 return ERR_IO_PENDING;
316 } 305 }
317 306
318 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const { 307 LoadState HttpStreamFactoryImpl::Job::GetLoadState() const {
319 switch (next_state_) { 308 switch (next_state_) {
320 case STATE_RESOLVE_PROXY_COMPLETE:
321 return session_->proxy_service()->GetLoadState(pac_request_);
322 case STATE_INIT_CONNECTION_COMPLETE: 309 case STATE_INIT_CONNECTION_COMPLETE:
323 case STATE_CREATE_STREAM_COMPLETE: 310 case STATE_CREATE_STREAM_COMPLETE:
324 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState(); 311 return using_quic_ ? LOAD_STATE_CONNECTING : connection_->GetLoadState();
325 default: 312 default:
326 return LOAD_STATE_IDLE; 313 return LOAD_STATE_IDLE;
327 } 314 }
328 } 315 }
329 316
330 void HttpStreamFactoryImpl::Job::Resume() { 317 void HttpStreamFactoryImpl::Job::Resume() {
331 DCHECK_EQ(job_type_, MAIN); 318 DCHECK_EQ(job_type_, MAIN);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 do { 667 do {
681 State state = next_state_; 668 State state = next_state_;
682 // Added to investigate crbug.com/711721. 669 // Added to investigate crbug.com/711721.
683 state_ = state; 670 state_ = state;
684 next_state_ = STATE_NONE; 671 next_state_ = STATE_NONE;
685 switch (state) { 672 switch (state) {
686 case STATE_START: 673 case STATE_START:
687 DCHECK_EQ(OK, rv); 674 DCHECK_EQ(OK, rv);
688 rv = DoStart(); 675 rv = DoStart();
689 break; 676 break;
690 case STATE_RESOLVE_PROXY:
691 DCHECK_EQ(OK, rv);
692 rv = DoResolveProxy();
693 break;
694 case STATE_RESOLVE_PROXY_COMPLETE:
695 rv = DoResolveProxyComplete(rv);
696 break;
697 case STATE_WAIT: 677 case STATE_WAIT:
698 DCHECK_EQ(OK, rv); 678 DCHECK_EQ(OK, rv);
699 rv = DoWait(); 679 rv = DoWait();
700 break; 680 break;
701 case STATE_WAIT_COMPLETE: 681 case STATE_WAIT_COMPLETE:
702 rv = DoWaitComplete(rv); 682 rv = DoWaitComplete(rv);
703 break; 683 break;
704 case STATE_INIT_CONNECTION: 684 case STATE_INIT_CONNECTION:
705 DCHECK_EQ(OK, rv); 685 DCHECK_EQ(OK, rv);
706 rv = DoInitConnection(); 686 rv = DoInitConnection();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 net_log->AddEvent(NetLogEventType::HTTP_STREAM_REQUEST_STARTED_JOB, 733 net_log->AddEvent(NetLogEventType::HTTP_STREAM_REQUEST_STARTED_JOB,
754 net_log_.source().ToEventParametersCallback()); 734 net_log_.source().ToEventParametersCallback());
755 } 735 }
756 736
757 // Don't connect to restricted ports. 737 // Don't connect to restricted ports.
758 if (!IsPortAllowedForScheme(destination_.port(), 738 if (!IsPortAllowedForScheme(destination_.port(),
759 request_info_.url.scheme())) { 739 request_info_.url.scheme())) {
760 return ERR_UNSAFE_PORT; 740 return ERR_UNSAFE_PORT;
761 } 741 }
762 742
763 next_state_ = STATE_RESOLVE_PROXY; 743 next_state_ = STATE_WAIT;
764 return OK; 744 return OK;
765 } 745 }
766 746
767 int HttpStreamFactoryImpl::Job::DoResolveProxy() {
768 DCHECK(!pac_request_);
769 DCHECK(session_);
770
771 next_state_ = STATE_RESOLVE_PROXY_COMPLETE;
772
773 if (request_info_.load_flags & LOAD_BYPASS_PROXY) {
774 proxy_info_.UseDirect();
775 return OK;
776 }
777
778 // If an alternative proxy server was provided, use that.
779 if (alternative_proxy_server_.is_valid()) {
780 proxy_info_.UseProxyServer(alternative_proxy_server_);
781 return OK;
782 }
783
784 return session_->proxy_service()->ResolveProxy(
785 origin_url_, request_info_.method, &proxy_info_, io_callback_,
786 &pac_request_, session_->params().proxy_delegate, net_log_);
787 }
788
789 int HttpStreamFactoryImpl::Job::DoResolveProxyComplete(int result) {
790 pac_request_ = NULL;
791
792 net_log_.AddEvent(
793 NetLogEventType::HTTP_STREAM_JOB_PROXY_SERVER_RESOLVED,
794 base::Bind(
795 &NetLogHttpStreamJobProxyServerResolved,
796 proxy_info_.is_empty() ? ProxyServer() : proxy_info_.proxy_server()));
797
798 if (result == OK) {
799 // Remove unsupported proxies from the list.
800 int supported_proxies =
801 ProxyServer::SCHEME_DIRECT | ProxyServer::SCHEME_HTTP |
802 ProxyServer::SCHEME_HTTPS | ProxyServer::SCHEME_SOCKS4 |
803 ProxyServer::SCHEME_SOCKS5;
804
805 if (session_->IsQuicEnabled())
806 supported_proxies |= ProxyServer::SCHEME_QUIC;
807
808 proxy_info_.RemoveProxiesWithoutScheme(supported_proxies);
809
810 if (proxy_info_.is_empty()) {
811 // No proxies/direct to choose from. This happens when we don't support
812 // any of the proxies in the returned list.
813 result = ERR_NO_SUPPORTED_PROXIES;
814 } else if (using_quic_ &&
815 (!proxy_info_.is_quic() && !proxy_info_.is_direct())) {
816 // QUIC can not be spoken to non-QUIC proxies. This error should not be
817 // user visible, because the non-alternative Job should be resumed.
818 result = ERR_NO_SUPPORTED_PROXIES;
819 }
820 }
821
822 if (result != OK) {
823 return result;
824 }
825
826 next_state_ = STATE_WAIT;
827
828 delegate_->OnResolveProxyComplete(this, request_info_, priority_,
829 server_ssl_config_, proxy_ssl_config_,
830 stream_type_);
831
832 return OK;
833 }
834
835 bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const { 747 bool HttpStreamFactoryImpl::Job::ShouldForceQuic() const {
836 return session_->IsQuicEnabled() && 748 return session_->IsQuicEnabled() &&
837 (base::ContainsKey(session_->params().origins_to_force_quic_on, 749 (base::ContainsKey(session_->params().origins_to_force_quic_on,
838 HostPortPair()) || 750 HostPortPair()) ||
839 base::ContainsKey(session_->params().origins_to_force_quic_on, 751 base::ContainsKey(session_->params().origins_to_force_quic_on,
840 destination_)) && 752 destination_)) &&
841 proxy_info_.is_direct() && origin_url_.SchemeIs(url::kHttpsScheme); 753 proxy_info_.is_direct() && origin_url_.SchemeIs(url::kHttpsScheme);
842 } 754 }
843 755
844 int HttpStreamFactoryImpl::Job::DoWait() { 756 int HttpStreamFactoryImpl::Job::DoWait() {
(...skipping 22 matching lines...) Expand all
867 779
868 return result; 780 return result;
869 } 781 }
870 782
871 int HttpStreamFactoryImpl::Job::DoInitConnectionImpl() { 783 int HttpStreamFactoryImpl::Job::DoInitConnectionImpl() {
872 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed. 784 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462812 is fixed.
873 tracked_objects::ScopedTracker tracking_profile( 785 tracked_objects::ScopedTracker tracking_profile(
874 FROM_HERE_WITH_EXPLICIT_FUNCTION( 786 FROM_HERE_WITH_EXPLICIT_FUNCTION(
875 "462812 HttpStreamFactoryImpl::Job::DoInitConnection")); 787 "462812 HttpStreamFactoryImpl::Job::DoInitConnection"));
876 DCHECK(!connection_->is_initialized()); 788 DCHECK(!connection_->is_initialized());
789
790 if (using_quic_ && !proxy_info_.is_quic() && !proxy_info_.is_direct()) {
791 // QUIC can not be spoken to non-QUIC proxies. This error should not be
792 // user visible, because the non-alternative Job should be resumed.
793 return ERR_NO_SUPPORTED_PROXIES;
794 }
795
877 DCHECK(proxy_info_.proxy_server().is_valid()); 796 DCHECK(proxy_info_.proxy_server().is_valid());
878 next_state_ = STATE_INIT_CONNECTION_COMPLETE; 797 next_state_ = STATE_INIT_CONNECTION_COMPLETE;
879 798
880 if (delegate_->OnInitConnection(proxy_info_)) { 799 if (delegate_->OnInitConnection(proxy_info_)) {
881 // Return since the connection initialization can be skipped. 800 // Return since the connection initialization can be skipped.
882 return OK; 801 return OK;
883 } 802 }
884 803
885 using_spdy_ = false; 804 using_spdy_ = false;
886 805
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 // Quic session is closed before stream can be created. 1058 // Quic session is closed before stream can be created.
1140 return ERR_CONNECTION_CLOSED; 1059 return ERR_CONNECTION_CLOSED;
1141 } 1060 }
1142 } 1061 }
1143 next_state_ = STATE_NONE; 1062 next_state_ = STATE_NONE;
1144 return OK; 1063 return OK;
1145 } 1064 }
1146 1065
1147 if (result < 0 && !ssl_started) 1066 if (result < 0 && !ssl_started)
1148 return ReconsiderProxyAfterError(result); 1067 return ReconsiderProxyAfterError(result);
1068
1149 establishing_tunnel_ = false; 1069 establishing_tunnel_ = false;
1150 1070
1151 // Handle SSL errors below. 1071 // Handle SSL errors below.
1152 if (using_ssl_) { 1072 if (using_ssl_) {
1153 DCHECK(ssl_started); 1073 DCHECK(ssl_started);
1154 if (IsCertificateError(result)) { 1074 if (IsCertificateError(result)) {
1155 result = HandleCertificateError(result); 1075 result = HandleCertificateError(result);
1156 if (result == OK && !connection_->socket()->IsConnectedAndIdle()) { 1076 if (result == OK && !connection_->socket()->IsConnectedAndIdle()) {
1157 ReturnToStateInitConnection(true /* close connection */); 1077 ReturnToStateInitConnection(true /* close connection */);
1158 return result; 1078 return result;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 } 1325 }
1406 1326
1407 if (request_info_.load_flags & LOAD_VERIFY_EV_CERT) 1327 if (request_info_.load_flags & LOAD_VERIFY_EV_CERT)
1408 ssl_config->verify_ev_cert = true; 1328 ssl_config->verify_ev_cert = true;
1409 1329
1410 // Disable Channel ID if privacy mode is enabled. 1330 // Disable Channel ID if privacy mode is enabled.
1411 if (request_info_.privacy_mode == PRIVACY_MODE_ENABLED) 1331 if (request_info_.privacy_mode == PRIVACY_MODE_ENABLED)
1412 ssl_config->channel_id_enabled = false; 1332 ssl_config->channel_id_enabled = false;
1413 } 1333 }
1414 1334
1415
1416 int HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError(int error) { 1335 int HttpStreamFactoryImpl::Job::ReconsiderProxyAfterError(int error) {
1417 DCHECK(!pac_request_);
1418 DCHECK(session_);
1419
1420 // A failure to resolve the hostname or any error related to establishing a
1421 // TCP connection could be grounds for trying a new proxy configuration.
1422 //
1423 // Why do this when a hostname cannot be resolved? Some URLs only make sense
1424 // to proxy servers. The hostname in those URLs might fail to resolve if we
1425 // are still using a non-proxy config. We need to check if a proxy config
1426 // now exists that corresponds to a proxy server that could load the URL.
1427 //
1428 switch (error) { 1336 switch (error) {
1429 case ERR_PROXY_CONNECTION_FAILED: 1337 case ERR_PROXY_CONNECTION_FAILED:
1430 case ERR_NAME_NOT_RESOLVED: 1338 case ERR_NAME_NOT_RESOLVED:
1431 case ERR_INTERNET_DISCONNECTED: 1339 case ERR_INTERNET_DISCONNECTED:
1432 case ERR_ADDRESS_UNREACHABLE: 1340 case ERR_ADDRESS_UNREACHABLE:
1433 case ERR_CONNECTION_CLOSED: 1341 case ERR_CONNECTION_CLOSED:
1434 case ERR_CONNECTION_TIMED_OUT: 1342 case ERR_CONNECTION_TIMED_OUT:
1435 case ERR_CONNECTION_RESET: 1343 case ERR_CONNECTION_RESET:
1436 case ERR_CONNECTION_REFUSED: 1344 case ERR_CONNECTION_REFUSED:
1437 case ERR_CONNECTION_ABORTED: 1345 case ERR_CONNECTION_ABORTED:
(...skipping 18 matching lines...) Expand all
1456 // 1364 //
1457 // Note that if the host resolving was done by the SOCKS5 proxy, we can't 1365 // Note that if the host resolving was done by the SOCKS5 proxy, we can't
1458 // differentiate between a proxy-side "host not found" versus a proxy-side 1366 // differentiate between a proxy-side "host not found" versus a proxy-side
1459 // "address unreachable" error, and will report both of these failures as 1367 // "address unreachable" error, and will report both of these failures as
1460 // ERR_ADDRESS_UNREACHABLE. 1368 // ERR_ADDRESS_UNREACHABLE.
1461 return ERR_ADDRESS_UNREACHABLE; 1369 return ERR_ADDRESS_UNREACHABLE;
1462 default: 1370 default:
1463 return error; 1371 return error;
1464 } 1372 }
1465 1373
1466 // Do not bypass non-QUIC proxy on ERR_MSG_TOO_BIG.
1467 if (!proxy_info_.is_quic() && error == ERR_MSG_TOO_BIG)
1468 return error;
1469
1470 if (request_info_.load_flags & LOAD_BYPASS_PROXY)
1471 return error;
1472
1473 // Alternative proxy server job should not use fallback proxies, and instead 1374 // Alternative proxy server job should not use fallback proxies, and instead
1474 // return. This would resume the main job (if possible) which may try the 1375 // return. This would resume the main job (if possible) which may try the
1475 // fallback proxies. 1376 // fallback proxies.
1476 if (alternative_proxy_server_.is_valid()) { 1377 if (alternative_proxy_server().is_valid()) {
1477 DCHECK_EQ(STATE_NONE, next_state_); 1378 DCHECK_EQ(STATE_NONE, next_state_);
1478 return error; 1379 return error;
1479 } 1380 }
1480 1381
1481 if (proxy_info_.is_https() && proxy_ssl_config_.send_client_cert) { 1382 should_reconsider_proxy_ = true;
1482 session_->ssl_client_auth_cache()->Remove( 1383 return error;
1483 proxy_info_.proxy_server().host_port_pair());
1484 }
1485
1486 int rv = session_->proxy_service()->ReconsiderProxyAfterError(
1487 request_info_.url, request_info_.method, error, &proxy_info_,
1488 io_callback_, &pac_request_, session_->params().proxy_delegate, net_log_);
1489 if (rv == OK || rv == ERR_IO_PENDING) {
1490 // If the error was during connection setup, there is no socket to
1491 // disconnect.
1492 if (connection_->socket())
1493 connection_->socket()->Disconnect();
1494 connection_->Reset();
1495 delegate_->RemoveRequestFromSpdySessionRequestMapForJob(this);
1496 next_state_ = STATE_RESOLVE_PROXY_COMPLETE;
1497 } else {
1498 // If ReconsiderProxyAfterError() failed synchronously, it means
1499 // there was nothing left to fall-back to, so fail the transaction
1500 // with the last connection error we got.
1501 // TODO(eroman): This is a confusing contract, make it more obvious.
1502 rv = error;
1503 }
1504
1505 return rv;
1506 } 1384 }
1507 1385
1508 int HttpStreamFactoryImpl::Job::HandleCertificateError(int error) { 1386 int HttpStreamFactoryImpl::Job::HandleCertificateError(int error) {
1509 DCHECK(using_ssl_); 1387 DCHECK(using_ssl_);
1510 DCHECK(IsCertificateError(error)); 1388 DCHECK(IsCertificateError(error));
1511 1389
1512 SSLClientSocket* ssl_socket = 1390 SSLClientSocket* ssl_socket =
1513 static_cast<SSLClientSocket*>(connection_->socket()); 1391 static_cast<SSLClientSocket*>(connection_->socket());
1514 ssl_socket->GetSSLInfo(&ssl_info_); 1392 ssl_socket->GetSSLInfo(&ssl_info_);
1515 1393
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 return; 1435 return;
1558 1436
1559 ConnectionAttempts socket_attempts = connection_->connection_attempts(); 1437 ConnectionAttempts socket_attempts = connection_->connection_attempts();
1560 if (connection_->socket()) { 1438 if (connection_->socket()) {
1561 connection_->socket()->GetConnectionAttempts(&socket_attempts); 1439 connection_->socket()->GetConnectionAttempts(&socket_attempts);
1562 } 1440 }
1563 1441
1564 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts); 1442 delegate_->AddConnectionAttemptsToRequest(this, socket_attempts);
1565 } 1443 }
1566 1444
1445 HttpStreamFactoryImpl::JobFactory::JobFactory() {}
1446
1447 HttpStreamFactoryImpl::JobFactory::~JobFactory() {}
1448
1449 HttpStreamFactoryImpl::Job* HttpStreamFactoryImpl::JobFactory::CreateMainJob(
1450 HttpStreamFactoryImpl::Job::Delegate* delegate,
1451 HttpStreamFactoryImpl::JobType job_type,
1452 HttpNetworkSession* session,
1453 const HttpRequestInfo& request_info,
1454 RequestPriority priority,
1455 const ProxyInfo& proxy_info,
1456 const SSLConfig& server_ssl_config,
1457 const SSLConfig& proxy_ssl_config,
1458 HostPortPair destination,
1459 GURL origin_url,
1460 bool enable_ip_based_pooling,
1461 NetLog* net_log) {
1462 return new HttpStreamFactoryImpl::Job(
1463 delegate, job_type, session, request_info, priority, proxy_info,
1464 server_ssl_config, proxy_ssl_config, destination, origin_url,
1465 enable_ip_based_pooling, net_log);
1466 }
1467
1468 HttpStreamFactoryImpl::Job* HttpStreamFactoryImpl::JobFactory::CreateAltSvcJob(
1469 HttpStreamFactoryImpl::Job::Delegate* delegate,
1470 HttpStreamFactoryImpl::JobType job_type,
1471 HttpNetworkSession* session,
1472 const HttpRequestInfo& request_info,
1473 RequestPriority priority,
1474 const ProxyInfo& proxy_info,
1475 const SSLConfig& server_ssl_config,
1476 const SSLConfig& proxy_ssl_config,
1477 HostPortPair destination,
1478 GURL origin_url,
1479 AlternativeService alternative_service,
1480 bool enable_ip_based_pooling,
1481 NetLog* net_log) {
1482 return new HttpStreamFactoryImpl::Job(
1483 delegate, job_type, session, request_info, priority, proxy_info,
1484 server_ssl_config, proxy_ssl_config, destination, origin_url,
1485 alternative_service, ProxyServer(), enable_ip_based_pooling, net_log);
1486 }
1487
1488 HttpStreamFactoryImpl::Job*
1489 HttpStreamFactoryImpl::JobFactory::CreateAltProxyJob(
1490 HttpStreamFactoryImpl::Job::Delegate* delegate,
1491 HttpStreamFactoryImpl::JobType job_type,
1492 HttpNetworkSession* session,
1493 const HttpRequestInfo& request_info,
1494 RequestPriority priority,
1495 const ProxyInfo& proxy_info,
1496 const SSLConfig& server_ssl_config,
1497 const SSLConfig& proxy_ssl_config,
1498 HostPortPair destination,
1499 GURL origin_url,
1500 const ProxyServer& alternative_proxy_server,
1501 bool enable_ip_based_pooling,
1502 NetLog* net_log) {
1503 return new HttpStreamFactoryImpl::Job(
1504 delegate, job_type, session, request_info, priority, proxy_info,
1505 server_ssl_config, proxy_ssl_config, destination, origin_url,
1506 AlternativeService(), alternative_proxy_server, enable_ip_based_pooling,
1507 net_log);
1508 }
1509
1567 } // namespace net 1510 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_job.h ('k') | net/http/http_stream_factory_impl_job_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698