OLD | NEW |
---|---|
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 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1003 // Other state (i.e. |using_ssl_|) suggests that |connection_| will have an | 1003 // Other state (i.e. |using_ssl_|) suggests that |connection_| will have an |
1004 // SSL socket, but there was an error before that could happen. This | 1004 // SSL socket, but there was an error before that could happen. This |
1005 // puts the in progress HttpProxy socket into |connection_| in order to | 1005 // puts the in progress HttpProxy socket into |connection_| in order to |
1006 // complete the auth (or read the response body). The tunnel restart code | 1006 // complete the auth (or read the response body). The tunnel restart code |
1007 // is careful to remove it before returning control to the rest of this | 1007 // is careful to remove it before returning control to the rest of this |
1008 // class. | 1008 // class. |
1009 connection_.reset(connection_->release_pending_http_proxy_connection()); | 1009 connection_.reset(connection_->release_pending_http_proxy_connection()); |
1010 return result; | 1010 return result; |
1011 } | 1011 } |
1012 | 1012 |
1013 if (IsSpdyAlternate() && !using_spdy_) { | |
1014 job_status_ = STATUS_BROKEN; | |
1015 MaybeMarkAlternativeServiceBroken(); | |
1016 return ERR_NPN_NEGOTIATION_FAILED; | |
1017 } | |
1018 | |
1013 if (!ssl_started && result < 0 && IsAlternate()) { | 1019 if (!ssl_started && result < 0 && IsAlternate()) { |
1014 job_status_ = STATUS_BROKEN; | 1020 job_status_ = STATUS_BROKEN; |
1015 // TODO(bnc): if (result == ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN), then | 1021 // TODO(bnc): if (result == ERR_ALTERNATIVE_CERT_NOT_VALID_FOR_ORIGIN), then |
1016 // instead of marking alternative service broken, mark (origin, alternative | 1022 // instead of marking alternative service broken, mark (origin, alternative |
1017 // service) couple as invalid. | 1023 // service) couple as invalid. |
1018 MaybeMarkAlternativeServiceBroken(); | 1024 MaybeMarkAlternativeServiceBroken(); |
1019 return result; | 1025 return result; |
1020 } | 1026 } |
1021 | 1027 |
1022 if (using_quic_) { | 1028 if (using_quic_) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 stream_.reset(new SpdyHttpStream(session, use_relative_url)); | 1096 stream_.reset(new SpdyHttpStream(session, use_relative_url)); |
1091 return OK; | 1097 return OK; |
1092 } | 1098 } |
1093 | 1099 |
1094 int HttpStreamFactoryImpl::Job::DoCreateStream() { | 1100 int HttpStreamFactoryImpl::Job::DoCreateStream() { |
1095 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462811 is fixed. | 1101 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462811 is fixed. |
1096 tracked_objects::ScopedTracker tracking_profile( | 1102 tracked_objects::ScopedTracker tracking_profile( |
1097 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 1103 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
1098 "462811 HttpStreamFactoryImpl::Job::DoCreateStream")); | 1104 "462811 HttpStreamFactoryImpl::Job::DoCreateStream")); |
1099 DCHECK(connection_->socket() || existing_spdy_session_.get() || using_quic_); | 1105 DCHECK(connection_->socket() || existing_spdy_session_.get() || using_quic_); |
1106 DCHECK(!IsAlternate() || IsSpdyAlternate()); | |
Ryan Hamilton
2015/05/05 20:51:12
nit: Personally, I find it hard to read dchecks wi
Bence
2015/05/06 13:21:56
Good point. Done.
| |
1100 | 1107 |
1101 next_state_ = STATE_CREATE_STREAM_COMPLETE; | 1108 next_state_ = STATE_CREATE_STREAM_COMPLETE; |
1102 | 1109 |
1103 // We only set the socket motivation if we're the first to use | 1110 // We only set the socket motivation if we're the first to use |
1104 // this socket. Is there a race for two SPDY requests? We really | 1111 // this socket. Is there a race for two SPDY requests? We really |
1105 // need to plumb this through to the connect level. | 1112 // need to plumb this through to the connect level. |
1106 if (connection_->socket() && !connection_->is_reused()) | 1113 if (connection_->socket() && !connection_->is_reused()) |
1107 SetSocketMotivation(); | 1114 SetSocketMotivation(); |
1108 | 1115 |
1109 if (!using_spdy_) { | 1116 if (!using_spdy_) { |
Ryan Hamilton
2015/05/05 20:51:12
Can you add a DHECK(!IsSpdyAlternate()) here?
Bence
2015/05/06 13:21:55
Done.
| |
1110 // We may get ftp scheme when fetching ftp resources through proxy. | 1117 // We may get ftp scheme when fetching ftp resources through proxy. |
1111 bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) && | 1118 bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) && |
1112 (request_info_.url.SchemeIs("http") || | 1119 (request_info_.url.SchemeIs("http") || |
1113 request_info_.url.SchemeIs("ftp")); | 1120 request_info_.url.SchemeIs("ftp")); |
1114 if (stream_factory_->for_websockets_) { | 1121 if (stream_factory_->for_websockets_) { |
1115 DCHECK(request_); | 1122 DCHECK(request_); |
1116 DCHECK(request_->websocket_handshake_stream_create_helper()); | 1123 DCHECK(request_->websocket_handshake_stream_create_helper()); |
1117 websocket_stream_.reset( | 1124 websocket_stream_.reset( |
1118 request_->websocket_handshake_stream_create_helper() | 1125 request_->websocket_handshake_stream_create_helper() |
1119 ->CreateBasicStream(connection_.Pass(), using_proxy)); | 1126 ->CreateBasicStream(connection_.Pass(), using_proxy)); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1546 | 1553 |
1547 void HttpStreamFactoryImpl::Job:: | 1554 void HttpStreamFactoryImpl::Job:: |
1548 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest() { | 1555 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest() { |
1549 if (IsOrphaned() || !connection_) | 1556 if (IsOrphaned() || !connection_) |
1550 return; | 1557 return; |
1551 | 1558 |
1552 request_->AddConnectionAttempts(connection_->connection_attempts()); | 1559 request_->AddConnectionAttempts(connection_->connection_attempts()); |
1553 } | 1560 } |
1554 | 1561 |
1555 } // namespace net | 1562 } // namespace net |
OLD | NEW |