Call BlockingManager methods from QpackEncoder when decoder stream instructions arrive. gfe-relnote: n/a, change to QUIC v99-only code. Protected by existing disabled gfe2_reloadable_flag_quic_enable_version_99. PiperOrigin-RevId: 263348337 Change-Id: I038980c82747e7b25e1af273697531519ca6fac8
diff --git a/quic/core/qpack/qpack_encoder.cc b/quic/core/qpack/qpack_encoder.cc index ddceef0..b6be648 100644 --- a/quic/core/qpack/qpack_encoder.cc +++ b/quic/core/qpack/qpack_encoder.cc
@@ -12,6 +12,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" +#include "net/third_party/quiche/src/quic/platform/api/quic_str_cat.h" namespace quic { @@ -120,16 +121,35 @@ maximum_blocked_streams_ = maximum_blocked_streams; } -void QpackEncoder::OnInsertCountIncrement(uint64_t /*increment*/) { - // TODO(bnc): Implement dynamic table management for encoding. +void QpackEncoder::OnInsertCountIncrement(uint64_t increment) { + if (increment == 0) { + decoder_stream_error_delegate_->OnDecoderStreamError( + "Invalid increment value 0."); + return; + } + + blocking_manager_.OnInsertCountIncrement(increment); + + if (blocking_manager_.known_received_count() > + header_table_.inserted_entry_count()) { + decoder_stream_error_delegate_->OnDecoderStreamError(QuicStrCat( + "Increment value ", increment, " raises known received count to ", + blocking_manager_.known_received_count(), + " exceeding inserted entry count ", + header_table_.inserted_entry_count())); + } } -void QpackEncoder::OnHeaderAcknowledgement(QuicStreamId /*stream_id*/) { - // TODO(bnc): Implement dynamic table management for encoding. +void QpackEncoder::OnHeaderAcknowledgement(QuicStreamId stream_id) { + if (!blocking_manager_.OnHeaderAcknowledgement(stream_id)) { + decoder_stream_error_delegate_->OnDecoderStreamError( + QuicStrCat("Header Acknowledgement received for stream ", stream_id, + " with no outstanding header blocks.")); + } } -void QpackEncoder::OnStreamCancellation(QuicStreamId /*stream_id*/) { - // TODO(bnc): Implement dynamic table management for encoding. +void QpackEncoder::OnStreamCancellation(QuicStreamId stream_id) { + blocking_manager_.OnStreamCancellation(stream_id); } void QpackEncoder::OnErrorDetected(QuicStringPiece error_message) {
diff --git a/quic/core/qpack/qpack_encoder.h b/quic/core/qpack/qpack_encoder.h index 1ced7fa..a1b6427 100644 --- a/quic/core/qpack/qpack_encoder.h +++ b/quic/core/qpack/qpack_encoder.h
@@ -10,6 +10,7 @@ #include <string> #include <vector> +#include "net/third_party/quiche/src/quic/core/qpack/qpack_blocking_manager.h" #include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h" #include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h" #include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" @@ -111,6 +112,7 @@ QpackEncoderStreamSender encoder_stream_sender_; QpackHeaderTable header_table_; uint64_t maximum_blocked_streams_; + QpackBlockingManager blocking_manager_; }; } // namespace quic
diff --git a/quic/core/qpack/qpack_encoder_test.cc b/quic/core/qpack/qpack_encoder_test.cc index bf5116e..56cfe84 100644 --- a/quic/core/qpack/qpack_encoder_test.cc +++ b/quic/core/qpack/qpack_encoder_test.cc
@@ -152,6 +152,34 @@ output); } +TEST_F(QpackEncoderTest, ZeroInsertCountIncrement) { + // Encoder receives insert count increment with forbidden value 0. + EXPECT_CALL(decoder_stream_error_delegate_, + OnDecoderStreamError(Eq("Invalid increment value 0."))); + encoder_.OnInsertCountIncrement(0); +} + +TEST_F(QpackEncoderTest, TooLargeInsertCountIncrement) { + // Encoder receives insert count increment with value that increases Known + // Received Count to a value (one) which is larger than the number of dynamic + // table insertions sent (zero). + EXPECT_CALL( + decoder_stream_error_delegate_, + OnDecoderStreamError(Eq("Increment value 1 raises known received count " + "to 1 exceeding inserted entry count 0"))); + encoder_.OnInsertCountIncrement(1); +} + +TEST_F(QpackEncoderTest, InvalidHeaderAcknowledgement) { + // Encoder receives header acknowledgement for a stream on which no header + // block with dynamic table entries was ever sent. + EXPECT_CALL( + decoder_stream_error_delegate_, + OnDecoderStreamError(Eq("Header Acknowledgement received for stream 0 " + "with no outstanding header blocks."))); + encoder_.OnHeaderAcknowledgement(/* stream_id = */ 0); +} + } // namespace } // namespace test } // namespace quic