Remove HttpDecoder::has_payload().
Instead of polling has_payload(), query QuicSpdyStreamBodyBuffer::HasBytesToRead().
Note the subtle change in behavior: OnBodyAvailable() will be called even if there
is no new payload decoded but the consumer has not read all the buffer previously.
Also add DCHECKs to QuicSpdyStream() methods that are only supposed to be called
in v99.
gfe-relnote: n/a. Other than adding a DCHECK, change behavior in QUIC v99 only. Not flag protected.
PiperOrigin-RevId: 238306060
Change-Id: I044ea4c0e49064c5193958b44c6cee61eb15e08f
diff --git a/quic/core/http/http_decoder.cc b/quic/core/http/http_decoder.cc
index 55879d0..34e4342 100644
--- a/quic/core/http/http_decoder.cc
+++ b/quic/core/http/http_decoder.cc
@@ -35,13 +35,11 @@
current_frame_length_(0),
remaining_frame_length_(0),
error_(QUIC_NO_ERROR),
- error_detail_(""),
- has_payload_(false) {}
+ error_detail_("") {}
HttpDecoder::~HttpDecoder() {}
QuicByteCount HttpDecoder::ProcessInput(const char* data, QuicByteCount len) {
- has_payload_ = false;
QuicDataReader reader(data, len);
while (error_ == QUIC_NO_ERROR && reader.BytesRemaining() != 0) {
switch (state_) {
@@ -112,7 +110,6 @@
RaiseError(QUIC_INTERNAL_ERROR, "Unable to read data");
return;
}
- has_payload_ = true;
visitor_->OnDataFramePayload(payload);
remaining_frame_length_ -= payload.length();
if (remaining_frame_length_ == 0) {
diff --git a/quic/core/http/http_decoder.h b/quic/core/http/http_decoder.h
index d6b1cc1..47d97b6 100644
--- a/quic/core/http/http_decoder.h
+++ b/quic/core/http/http_decoder.h
@@ -108,8 +108,6 @@
// case error() should be consulted.
QuicByteCount ProcessInput(const char* data, QuicByteCount len);
- bool has_payload() { return has_payload_; }
-
QuicErrorCode error() const { return error_; }
const std::string& error_detail() const { return error_detail_; }
@@ -171,9 +169,6 @@
QuicErrorCode error_;
// The issue which caused |error_|
std::string error_detail_;
- // True if the call to ProcessInput() generates any payload. Flushed every
- // time ProcessInput() is called.
- bool has_payload_;
// Remaining unparsed data.
std::string buffer_;
// Remaining unparsed length field data.
diff --git a/quic/core/http/quic_spdy_stream.cc b/quic/core/http/quic_spdy_stream.cc
index 9aa4ce7..ce1370b 100644
--- a/quic/core/http/quic_spdy_stream.cc
+++ b/quic/core/http/quic_spdy_stream.cc
@@ -470,6 +470,8 @@
}
void QuicSpdyStream::OnDataAvailable() {
+ DCHECK(FinishedReadingHeaders());
+
if (!VersionHasDataFrameHeader(
session()->connection()->transport_version())) {
OnBodyAvailable();
@@ -477,16 +479,12 @@
}
iovec iov;
- bool has_payload = false;
while (sequencer()->PrefetchNextRegion(&iov)) {
decoder_.ProcessInput(reinterpret_cast<const char*>(iov.iov_base),
iov.iov_len);
- if (decoder_.has_payload()) {
- has_payload = true;
- }
}
- if (has_payload) {
+ if (body_buffer_.HasBytesToRead()) {
OnBodyAvailable();
return;
}
@@ -560,14 +558,22 @@
}
void QuicSpdyStream::OnDataFrameStart(Http3FrameLengths frame_lengths) {
+ DCHECK(
+ VersionHasDataFrameHeader(session()->connection()->transport_version()));
+
body_buffer_.OnDataHeader(frame_lengths);
}
void QuicSpdyStream::OnDataFramePayload(QuicStringPiece payload) {
+ DCHECK(
+ VersionHasDataFrameHeader(session()->connection()->transport_version()));
+
body_buffer_.OnDataPayload(payload);
}
void QuicSpdyStream::OnDataFrameEnd() {
+ DCHECK(
+ VersionHasDataFrameHeader(session()->connection()->transport_version()));
DVLOG(1) << "Reaches the end of a data frame. Total bytes received are "
<< body_buffer_.total_body_bytes_received();
}