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 if (IsAlternate()) |
| 1107 DCHECK(IsSpdyAlternate()); |
1100 | 1108 |
1101 next_state_ = STATE_CREATE_STREAM_COMPLETE; | 1109 next_state_ = STATE_CREATE_STREAM_COMPLETE; |
1102 | 1110 |
1103 // We only set the socket motivation if we're the first to use | 1111 // 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 | 1112 // this socket. Is there a race for two SPDY requests? We really |
1105 // need to plumb this through to the connect level. | 1113 // need to plumb this through to the connect level. |
1106 if (connection_->socket() && !connection_->is_reused()) | 1114 if (connection_->socket() && !connection_->is_reused()) |
1107 SetSocketMotivation(); | 1115 SetSocketMotivation(); |
1108 | 1116 |
1109 if (!using_spdy_) { | 1117 if (!using_spdy_) { |
| 1118 DCHECK(!IsSpdyAlternate()); |
1110 // We may get ftp scheme when fetching ftp resources through proxy. | 1119 // We may get ftp scheme when fetching ftp resources through proxy. |
1111 bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) && | 1120 bool using_proxy = (proxy_info_.is_http() || proxy_info_.is_https()) && |
1112 (request_info_.url.SchemeIs("http") || | 1121 (request_info_.url.SchemeIs("http") || |
1113 request_info_.url.SchemeIs("ftp")); | 1122 request_info_.url.SchemeIs("ftp")); |
1114 if (stream_factory_->for_websockets_) { | 1123 if (stream_factory_->for_websockets_) { |
1115 DCHECK(request_); | 1124 DCHECK(request_); |
1116 DCHECK(request_->websocket_handshake_stream_create_helper()); | 1125 DCHECK(request_->websocket_handshake_stream_create_helper()); |
1117 websocket_stream_.reset( | 1126 websocket_stream_.reset( |
1118 request_->websocket_handshake_stream_create_helper() | 1127 request_->websocket_handshake_stream_create_helper() |
1119 ->CreateBasicStream(connection_.Pass(), using_proxy)); | 1128 ->CreateBasicStream(connection_.Pass(), using_proxy)); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 | 1555 |
1547 void HttpStreamFactoryImpl::Job:: | 1556 void HttpStreamFactoryImpl::Job:: |
1548 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest() { | 1557 MaybeCopyConnectionAttemptsFromClientSocketHandleToRequest() { |
1549 if (IsOrphaned() || !connection_) | 1558 if (IsOrphaned() || !connection_) |
1550 return; | 1559 return; |
1551 | 1560 |
1552 request_->AddConnectionAttempts(connection_->connection_attempts()); | 1561 request_->AddConnectionAttempts(connection_->connection_attempts()); |
1553 } | 1562 } |
1554 | 1563 |
1555 } // namespace net | 1564 } // namespace net |
OLD | NEW |