Rewrite QuicSpdyStreamBodyBuffer's consumed byte tracking algorithm.

This is motivated by having to consume unknown frames (in a later CL), see
cr/258682203 for the end goal.

There is some behavioral change as a side effect of the new algorithm: DATA
frame headers are consumed immediately, not only when some of the corresponding
payload is consumed.  This hinges on the previously undocumented property of HttpDecoder that in only calls Visitor::On*FrameStart() methods after the entire frame header is processed.  This behavioral change necessitates minor updates to tests.

I plan four more CLs after this: one to move HEADERS frame header and
payload consumption calculations from QuicSpdyStream to
QuicSpdyStreamBodyBuffer; one to consume unknown frames; one to rename
QuicSpdyStreamBodyBuffer to QuicSpdyStreamBodyManager or something similar;
and one to remove Http3FrameLengths if by that point it's entirely unused.

gfe-relnote: n/a, change to QUIC v99-only code.  Protected by existing disabled gfe2_reloadable_flag_quic_enable_version_99.
PiperOrigin-RevId: 259987101
Change-Id: Id8a734fb36466b3502373097faba2c6c81c793de
diff --git a/quic/core/http/quic_spdy_stream_test.cc b/quic/core/http/quic_spdy_stream_test.cc
index f9777ec..ddfb651 100644
--- a/quic/core/http/quic_spdy_stream_test.cc
+++ b/quic/core/http/quic_spdy_stream_test.cc
@@ -2104,16 +2104,18 @@
   // DATA frame.
   QuicStringPiece data_payload(kDataFramePayload);
   std::string data_frame = DataFrame(data_payload);
+  QuicByteCount data_frame_header_length =
+      data_frame.size() - data_payload.size();
 
-  // DATA frame is not consumed because payload has to be buffered.
-  // TODO(bnc): Consume frame header as soon as possible.
+  // DATA frame header is consumed.
+  // DATA frame payload is not consumed because payload has to be buffered.
   OnStreamFrame(data_frame);
-  EXPECT_EQ(0u, NewlyConsumedBytes());
+  EXPECT_EQ(data_frame_header_length, NewlyConsumedBytes());
 
   // Consume all but last byte of data.
   EXPECT_EQ(data_payload.substr(0, data_payload.size() - 1),
             ReadFromStream(data_payload.size() - 1));
-  EXPECT_EQ(data_frame.size() - 1, NewlyConsumedBytes());
+  EXPECT_EQ(data_payload.size() - 1, NewlyConsumedBytes());
 
   // Trailing HEADERS frame with QPACK encoded
   // single header field "custom-key: custom-value".