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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 DCHECK(!response_headers_received_); | 457 DCHECK(!response_headers_received_); |
458 if (rv > 0) { | 458 if (rv > 0) { |
459 headers_bytes_received_ += rv; | 459 headers_bytes_received_ += rv; |
460 rv = ProcessResponseHeaders(response_header_block_); | 460 rv = ProcessResponseHeaders(response_header_block_); |
461 } | 461 } |
462 if (rv != ERR_IO_PENDING && !callback_.is_null()) { | 462 if (rv != ERR_IO_PENDING && !callback_.is_null()) { |
463 DoCallback(rv); | 463 DoCallback(rv); |
464 } | 464 } |
465 } | 465 } |
466 | 466 |
467 void QuicHttpStream::OnTrailingHeadersAvailable(const SpdyHeaderBlock& headers, | 467 void QuicHttpStream::ReadTrailingHeaders() { |
468 size_t frame_len) { | 468 if (!stream_) |
xunjieli
2017/05/26 15:53:06
Is the null check needed? I thought the handle is
Ryan Hamilton
2017/05/26 22:35:50
It's still null out in ResetStream, as of this CL.
xunjieli
2017/05/29 14:06:08
Acknowledged.
| |
469 return; | |
470 | |
471 int rv = stream_->ReadTrailingHeaders( | |
472 &trailing_header_block_, | |
473 base::Bind(&QuicHttpStream::OnReadTrailingHeadersComplete, | |
474 weak_factory_.GetWeakPtr())); | |
475 | |
476 OnReadTrailingHeadersComplete(rv); | |
xunjieli
2017/05/26 15:53:05
Should we test (rv != ERR_IO_PENDING) before calli
Ryan Hamilton
2017/05/26 22:35:50
Good point. Amusingly, OnReadTrailingHeadersComple
| |
477 } | |
478 | |
479 void QuicHttpStream::OnReadTrailingHeadersComplete(int rv) { | |
469 DCHECK(response_headers_received_); | 480 DCHECK(response_headers_received_); |
470 headers_bytes_received_ += frame_len; | 481 if (rv > 0) |
482 headers_bytes_received_ += rv; | |
471 | 483 |
472 // QuicHttpStream ignores trailers. | 484 // QuicHttpStream ignores trailers. |
473 if (stream_->IsDoneReading()) { | 485 if (stream_->IsDoneReading()) { |
474 // Close the read side. If the write side has been closed, this will | 486 // Close the read side. If the write side has been closed, this will |
475 // invoke QuicHttpStream::OnClose to reset the stream. | 487 // invoke QuicHttpStream::OnClose to reset the stream. |
476 stream_->OnFinRead(); | 488 stream_->OnFinRead(); |
477 SetResponseStatus(OK); | 489 SetResponseStatus(OK); |
478 } | 490 } |
479 } | 491 } |
480 | 492 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
744 response_info_->was_alpn_negotiated = true; | 756 response_info_->was_alpn_negotiated = true; |
745 response_info_->alpn_negotiated_protocol = | 757 response_info_->alpn_negotiated_protocol = |
746 HttpResponseInfo::ConnectionInfoToString(response_info_->connection_info); | 758 HttpResponseInfo::ConnectionInfoToString(response_info_->connection_info); |
747 response_info_->response_time = base::Time::Now(); | 759 response_info_->response_time = base::Time::Now(); |
748 response_info_->request_time = request_time_; | 760 response_info_->request_time = request_time_; |
749 response_headers_received_ = true; | 761 response_headers_received_ = true; |
750 | 762 |
751 // Populate |connect_timing_| when response headers are received. This should | 763 // Populate |connect_timing_| when response headers are received. This should |
752 // take care of 0-RTT where request is sent before handshake is confirmed. | 764 // take care of 0-RTT where request is sent before handshake is confirmed. |
753 connect_timing_ = quic_session()->GetConnectTiming(); | 765 connect_timing_ = quic_session()->GetConnectTiming(); |
766 | |
767 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
768 FROM_HERE, base::Bind(&QuicHttpStream::ReadTrailingHeaders, | |
769 weak_factory_.GetWeakPtr())); | |
770 | |
754 return OK; | 771 return OK; |
755 } | 772 } |
756 | 773 |
757 void QuicHttpStream::OnReadBodyComplete(int rv) { | 774 void QuicHttpStream::OnReadBodyComplete(int rv) { |
758 CHECK(callback_); | 775 CHECK(callback_); |
759 user_buffer_ = nullptr; | 776 user_buffer_ = nullptr; |
760 user_buffer_len_ = 0; | 777 user_buffer_len_ = 0; |
761 rv = HandleReadComplete(rv); | 778 rv = HandleReadComplete(rv); |
762 DoCallback(rv); | 779 DoCallback(rv); |
763 } | 780 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
831 quic_stream_error_ != QUIC_STREAM_CONNECTION_ERROR) { | 848 quic_stream_error_ != QUIC_STREAM_CONNECTION_ERROR) { |
832 return ERR_QUIC_PROTOCOL_ERROR; | 849 return ERR_QUIC_PROTOCOL_ERROR; |
833 } | 850 } |
834 | 851 |
835 DCHECK_NE(QUIC_HANDSHAKE_TIMEOUT, quic_connection_error_); | 852 DCHECK_NE(QUIC_HANDSHAKE_TIMEOUT, quic_connection_error_); |
836 | 853 |
837 return ERR_QUIC_PROTOCOL_ERROR; | 854 return ERR_QUIC_PROTOCOL_ERROR; |
838 } | 855 } |
839 | 856 |
840 } // namespace net | 857 } // namespace net |
OLD | NEW |