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

Side by Side Diff: net/quic/chromium/quic_http_stream.cc

Issue 2900533002: Add an async ReadTrailers method to QuicChromiumClientStream::Handle (Closed)
Patch Set: Fix comments Created 3 years, 6 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
« no previous file with comments | « net/quic/chromium/quic_http_stream.h ('k') | net/quic/chromium/quic_http_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 : MultiplexedHttpStream(std::move(session)), 49 : MultiplexedHttpStream(std::move(session)),
50 next_state_(STATE_NONE), 50 next_state_(STATE_NONE),
51 stream_(nullptr), 51 stream_(nullptr),
52 request_info_(nullptr), 52 request_info_(nullptr),
53 request_body_stream_(nullptr), 53 request_body_stream_(nullptr),
54 priority_(MINIMUM_PRIORITY), 54 priority_(MINIMUM_PRIORITY),
55 response_info_(nullptr), 55 response_info_(nullptr),
56 has_response_status_(false), 56 has_response_status_(false),
57 response_status_(ERR_UNEXPECTED), 57 response_status_(ERR_UNEXPECTED),
58 response_headers_received_(false), 58 response_headers_received_(false),
59 trailing_headers_received_(false),
59 headers_bytes_received_(0), 60 headers_bytes_received_(0),
60 headers_bytes_sent_(0), 61 headers_bytes_sent_(0),
61 closed_stream_received_bytes_(0), 62 closed_stream_received_bytes_(0),
62 closed_stream_sent_bytes_(0), 63 closed_stream_sent_bytes_(0),
63 closed_is_first_stream_(false), 64 closed_is_first_stream_(false),
64 user_buffer_len_(0), 65 user_buffer_len_(0),
65 session_error_(ERR_UNEXPECTED), 66 session_error_(ERR_UNEXPECTED),
66 quic_connection_error_(QUIC_NO_ERROR), 67 quic_connection_error_(QUIC_NO_ERROR),
67 quic_stream_error_(QUIC_STREAM_NO_ERROR), 68 quic_stream_error_(QUIC_STREAM_NO_ERROR),
68 found_promise_(false), 69 found_promise_(false),
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 DCHECK(!response_headers_received_); 458 DCHECK(!response_headers_received_);
458 if (rv > 0) { 459 if (rv > 0) {
459 headers_bytes_received_ += rv; 460 headers_bytes_received_ += rv;
460 rv = ProcessResponseHeaders(response_header_block_); 461 rv = ProcessResponseHeaders(response_header_block_);
461 } 462 }
462 if (rv != ERR_IO_PENDING && !callback_.is_null()) { 463 if (rv != ERR_IO_PENDING && !callback_.is_null()) {
463 DoCallback(rv); 464 DoCallback(rv);
464 } 465 }
465 } 466 }
466 467
467 void QuicHttpStream::OnTrailingHeadersAvailable(const SpdyHeaderBlock& headers, 468 void QuicHttpStream::ReadTrailingHeaders() {
468 size_t frame_len) { 469 if (!stream_)
470 return;
471
472 int rv = stream_->ReadTrailingHeaders(
473 &trailing_header_block_,
474 base::Bind(&QuicHttpStream::OnReadTrailingHeadersComplete,
475 weak_factory_.GetWeakPtr()));
476
477 if (rv != ERR_IO_PENDING)
478 OnReadTrailingHeadersComplete(rv);
479 }
480
481 void QuicHttpStream::OnReadTrailingHeadersComplete(int rv) {
469 DCHECK(response_headers_received_); 482 DCHECK(response_headers_received_);
470 headers_bytes_received_ += frame_len; 483 if (rv > 0)
484 headers_bytes_received_ += rv;
471 485
472 // QuicHttpStream ignores trailers. 486 // QuicHttpStream ignores trailers.
473 if (stream_->IsDoneReading()) { 487 if (stream_->IsDoneReading()) {
474 // Close the read side. If the write side has been closed, this will 488 // Close the read side. If the write side has been closed, this will
475 // invoke QuicHttpStream::OnClose to reset the stream. 489 // invoke QuicHttpStream::OnClose to reset the stream.
476 stream_->OnFinRead(); 490 stream_->OnFinRead();
477 SetResponseStatus(OK); 491 SetResponseStatus(OK);
478 } 492 }
479 } 493 }
480 494
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 response_info_->was_alpn_negotiated = true; 758 response_info_->was_alpn_negotiated = true;
745 response_info_->alpn_negotiated_protocol = 759 response_info_->alpn_negotiated_protocol =
746 HttpResponseInfo::ConnectionInfoToString(response_info_->connection_info); 760 HttpResponseInfo::ConnectionInfoToString(response_info_->connection_info);
747 response_info_->response_time = base::Time::Now(); 761 response_info_->response_time = base::Time::Now();
748 response_info_->request_time = request_time_; 762 response_info_->request_time = request_time_;
749 response_headers_received_ = true; 763 response_headers_received_ = true;
750 764
751 // Populate |connect_timing_| when response headers are received. This should 765 // Populate |connect_timing_| when response headers are received. This should
752 // take care of 0-RTT where request is sent before handshake is confirmed. 766 // take care of 0-RTT where request is sent before handshake is confirmed.
753 connect_timing_ = quic_session()->GetConnectTiming(); 767 connect_timing_ = quic_session()->GetConnectTiming();
768
769 base::ThreadTaskRunnerHandle::Get()->PostTask(
770 FROM_HERE, base::Bind(&QuicHttpStream::ReadTrailingHeaders,
771 weak_factory_.GetWeakPtr()));
772
754 return OK; 773 return OK;
755 } 774 }
756 775
757 void QuicHttpStream::OnReadBodyComplete(int rv) { 776 void QuicHttpStream::OnReadBodyComplete(int rv) {
758 CHECK(callback_); 777 CHECK(callback_);
759 user_buffer_ = nullptr; 778 user_buffer_ = nullptr;
760 user_buffer_len_ = 0; 779 user_buffer_len_ = 0;
761 rv = HandleReadComplete(rv); 780 rv = HandleReadComplete(rv);
762 DoCallback(rv); 781 DoCallback(rv);
763 } 782 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 quic_stream_error_ != QUIC_STREAM_CONNECTION_ERROR) { 851 quic_stream_error_ != QUIC_STREAM_CONNECTION_ERROR) {
833 return ERR_QUIC_PROTOCOL_ERROR; 852 return ERR_QUIC_PROTOCOL_ERROR;
834 } 853 }
835 854
836 DCHECK_NE(QUIC_HANDSHAKE_TIMEOUT, quic_connection_error_); 855 DCHECK_NE(QUIC_HANDSHAKE_TIMEOUT, quic_connection_error_);
837 856
838 return ERR_QUIC_PROTOCOL_ERROR; 857 return ERR_QUIC_PROTOCOL_ERROR;
839 } 858 }
840 859
841 } // namespace net 860 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_http_stream.h ('k') | net/quic/chromium/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698