Chromium Code Reviews| 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/quic/chromium/quic_http_stream.h" | 5 #include "net/quic/chromium/quic_http_stream.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 dict->SetString("url", url->spec()); | 39 dict->SetString("url", url->spec()); |
| 40 return std::move(dict); | 40 return std::move(dict); |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 QuicHttpStream::QuicHttpStream( | 45 QuicHttpStream::QuicHttpStream( |
| 46 const base::WeakPtr<QuicChromiumClientSession>& session) | 46 const base::WeakPtr<QuicChromiumClientSession>& session) |
| 47 : next_state_(STATE_NONE), | 47 : next_state_(STATE_NONE), |
| 48 session_(session), | 48 session_(session), |
| 49 quic_version_(session->GetQuicVersion()), | |
|
Ryan Hamilton
2016/10/28 19:02:02
We're only speaking 1 version of QUIC at a time in
Bence
2016/11/01 15:11:23
Hm, I see. QuicFramer's version can change after
Ryan Hamilton
2016/11/03 14:33:05
SGTM!
| |
| 49 session_error_(OK), | 50 session_error_(OK), |
| 50 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()), | 51 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()), |
| 51 stream_(nullptr), | 52 stream_(nullptr), |
| 52 request_info_(nullptr), | 53 request_info_(nullptr), |
| 53 request_body_stream_(nullptr), | 54 request_body_stream_(nullptr), |
| 54 priority_(MINIMUM_PRIORITY), | 55 priority_(MINIMUM_PRIORITY), |
| 55 response_info_(nullptr), | 56 response_info_(nullptr), |
| 56 response_status_(OK), | 57 response_status_(OK), |
| 57 response_headers_received_(false), | 58 response_headers_received_(false), |
| 58 headers_bytes_received_(0), | 59 headers_bytes_received_(0), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 | 121 |
| 121 DCHECK_EQ(STATE_HANDLE_PROMISE_COMPLETE, next_state_); | 122 DCHECK_EQ(STATE_HANDLE_PROMISE_COMPLETE, next_state_); |
| 122 if (!stream) { | 123 if (!stream) { |
| 123 // rendezvous has failed so proceed as with a non-push request. | 124 // rendezvous has failed so proceed as with a non-push request. |
| 124 next_state_ = STATE_REQUEST_STREAM; | 125 next_state_ = STATE_REQUEST_STREAM; |
| 125 } | 126 } |
| 126 | 127 |
| 127 OnIOComplete(OK); | 128 OnIOComplete(OK); |
| 128 } | 129 } |
| 129 | 130 |
| 131 HttpResponseInfo::ConnectionInfo QuicHttpStream::ConnectionInfoFromQuicVersion( | |
| 132 QuicVersion quic_version) { | |
| 133 switch (quic_version) { | |
| 134 case QUIC_VERSION_UNSUPPORTED: | |
| 135 return HttpResponseInfo::CONNECTION_INFO_QUIC_UNKNOWN_VERSION; | |
| 136 case QUIC_VERSION_32: | |
| 137 return HttpResponseInfo::CONNECTION_INFO_QUIC_32; | |
| 138 case QUIC_VERSION_33: | |
| 139 return HttpResponseInfo::CONNECTION_INFO_QUIC_33; | |
| 140 case QUIC_VERSION_34: | |
| 141 return HttpResponseInfo::CONNECTION_INFO_QUIC_34; | |
| 142 case QUIC_VERSION_35: | |
| 143 return HttpResponseInfo::CONNECTION_INFO_QUIC_35; | |
| 144 case QUIC_VERSION_36: | |
| 145 return HttpResponseInfo::CONNECTION_INFO_QUIC_36; | |
| 146 } | |
| 147 NOTREACHED(); | |
| 148 return HttpResponseInfo::CONNECTION_INFO_QUIC_UNKNOWN_VERSION; | |
| 149 } | |
| 150 | |
| 130 int QuicHttpStream::InitializeStream(const HttpRequestInfo* request_info, | 151 int QuicHttpStream::InitializeStream(const HttpRequestInfo* request_info, |
| 131 RequestPriority priority, | 152 RequestPriority priority, |
| 132 const NetLogWithSource& stream_net_log, | 153 const NetLogWithSource& stream_net_log, |
| 133 const CompletionCallback& callback) { | 154 const CompletionCallback& callback) { |
| 134 CHECK(callback_.is_null()); | 155 CHECK(callback_.is_null()); |
| 135 DCHECK(!stream_); | 156 DCHECK(!stream_); |
| 136 if (!session_) | 157 if (!session_) |
| 137 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED | 158 return was_handshake_confirmed_ ? ERR_CONNECTION_CLOSED |
| 138 : ERR_QUIC_HANDSHAKE_FAILED; | 159 : ERR_QUIC_HANDSHAKE_FAILED; |
| 139 | 160 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 return session_->GetTokenBindingSignature(key, tb_type, out); | 444 return session_->GetTokenBindingSignature(key, tb_type, out); |
| 424 } | 445 } |
| 425 | 446 |
| 426 void QuicHttpStream::Drain(HttpNetworkSession* session) { | 447 void QuicHttpStream::Drain(HttpNetworkSession* session) { |
| 427 NOTREACHED(); | 448 NOTREACHED(); |
| 428 Close(false); | 449 Close(false); |
| 429 delete this; | 450 delete this; |
| 430 } | 451 } |
| 431 | 452 |
| 432 void QuicHttpStream::PopulateNetErrorDetails(NetErrorDetails* details) { | 453 void QuicHttpStream::PopulateNetErrorDetails(NetErrorDetails* details) { |
| 433 details->connection_info = HttpResponseInfo::CONNECTION_INFO_QUIC; | 454 details->connection_info = ConnectionInfoFromQuicVersion(quic_version_); |
| 434 if (was_handshake_confirmed_) | 455 if (was_handshake_confirmed_) |
| 435 details->quic_connection_error = quic_connection_error_; | 456 details->quic_connection_error = quic_connection_error_; |
| 436 if (session_) { | 457 if (session_) { |
| 437 session_->PopulateNetErrorDetails(details); | 458 session_->PopulateNetErrorDetails(details); |
| 438 } else { | 459 } else { |
| 439 details->quic_port_migration_detected = port_migration_detected_; | 460 details->quic_port_migration_detected = port_migration_detected_; |
| 440 } | 461 } |
| 441 } | 462 } |
| 442 | 463 |
| 443 void QuicHttpStream::SetPriority(RequestPriority priority) { | 464 void QuicHttpStream::SetPriority(RequestPriority priority) { |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 781 } | 802 } |
| 782 | 803 |
| 783 int QuicHttpStream::ProcessResponseHeaders(const SpdyHeaderBlock& headers) { | 804 int QuicHttpStream::ProcessResponseHeaders(const SpdyHeaderBlock& headers) { |
| 784 if (!SpdyHeadersToHttpResponse(headers, response_info_)) { | 805 if (!SpdyHeadersToHttpResponse(headers, response_info_)) { |
| 785 DLOG(WARNING) << "Invalid headers"; | 806 DLOG(WARNING) << "Invalid headers"; |
| 786 return ERR_QUIC_PROTOCOL_ERROR; | 807 return ERR_QUIC_PROTOCOL_ERROR; |
| 787 } | 808 } |
| 788 // Put the peer's IP address and port into the response. | 809 // Put the peer's IP address and port into the response. |
| 789 IPEndPoint address = session_->peer_address(); | 810 IPEndPoint address = session_->peer_address(); |
| 790 response_info_->socket_address = HostPortPair::FromIPEndPoint(address); | 811 response_info_->socket_address = HostPortPair::FromIPEndPoint(address); |
| 791 response_info_->connection_info = HttpResponseInfo::CONNECTION_INFO_QUIC; | 812 response_info_->connection_info = |
| 813 ConnectionInfoFromQuicVersion(quic_version_); | |
| 792 response_info_->vary_data.Init(*request_info_, | 814 response_info_->vary_data.Init(*request_info_, |
| 793 *response_info_->headers.get()); | 815 *response_info_->headers.get()); |
| 794 response_info_->was_alpn_negotiated = true; | 816 response_info_->was_alpn_negotiated = true; |
| 795 response_info_->alpn_negotiated_protocol = "quic/1+spdy/3"; | 817 response_info_->alpn_negotiated_protocol = |
| 818 HttpResponseInfo::ConnectionInfoToString(response_info_->connection_info); | |
| 796 response_info_->response_time = base::Time::Now(); | 819 response_info_->response_time = base::Time::Now(); |
| 797 response_info_->request_time = request_time_; | 820 response_info_->request_time = request_time_; |
| 798 response_headers_received_ = true; | 821 response_headers_received_ = true; |
| 799 | 822 |
| 800 // Populate |connect_timing_| when response headers are received. This should | 823 // Populate |connect_timing_| when response headers are received. This should |
| 801 // take care of 0-RTT where request is sent before handshake is confirmed. | 824 // take care of 0-RTT where request is sent before handshake is confirmed. |
| 802 connect_timing_ = session_->GetConnectTiming(); | 825 connect_timing_ = session_->GetConnectTiming(); |
| 803 return OK; | 826 return OK; |
| 804 } | 827 } |
| 805 | 828 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 832 closed_is_first_stream_ = stream_->IsFirstStream(); | 855 closed_is_first_stream_ = stream_->IsFirstStream(); |
| 833 stream_ = nullptr; | 856 stream_ = nullptr; |
| 834 | 857 |
| 835 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress | 858 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress |
| 836 // read. | 859 // read. |
| 837 if (request_body_stream_) | 860 if (request_body_stream_) |
| 838 request_body_stream_->Reset(); | 861 request_body_stream_->Reset(); |
| 839 } | 862 } |
| 840 | 863 |
| 841 } // namespace net | 864 } // namespace net |
| OLD | NEW |