Use quiche string libraries in third_party/quic/core/qpack gfe-relnote: n/a, no functional change PiperOrigin-RevId: 285014753 Change-Id: I400c158ecab7cbc70666dd8a7651aaec249a5d2e
diff --git a/quic/core/qpack/fuzzer/qpack_decoder_fuzzer.cc b/quic/core/qpack/fuzzer/qpack_decoder_fuzzer.cc index 162f88a..d5afa99 100644 --- a/quic/core/qpack/fuzzer/qpack_decoder_fuzzer.cc +++ b/quic/core/qpack/fuzzer/qpack_decoder_fuzzer.cc
@@ -9,9 +9,9 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h" #include "net/third_party/quiche/src/quic/platform/api/quic_fuzzed_data_provider.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test { @@ -30,7 +30,8 @@ ErrorDelegate(bool* error_detected) : error_detected_(error_detected) {} ~ErrorDelegate() override = default; - void OnEncoderStreamError(QuicStringPiece /*error_message*/) override { + void OnEncoderStreamError( + quiche::QuicheStringPiece /*error_message*/) override { *error_detected_ = true; } @@ -50,8 +51,8 @@ error_detected_(error_detected) {} ~HeadersHandler() override = default; - void OnHeaderDecoded(QuicStringPiece /*name*/, - QuicStringPiece /*value*/) override {} + void OnHeaderDecoded(quiche::QuicheStringPiece /*name*/, + quiche::QuicheStringPiece /*value*/) override {} // Remove DecoderAndHandler from |*processing_decoders|. void OnDecodingCompleted() override { @@ -60,7 +61,8 @@ CHECK_EQ(1u, result); } - void OnDecodingErrorDetected(QuicStringPiece /*error_message*/) override { + void OnDecodingErrorDetected( + quiche::QuicheStringPiece /*error_message*/) override { *error_detected_ = true; }
diff --git a/quic/core/qpack/fuzzer/qpack_encoder_stream_receiver_fuzzer.cc b/quic/core/qpack/fuzzer/qpack_encoder_stream_receiver_fuzzer.cc index 9b5fe11..78467a8 100644 --- a/quic/core/qpack/fuzzer/qpack_encoder_stream_receiver_fuzzer.cc +++ b/quic/core/qpack/fuzzer/qpack_encoder_stream_receiver_fuzzer.cc
@@ -9,7 +9,7 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_fuzzed_data_provider.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test { @@ -24,12 +24,14 @@ void OnInsertWithNameReference(bool /*is_static*/, uint64_t /*name_index*/, - QuicStringPiece /*value*/) override {} - void OnInsertWithoutNameReference(QuicStringPiece /*name*/, - QuicStringPiece /*value*/) override {} + quiche::QuicheStringPiece /*value*/) override { + } + void OnInsertWithoutNameReference( + quiche::QuicheStringPiece /*name*/, + quiche::QuicheStringPiece /*value*/) override {} void OnDuplicate(uint64_t /*index*/) override {} void OnSetDynamicTableCapacity(uint64_t /*capacity*/) override {} - void OnErrorDetected(QuicStringPiece /*error_message*/) override { + void OnErrorDetected(quiche::QuicheStringPiece /*error_message*/) override { error_detected_ = true; }
diff --git a/quic/core/qpack/fuzzer/qpack_encoder_stream_sender_fuzzer.cc b/quic/core/qpack/fuzzer/qpack_encoder_stream_sender_fuzzer.cc index 7efaf88..d3e226c 100644 --- a/quic/core/qpack/fuzzer/qpack_encoder_stream_sender_fuzzer.cc +++ b/quic/core/qpack/fuzzer/qpack_encoder_stream_sender_fuzzer.cc
@@ -9,7 +9,6 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h" #include "net/third_party/quiche/src/quic/platform/api/quic_fuzzed_data_provider.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h"
diff --git a/quic/core/qpack/fuzzer/qpack_round_trip_fuzzer.cc b/quic/core/qpack/fuzzer/qpack_round_trip_fuzzer.cc index 018bf09..8c94f1e 100644 --- a/quic/core/qpack/fuzzer/qpack_round_trip_fuzzer.cc +++ b/quic/core/qpack/fuzzer/qpack_round_trip_fuzzer.cc
@@ -18,6 +18,7 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_fuzzed_data_provider.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" namespace quic { @@ -63,7 +64,8 @@ public: ~CrashingDecoderStreamErrorDelegate() override = default; - void OnDecoderStreamError(QuicStringPiece error_message) override { + void OnDecoderStreamError( + quiche::QuicheStringPiece error_message) override { CHECK(false) << error_message; } }; @@ -90,7 +92,7 @@ virtual void OnHeaderBlockStart(QuicStreamId stream_id) = 0; // Called when part or all of a header block is transmitted. virtual void OnHeaderBlockFragment(QuicStreamId stream_id, - QuicStringPiece data) = 0; + quiche::QuicheStringPiece data) = 0; // Called when transmission of a header block is complete. virtual void OnHeaderBlockEnd(QuicStreamId stream_id) = 0; }; @@ -203,16 +205,19 @@ size_t RemainingLength() const { return data_.length() - offset_; } - QuicStringPiece Consume(size_t length) { + quiche::QuicheStringPiece Consume(size_t length) { DCHECK_NE(0u, length); DCHECK_LE(length, RemainingLength()); - QuicStringPiece consumed = QuicStringPiece(&data_[offset_], length); + quiche::QuicheStringPiece consumed = + quiche::QuicheStringPiece(&data_[offset_], length); offset_ += length; return consumed; } - QuicStringPiece ConsumeRemaining() { return Consume(RemainingLength()); } + quiche::QuicheStringPiece ConsumeRemaining() { + return Consume(RemainingLength()); + } private: // Complete header block. @@ -274,11 +279,11 @@ visitor_->OnHeaderBlockDecoded(stream_id_); } - void OnHeaderDecodingError(QuicStringPiece error_message) override { + void OnHeaderDecodingError(quiche::QuicheStringPiece error_message) override { CHECK(false) << error_message; } - void Decode(QuicStringPiece data) { accumulator_.Decode(data); } + void Decode(quiche::QuicheStringPiece data) { accumulator_.Decode(data); } void EndHeaderBlock() { accumulator_.EndHeaderBlock(); } @@ -357,7 +362,7 @@ } void OnHeaderBlockFragment(QuicStreamId stream_id, - QuicStringPiece data) override { + quiche::QuicheStringPiece data) override { auto it = verifying_decoders_.find(stream_id); CHECK(it != verifying_decoders_.end()); it->second->Decode(data); @@ -376,7 +381,8 @@ public: ~CrashingEncoderStreamErrorDelegate() override = default; - void OnEncoderStreamError(QuicStringPiece error_message) override { + void OnEncoderStreamError( + quiche::QuicheStringPiece error_message) override { CHECK(false) << error_message; } }; @@ -406,7 +412,7 @@ ~DelayedStreamDataTransmitter() { CHECK(stream_data.empty()); } // QpackStreamSenderDelegate implementation. - void WriteStreamData(QuicStringPiece data) override { + void WriteStreamData(quiche::QuicheStringPiece data) override { stream_data.push(std::string(data.data(), data.size())); }
diff --git a/quic/core/qpack/qpack_decoded_headers_accumulator.cc b/quic/core/qpack/qpack_decoded_headers_accumulator.cc index b1f8012..7aa0f11 100644 --- a/quic/core/qpack/qpack_decoded_headers_accumulator.cc +++ b/quic/core/qpack/qpack_decoded_headers_accumulator.cc
@@ -5,6 +5,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_decoded_headers_accumulator.h" #include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -31,8 +32,9 @@ quic_header_list_.OnHeaderBlockStart(); } -void QpackDecodedHeadersAccumulator::OnHeaderDecoded(QuicStringPiece name, - QuicStringPiece value) { +void QpackDecodedHeadersAccumulator::OnHeaderDecoded( + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { DCHECK(!error_detected_); uncompressed_header_bytes_without_overhead_ += name.size() + value.size(); @@ -67,7 +69,7 @@ } void QpackDecodedHeadersAccumulator::OnDecodingErrorDetected( - QuicStringPiece error_message) { + quiche::QuicheStringPiece error_message) { DCHECK(!error_detected_); DCHECK(!headers_decoded_); @@ -76,7 +78,7 @@ visitor_->OnHeaderDecodingError(error_message); } -void QpackDecodedHeadersAccumulator::Decode(QuicStringPiece data) { +void QpackDecodedHeadersAccumulator::Decode(quiche::QuicheStringPiece data) { DCHECK(!error_detected_); compressed_header_bytes_ += data.size();
diff --git a/quic/core/qpack/qpack_decoded_headers_accumulator.h b/quic/core/qpack/qpack_decoded_headers_accumulator.h index 96b527e..334fcbd 100644 --- a/quic/core/qpack/qpack_decoded_headers_accumulator.h +++ b/quic/core/qpack/qpack_decoded_headers_accumulator.h
@@ -12,7 +12,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -45,7 +45,8 @@ bool header_list_size_limit_exceeded) = 0; // Called when an error has occurred. - virtual void OnHeaderDecodingError(QuicStringPiece error_message) = 0; + virtual void OnHeaderDecodingError( + quiche::QuicheStringPiece error_message) = 0; }; QpackDecodedHeadersAccumulator(QuicStreamId id, @@ -56,14 +57,16 @@ // QpackProgressiveDecoder::HeadersHandlerInterface implementation. // These methods should only be called by |decoder_|. - void OnHeaderDecoded(QuicStringPiece name, QuicStringPiece value) override; + void OnHeaderDecoded(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) override; void OnDecodingCompleted() override; - void OnDecodingErrorDetected(QuicStringPiece error_message) override; + void OnDecodingErrorDetected( + quiche::QuicheStringPiece error_message) override; // Decode payload data. // Must not be called if an error has been detected. // Must not be called after EndHeaderBlock(). - void Decode(QuicStringPiece data); + void Decode(quiche::QuicheStringPiece data); // Signal end of HEADERS frame. // Must not be called if an error has been detected.
diff --git a/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc b/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc index 2334e89..c98f854 100644 --- a/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc +++ b/quic/core/qpack/qpack_decoded_headers_accumulator_test.cc
@@ -8,9 +8,10 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using ::testing::_; using ::testing::ElementsAre; @@ -44,7 +45,8 @@ MOCK_METHOD2(OnHeadersDecoded, void(QuicHeaderList headers, bool header_list_size_limit_exceeded)); - MOCK_METHOD1(OnHeaderDecodingError, void(QuicStringPiece error_message)); + MOCK_METHOD1(OnHeaderDecodingError, + void(quiche::QuicheStringPiece error_message)); }; } // anonymous namespace @@ -79,7 +81,7 @@ // HEADERS frame payload must have a complete Header Block Prefix. TEST_F(QpackDecodedHeadersAccumulatorTest, TruncatedHeaderBlockPrefix) { - accumulator_.Decode(QuicTextUtils::HexDecode("00")); + accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("00")); EXPECT_CALL(visitor_, OnHeaderDecodingError(Eq("Incomplete header data prefix."))); @@ -87,7 +89,7 @@ } TEST_F(QpackDecodedHeadersAccumulatorTest, EmptyHeaderList) { - std::string encoded_data(QuicTextUtils::HexDecode("0000")); + std::string encoded_data(quiche::QuicheTextUtils::HexDecode("0000")); accumulator_.Decode(encoded_data); QuicHeaderList header_list; @@ -103,7 +105,7 @@ // This payload is the prefix of a valid payload, but EndHeaderBlock() is called // before it can be completely decoded. TEST_F(QpackDecodedHeadersAccumulatorTest, TruncatedPayload) { - accumulator_.Decode(QuicTextUtils::HexDecode("00002366")); + accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("00002366")); EXPECT_CALL(visitor_, OnHeaderDecodingError(Eq("Incomplete header block."))); accumulator_.EndHeaderBlock(); @@ -113,11 +115,12 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, InvalidPayload) { EXPECT_CALL(visitor_, OnHeaderDecodingError(Eq("Static table entry not found."))); - accumulator_.Decode(QuicTextUtils::HexDecode("0000ff23ff24")); + accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("0000ff23ff24")); } TEST_F(QpackDecodedHeadersAccumulatorTest, Success) { - std::string encoded_data(QuicTextUtils::HexDecode("000023666f6f03626172")); + std::string encoded_data( + quiche::QuicheTextUtils::HexDecode("000023666f6f03626172")); accumulator_.Decode(encoded_data); QuicHeaderList header_list; @@ -135,7 +138,7 @@ // otherwise decoding could fail with "incomplete header block" error. TEST_F(QpackDecodedHeadersAccumulatorTest, ExceedLimitThenSplitInstruction) { // Total length of header list exceeds kMaxHeaderListSize. - accumulator_.Decode(QuicTextUtils::HexDecode( + accumulator_.Decode(quiche::QuicheTextUtils::HexDecode( "0000" // header block prefix "26666f6f626172" // header key: "foobar" "7d61616161616161616161616161616161616161" // header value: 'a' 125 times @@ -143,7 +146,7 @@ "616161616161616161616161616161616161616161616161616161616161616161616161" "61616161616161616161616161616161616161616161616161616161616161616161" "ff")); // first byte of a two-byte long Indexed Header Field instruction - accumulator_.Decode(QuicTextUtils::HexDecode( + accumulator_.Decode(quiche::QuicheTextUtils::HexDecode( "0f" // second byte of a two-byte long Indexed Header Field instruction )); @@ -154,7 +157,7 @@ // Test that header list limit enforcement works with blocked encoding. TEST_F(QpackDecodedHeadersAccumulatorTest, ExceedLimitBlocked) { // Total length of header list exceeds kMaxHeaderListSize. - accumulator_.Decode(QuicTextUtils::HexDecode( + accumulator_.Decode(quiche::QuicheTextUtils::HexDecode( "0200" // header block prefix "80" // reference to dynamic table entry not yet received "26666f6f626172" // header key: "foobar" @@ -176,7 +179,7 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, BlockedDecoding) { // Reference to dynamic table entry not yet received. - std::string encoded_data(QuicTextUtils::HexDecode("020080")); + std::string encoded_data(quiche::QuicheTextUtils::HexDecode("020080")); accumulator_.Decode(encoded_data); accumulator_.EndHeaderBlock(); @@ -200,7 +203,7 @@ TEST_F(QpackDecodedHeadersAccumulatorTest, BlockedDecodingUnblockedBeforeEndOfHeaderBlock) { // Reference to dynamic table entry not yet received. - accumulator_.Decode(QuicTextUtils::HexDecode("020080")); + accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("020080")); // Set dynamic table capacity. qpack_decoder_.OnSetDynamicTableCapacity(kMaxDynamicTableCapacity); @@ -210,7 +213,7 @@ // Rest of header block: same entry again. EXPECT_CALL(decoder_stream_sender_delegate_, WriteStreamData(Eq(kHeaderAcknowledgement))); - accumulator_.Decode(QuicTextUtils::HexDecode("80")); + accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("80")); QuicHeaderList header_list; EXPECT_CALL(visitor_, OnHeadersDecoded(_, false)) @@ -225,12 +228,12 @@ BlockedDecodingUnblockedAndErrorBeforeEndOfHeaderBlock) { // Required Insert Count higher than number of entries causes decoding to be // blocked. - accumulator_.Decode(QuicTextUtils::HexDecode("0200")); + accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("0200")); // Indexed Header Field instruction addressing dynamic table entry with // relative index 0, absolute index 0. - accumulator_.Decode(QuicTextUtils::HexDecode("80")); + accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("80")); // Relative index larger than or equal to Base is invalid. - accumulator_.Decode(QuicTextUtils::HexDecode("81")); + accumulator_.Decode(quiche::QuicheTextUtils::HexDecode("81")); // Set dynamic table capacity. qpack_decoder_.OnSetDynamicTableCapacity(kMaxDynamicTableCapacity);
diff --git a/quic/core/qpack/qpack_decoder.cc b/quic/core/qpack/qpack_decoder.cc index 3ae6bce..17790de 100644 --- a/quic/core/qpack/qpack_decoder.cc +++ b/quic/core/qpack/qpack_decoder.cc
@@ -8,6 +8,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_index_conversions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -69,7 +70,7 @@ void QpackDecoder::OnInsertWithNameReference(bool is_static, uint64_t name_index, - QuicStringPiece value) { + quiche::QuicheStringPiece value) { if (is_static) { auto entry = header_table_.LookupEntry(/* is_static = */ true, name_index); if (!entry) { @@ -108,8 +109,9 @@ } } -void QpackDecoder::OnInsertWithoutNameReference(QuicStringPiece name, - QuicStringPiece value) { +void QpackDecoder::OnInsertWithoutNameReference( + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { const QpackEntry* entry = header_table_.InsertEntry(name, value); if (!entry) { encoder_stream_error_delegate_->OnEncoderStreamError( @@ -147,7 +149,7 @@ } } -void QpackDecoder::OnErrorDetected(QuicStringPiece error_message) { +void QpackDecoder::OnErrorDetected(quiche::QuicheStringPiece error_message) { encoder_stream_error_delegate_->OnEncoderStreamError(error_message); }
diff --git a/quic/core/qpack/qpack_decoder.h b/quic/core/qpack/qpack_decoder.h index 4ac1e44..e09b14b 100644 --- a/quic/core/qpack/qpack_decoder.h +++ b/quic/core/qpack/qpack_decoder.h
@@ -15,7 +15,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_progressive_decoder.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -34,7 +34,8 @@ public: virtual ~EncoderStreamErrorDelegate() {} - virtual void OnEncoderStreamError(QuicStringPiece error_message) = 0; + virtual void OnEncoderStreamError( + quiche::QuicheStringPiece error_message) = 0; }; QpackDecoder(uint64_t maximum_dynamic_table_capacity, @@ -79,12 +80,12 @@ // QpackEncoderStreamReceiver::Delegate implementation void OnInsertWithNameReference(bool is_static, uint64_t name_index, - QuicStringPiece value) override; - void OnInsertWithoutNameReference(QuicStringPiece name, - QuicStringPiece value) override; + quiche::QuicheStringPiece value) override; + void OnInsertWithoutNameReference(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) override; void OnDuplicate(uint64_t index) override; void OnSetDynamicTableCapacity(uint64_t capacity) override; - void OnErrorDetected(QuicStringPiece error_message) override; + void OnErrorDetected(quiche::QuicheStringPiece error_message) override; // delegate must be set if dynamic table capacity is not zero. void set_qpack_stream_sender_delegate(QpackStreamSenderDelegate* delegate) {
diff --git a/quic/core/qpack/qpack_decoder_stream_receiver.cc b/quic/core/qpack/qpack_decoder_stream_receiver.cc index 2ba89d4..5d6cf83 100644 --- a/quic/core/qpack/qpack_decoder_stream_receiver.cc +++ b/quic/core/qpack/qpack_decoder_stream_receiver.cc
@@ -7,6 +7,7 @@ #include "net/third_party/quiche/src/http2/decoder/decode_buffer.h" #include "net/third_party/quiche/src/http2/decoder/decode_status.h" #include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -17,7 +18,7 @@ DCHECK(delegate_); } -void QpackDecoderStreamReceiver::Decode(QuicStringPiece data) { +void QpackDecoderStreamReceiver::Decode(quiche::QuicheStringPiece data) { if (data.empty() || error_detected_) { return; } @@ -42,7 +43,8 @@ return true; } -void QpackDecoderStreamReceiver::OnError(QuicStringPiece error_message) { +void QpackDecoderStreamReceiver::OnError( + quiche::QuicheStringPiece error_message) { DCHECK(!error_detected_); error_detected_ = true;
diff --git a/quic/core/qpack/qpack_decoder_stream_receiver.h b/quic/core/qpack/qpack_decoder_stream_receiver.h index 396c6df..19f51f0 100644 --- a/quic/core/qpack/qpack_decoder_stream_receiver.h +++ b/quic/core/qpack/qpack_decoder_stream_receiver.h
@@ -11,7 +11,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -34,7 +34,7 @@ // 5.3.3 Stream Cancellation virtual void OnStreamCancellation(QuicStreamId stream_id) = 0; // Decoding error - virtual void OnErrorDetected(QuicStringPiece error_message) = 0; + virtual void OnErrorDetected(quiche::QuicheStringPiece error_message) = 0; }; explicit QpackDecoderStreamReceiver(Delegate* delegate); @@ -47,11 +47,11 @@ // Decode data and call appropriate Delegate method after each decoded // instruction. Once an error occurs, Delegate::OnErrorDetected() is called, // and all further data is ignored. - void Decode(QuicStringPiece data) override; + void Decode(quiche::QuicheStringPiece data) override; // QpackInstructionDecoder::Delegate implementation. bool OnInstructionDecoded(const QpackInstruction* instruction) override; - void OnError(QuicStringPiece error_message) override; + void OnError(quiche::QuicheStringPiece error_message) override; private: QpackInstructionDecoder instruction_decoder_;
diff --git a/quic/core/qpack/qpack_decoder_stream_receiver_test.cc b/quic/core/qpack/qpack_decoder_stream_receiver_test.cc index 29a00d1..44a2286 100644 --- a/quic/core/qpack/qpack_decoder_stream_receiver_test.cc +++ b/quic/core/qpack/qpack_decoder_stream_receiver_test.cc
@@ -5,7 +5,8 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_receiver.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using testing::Eq; using testing::StrictMock; @@ -21,7 +22,7 @@ MOCK_METHOD1(OnInsertCountIncrement, void(uint64_t increment)); MOCK_METHOD1(OnHeaderAcknowledgement, void(QuicStreamId stream_id)); MOCK_METHOD1(OnStreamCancellation, void(QuicStreamId stream_id)); - MOCK_METHOD1(OnErrorDetected, void(QuicStringPiece error_message)); + MOCK_METHOD1(OnErrorDetected, void(quiche::QuicheStringPiece error_message)); }; class QpackDecoderStreamReceiverTest : public QuicTest { @@ -35,53 +36,53 @@ TEST_F(QpackDecoderStreamReceiverTest, InsertCountIncrement) { EXPECT_CALL(delegate_, OnInsertCountIncrement(0)); - stream_.Decode(QuicTextUtils::HexDecode("00")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("00")); EXPECT_CALL(delegate_, OnInsertCountIncrement(10)); - stream_.Decode(QuicTextUtils::HexDecode("0a")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("0a")); EXPECT_CALL(delegate_, OnInsertCountIncrement(63)); - stream_.Decode(QuicTextUtils::HexDecode("3f00")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("3f00")); EXPECT_CALL(delegate_, OnInsertCountIncrement(200)); - stream_.Decode(QuicTextUtils::HexDecode("3f8901")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("3f8901")); EXPECT_CALL(delegate_, OnErrorDetected(Eq("Encoded integer too large."))); - stream_.Decode(QuicTextUtils::HexDecode("3fffffffffffffffffffff")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("3fffffffffffffffffffff")); } TEST_F(QpackDecoderStreamReceiverTest, HeaderAcknowledgement) { EXPECT_CALL(delegate_, OnHeaderAcknowledgement(0)); - stream_.Decode(QuicTextUtils::HexDecode("80")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("80")); EXPECT_CALL(delegate_, OnHeaderAcknowledgement(37)); - stream_.Decode(QuicTextUtils::HexDecode("a5")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("a5")); EXPECT_CALL(delegate_, OnHeaderAcknowledgement(127)); - stream_.Decode(QuicTextUtils::HexDecode("ff00")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("ff00")); EXPECT_CALL(delegate_, OnHeaderAcknowledgement(503)); - stream_.Decode(QuicTextUtils::HexDecode("fff802")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("fff802")); EXPECT_CALL(delegate_, OnErrorDetected(Eq("Encoded integer too large."))); - stream_.Decode(QuicTextUtils::HexDecode("ffffffffffffffffffffff")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("ffffffffffffffffffffff")); } TEST_F(QpackDecoderStreamReceiverTest, StreamCancellation) { EXPECT_CALL(delegate_, OnStreamCancellation(0)); - stream_.Decode(QuicTextUtils::HexDecode("40")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("40")); EXPECT_CALL(delegate_, OnStreamCancellation(19)); - stream_.Decode(QuicTextUtils::HexDecode("53")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("53")); EXPECT_CALL(delegate_, OnStreamCancellation(63)); - stream_.Decode(QuicTextUtils::HexDecode("7f00")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("7f00")); EXPECT_CALL(delegate_, OnStreamCancellation(110)); - stream_.Decode(QuicTextUtils::HexDecode("7f2f")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("7f2f")); EXPECT_CALL(delegate_, OnErrorDetected(Eq("Encoded integer too large."))); - stream_.Decode(QuicTextUtils::HexDecode("7fffffffffffffffffffff")); + stream_.Decode(quiche::QuicheTextUtils::HexDecode("7fffffffffffffffffffff")); } } // namespace
diff --git a/quic/core/qpack/qpack_decoder_stream_sender.cc b/quic/core/qpack/qpack_decoder_stream_sender.cc index 72a446b..34f4de8 100644 --- a/quic/core/qpack/qpack_decoder_stream_sender.cc +++ b/quic/core/qpack/qpack_decoder_stream_sender.cc
@@ -10,6 +10,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic {
diff --git a/quic/core/qpack/qpack_decoder_stream_sender.h b/quic/core/qpack/qpack_decoder_stream_sender.h index d9033b0..eee95c1 100644 --- a/quic/core/qpack/qpack_decoder_stream_sender.h +++ b/quic/core/qpack/qpack_decoder_stream_sender.h
@@ -11,7 +11,6 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" namespace quic {
diff --git a/quic/core/qpack/qpack_decoder_stream_sender_test.cc b/quic/core/qpack/qpack_decoder_stream_sender_test.cc index e3dc124..1d18fa9 100644 --- a/quic/core/qpack/qpack_decoder_stream_sender_test.cc +++ b/quic/core/qpack/qpack_decoder_stream_sender_test.cc
@@ -5,8 +5,8 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_decoder_stream_sender.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using ::testing::Eq; using ::testing::StrictMock; @@ -27,57 +27,67 @@ }; TEST_F(QpackDecoderStreamSenderTest, InsertCountIncrement) { - EXPECT_CALL(delegate_, WriteStreamData(Eq(QuicTextUtils::HexDecode("00")))); + EXPECT_CALL(delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("00")))); stream_.SendInsertCountIncrement(0); stream_.Flush(); - EXPECT_CALL(delegate_, WriteStreamData(Eq(QuicTextUtils::HexDecode("0a")))); + EXPECT_CALL(delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("0a")))); stream_.SendInsertCountIncrement(10); stream_.Flush(); - EXPECT_CALL(delegate_, WriteStreamData(Eq(QuicTextUtils::HexDecode("3f00")))); + EXPECT_CALL(delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("3f00")))); stream_.SendInsertCountIncrement(63); stream_.Flush(); - EXPECT_CALL(delegate_, - WriteStreamData(Eq(QuicTextUtils::HexDecode("3f8901")))); + EXPECT_CALL(delegate_, WriteStreamData( + Eq(quiche::QuicheTextUtils::HexDecode("3f8901")))); stream_.SendInsertCountIncrement(200); stream_.Flush(); } TEST_F(QpackDecoderStreamSenderTest, HeaderAcknowledgement) { - EXPECT_CALL(delegate_, WriteStreamData(Eq(QuicTextUtils::HexDecode("80")))); + EXPECT_CALL(delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("80")))); stream_.SendHeaderAcknowledgement(0); stream_.Flush(); - EXPECT_CALL(delegate_, WriteStreamData(Eq(QuicTextUtils::HexDecode("a5")))); + EXPECT_CALL(delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("a5")))); stream_.SendHeaderAcknowledgement(37); stream_.Flush(); - EXPECT_CALL(delegate_, WriteStreamData(Eq(QuicTextUtils::HexDecode("ff00")))); + EXPECT_CALL(delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("ff00")))); stream_.SendHeaderAcknowledgement(127); stream_.Flush(); - EXPECT_CALL(delegate_, - WriteStreamData(Eq(QuicTextUtils::HexDecode("fff802")))); + EXPECT_CALL(delegate_, WriteStreamData( + Eq(quiche::QuicheTextUtils::HexDecode("fff802")))); stream_.SendHeaderAcknowledgement(503); stream_.Flush(); } TEST_F(QpackDecoderStreamSenderTest, StreamCancellation) { - EXPECT_CALL(delegate_, WriteStreamData(Eq(QuicTextUtils::HexDecode("40")))); + EXPECT_CALL(delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("40")))); stream_.SendStreamCancellation(0); stream_.Flush(); - EXPECT_CALL(delegate_, WriteStreamData(Eq(QuicTextUtils::HexDecode("53")))); + EXPECT_CALL(delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("53")))); stream_.SendStreamCancellation(19); stream_.Flush(); - EXPECT_CALL(delegate_, WriteStreamData(Eq(QuicTextUtils::HexDecode("7f00")))); + EXPECT_CALL(delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("7f00")))); stream_.SendStreamCancellation(63); stream_.Flush(); - EXPECT_CALL(delegate_, WriteStreamData(Eq(QuicTextUtils::HexDecode("7f2f")))); + EXPECT_CALL(delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("7f2f")))); stream_.SendStreamCancellation(110); stream_.Flush(); } @@ -87,15 +97,16 @@ stream_.SendHeaderAcknowledgement(37); stream_.SendStreamCancellation(0); - EXPECT_CALL(delegate_, - WriteStreamData(Eq(QuicTextUtils::HexDecode("0aa540")))); + EXPECT_CALL(delegate_, WriteStreamData( + Eq(quiche::QuicheTextUtils::HexDecode("0aa540")))); stream_.Flush(); stream_.SendInsertCountIncrement(63); stream_.SendStreamCancellation(110); - EXPECT_CALL(delegate_, - WriteStreamData(Eq(QuicTextUtils::HexDecode("3f007f2f")))); + EXPECT_CALL( + delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("3f007f2f")))); stream_.Flush(); }
diff --git a/quic/core/qpack/qpack_decoder_test.cc b/quic/core/qpack/qpack_decoder_test.cc index 1fc5802..8b546b0 100644 --- a/quic/core/qpack/qpack_decoder_test.cc +++ b/quic/core/qpack/qpack_decoder_test.cc
@@ -8,9 +8,10 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" using ::testing::_; @@ -48,12 +49,13 @@ // Destroy QpackProgressiveDecoder on error to test that it does not crash. // See https://crbug.com/1025209. ON_CALL(handler_, OnDecodingErrorDetected(_)) - .WillByDefault(Invoke([this](QuicStringPiece /* error_message */) { - progressive_decoder_.reset(); - })); + .WillByDefault( + Invoke([this](quiche::QuicheStringPiece /* error_message */) { + progressive_decoder_.reset(); + })); } - void DecodeEncoderStreamData(QuicStringPiece data) { + void DecodeEncoderStreamData(quiche::QuicheStringPiece data) { qpack_decoder_.encoder_stream_receiver()->Decode(data); } @@ -69,7 +71,7 @@ // Pass header block data to QpackProgressiveDecoder::Decode() // in fragments dictated by |fragment_mode_|. - void DecodeData(QuicStringPiece data) { + void DecodeData(quiche::QuicheStringPiece data) { auto fragment_size_generator = FragmentModeToFragmentSizeGenerator(fragment_mode_); while (progressive_decoder_ && !data.empty()) { @@ -89,7 +91,7 @@ } // Decode an entire header block. - void DecodeHeaderBlock(QuicStringPiece data) { + void DecodeHeaderBlock(quiche::QuicheStringPiece data) { StartDecoding(); DecodeData(data); EndDecoding(); @@ -115,7 +117,7 @@ OnDecodingErrorDetected(Eq("Incomplete header data prefix."))); // Header Data Prefix is at least two bytes long. - DecodeHeaderBlock(QuicTextUtils::HexDecode("00")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("00")); } // Regression test for https://1025209: QpackProgressiveDecoder must not crash @@ -127,50 +129,52 @@ OnDecodingErrorDetected(Eq("Encoded integer too large."))); // Encoded Required Insert Count in Header Data Prefix is too large. - DecodeData(QuicTextUtils::HexDecode("ffffffffffffffffffffffffffff")); + DecodeData( + quiche::QuicheTextUtils::HexDecode("ffffffffffffffffffffffffffff")); } TEST_P(QpackDecoderTest, EmptyHeaderBlock) { EXPECT_CALL(handler_, OnDecodingCompleted()); - DecodeHeaderBlock(QuicTextUtils::HexDecode("0000")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("0000")); } TEST_P(QpackDecoderTest, LiteralEntryEmptyName) { EXPECT_CALL(handler_, OnHeaderDecoded(Eq(""), Eq("foo"))); EXPECT_CALL(handler_, OnDecodingCompleted()); - DecodeHeaderBlock(QuicTextUtils::HexDecode("00002003666f6f")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("00002003666f6f")); } TEST_P(QpackDecoderTest, LiteralEntryEmptyValue) { EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq(""))); EXPECT_CALL(handler_, OnDecodingCompleted()); - DecodeHeaderBlock(QuicTextUtils::HexDecode("000023666f6f00")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("000023666f6f00")); } TEST_P(QpackDecoderTest, LiteralEntryEmptyNameAndValue) { EXPECT_CALL(handler_, OnHeaderDecoded(Eq(""), Eq(""))); EXPECT_CALL(handler_, OnDecodingCompleted()); - DecodeHeaderBlock(QuicTextUtils::HexDecode("00002000")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("00002000")); } TEST_P(QpackDecoderTest, SimpleLiteralEntry) { EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar"))); EXPECT_CALL(handler_, OnDecodingCompleted()); - DecodeHeaderBlock(QuicTextUtils::HexDecode("000023666f6f03626172")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("000023666f6f03626172")); } TEST_P(QpackDecoderTest, MultipleLiteralEntries) { EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar"))); std::string str(127, 'a'); - EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foobaar"), QuicStringPiece(str))); + EXPECT_CALL(handler_, + OnHeaderDecoded(Eq("foobaar"), quiche::QuicheStringPiece(str))); EXPECT_CALL(handler_, OnDecodingCompleted()); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0000" // prefix "23666f6f03626172" // foo: bar "2700666f6f62616172" // 7 octet long header name, the smallest number @@ -188,7 +192,8 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Encoded integer too large."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode("000027ffffffffffffffffffff")); + DecodeHeaderBlock( + quiche::QuicheTextUtils::HexDecode("000027ffffffffffffffffffff")); } // Name Length value can be decoded by varint decoder but exceeds 1 MB limit. @@ -196,7 +201,7 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("String literal too long."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode("000027ffff7f")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("000027ffff7f")); } // Value Length value is too large for varint decoder to decode. @@ -205,7 +210,7 @@ OnDecodingErrorDetected(Eq("Encoded integer too large."))); DecodeHeaderBlock( - QuicTextUtils::HexDecode("000023666f6f7fffffffffffffffffffff")); + quiche::QuicheTextUtils::HexDecode("000023666f6f7fffffffffffffffffffff")); } // Value Length value can be decoded by varint decoder but exceeds 1 MB limit. @@ -213,22 +218,22 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("String literal too long."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode("000023666f6f7fffff7f")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("000023666f6f7fffff7f")); } TEST_P(QpackDecoderTest, IncompleteHeaderBlock) { EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Incomplete header block."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode("00002366")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("00002366")); } TEST_P(QpackDecoderTest, HuffmanSimple) { EXPECT_CALL(handler_, OnHeaderDecoded(Eq("custom-key"), Eq("custom-value"))); EXPECT_CALL(handler_, OnDecodingCompleted()); - DecodeHeaderBlock( - QuicTextUtils::HexDecode("00002f0125a849e95ba97d7f8925a849e95bb8e8b4bf")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( + "00002f0125a849e95ba97d7f8925a849e95bb8e8b4bf")); } TEST_P(QpackDecoderTest, AlternatingHuffmanNonHuffman) { @@ -236,7 +241,7 @@ .Times(4); EXPECT_CALL(handler_, OnDecodingCompleted()); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0000" // Prefix. "2f0125a849e95ba97d7f" // Huffman-encoded name. "8925a849e95bb8e8b4bf" // Huffman-encoded value. @@ -249,44 +254,44 @@ } TEST_P(QpackDecoderTest, HuffmanNameDoesNotHaveEOSPrefix) { - EXPECT_CALL(handler_, OnDecodingErrorDetected(QuicStringPiece( + EXPECT_CALL(handler_, OnDecodingErrorDetected(quiche::QuicheStringPiece( "Error in Huffman-encoded string."))); // 'y' ends in 0b0 on the most significant bit of the last byte. // The remaining 7 bits must be a prefix of EOS, which is all 1s. - DecodeHeaderBlock( - QuicTextUtils::HexDecode("00002f0125a849e95ba97d7e8925a849e95bb8e8b4bf")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( + "00002f0125a849e95ba97d7e8925a849e95bb8e8b4bf")); } TEST_P(QpackDecoderTest, HuffmanValueDoesNotHaveEOSPrefix) { - EXPECT_CALL(handler_, OnDecodingErrorDetected(QuicStringPiece( + EXPECT_CALL(handler_, OnDecodingErrorDetected(quiche::QuicheStringPiece( "Error in Huffman-encoded string."))); // 'e' ends in 0b101, taking up the 3 most significant bits of the last byte. // The remaining 5 bits must be a prefix of EOS, which is all 1s. - DecodeHeaderBlock( - QuicTextUtils::HexDecode("00002f0125a849e95ba97d7f8925a849e95bb8e8b4be")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( + "00002f0125a849e95ba97d7f8925a849e95bb8e8b4be")); } TEST_P(QpackDecoderTest, HuffmanNameEOSPrefixTooLong) { - EXPECT_CALL(handler_, OnDecodingErrorDetected(QuicStringPiece( + EXPECT_CALL(handler_, OnDecodingErrorDetected(quiche::QuicheStringPiece( "Error in Huffman-encoded string."))); // The trailing EOS prefix must be at most 7 bits long. Appending one octet // with value 0xff is invalid, even though 0b111111111111111 (15 bits) is a // prefix of EOS. - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "00002f0225a849e95ba97d7fff8925a849e95bb8e8b4bf")); } TEST_P(QpackDecoderTest, HuffmanValueEOSPrefixTooLong) { - EXPECT_CALL(handler_, OnDecodingErrorDetected(QuicStringPiece( + EXPECT_CALL(handler_, OnDecodingErrorDetected(quiche::QuicheStringPiece( "Error in Huffman-encoded string."))); // The trailing EOS prefix must be at most 7 bits long. Appending one octet // with value 0xff is invalid, even though 0b1111111111111 (13 bits) is a // prefix of EOS. - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "00002f0125a849e95ba97d7f8a25a849e95bb8e8b4bfff")); } @@ -308,7 +313,7 @@ EXPECT_CALL(handler_, OnDecodingCompleted()); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0000d1dfccd45f108621e9aec2a11f5c8294e75f000554524143455f1000")); } @@ -321,11 +326,11 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Static table entry not found."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode("0000ff23ff24")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("0000ff23ff24")); } TEST_P(QpackDecoderTest, DynamicTable) { - DecodeEncoderStreamData(QuicTextUtils::HexDecode( + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode( "3fe107" // Set dynamic table capacity to 1024. "6294e703626172" // Add literal entry with name "foo" and value "bar". "80035a5a5a" // Add entry with name of dynamic table entry index 0 @@ -354,7 +359,7 @@ .InSequence(s); EXPECT_CALL(handler_, OnDecodingCompleted()).InSequence(s); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0500" // Required Insert Count 4 and Delta Base 0. // Base is 4 + 0 = 4. "83" // Dynamic table entry with relative index 3, absolute index 0. @@ -375,7 +380,7 @@ .InSequence(s); EXPECT_CALL(handler_, OnDecodingCompleted()).InSequence(s); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0502" // Required Insert Count 4 and Delta Base 2. // Base is 4 + 2 = 6. "85" // Dynamic table entry with relative index 5, absolute index 0. @@ -396,7 +401,7 @@ .InSequence(s); EXPECT_CALL(handler_, OnDecodingCompleted()).InSequence(s); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0582" // Required Insert Count 4 and Delta Base 2 with sign bit set. // Base is 4 - 2 - 1 = 1. "80" // Dynamic table entry with relative index 0, absolute index 0. @@ -409,28 +414,28 @@ TEST_P(QpackDecoderTest, DecreasingDynamicTableCapacityEvictsEntries) { // Set dynamic table capacity to 1024. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fe107")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107")); // Add literal entry with name "foo" and value "bar". - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar"))); EXPECT_CALL(handler_, OnDecodingCompleted()); EXPECT_CALL(decoder_stream_sender_delegate_, WriteStreamData(Eq(kHeaderAcknowledgement))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0200" // Required Insert Count 1 and Delta Base 0. // Base is 1 + 0 = 1. "80")); // Dynamic table entry with relative index 0, absolute index 0. // Change dynamic table capacity to 32 bytes, smaller than the entry. // This must cause the entry to be evicted. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3f01")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3f01")); EXPECT_CALL(handler_, OnDecodingErrorDetected( Eq("Dynamic table entry already evicted."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0200" // Required Insert Count 1 and Delta Base 0. // Base is 1 + 0 = 1. "80")); // Dynamic table entry with relative index 0, absolute index 0. @@ -441,9 +446,9 @@ OnEncoderStreamError(Eq("Error inserting literal entry."))); // Set dynamic table capacity to 34. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3f03")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3f03")); // Add literal entry with name "foo" and value "bar", size is 32 + 3 + 3 = 38. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); } TEST_P(QpackDecoderTest, EncoderStreamErrorInvalidStaticTableEntry) { @@ -451,14 +456,14 @@ OnEncoderStreamError(Eq("Invalid static table entry."))); // Address invalid static table entry index 99. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("ff2400")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("ff2400")); } TEST_P(QpackDecoderTest, EncoderStreamErrorInvalidDynamicTableEntry) { EXPECT_CALL(encoder_stream_error_delegate_, OnEncoderStreamError(Eq("Invalid relative index."))); - DecodeEncoderStreamData(QuicTextUtils::HexDecode( + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode( "3fe107" // Set dynamic table capacity to 1024. "6294e703626172" // Add literal entry with name "foo" and value "bar". "8100")); // Address dynamic table entry with relative index 1. Such @@ -470,7 +475,7 @@ EXPECT_CALL(encoder_stream_error_delegate_, OnEncoderStreamError(Eq("Invalid relative index."))); - DecodeEncoderStreamData(QuicTextUtils::HexDecode( + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode( "3fe107" // Set dynamic table capacity to 1024. "6294e703626172" // Add literal entry with name "foo" and value "bar". "01")); // Duplicate dynamic table entry with relative index 1. Such @@ -482,18 +487,19 @@ EXPECT_CALL(encoder_stream_error_delegate_, OnEncoderStreamError(Eq("Encoded integer too large."))); - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fffffffffffffffffffff")); + DecodeEncoderStreamData( + quiche::QuicheTextUtils::HexDecode("3fffffffffffffffffffff")); } TEST_P(QpackDecoderTest, InvalidDynamicEntryWhenBaseIsZero) { EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Invalid relative index."))); // Set dynamic table capacity to 1024. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fe107")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107")); // Add literal entry with name "foo" and value "bar". - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0280" // Required Insert Count is 1. Base 1 - 1 - 0 = 0 is explicitly // permitted by the spec. "80")); // However, addressing entry with relative index 0 would point to @@ -505,18 +511,18 @@ // Required Insert Count 1, Delta Base 1 with sign bit set, Base would // be 1 - 1 - 1 = -1, but it is not allowed to be negative. - DecodeHeaderBlock(QuicTextUtils::HexDecode("0281")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("0281")); } TEST_P(QpackDecoderTest, InvalidDynamicEntryByRelativeIndex) { // Set dynamic table capacity to 1024. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fe107")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107")); // Add literal entry with name "foo" and value "bar". - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Invalid relative index."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0200" // Required Insert Count 1 and Delta Base 0. // Base is 1 + 0 = 1. "81")); // Indexed Header Field instruction addressing relative index 1. @@ -524,7 +530,7 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Invalid relative index."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0200" // Required Insert Count 1 and Delta Base 0. // Base is 1 + 0 = 1. "4100")); // Literal Header Field with Name Reference instruction @@ -534,18 +540,18 @@ TEST_P(QpackDecoderTest, EvictedDynamicTableEntry) { // Update dynamic table capacity to 128. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3f61")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3f61")); // Add literal entry with name "foo" and value "bar", size 32 + 3 + 3 = 38. // This fits in the table three times. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); // Duplicate entry four times. This evicts the first two instances. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("00000000")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("00000000")); EXPECT_CALL(handler_, OnDecodingErrorDetected( Eq("Dynamic table entry already evicted."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0500" // Required Insert Count 4 and Delta Base 0. // Base is 4 + 0 = 4. "82")); // Indexed Header Field instruction addressing relative index 2. @@ -554,7 +560,7 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected( Eq("Dynamic table entry already evicted."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0500" // Required Insert Count 4 and Delta Base 0. // Base is 4 + 0 = 4. "4200")); // Literal Header Field with Name Reference instruction @@ -564,7 +570,7 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected( Eq("Dynamic table entry already evicted."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0380" // Required Insert Count 2 and Delta Base 0 with sign bit set. // Base is 2 - 0 - 1 = 1 "10")); // Indexed Header Field instruction addressing dynamic table @@ -574,7 +580,7 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected( Eq("Dynamic table entry already evicted."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0380" // Required Insert Count 2 and Delta Base 0 with sign bit set. // Base is 2 - 0 - 1 = 1 "0000")); // Literal Header Field With Name Reference instruction @@ -588,12 +594,12 @@ OnEncoderStreamError(Eq("Error updating dynamic table capacity."))); // Try to update dynamic table capacity to 2048, which exceeds the maximum. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fe10f")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe10f")); } TEST_P(QpackDecoderTest, SetDynamicTableCapacity) { // Update dynamic table capacity to 128, which does not exceed the maximum. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3f61")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3f61")); } TEST_P(QpackDecoderTest, InvalidEncodedRequiredInsertCount) { @@ -603,7 +609,7 @@ // A value of 1 cannot be encoded as 65 even though it has the same remainder. EXPECT_CALL(handler_, OnDecodingErrorDetected( Eq("Error decoding Required Insert Count."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode("4100")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("4100")); } // Regression test for https://crbug.com/970218: Decoder must stop processing @@ -612,7 +618,7 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected( Eq("Error decoding Required Insert Count."))); // Header Block Prefix followed by some extra data. - DecodeHeaderBlock(QuicTextUtils::HexDecode("410000")); + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode("410000")); } TEST_P(QpackDecoderTest, WrappedRequiredInsertCount) { @@ -620,12 +626,12 @@ // MaxEntries is 1024 / 32 = 32. // Set dynamic table capacity to 1024. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fe107")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107")); // Add literal entry with name "foo" and a 600 byte long value. This will fit // in the dynamic table once but not twice. DecodeEncoderStreamData( - QuicTextUtils::HexDecode("6294e7" // Name "foo". - "7fd903")); // Value length 600. + quiche::QuicheTextUtils::HexDecode("6294e7" // Name "foo". + "7fd903")); // Value length 600. std::string header_value(600, 'Z'); DecodeEncoderStreamData(header_value); @@ -640,7 +646,7 @@ WriteStreamData(Eq(kHeaderAcknowledgement))); // Send header block with Required Insert Count = 201. - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0a00" // Encoded Required Insert Count 10, Required Insert Count 201, // Delta Base 0, Base 201. "80")); // Emit dynamic table entry with relative index 0. @@ -648,31 +654,31 @@ TEST_P(QpackDecoderTest, NonZeroRequiredInsertCountButNoDynamicEntries) { // Set dynamic table capacity to 1024. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fe107")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107")); // Add literal entry with name "foo" and value "bar". - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); EXPECT_CALL(handler_, OnHeaderDecoded(Eq(":method"), Eq("GET"))); EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Required Insert Count too large."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0200" // Required Insert Count is 1. "d1")); // But the only instruction references the static table. } TEST_P(QpackDecoderTest, AddressEntryNotAllowedByRequiredInsertCount) { // Set dynamic table capacity to 1024. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fe107")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107")); // Add literal entry with name "foo" and value "bar". - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); EXPECT_CALL( handler_, OnDecodingErrorDetected( Eq("Absolute Index must be smaller than Required Insert Count."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0201" // Required Insert Count 1 and Delta Base 1. // Base is 1 + 1 = 2. "80")); // Indexed Header Field instruction addressing dynamic table @@ -684,7 +690,7 @@ OnDecodingErrorDetected( Eq("Absolute Index must be smaller than Required Insert Count."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0201" // Required Insert Count 1 and Delta Base 1. // Base is 1 + 1 = 2. "4000")); // Literal Header Field with Name Reference instruction @@ -697,7 +703,7 @@ OnDecodingErrorDetected( Eq("Absolute Index must be smaller than Required Insert Count."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0200" // Required Insert Count 1 and Delta Base 0. // Base is 1 + 0 = 1. "10")); // Indexed Header Field with Post-Base Index instruction @@ -710,7 +716,7 @@ OnDecodingErrorDetected( Eq("Absolute Index must be smaller than Required Insert Count."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0200" // Required Insert Count 1 and Delta Base 0. // Base is 1 + 0 = 1. "0000")); // Literal Header Field with Post-Base Name Reference @@ -721,19 +727,19 @@ TEST_P(QpackDecoderTest, PromisedRequiredInsertCountLargerThanActual) { // Set dynamic table capacity to 1024. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fe107")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107")); // Add literal entry with name "foo" and value "bar". - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); // Duplicate entry twice so that decoding of header blocks with Required // Insert Count not exceeding 3 is not blocked. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("00")); - DecodeEncoderStreamData(QuicTextUtils::HexDecode("00")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("00")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("00")); EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar"))); EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Required Insert Count too large."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0300" // Required Insert Count 2 and Delta Base 0. // Base is 2 + 0 = 2. "81")); // Indexed Header Field instruction addressing dynamic table @@ -745,7 +751,7 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Required Insert Count too large."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0300" // Required Insert Count 2 and Delta Base 0. // Base is 2 + 0 = 2. "4100")); // Literal Header Field with Name Reference instruction @@ -757,7 +763,7 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Required Insert Count too large."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0481" // Required Insert Count 3 and Delta Base 1 with sign bit set. // Base is 3 - 1 - 1 = 1. "10")); // Indexed Header Field with Post-Base Index instruction @@ -769,7 +775,7 @@ EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Required Insert Count too large."))); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0481" // Required Insert Count 3 and Delta Base 1 with sign bit set. // Base is 3 - 1 - 1 = 1. "0000")); // Literal Header Field with Post-Base Name Reference @@ -779,7 +785,7 @@ } TEST_P(QpackDecoderTest, BlockedDecoding) { - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0200" // Required Insert Count 1 and Delta Base 0. // Base is 1 + 0 = 1. "80")); // Indexed Header Field instruction addressing dynamic table @@ -791,14 +797,14 @@ WriteStreamData(Eq(kHeaderAcknowledgement))); // Set dynamic table capacity to 1024. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fe107")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107")); // Add literal entry with name "foo" and value "bar". - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); } TEST_P(QpackDecoderTest, BlockedDecodingUnblockedBeforeEndOfHeaderBlock) { StartDecoding(); - DecodeData(QuicTextUtils::HexDecode( + DecodeData(quiche::QuicheTextUtils::HexDecode( "0200" // Required Insert Count 1 and Delta Base 0. // Base is 1 + 0 = 1. "80" // Indexed Header Field instruction addressing dynamic table @@ -806,7 +812,7 @@ "d1")); // Static table entry with index 17. // Set dynamic table capacity to 1024. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fe107")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107")); // Add literal entry with name "foo" and value "bar". Decoding is now // unblocked because dynamic table Insert Count reached the Required Insert @@ -814,14 +820,14 @@ // the already consumed part of the header block. EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar"))); EXPECT_CALL(handler_, OnHeaderDecoded(Eq(":method"), Eq("GET"))); - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); Mock::VerifyAndClearExpectations(&handler_); // Rest of header block is processed by QpackProgressiveDecoder // in the unblocked state. EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar"))); EXPECT_CALL(handler_, OnHeaderDecoded(Eq(":scheme"), Eq("https"))); - DecodeData(QuicTextUtils::HexDecode( + DecodeData(quiche::QuicheTextUtils::HexDecode( "80" // Indexed Header Field instruction addressing dynamic table // entry with relative index 0, absolute index 0. "d7")); // Static table entry with index 23. @@ -837,7 +843,7 @@ TEST_P(QpackDecoderTest, BlockedDecodingUnblockedAndErrorBeforeEndOfHeaderBlock) { StartDecoding(); - DecodeData(QuicTextUtils::HexDecode( + DecodeData(quiche::QuicheTextUtils::HexDecode( "0200" // Required Insert Count 1 and Delta Base 0. // Base is 1 + 0 = 1. "80" // Indexed Header Field instruction addressing dynamic table @@ -845,7 +851,7 @@ "81")); // Relative index 1 is equal to Base, therefore invalid. // Set dynamic table capacity to 1024. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3fe107")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3fe107")); // Add literal entry with name "foo" and value "bar". Decoding is now // unblocked because dynamic table Insert Count reached the Required Insert @@ -853,7 +859,7 @@ // the already consumed part of the header block. EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("bar"))); EXPECT_CALL(handler_, OnDecodingErrorDetected(Eq("Invalid relative index."))); - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); } // Make sure that Required Insert Count is compared to Insert Count, @@ -861,19 +867,19 @@ TEST_P(QpackDecoderTest, BlockedDecodingAndEvictedEntries) { // Update dynamic table capacity to 128. // At most three non-empty entries fit in the dynamic table. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("3f61")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("3f61")); - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0700" // Required Insert Count 6 and Delta Base 0. // Base is 6 + 0 = 6. "80")); // Indexed Header Field instruction addressing dynamic table // entry with relative index 0, absolute index 5. // Add literal entry with name "foo" and value "bar". - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e703626172")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e703626172")); // Duplicate entry four times. This evicts the first two instances. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("00000000")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("00000000")); EXPECT_CALL(handler_, OnHeaderDecoded(Eq("foo"), Eq("baz"))); EXPECT_CALL(handler_, OnDecodingCompleted()); @@ -882,13 +888,13 @@ // Add literal entry with name "foo" and value "bar". // Insert Count is now 6, reaching Required Insert Count of the header block. - DecodeEncoderStreamData(QuicTextUtils::HexDecode("6294e70362617a")); + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode("6294e70362617a")); } TEST_P(QpackDecoderTest, TooManyBlockedStreams) { // Required Insert Count 1 and Delta Base 0. // Without any dynamic table entries received, decoding is blocked. - std::string data = QuicTextUtils::HexDecode("0200"); + std::string data = quiche::QuicheTextUtils::HexDecode("0200"); auto progressive_decoder1 = CreateProgressiveDecoder(/* stream_id = */ 1); progressive_decoder1->Decode(data); @@ -901,7 +907,7 @@ } TEST_P(QpackDecoderTest, InsertCountIncrement) { - DecodeEncoderStreamData(QuicTextUtils::HexDecode( + DecodeEncoderStreamData(quiche::QuicheTextUtils::HexDecode( "3fe107" // Set dynamic table capacity to 1024. "6294e703626172" // Add literal entry with name "foo" and value "bar". "00")); // Duplicate entry. @@ -913,11 +919,11 @@ // Known Insert Count to one. Decoder should send an Insert Count Increment // instruction with increment of one to update Known Insert Count to two. EXPECT_CALL(decoder_stream_sender_delegate_, - WriteStreamData(Eq(QuicTextUtils::HexDecode( + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode( "81" // Header Acknowledgement on stream 1 "01")))); // Insert Count Increment with increment of one - DecodeHeaderBlock(QuicTextUtils::HexDecode( + DecodeHeaderBlock(quiche::QuicheTextUtils::HexDecode( "0200" // Required Insert Count 1 and Delta Base 0. // Base is 1 + 0 = 1. "80")); // Dynamic table entry with relative index 0, absolute index 0.
diff --git a/quic/core/qpack/qpack_encoder.cc b/quic/core/qpack/qpack_encoder.cc index 59e172e..2b30e98 100644 --- a/quic/core/qpack/qpack_encoder.cc +++ b/quic/core/qpack/qpack_encoder.cc
@@ -12,7 +12,8 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h" #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_str_cat.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -57,7 +58,7 @@ QpackEncoder::EncodeLiteralHeaderFieldWithNameReference( bool is_static, uint64_t index, - QuicStringPiece value, + quiche::QuicheStringPiece value, QpackBlockingManager::IndexSet* referred_indices) { // Add |index| to |*referred_indices| only if entry is in the dynamic table. if (!is_static) { @@ -69,8 +70,8 @@ // static QpackInstructionWithValues QpackEncoder::EncodeLiteralHeaderField( - QuicStringPiece name, - QuicStringPiece value) { + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { return QpackInstructionWithValues::LiteralHeaderField(name, value); } @@ -104,8 +105,8 @@ for (const auto& header : ValueSplittingHeaderList(&header_list)) { // These strings are owned by |header_list|. - QuicStringPiece name = header.first; - QuicStringPiece value = header.second; + quiche::QuicheStringPiece name = header.first; + quiche::QuicheStringPiece value = header.second; bool is_static; uint64_t index; @@ -397,7 +398,7 @@ if (blocking_manager_.known_received_count() > header_table_.inserted_entry_count()) { - decoder_stream_error_delegate_->OnDecoderStreamError(QuicStrCat( + decoder_stream_error_delegate_->OnDecoderStreamError(quiche::QuicheStrCat( "Increment value ", increment, " raises known received count to ", blocking_manager_.known_received_count(), " exceeding inserted entry count ", @@ -408,8 +409,8 @@ 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.")); + quiche::QuicheStrCat("Header Acknowledgement received for stream ", + stream_id, " with no outstanding header blocks.")); } } @@ -417,7 +418,7 @@ blocking_manager_.OnStreamCancellation(stream_id); } -void QpackEncoder::OnErrorDetected(QuicStringPiece error_message) { +void QpackEncoder::OnErrorDetected(quiche::QuicheStringPiece error_message) { decoder_stream_error_delegate_->OnDecoderStreamError(error_message); }
diff --git a/quic/core/qpack/qpack_encoder.h b/quic/core/qpack/qpack_encoder.h index e635e3b..0f1d14c 100644 --- a/quic/core/qpack/qpack_encoder.h +++ b/quic/core/qpack/qpack_encoder.h
@@ -18,7 +18,7 @@ #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" #include "net/third_party/quiche/src/quic/platform/api/quic_exported_stats.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace spdy { @@ -45,7 +45,8 @@ public: virtual ~DecoderStreamErrorDelegate() {} - virtual void OnDecoderStreamError(QuicStringPiece error_message) = 0; + virtual void OnDecoderStreamError( + quiche::QuicheStringPiece error_message) = 0; }; QpackEncoder(DecoderStreamErrorDelegate* decoder_stream_error_delegate); @@ -77,7 +78,7 @@ void OnInsertCountIncrement(uint64_t increment) override; void OnHeaderAcknowledgement(QuicStreamId stream_id) override; void OnStreamCancellation(QuicStreamId stream_id) override; - void OnErrorDetected(QuicStringPiece error_message) override; + void OnErrorDetected(quiche::QuicheStringPiece error_message) override; // delegate must be set if dynamic table capacity is not zero. void set_qpack_stream_sender_delegate(QpackStreamSenderDelegate* delegate) { @@ -110,13 +111,13 @@ static QpackInstructionWithValues EncodeLiteralHeaderFieldWithNameReference( bool is_static, uint64_t index, - QuicStringPiece value, + quiche::QuicheStringPiece value, QpackBlockingManager::IndexSet* referred_indices); // Generate literal header field instruction. static QpackInstructionWithValues EncodeLiteralHeaderField( - QuicStringPiece name, - QuicStringPiece value); + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value); // Performs first pass of two-pass encoding: represent each header field in // |*header_list| as a reference to an existing entry, the name of an existing @@ -127,8 +128,8 @@ // sets |*encoder_stream_sent_byte_count| to the number of bytes sent on the // encoder stream to insert dynamic table entries. Returns list of header // field representations, with all dynamic table entries referred to with - // absolute indices. Returned Instructions object may have QuicStringPieces - // pointing to strings owned by |*header_list|. + // absolute indices. Returned Instructions object may have + // quiche::QuicheStringPieces pointing to strings owned by |*header_list|. Instructions FirstPassEncode(QuicStreamId stream_id, const spdy::SpdyHeaderBlock& header_list, QpackBlockingManager::IndexSet* referred_indices,
diff --git a/quic/core/qpack/qpack_encoder_stream_receiver.cc b/quic/core/qpack/qpack_encoder_stream_receiver.cc index c46cc3c..56ee232 100644 --- a/quic/core/qpack/qpack_encoder_stream_receiver.cc +++ b/quic/core/qpack/qpack_encoder_stream_receiver.cc
@@ -7,6 +7,7 @@ #include "net/third_party/quiche/src/http2/decoder/decode_buffer.h" #include "net/third_party/quiche/src/http2/decoder/decode_status.h" #include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -17,7 +18,7 @@ DCHECK(delegate_); } -void QpackEncoderStreamReceiver::Decode(QuicStringPiece data) { +void QpackEncoderStreamReceiver::Decode(quiche::QuicheStringPiece data) { if (data.empty() || error_detected_) { return; } @@ -50,7 +51,8 @@ return true; } -void QpackEncoderStreamReceiver::OnError(QuicStringPiece error_message) { +void QpackEncoderStreamReceiver::OnError( + quiche::QuicheStringPiece error_message) { DCHECK(!error_detected_); error_detected_ = true;
diff --git a/quic/core/qpack/qpack_encoder_stream_receiver.h b/quic/core/qpack/qpack_encoder_stream_receiver.h index b393b54..80622e5 100644 --- a/quic/core/qpack/qpack_encoder_stream_receiver.h +++ b/quic/core/qpack/qpack_encoder_stream_receiver.h
@@ -11,7 +11,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h" #include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_receiver.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -29,16 +29,17 @@ // 5.2.1. Insert With Name Reference virtual void OnInsertWithNameReference(bool is_static, uint64_t name_index, - QuicStringPiece value) = 0; + quiche::QuicheStringPiece value) = 0; // 5.2.2. Insert Without Name Reference - virtual void OnInsertWithoutNameReference(QuicStringPiece name, - QuicStringPiece value) = 0; + virtual void OnInsertWithoutNameReference( + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) = 0; // 5.2.3. Duplicate virtual void OnDuplicate(uint64_t index) = 0; // 5.2.4. Set Dynamic Table Capacity virtual void OnSetDynamicTableCapacity(uint64_t capacity) = 0; // Decoding error - virtual void OnErrorDetected(QuicStringPiece error_message) = 0; + virtual void OnErrorDetected(quiche::QuicheStringPiece error_message) = 0; }; explicit QpackEncoderStreamReceiver(Delegate* delegate); @@ -52,11 +53,11 @@ // Decode data and call appropriate Delegate method after each decoded // instruction. Once an error occurs, Delegate::OnErrorDetected() is called, // and all further data is ignored. - void Decode(QuicStringPiece data) override; + void Decode(quiche::QuicheStringPiece data) override; // QpackInstructionDecoder::Delegate implementation. bool OnInstructionDecoded(const QpackInstruction* instruction) override; - void OnError(QuicStringPiece error_message) override; + void OnError(quiche::QuicheStringPiece error_message) override; private: QpackInstructionDecoder instruction_decoder_;
diff --git a/quic/core/qpack/qpack_encoder_stream_receiver_test.cc b/quic/core/qpack/qpack_encoder_stream_receiver_test.cc index f012390..b5edd5f 100644 --- a/quic/core/qpack/qpack_encoder_stream_receiver_test.cc +++ b/quic/core/qpack/qpack_encoder_stream_receiver_test.cc
@@ -5,7 +5,8 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_receiver.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using testing::Eq; using testing::StrictMock; @@ -21,12 +22,13 @@ MOCK_METHOD3(OnInsertWithNameReference, void(bool is_static, uint64_t name_index, - QuicStringPiece value)); + quiche::QuicheStringPiece value)); MOCK_METHOD2(OnInsertWithoutNameReference, - void(QuicStringPiece name, QuicStringPiece value)); + void(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value)); MOCK_METHOD1(OnDuplicate, void(uint64_t index)); MOCK_METHOD1(OnSetDynamicTableCapacity, void(uint64_t capacity)); - MOCK_METHOD1(OnErrorDetected, void(QuicStringPiece error_message)); + MOCK_METHOD1(OnErrorDetected, void(quiche::QuicheStringPiece error_message)); }; class QpackEncoderStreamReceiverTest : public QuicTest { @@ -34,7 +36,7 @@ QpackEncoderStreamReceiverTest() : stream_(&delegate_) {} ~QpackEncoderStreamReceiverTest() override = default; - void Decode(QuicStringPiece data) { stream_.Decode(data); } + void Decode(quiche::QuicheStringPiece data) { stream_.Decode(data); } StrictMock<MockDelegate>* delegate() { return &delegate_; } private: @@ -54,7 +56,7 @@ EXPECT_CALL(*delegate(), OnInsertWithNameReference(false, 42, Eq(std::string(127, 'Z')))); - Decode(QuicTextUtils::HexDecode( + Decode(quiche::QuicheTextUtils::HexDecode( "c500" "c28294e7" "bf4a03626172" @@ -67,13 +69,13 @@ TEST_F(QpackEncoderStreamReceiverTest, InsertWithNameReferenceIndexTooLarge) { EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large."))); - Decode(QuicTextUtils::HexDecode("bfffffffffffffffffffffff")); + Decode(quiche::QuicheTextUtils::HexDecode("bfffffffffffffffffffffff")); } TEST_F(QpackEncoderStreamReceiverTest, InsertWithNameReferenceValueTooLong) { EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large."))); - Decode(QuicTextUtils::HexDecode("c57fffffffffffffffffffff")); + Decode(quiche::QuicheTextUtils::HexDecode("c57fffffffffffffffffffff")); } TEST_F(QpackEncoderStreamReceiverTest, InsertWithoutNameReference) { @@ -89,7 +91,7 @@ OnInsertWithoutNameReference(Eq(std::string(31, 'Z')), Eq(std::string(127, 'Z')))); - Decode(QuicTextUtils::HexDecode( + Decode(quiche::QuicheTextUtils::HexDecode( "4000" "4362617203626172" "6294e78294e7" @@ -105,7 +107,7 @@ InsertWithoutNameReferenceNameTooLongForVarintDecoder) { EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large."))); - Decode(QuicTextUtils::HexDecode("5fffffffffffffffffffff")); + Decode(quiche::QuicheTextUtils::HexDecode("5fffffffffffffffffffff")); } // Name Length value can be decoded by varint decoder but exceeds 1 MB limit. @@ -113,7 +115,7 @@ InsertWithoutNameReferenceNameExceedsLimit) { EXPECT_CALL(*delegate(), OnErrorDetected(Eq("String literal too long."))); - Decode(QuicTextUtils::HexDecode("5fffff7f")); + Decode(quiche::QuicheTextUtils::HexDecode("5fffff7f")); } // Value Length value is too large for varint decoder to decode. @@ -121,7 +123,7 @@ InsertWithoutNameReferenceValueTooLongForVarintDecoder) { EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large."))); - Decode(QuicTextUtils::HexDecode("436261727fffffffffffffffffffff")); + Decode(quiche::QuicheTextUtils::HexDecode("436261727fffffffffffffffffffff")); } // Value Length value can be decoded by varint decoder but exceeds 1 MB limit. @@ -129,7 +131,7 @@ InsertWithoutNameReferenceValueExceedsLimit) { EXPECT_CALL(*delegate(), OnErrorDetected(Eq("String literal too long."))); - Decode(QuicTextUtils::HexDecode("436261727fffff7f")); + Decode(quiche::QuicheTextUtils::HexDecode("436261727fffff7f")); } TEST_F(QpackEncoderStreamReceiverTest, Duplicate) { @@ -138,13 +140,13 @@ // Large index requires two extension bytes. EXPECT_CALL(*delegate(), OnDuplicate(500)); - Decode(QuicTextUtils::HexDecode("111fd503")); + Decode(quiche::QuicheTextUtils::HexDecode("111fd503")); } TEST_F(QpackEncoderStreamReceiverTest, DuplicateIndexTooLarge) { EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large."))); - Decode(QuicTextUtils::HexDecode("1fffffffffffffffffffff")); + Decode(quiche::QuicheTextUtils::HexDecode("1fffffffffffffffffffff")); } TEST_F(QpackEncoderStreamReceiverTest, SetDynamicTableCapacity) { @@ -153,13 +155,13 @@ // Large capacity requires two extension bytes. EXPECT_CALL(*delegate(), OnSetDynamicTableCapacity(500)); - Decode(QuicTextUtils::HexDecode("313fd503")); + Decode(quiche::QuicheTextUtils::HexDecode("313fd503")); } TEST_F(QpackEncoderStreamReceiverTest, SetDynamicTableCapacityTooLarge) { EXPECT_CALL(*delegate(), OnErrorDetected(Eq("Encoded integer too large."))); - Decode(QuicTextUtils::HexDecode("3fffffffffffffffffffff")); + Decode(quiche::QuicheTextUtils::HexDecode("3fffffffffffffffffffff")); } } // namespace
diff --git a/quic/core/qpack/qpack_encoder_stream_sender.cc b/quic/core/qpack/qpack_encoder_stream_sender.cc index 5182864..19311b6 100644 --- a/quic/core/qpack/qpack_encoder_stream_sender.cc +++ b/quic/core/qpack/qpack_encoder_stream_sender.cc
@@ -10,6 +10,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -18,7 +19,7 @@ void QpackEncoderStreamSender::SendInsertWithNameReference( bool is_static, uint64_t name_index, - QuicStringPiece value) { + quiche::QuicheStringPiece value) { instruction_encoder_.Encode( QpackInstructionWithValues::InsertWithNameReference(is_static, name_index, value), @@ -26,8 +27,8 @@ } void QpackEncoderStreamSender::SendInsertWithoutNameReference( - QuicStringPiece name, - QuicStringPiece value) { + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { instruction_encoder_.Encode( QpackInstructionWithValues::InsertWithoutNameReference(name, value), &buffer_);
diff --git a/quic/core/qpack/qpack_encoder_stream_sender.h b/quic/core/qpack/qpack_encoder_stream_sender.h index de9e8f1..5701db5 100644 --- a/quic/core/qpack/qpack_encoder_stream_sender.h +++ b/quic/core/qpack/qpack_encoder_stream_sender.h
@@ -11,7 +11,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -29,10 +29,10 @@ // 5.2.1. Insert With Name Reference void SendInsertWithNameReference(bool is_static, uint64_t name_index, - QuicStringPiece value); + quiche::QuicheStringPiece value); // 5.2.2. Insert Without Name Reference - void SendInsertWithoutNameReference(QuicStringPiece name, - QuicStringPiece value); + void SendInsertWithoutNameReference(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value); // 5.2.3. Duplicate void SendDuplicate(uint64_t index); // 5.2.4. Set Dynamic Table Capacity
diff --git a/quic/core/qpack/qpack_encoder_stream_sender_test.cc b/quic/core/qpack/qpack_encoder_stream_sender_test.cc index 0a42df2..b3fd5f9 100644 --- a/quic/core/qpack/qpack_encoder_stream_sender_test.cc +++ b/quic/core/qpack/qpack_encoder_stream_sender_test.cc
@@ -5,8 +5,8 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_encoder_stream_sender.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using ::testing::Eq; using ::testing::StrictMock; @@ -28,26 +28,27 @@ TEST_F(QpackEncoderStreamSenderTest, InsertWithNameReference) { // Static, index fits in prefix, empty value. - std::string expected_encoded_data = QuicTextUtils::HexDecode("c500"); + std::string expected_encoded_data = + quiche::QuicheTextUtils::HexDecode("c500"); EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data))); stream_.SendInsertWithNameReference(true, 5, ""); EXPECT_EQ(expected_encoded_data.size(), stream_.Flush()); // Static, index fits in prefix, Huffman encoded value. - expected_encoded_data = QuicTextUtils::HexDecode("c28294e7"); + expected_encoded_data = quiche::QuicheTextUtils::HexDecode("c28294e7"); EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data))); stream_.SendInsertWithNameReference(true, 2, "foo"); EXPECT_EQ(expected_encoded_data.size(), stream_.Flush()); // Not static, index does not fit in prefix, not Huffman encoded value. - expected_encoded_data = QuicTextUtils::HexDecode("bf4a03626172"); + expected_encoded_data = quiche::QuicheTextUtils::HexDecode("bf4a03626172"); EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data))); stream_.SendInsertWithNameReference(false, 137, "bar"); EXPECT_EQ(expected_encoded_data.size(), stream_.Flush()); // Value length does not fit in prefix. // 'Z' would be Huffman encoded to 8 bits, so no Huffman encoding is used. - expected_encoded_data = QuicTextUtils::HexDecode( + expected_encoded_data = quiche::QuicheTextUtils::HexDecode( "aa7f005a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a" "5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a" "5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a" @@ -59,26 +60,28 @@ TEST_F(QpackEncoderStreamSenderTest, InsertWithoutNameReference) { // Empty name and value. - std::string expected_encoded_data = QuicTextUtils::HexDecode("4000"); + std::string expected_encoded_data = + quiche::QuicheTextUtils::HexDecode("4000"); EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data))); stream_.SendInsertWithoutNameReference("", ""); EXPECT_EQ(expected_encoded_data.size(), stream_.Flush()); // Huffman encoded short strings. - expected_encoded_data = QuicTextUtils::HexDecode("6294e78294e7"); + expected_encoded_data = quiche::QuicheTextUtils::HexDecode("6294e78294e7"); EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data))); stream_.SendInsertWithoutNameReference("foo", "foo"); EXPECT_EQ(expected_encoded_data.size(), stream_.Flush()); // Not Huffman encoded short strings. - expected_encoded_data = QuicTextUtils::HexDecode("4362617203626172"); + expected_encoded_data = + quiche::QuicheTextUtils::HexDecode("4362617203626172"); EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data))); stream_.SendInsertWithoutNameReference("bar", "bar"); EXPECT_EQ(expected_encoded_data.size(), stream_.Flush()); // Not Huffman encoded long strings; length does not fit on prefix. // 'Z' would be Huffman encoded to 8 bits, so no Huffman encoding is used. - expected_encoded_data = QuicTextUtils::HexDecode( + expected_encoded_data = quiche::QuicheTextUtils::HexDecode( "5f005a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a7f" "005a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a" "5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a" @@ -92,13 +95,13 @@ TEST_F(QpackEncoderStreamSenderTest, Duplicate) { // Small index fits in prefix. - std::string expected_encoded_data = QuicTextUtils::HexDecode("11"); + std::string expected_encoded_data = quiche::QuicheTextUtils::HexDecode("11"); EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data))); stream_.SendDuplicate(17); EXPECT_EQ(expected_encoded_data.size(), stream_.Flush()); // Large index requires two extension bytes. - expected_encoded_data = QuicTextUtils::HexDecode("1fd503"); + expected_encoded_data = quiche::QuicheTextUtils::HexDecode("1fd503"); EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data))); stream_.SendDuplicate(500); EXPECT_EQ(expected_encoded_data.size(), stream_.Flush()); @@ -106,13 +109,13 @@ TEST_F(QpackEncoderStreamSenderTest, SetDynamicTableCapacity) { // Small capacity fits in prefix. - std::string expected_encoded_data = QuicTextUtils::HexDecode("31"); + std::string expected_encoded_data = quiche::QuicheTextUtils::HexDecode("31"); EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data))); stream_.SendSetDynamicTableCapacity(17); EXPECT_EQ(expected_encoded_data.size(), stream_.Flush()); // Large capacity requires two extension bytes. - expected_encoded_data = QuicTextUtils::HexDecode("3fd503"); + expected_encoded_data = quiche::QuicheTextUtils::HexDecode("3fd503"); EXPECT_CALL(delegate_, WriteStreamData(Eq(expected_encoded_data))); stream_.SendSetDynamicTableCapacity(500); EXPECT_EQ(expected_encoded_data.size(), stream_.Flush()); @@ -132,7 +135,7 @@ // Duplicate entry. stream_.SendDuplicate(17); - std::string expected_encoded_data = QuicTextUtils::HexDecode( + std::string expected_encoded_data = quiche::QuicheTextUtils::HexDecode( "c500" // Insert entry with static name reference. "c28294e7" // Insert entry with static name reference. "6294e78294e7" // Insert literal entry.
diff --git a/quic/core/qpack/qpack_encoder_test.cc b/quic/core/qpack/qpack_encoder_test.cc index 6b92e4b..212257c 100644 --- a/quic/core/qpack/qpack_encoder_test.cc +++ b/quic/core/qpack/qpack_encoder_test.cc
@@ -8,11 +8,12 @@ #include <string> #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_peer.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_header_table_peer.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using ::testing::_; using ::testing::Eq; @@ -48,7 +49,7 @@ spdy::SpdyHeaderBlock header_list; std::string output = Encode(header_list); - EXPECT_EQ(QuicTextUtils::HexDecode("0000"), output); + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0000"), output); } TEST_F(QpackEncoderTest, EmptyName) { @@ -56,7 +57,7 @@ header_list[""] = "foo"; std::string output = Encode(header_list); - EXPECT_EQ(QuicTextUtils::HexDecode("0000208294e7"), output); + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0000208294e7"), output); } TEST_F(QpackEncoderTest, EmptyValue) { @@ -64,7 +65,7 @@ header_list["foo"] = ""; std::string output = Encode(header_list); - EXPECT_EQ(QuicTextUtils::HexDecode("00002a94e700"), output); + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("00002a94e700"), output); } TEST_F(QpackEncoderTest, EmptyNameAndValue) { @@ -72,7 +73,7 @@ header_list[""] = ""; std::string output = Encode(header_list); - EXPECT_EQ(QuicTextUtils::HexDecode("00002000"), output); + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("00002000"), output); } TEST_F(QpackEncoderTest, Simple) { @@ -80,7 +81,7 @@ header_list["foo"] = "bar"; std::string output = Encode(header_list); - EXPECT_EQ(QuicTextUtils::HexDecode("00002a94e703626172"), output); + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("00002a94e703626172"), output); } TEST_F(QpackEncoderTest, Multiple) { @@ -91,7 +92,7 @@ std::string output = Encode(header_list); EXPECT_EQ( - QuicTextUtils::HexDecode( + quiche::QuicheTextUtils::HexDecode( "0000" // prefix "2a94e703626172" // foo: bar "27005a5a5a5a5a5a5a" // 7 octet long header name, the smallest number @@ -113,7 +114,7 @@ header_list["location"] = ""; std::string output = Encode(header_list); - EXPECT_EQ(QuicTextUtils::HexDecode("0000d1dfcc"), output); + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0000d1dfcc"), output); } { spdy::SpdyHeaderBlock header_list; @@ -122,8 +123,9 @@ header_list["location"] = "foo"; std::string output = Encode(header_list); - EXPECT_EQ(QuicTextUtils::HexDecode("0000d45f108621e9aec2a11f5c8294e7"), - output); + EXPECT_EQ( + quiche::QuicheTextUtils::HexDecode("0000d45f108621e9aec2a11f5c8294e7"), + output); } { spdy::SpdyHeaderBlock header_list; @@ -131,7 +133,8 @@ header_list["accept-encoding"] = ""; std::string output = Encode(header_list); - EXPECT_EQ(QuicTextUtils::HexDecode("00005f000554524143455f1000"), output); + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("00005f000554524143455f1000"), + output); } } @@ -142,19 +145,19 @@ QpackEncoder encoder(&decoder_stream_error_delegate_); encoder.set_qpack_stream_sender_delegate(&encoder_stream_sender_delegate_); encoder.decoder_stream_receiver()->Decode( - QuicTextUtils::HexDecode("ffffffffffffffffffffff")); + quiche::QuicheTextUtils::HexDecode("ffffffffffffffffffffff")); } TEST_F(QpackEncoderTest, SplitAlongNullCharacter) { spdy::SpdyHeaderBlock header_list; - header_list["foo"] = QuicStringPiece("bar\0bar\0baz", 11); + header_list["foo"] = quiche::QuicheStringPiece("bar\0bar\0baz", 11); std::string output = Encode(header_list); - EXPECT_EQ(QuicTextUtils::HexDecode("0000" // prefix - "2a94e703626172" // foo: bar - "2a94e703626172" // foo: bar - "2a94e70362617a" // foo: baz - ), + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0000" // prefix + "2a94e703626172" // foo: bar + "2a94e703626172" // foo: bar + "2a94e70362617a" // foo: baz + ), output); } @@ -212,8 +215,9 @@ encoder_.SetMaximumDynamicTableCapacity(4096); // Set Dynamic Table Capacity instruction. - EXPECT_CALL(encoder_stream_sender_delegate_, - WriteStreamData(Eq(QuicTextUtils::HexDecode("3fe11f")))); + EXPECT_CALL( + encoder_stream_sender_delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("3fe11f")))); encoder_.SetDynamicTableCapacity(4096); spdy::SpdyHeaderBlock header_list; @@ -223,7 +227,7 @@ header_list["cookie"] = "baz"; // name matches static entry // Insert three entries into the dynamic table. - std::string insert_entries = QuicTextUtils::HexDecode( + std::string insert_entries = quiche::QuicheTextUtils::HexDecode( "62" // insert without name reference "94e7" // Huffman-encoded name "foo" "03626172" // value "bar" @@ -234,7 +238,7 @@ EXPECT_CALL(encoder_stream_sender_delegate_, WriteStreamData(Eq(insert_entries))); - EXPECT_EQ(QuicTextUtils::HexDecode( + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode( "0400" // prefix "828180"), // dynamic entries with relative index 0, 1, and 2 Encode(header_list)); @@ -249,7 +253,7 @@ // Set Dynamic Table Capacity instruction. EXPECT_CALL(encoder_stream_sender_delegate_, - WriteStreamData(Eq(QuicTextUtils::HexDecode("3f07")))); + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("3f07")))); encoder_.SetDynamicTableCapacity(QpackEntry::Size("foo", "bar")); spdy::SpdyHeaderBlock header_list; @@ -260,21 +264,22 @@ header_list["bar"] = "baz"; // no match // Insert one entry into the dynamic table. - std::string insert_entry = QuicTextUtils::HexDecode( + std::string insert_entry = quiche::QuicheTextUtils::HexDecode( "62" // insert without name reference "94e7" // Huffman-encoded name "foo" "03626172"); // value "bar" EXPECT_CALL(encoder_stream_sender_delegate_, WriteStreamData(Eq(insert_entry))); - EXPECT_EQ(QuicTextUtils::HexDecode("0200" // prefix - "80" // dynamic entry 0 - "40" // reference to dynamic entry 0 name - "0362617a" // with literal value "baz" - "55" // reference to static entry 5 name - "0362617a" // with literal value "baz" - "23626172" // literal name "bar" - "0362617a"), // with literal value "baz" + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode( + "0200" // prefix + "80" // dynamic entry 0 + "40" // reference to dynamic entry 0 name + "0362617a" // with literal value "baz" + "55" // reference to static entry 5 name + "0362617a" // with literal value "baz" + "23626172" // literal name "bar" + "0362617a"), // with literal value "baz" Encode(header_list)); EXPECT_EQ(insert_entry.size(), encoder_stream_sent_byte_count_); @@ -285,23 +290,24 @@ encoder_.SetMaximumDynamicTableCapacity(4096); // Set Dynamic Table Capacity instruction. - EXPECT_CALL(encoder_stream_sender_delegate_, - WriteStreamData(Eq(QuicTextUtils::HexDecode("3fe11f")))); + EXPECT_CALL( + encoder_stream_sender_delegate_, + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("3fe11f")))); encoder_.SetDynamicTableCapacity(4096); spdy::SpdyHeaderBlock header_list1; header_list1["foo"] = "bar"; // Insert one entry into the dynamic table. - std::string insert_entry1 = QuicTextUtils::HexDecode( + std::string insert_entry1 = quiche::QuicheTextUtils::HexDecode( "62" // insert without name reference "94e7" // Huffman-encoded name "foo" "03626172"); // value "bar" EXPECT_CALL(encoder_stream_sender_delegate_, WriteStreamData(Eq(insert_entry1))); - EXPECT_EQ(QuicTextUtils::HexDecode("0200" // prefix - "80"), // dynamic entry 0 + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0200" // prefix + "80"), // dynamic entry 0 encoder_.EncodeHeaderList(/* stream_id = */ 1, header_list1, &encoder_stream_sent_byte_count_)); EXPECT_EQ(insert_entry1.size(), encoder_stream_sent_byte_count_); @@ -314,15 +320,16 @@ header_list2["cookie"] = "baz"; // name matches static entry header_list2["bar"] = "baz"; // no match - EXPECT_EQ(QuicTextUtils::HexDecode("0000" // prefix - "2a94e7" // literal name "foo" - "03626172" // with literal value "bar" - "2a94e7" // literal name "foo" - "0362617a" // with literal value "baz" - "55" // name of static entry 5 - "0362617a" // with literal value "baz" - "23626172" // literal name "bar" - "0362617a"), // with literal value "baz" + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode( + "0000" // prefix + "2a94e7" // literal name "foo" + "03626172" // with literal value "bar" + "2a94e7" // literal name "foo" + "0362617a" // with literal value "baz" + "55" // name of static entry 5 + "0362617a" // with literal value "baz" + "23626172" // literal name "bar" + "0362617a"), // with literal value "baz" encoder_.EncodeHeaderList(/* stream_id = */ 2, header_list2, &encoder_stream_sent_byte_count_)); EXPECT_EQ(0u, encoder_stream_sent_byte_count_); @@ -332,7 +339,7 @@ encoder_.OnInsertCountIncrement(1); // Insert three entries into the dynamic table. - std::string insert_entries = QuicTextUtils::HexDecode( + std::string insert_entries = quiche::QuicheTextUtils::HexDecode( "80" // insert with name reference, dynamic index 0 "0362617a" // value "baz" "c5" // insert with name reference, static index 5 @@ -343,22 +350,23 @@ EXPECT_CALL(encoder_stream_sender_delegate_, WriteStreamData(Eq(insert_entries))); - EXPECT_EQ(QuicTextUtils::HexDecode("0500" // prefix - "83828180"), // dynamic entries + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0500" // prefix + "83828180"), // dynamic entries encoder_.EncodeHeaderList(/* stream_id = */ 3, header_list2, &encoder_stream_sent_byte_count_)); EXPECT_EQ(insert_entries.size(), encoder_stream_sent_byte_count_); // Stream 3 is blocked. Stream 4 is not allowed to block, but it can // reference already acknowledged dynamic entry 0. - EXPECT_EQ(QuicTextUtils::HexDecode("0200" // prefix - "80" // dynamic entry 0 - "2a94e7" // literal name "foo" - "0362617a" // with literal value "baz" - "2c21cfd4c5" // literal name "cookie" - "0362617a" // with literal value "baz" - "23626172" // literal name "bar" - "0362617a"), // with literal value "baz" + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode( + "0200" // prefix + "80" // dynamic entry 0 + "2a94e7" // literal name "foo" + "0362617a" // with literal value "baz" + "2c21cfd4c5" // literal name "cookie" + "0362617a" // with literal value "baz" + "23626172" // literal name "bar" + "0362617a"), // with literal value "baz" encoder_.EncodeHeaderList(/* stream_id = */ 4, header_list2, &encoder_stream_sent_byte_count_)); EXPECT_EQ(0u, encoder_stream_sent_byte_count_); @@ -369,10 +377,11 @@ // Stream 5 is not allowed to block, but it can reference already acknowledged // dynamic entries 0, 1, and 2. - EXPECT_EQ(QuicTextUtils::HexDecode("0400" // prefix - "828180" // dynamic entries - "23626172" // literal name "bar" - "0362617a"), // with literal value "baz" + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode( + "0400" // prefix + "828180" // dynamic entries + "23626172" // literal name "bar" + "0362617a"), // with literal value "baz" encoder_.EncodeHeaderList(/* stream_id = */ 5, header_list2, &encoder_stream_sent_byte_count_)); EXPECT_EQ(0u, encoder_stream_sent_byte_count_); @@ -381,8 +390,8 @@ // Stream 3 is not blocked any longer. encoder_.OnHeaderAcknowledgement(3); - EXPECT_EQ(QuicTextUtils::HexDecode("0500" // prefix - "83828180"), // dynamic entries + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode("0500" // prefix + "83828180"), // dynamic entries encoder_.EncodeHeaderList(/* stream_id = */ 6, header_list2, &encoder_stream_sent_byte_count_)); EXPECT_EQ(0u, encoder_stream_sent_byte_count_); @@ -419,10 +428,10 @@ // Insert ten entries into the dynamic table. EXPECT_CALL(encoder_stream_sender_delegate_, WriteStreamData(_)); - EXPECT_EQ( - QuicTextUtils::HexDecode("0b00" // prefix - "89888786858483828180"), // dynamic entries - Encode(header_list1)); + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode( + "0b00" // prefix + "89888786858483828180"), // dynamic entries + Encode(header_list1)); // Entry is identical to oldest one, which is draining. It will be // duplicated and referenced. @@ -431,10 +440,11 @@ // Duplicate oldest entry. EXPECT_CALL(encoder_stream_sender_delegate_, - WriteStreamData(Eq(QuicTextUtils::HexDecode("09")))); + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("09")))); - EXPECT_EQ(QuicTextUtils::HexDecode("0c00" // prefix - "80"), // most recent dynamic table entry + EXPECT_EQ(quiche::QuicheTextUtils::HexDecode( + "0c00" // prefix + "80"), // most recent dynamic table entry Encode(header_list2)); spdy::SpdyHeaderBlock header_list3; @@ -445,12 +455,13 @@ // no room to insert new entry, it will be encoded with string literals. header_list3.AppendValueOrAddHeader("two", "bar"); - EXPECT_EQ(QuicTextUtils::HexDecode("0000" // prefix - "2374776f" // literal name "two" - "8294e7" // literal value "foo" - "2374776f" // literal name "two" - "03626172"), // literal value "bar" - Encode(header_list3)); + EXPECT_EQ( + quiche::QuicheTextUtils::HexDecode("0000" // prefix + "2374776f" // literal name "two" + "8294e7" // literal value "foo" + "2374776f" // literal name "two" + "03626172"), // literal value "bar" + Encode(header_list3)); } TEST_F(QpackEncoderTest, DynamicTableCapacityLessThanMaximum) { @@ -458,7 +469,7 @@ // Set Dynamic Table Capacity instruction. EXPECT_CALL(encoder_stream_sender_delegate_, - WriteStreamData(Eq(QuicTextUtils::HexDecode("3e")))); + WriteStreamData(Eq(quiche::QuicheTextUtils::HexDecode("3e")))); encoder_.SetDynamicTableCapacity(30); QpackHeaderTable* header_table = QpackEncoderPeer::header_table(&encoder_);
diff --git a/quic/core/qpack/qpack_header_table.cc b/quic/core/qpack/qpack_header_table.cc index 4cafa19..472db89 100644 --- a/quic/core/qpack/qpack_header_table.cc +++ b/quic/core/qpack/qpack_header_table.cc
@@ -6,6 +6,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -50,8 +51,8 @@ } QpackHeaderTable::MatchType QpackHeaderTable::FindHeaderField( - QuicStringPiece name, - QuicStringPiece value, + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value, bool* is_static, uint64_t* index) const { QpackEntry query(name, value); @@ -95,8 +96,9 @@ return MatchType::kNoMatch; } -const QpackEntry* QpackHeaderTable::InsertEntry(QuicStringPiece name, - QuicStringPiece value) { +const QpackEntry* QpackHeaderTable::InsertEntry( + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { const uint64_t entry_size = QpackEntry::Size(name, value); if (entry_size > dynamic_table_capacity_) { return nullptr;
diff --git a/quic/core/qpack/qpack_header_table.h b/quic/core/qpack/qpack_header_table.h index dd5ca3b..e3fb975 100644 --- a/quic/core/qpack/qpack_header_table.h +++ b/quic/core/qpack/qpack_header_table.h
@@ -11,7 +11,7 @@ #include <vector> #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_entry.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_header_table.h" @@ -70,15 +70,16 @@ // Returns the absolute index of an entry with matching name and value if such // exists, otherwise one with matching name is such exists. |index| is zero // based for both the static and the dynamic table. - MatchType FindHeaderField(QuicStringPiece name, - QuicStringPiece value, + MatchType FindHeaderField(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value, bool* is_static, uint64_t* index) const; // Insert (name, value) into the dynamic table. May evict entries. Returns a // pointer to the inserted owned entry on success. Returns nullptr if entry // is larger than the capacity of the dynamic table. - const QpackEntry* InsertEntry(QuicStringPiece name, QuicStringPiece value); + const QpackEntry* InsertEntry(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value); // Returns the size of the largest entry that could be inserted into the // dynamic table without evicting entry |index|. |index| might be larger than
diff --git a/quic/core/qpack/qpack_header_table_test.cc b/quic/core/qpack/qpack_header_table_test.cc index 5638aff..071c65c 100644 --- a/quic/core/qpack/qpack_header_table_test.cc +++ b/quic/core/qpack/qpack_header_table_test.cc
@@ -9,6 +9,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_static_table.h" #include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_entry.h" using ::testing::Mock; @@ -39,8 +40,8 @@ void ExpectEntryAtIndex(bool is_static, uint64_t index, - QuicStringPiece expected_name, - QuicStringPiece expected_value) const { + quiche::QuicheStringPiece expected_name, + quiche::QuicheStringPiece expected_value) const { const auto* entry = table_.LookupEntry(is_static, index); ASSERT_TRUE(entry); EXPECT_EQ(expected_name, entry->name()); @@ -51,8 +52,8 @@ EXPECT_FALSE(table_.LookupEntry(is_static, index)); } - void ExpectMatch(QuicStringPiece name, - QuicStringPiece value, + void ExpectMatch(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value, QpackHeaderTable::MatchType expected_match_type, bool expected_is_static, uint64_t expected_index) const { @@ -69,7 +70,8 @@ EXPECT_EQ(expected_index, index) << name << ": " << value; } - void ExpectNoMatch(QuicStringPiece name, QuicStringPiece value) const { + void ExpectNoMatch(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) const { bool is_static = false; uint64_t index = 0; @@ -80,11 +82,13 @@ << name << ": " << value; } - void InsertEntry(QuicStringPiece name, QuicStringPiece value) { + void InsertEntry(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { EXPECT_TRUE(table_.InsertEntry(name, value)); } - void ExpectToFailInsertingEntry(QuicStringPiece name, QuicStringPiece value) { + void ExpectToFailInsertingEntry(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { EXPECT_FALSE(table_.InsertEntry(name, value)); }
diff --git a/quic/core/qpack/qpack_instruction_decoder.cc b/quic/core/qpack/qpack_instruction_decoder.cc index fede8e3..1f85d7f 100644 --- a/quic/core/qpack/qpack_instruction_decoder.cc +++ b/quic/core/qpack/qpack_instruction_decoder.cc
@@ -9,6 +9,7 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -32,7 +33,7 @@ error_detected_(false), state_(State::kStartInstruction) {} -bool QpackInstructionDecoder::Decode(QuicStringPiece data) { +bool QpackInstructionDecoder::Decode(quiche::QuicheStringPiece data) { DCHECK(!data.empty()); DCHECK(!error_detected_); @@ -76,8 +77,8 @@ DCHECK_LE(bytes_consumed, data.size()); - data = QuicStringPiece(data.data() + bytes_consumed, - data.size() - bytes_consumed); + data = quiche::QuicheStringPiece(data.data() + bytes_consumed, + data.size() - bytes_consumed); // Stop processing if no more data but next state would require it. if (data.empty() && (state_ != State::kStartField) && @@ -93,7 +94,8 @@ return state_ == State::kStartInstruction; } -bool QpackInstructionDecoder::DoStartInstruction(QuicStringPiece data) { +bool QpackInstructionDecoder::DoStartInstruction( + quiche::QuicheStringPiece data) { DCHECK(!data.empty()); instruction_ = LookupOpcode(data[0]); @@ -131,7 +133,7 @@ } } -bool QpackInstructionDecoder::DoReadBit(QuicStringPiece data) { +bool QpackInstructionDecoder::DoReadBit(quiche::QuicheStringPiece data) { DCHECK(!data.empty()); switch (field_->type) { @@ -161,7 +163,7 @@ } } -bool QpackInstructionDecoder::DoVarintStart(QuicStringPiece data, +bool QpackInstructionDecoder::DoVarintStart(quiche::QuicheStringPiece data, size_t* bytes_consumed) { DCHECK(!data.empty()); DCHECK(field_->type == QpackInstructionFieldType::kVarint || @@ -190,7 +192,7 @@ } } -bool QpackInstructionDecoder::DoVarintResume(QuicStringPiece data, +bool QpackInstructionDecoder::DoVarintResume(quiche::QuicheStringPiece data, size_t* bytes_consumed) { DCHECK(!data.empty()); DCHECK(field_->type == QpackInstructionFieldType::kVarint || @@ -263,7 +265,7 @@ return true; } -bool QpackInstructionDecoder::DoReadString(QuicStringPiece data, +bool QpackInstructionDecoder::DoReadString(quiche::QuicheStringPiece data, size_t* bytes_consumed) { DCHECK(!data.empty()); DCHECK(field_->type == QpackInstructionFieldType::kName || @@ -321,7 +323,7 @@ return nullptr; } -void QpackInstructionDecoder::OnError(QuicStringPiece error_message) { +void QpackInstructionDecoder::OnError(quiche::QuicheStringPiece error_message) { DCHECK(!error_detected_); error_detected_ = true;
diff --git a/quic/core/qpack/qpack_instruction_decoder.h b/quic/core/qpack/qpack_instruction_decoder.h index 4c21773..08eb665 100644 --- a/quic/core/qpack/qpack_instruction_decoder.h +++ b/quic/core/qpack/qpack_instruction_decoder.h
@@ -13,7 +13,7 @@ #include "net/third_party/quiche/src/http2/hpack/varint/hpack_varint_decoder.h" #include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -42,7 +42,7 @@ // No more data is processed afterwards. // Implementations are allowed to destroy the QpackInstructionDecoder // instance synchronously. - virtual void OnError(QuicStringPiece error_message) = 0; + virtual void OnError(quiche::QuicheStringPiece error_message) = 0; }; // Both |*language| and |*delegate| must outlive this object. @@ -54,7 +54,7 @@ // Provide a data fragment to decode. Must not be called after an error has // occurred. Must not be called with empty |data|. Return true on success, // false on error (in which case Delegate::OnError() is called synchronously). - bool Decode(QuicStringPiece data); + bool Decode(quiche::QuicheStringPiece data); // Returns true if no decoding has taken place yet or if the last instruction // has been entirely parsed. @@ -94,13 +94,13 @@ // data and set |*bytes_consumed| to the number of octets processed. Some // take input data but do not consume any bytes. Some do not take any // arguments because they only change internal state. - bool DoStartInstruction(QuicStringPiece data); + bool DoStartInstruction(quiche::QuicheStringPiece data); bool DoStartField(); - bool DoReadBit(QuicStringPiece data); - bool DoVarintStart(QuicStringPiece data, size_t* bytes_consumed); - bool DoVarintResume(QuicStringPiece data, size_t* bytes_consumed); + bool DoReadBit(quiche::QuicheStringPiece data); + bool DoVarintStart(quiche::QuicheStringPiece data, size_t* bytes_consumed); + bool DoVarintResume(quiche::QuicheStringPiece data, size_t* bytes_consumed); bool DoVarintDone(); - bool DoReadString(QuicStringPiece data, size_t* bytes_consumed); + bool DoReadString(quiche::QuicheStringPiece data, size_t* bytes_consumed); bool DoReadStringDone(); // Identify instruction based on opcode encoded in |byte|. @@ -108,7 +108,7 @@ const QpackInstruction* LookupOpcode(uint8_t byte) const; // Stops decoding and calls Delegate::OnError(). - void OnError(QuicStringPiece error_message); + void OnError(quiche::QuicheStringPiece error_message); // Describes the language used for decoding. const QpackLanguage* const language_;
diff --git a/quic/core/qpack/qpack_instruction_decoder_test.cc b/quic/core/qpack/qpack_instruction_decoder_test.cc index c066827..99cda08 100644 --- a/quic/core/qpack/qpack_instruction_decoder_test.cc +++ b/quic/core/qpack/qpack_instruction_decoder_test.cc
@@ -9,8 +9,9 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using ::testing::_; using ::testing::Eq; @@ -61,7 +62,7 @@ ~MockDelegate() override = default; MOCK_METHOD1(OnInstructionDecoded, bool(const QpackInstruction* instruction)); - MOCK_METHOD1(OnError, void(QuicStringPiece error_message)); + MOCK_METHOD1(OnError, void(quiche::QuicheStringPiece error_message)); }; class QpackInstructionDecoderTest : public QuicTestWithParam<FragmentMode> { @@ -76,8 +77,10 @@ // Destroy QpackInstructionDecoder on error to test that it does not crash. // See https://crbug.com/1025209. ON_CALL(delegate_, OnError(_)) - .WillByDefault(Invoke( - [this](QuicStringPiece /* error_message */) { decoder_.reset(); })); + .WillByDefault( + Invoke([this](quiche::QuicheStringPiece /* error_message */) { + decoder_.reset(); + })); } // Decode one full instruction with fragment sizes dictated by @@ -86,7 +89,7 @@ // verifies that AtInstructionBoundary() returns true before and after the // instruction, and returns false while decoding is in progress. // Assumes that delegate methods destroy |decoder_| if they return false. - void DecodeInstruction(QuicStringPiece data) { + void DecodeInstruction(quiche::QuicheStringPiece data) { EXPECT_TRUE(decoder_->AtInstructionBoundary()); FragmentSizeGenerator fragment_size_generator = @@ -123,14 +126,14 @@ TEST_P(QpackInstructionDecoderTest, SBitAndVarint2) { EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction1())); - DecodeInstruction(QuicTextUtils::HexDecode("7f01ff65")); + DecodeInstruction(quiche::QuicheTextUtils::HexDecode("7f01ff65")); EXPECT_TRUE(decoder_->s_bit()); EXPECT_EQ(64u, decoder_->varint()); EXPECT_EQ(356u, decoder_->varint2()); EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction1())); - DecodeInstruction(QuicTextUtils::HexDecode("05c8")); + DecodeInstruction(quiche::QuicheTextUtils::HexDecode("05c8")); EXPECT_FALSE(decoder_->s_bit()); EXPECT_EQ(5u, decoder_->varint()); @@ -139,19 +142,19 @@ TEST_P(QpackInstructionDecoderTest, NameAndValue) { EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction2())); - DecodeInstruction(QuicTextUtils::HexDecode("83666f6f03626172")); + DecodeInstruction(quiche::QuicheTextUtils::HexDecode("83666f6f03626172")); EXPECT_EQ("foo", decoder_->name()); EXPECT_EQ("bar", decoder_->value()); EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction2())); - DecodeInstruction(QuicTextUtils::HexDecode("8000")); + DecodeInstruction(quiche::QuicheTextUtils::HexDecode("8000")); EXPECT_EQ("", decoder_->name()); EXPECT_EQ("", decoder_->value()); EXPECT_CALL(delegate_, OnInstructionDecoded(TestInstruction2())); - DecodeInstruction(QuicTextUtils::HexDecode("c294e7838c767f")); + DecodeInstruction(quiche::QuicheTextUtils::HexDecode("c294e7838c767f")); EXPECT_EQ("foo", decoder_->name()); EXPECT_EQ("bar", decoder_->value()); @@ -159,12 +162,13 @@ TEST_P(QpackInstructionDecoderTest, InvalidHuffmanEncoding) { EXPECT_CALL(delegate_, OnError(Eq("Error in Huffman-encoded string."))); - DecodeInstruction(QuicTextUtils::HexDecode("c1ff")); + DecodeInstruction(quiche::QuicheTextUtils::HexDecode("c1ff")); } TEST_P(QpackInstructionDecoderTest, InvalidVarintEncoding) { EXPECT_CALL(delegate_, OnError(Eq("Encoded integer too large."))); - DecodeInstruction(QuicTextUtils::HexDecode("ffffffffffffffffffffff")); + DecodeInstruction( + quiche::QuicheTextUtils::HexDecode("ffffffffffffffffffffff")); } TEST_P(QpackInstructionDecoderTest, DelegateSignalsError) { @@ -186,8 +190,8 @@ return false; })); - EXPECT_FALSE( - decoder_->Decode(QuicTextUtils::HexDecode("01000200030004000500"))); + EXPECT_FALSE(decoder_->Decode( + quiche::QuicheTextUtils::HexDecode("01000200030004000500"))); } // QpackInstructionDecoder must not crash if it is destroyed from a @@ -200,7 +204,7 @@ decoder_.reset(); return false; })); - DecodeInstruction(QuicTextUtils::HexDecode("0100")); + DecodeInstruction(quiche::QuicheTextUtils::HexDecode("0100")); } } // namespace
diff --git a/quic/core/qpack/qpack_instruction_encoder.cc b/quic/core/qpack/qpack_instruction_encoder.cc index a87489d..41e2d76 100644 --- a/quic/core/qpack/qpack_instruction_encoder.cc +++ b/quic/core/qpack/qpack_instruction_encoder.cc
@@ -10,6 +10,7 @@ #include "net/third_party/quiche/src/http2/hpack/varint/hpack_varint_encoder.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_string_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -127,8 +128,8 @@ state_ = State::kWriteString; } -void QpackInstructionEncoder::DoStartString(QuicStringPiece name, - QuicStringPiece value) { +void QpackInstructionEncoder::DoStartString(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { DCHECK(field_->type == QpackInstructionFieldType::kName || field_->type == QpackInstructionFieldType::kValue);
diff --git a/quic/core/qpack/qpack_instruction_encoder.h b/quic/core/qpack/qpack_instruction_encoder.h index 04b2888..2a955f8 100644 --- a/quic/core/qpack/qpack_instruction_encoder.h +++ b/quic/core/qpack/qpack_instruction_encoder.h
@@ -10,7 +10,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -52,7 +52,8 @@ void DoStartField(); void DoSBit(bool s_bit); void DoVarintEncode(uint64_t varint, uint64_t varint2, std::string* output); - void DoStartString(QuicStringPiece name, QuicStringPiece value); + void DoStartString(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value); void DoWriteString(std::string* output); @@ -63,7 +64,7 @@ // If Huffman encoding is used, points to a substring of // |huffman_encoded_string_|. // Otherwise points to a substring of |name_| or |value_|. - QuicStringPiece string_to_write_; + quiche::QuicheStringPiece string_to_write_; // Storage for a single byte that contains multiple fields, that is, multiple // states are writing it.
diff --git a/quic/core/qpack/qpack_instruction_encoder_test.cc b/quic/core/qpack/qpack_instruction_encoder_test.cc index 79dfe2a..6f3337c 100644 --- a/quic/core/qpack/qpack_instruction_encoder_test.cc +++ b/quic/core/qpack/qpack_instruction_encoder_test.cc
@@ -6,7 +6,8 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_text_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { namespace test { @@ -36,12 +37,12 @@ } static void set_name(QpackInstructionWithValues* instruction_with_values, - QuicStringPiece name) { + quiche::QuicheStringPiece name) { instruction_with_values->name_ = name; } static void set_value(QpackInstructionWithValues* instruction_with_values, - QuicStringPiece value) { + quiche::QuicheStringPiece value) { instruction_with_values->value_ = value; } }; @@ -61,9 +62,12 @@ // Compare substring appended to |output_| since last EncodedSegmentMatches() // call against hex-encoded argument. - bool EncodedSegmentMatches(QuicStringPiece hex_encoded_expected_substring) { - auto recently_encoded = QuicStringPiece(output_).substr(verified_position_); - auto expected = QuicTextUtils::HexDecode(hex_encoded_expected_substring); + bool EncodedSegmentMatches( + quiche::QuicheStringPiece hex_encoded_expected_substring) { + auto recently_encoded = + quiche::QuicheStringPiece(output_).substr(verified_position_); + auto expected = + quiche::QuicheTextUtils::HexDecode(hex_encoded_expected_substring); verified_position_ = output_.size(); return recently_encoded == expected; }
diff --git a/quic/core/qpack/qpack_instructions.cc b/quic/core/qpack/qpack_instructions.cc index a6a7529..1e5d112 100644 --- a/quic/core/qpack/qpack_instructions.cc +++ b/quic/core/qpack/qpack_instructions.cc
@@ -7,6 +7,7 @@ #include <limits> #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -203,7 +204,7 @@ QpackInstructionWithValues QpackInstructionWithValues::InsertWithNameReference( bool is_static, uint64_t name_index, - QuicStringPiece value) { + quiche::QuicheStringPiece value) { QpackInstructionWithValues instruction_with_values; instruction_with_values.instruction_ = InsertWithNameReferenceInstruction(); instruction_with_values.s_bit_ = is_static; @@ -215,8 +216,9 @@ // static QpackInstructionWithValues -QpackInstructionWithValues::InsertWithoutNameReference(QuicStringPiece name, - QuicStringPiece value) { +QpackInstructionWithValues::InsertWithoutNameReference( + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { QpackInstructionWithValues instruction_with_values; instruction_with_values.instruction_ = InsertWithoutNameReferenceInstruction(); @@ -305,7 +307,7 @@ QpackInstructionWithValues::LiteralHeaderFieldNameReference( bool is_static, uint64_t index, - QuicStringPiece value) { + quiche::QuicheStringPiece value) { QpackInstructionWithValues instruction_with_values; instruction_with_values.instruction_ = QpackLiteralHeaderFieldNameReferenceInstruction(); @@ -318,8 +320,8 @@ // static QpackInstructionWithValues QpackInstructionWithValues::LiteralHeaderField( - QuicStringPiece name, - QuicStringPiece value) { + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { QpackInstructionWithValues instruction_with_values; instruction_with_values.instruction_ = QpackLiteralHeaderFieldInstruction(); instruction_with_values.name_ = name;
diff --git a/quic/core/qpack/qpack_instructions.h b/quic/core/qpack/qpack_instructions.h index 0ff18bf..d63a1e2 100644 --- a/quic/core/qpack/qpack_instructions.h +++ b/quic/core/qpack/qpack_instructions.h
@@ -11,7 +11,7 @@ #include <vector> #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -151,10 +151,10 @@ static QpackInstructionWithValues InsertWithNameReference( bool is_static, uint64_t name_index, - QuicStringPiece value); + quiche::QuicheStringPiece value); static QpackInstructionWithValues InsertWithoutNameReference( - QuicStringPiece name, - QuicStringPiece value); + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value); static QpackInstructionWithValues Duplicate(uint64_t index); static QpackInstructionWithValues SetDynamicTableCapacity(uint64_t capacity); @@ -172,16 +172,17 @@ static QpackInstructionWithValues LiteralHeaderFieldNameReference( bool is_static, uint64_t index, - QuicStringPiece value); - static QpackInstructionWithValues LiteralHeaderField(QuicStringPiece name, - QuicStringPiece value); + quiche::QuicheStringPiece value); + static QpackInstructionWithValues LiteralHeaderField( + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value); const QpackInstruction* instruction() const { return instruction_; } bool s_bit() const { return s_bit_; } uint64_t varint() const { return varint_; } uint64_t varint2() const { return varint2_; } - QuicStringPiece name() const { return name_; } - QuicStringPiece value() const { return value_; } + quiche::QuicheStringPiece name() const { return name_; } + quiche::QuicheStringPiece value() const { return value_; } // Used by QpackEncoder, because in the first pass it stores absolute indices, // which are converted into relative indices in the second pass after base is @@ -198,8 +199,8 @@ bool s_bit_; uint64_t varint_; uint64_t varint2_; - QuicStringPiece name_; - QuicStringPiece value_; + quiche::QuicheStringPiece name_; + quiche::QuicheStringPiece value_; }; } // namespace quic
diff --git a/quic/core/qpack/qpack_offline_decoder_bin.cc b/quic/core/qpack/qpack_offline_decoder_bin.cc index 327816e..c1c002f 100644 --- a/quic/core/qpack/qpack_offline_decoder_bin.cc +++ b/quic/core/qpack/qpack_offline_decoder_bin.cc
@@ -7,8 +7,8 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_offline_decoder.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" int main(int argc, char* argv[]) { const char* usage = @@ -25,8 +25,8 @@ size_t i; size_t success_count = 0; for (i = 0; 2 * i < args.size(); ++i) { - const quic::QuicStringPiece input_filename(args[2 * i]); - const quic::QuicStringPiece expected_headers_filename(args[2 * i + 1]); + const quiche::QuicheStringPiece input_filename(args[2 * i]); + const quiche::QuicheStringPiece expected_headers_filename(args[2 * i + 1]); // Every file represents a different connection, // therefore every file needs a fresh decoding context.
diff --git a/quic/core/qpack/qpack_progressive_decoder.cc b/quic/core/qpack/qpack_progressive_decoder.cc index c9e19d2..cf20bde 100644 --- a/quic/core/qpack/qpack_progressive_decoder.cc +++ b/quic/core/qpack/qpack_progressive_decoder.cc
@@ -12,6 +12,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_instructions.h" #include "net/third_party/quiche/src/quic/core/qpack/qpack_required_insert_count.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -45,7 +46,7 @@ } } -void QpackProgressiveDecoder::Decode(QuicStringPiece data) { +void QpackProgressiveDecoder::Decode(quiche::QuicheStringPiece data) { DCHECK(decoding_); if (data.empty() || error_detected_) { @@ -113,7 +114,7 @@ return DoLiteralHeaderFieldInstruction(); } -void QpackProgressiveDecoder::OnError(QuicStringPiece error_message) { +void QpackProgressiveDecoder::OnError(quiche::QuicheStringPiece error_message) { DCHECK(!error_detected_); error_detected_ = true;
diff --git a/quic/core/qpack/qpack_progressive_decoder.h b/quic/core/qpack/qpack_progressive_decoder.h index 6599c1a..f9c0224 100644 --- a/quic/core/qpack/qpack_progressive_decoder.h +++ b/quic/core/qpack/qpack_progressive_decoder.h
@@ -14,7 +14,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_instruction_decoder.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -32,8 +32,8 @@ // Called when a new header name-value pair is decoded. Multiple values for // a given name will be emitted as multiple calls to OnHeader. - virtual void OnHeaderDecoded(QuicStringPiece name, - QuicStringPiece value) = 0; + virtual void OnHeaderDecoded(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) = 0; // Called when the header block is completely decoded. // Indicates the total number of bytes in this block. @@ -46,7 +46,8 @@ // Called when a decoding error has occurred. No other methods will be // called afterwards. Implementations are allowed to destroy // the QpackProgressiveDecoder instance synchronously. - virtual void OnDecodingErrorDetected(QuicStringPiece error_message) = 0; + virtual void OnDecodingErrorDetected( + quiche::QuicheStringPiece error_message) = 0; }; // Interface for keeping track of blocked streams for the purpose of enforcing @@ -89,7 +90,7 @@ ~QpackProgressiveDecoder() override; // Provide a data fragment to decode. - void Decode(QuicStringPiece data); + void Decode(quiche::QuicheStringPiece data); // Signal that the entire header block has been received and passed in // through Decode(). No methods must be called afterwards. @@ -97,7 +98,7 @@ // QpackInstructionDecoder::Delegate implementation. bool OnInstructionDecoded(const QpackInstruction* instruction) override; - void OnError(QuicStringPiece error_message) override; + void OnError(quiche::QuicheStringPiece error_message) override; // QpackHeaderTable::Observer implementation. void OnInsertCountReachedThreshold() override;
diff --git a/quic/core/qpack/qpack_receive_stream.cc b/quic/core/qpack/qpack_receive_stream.cc index 5920398..a5df828 100644 --- a/quic/core/qpack/qpack_receive_stream.cc +++ b/quic/core/qpack/qpack_receive_stream.cc
@@ -5,6 +5,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_receive_stream.h" #include "net/third_party/quiche/src/quic/core/quic_session.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { QpackReceiveStream::QpackReceiveStream(PendingStream* pending, @@ -25,7 +26,7 @@ while (!reading_stopped() && sequencer()->GetReadableRegion(&iov)) { DCHECK(!sequencer()->IsClosed()); - receiver_->Decode(QuicStringPiece( + receiver_->Decode(quiche::QuicheStringPiece( reinterpret_cast<const char*>(iov.iov_base), iov.iov_len)); sequencer()->MarkConsumed(iov.iov_len); }
diff --git a/quic/core/qpack/qpack_receive_stream_test.cc b/quic/core/qpack/qpack_receive_stream_test.cc index af02f64..6aeeeae 100644 --- a/quic/core/qpack/qpack_receive_stream_test.cc +++ b/quic/core/qpack/qpack_receive_stream_test.cc
@@ -8,6 +8,7 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test { @@ -61,7 +62,7 @@ : GetNthServerInitiatedUnidirectionalStreamId( session_.transport_version(), 3); char type[] = {0x03}; - QuicStreamFrame data1(id, false, 0, QuicStringPiece(type, 1)); + QuicStreamFrame data1(id, false, 0, quiche::QuicheStringPiece(type, 1)); session_.OnStreamFrame(data1); qpack_receive_stream_ = QuicSpdySessionPeer::GetQpackDecoderReceiveStream(&session_);
diff --git a/quic/core/qpack/qpack_round_trip_test.cc b/quic/core/qpack/qpack_round_trip_test.cc index f0dc797..8625baa 100644 --- a/quic/core/qpack/qpack_round_trip_test.cc +++ b/quic/core/qpack/qpack_round_trip_test.cc
@@ -5,11 +5,11 @@ #include <string> #include <tuple> -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_decoder_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_encoder_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/qpack/qpack_test_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" using ::testing::Values; @@ -126,7 +126,7 @@ TEST_P(QpackRoundTripTest, ValueHasNullCharacter) { spdy::SpdyHeaderBlock header_list; - header_list["foo"] = QuicStringPiece("bar\0bar\0baz", 11); + header_list["foo"] = quiche::QuicheStringPiece("bar\0bar\0baz", 11); spdy::SpdyHeaderBlock output = EncodeThenDecode(header_list); EXPECT_EQ(header_list, output);
diff --git a/quic/core/qpack/qpack_send_stream.cc b/quic/core/qpack/qpack_send_stream.cc index 50fe687..23f9db2 100644 --- a/quic/core/qpack/qpack_send_stream.cc +++ b/quic/core/qpack/qpack_send_stream.cc
@@ -6,6 +6,7 @@ #include "net/third_party/quiche/src/quic/core/quic_session.h" #include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { QpackSendStream::QpackSendStream(QuicStreamId id, @@ -23,7 +24,7 @@ ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); } -void QpackSendStream::WriteStreamData(QuicStringPiece data) { +void QpackSendStream::WriteStreamData(quiche::QuicheStringPiece data) { QuicConnection::ScopedPacketFlusher flusher(session()->connection()); MaybeSendStreamType(); WriteOrBufferData(data, false, nullptr); @@ -34,8 +35,8 @@ char type[sizeof(http3_stream_type_)]; QuicDataWriter writer(QUIC_ARRAYSIZE(type), type); writer.WriteVarInt62(http3_stream_type_); - WriteOrBufferData(QuicStringPiece(writer.data(), writer.length()), false, - nullptr); + WriteOrBufferData(quiche::QuicheStringPiece(writer.data(), writer.length()), + false, nullptr); stream_type_sent_ = true; } }
diff --git a/quic/core/qpack/qpack_send_stream.h b/quic/core/qpack/qpack_send_stream.h index 09c6020..bc2d9c0 100644 --- a/quic/core/qpack/qpack_send_stream.h +++ b/quic/core/qpack/qpack_send_stream.h
@@ -10,7 +10,7 @@ #include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h" #include "net/third_party/quiche/src/quic/core/quic_stream.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -40,7 +40,7 @@ // Writes the instructions to peer. The stream type will be sent // before the first instruction so that the peer can open an qpack stream. - void WriteStreamData(QuicStringPiece data) override; + void WriteStreamData(quiche::QuicheStringPiece data) override; // TODO(b/112770235): Remove this method once QuicStreamIdManager supports // creating HTTP/3 unidirectional streams dynamically.
diff --git a/quic/core/qpack/qpack_send_stream_test.cc b/quic/core/qpack/qpack_send_stream_test.cc index 9529f51..e1f32bb 100644 --- a/quic/core/qpack/qpack_send_stream_test.cc +++ b/quic/core/qpack/qpack_send_stream_test.cc
@@ -9,6 +9,8 @@ #include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" #include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test { @@ -35,7 +37,7 @@ // Used by ::testing::PrintToStringParamName(). std::string PrintToString(const TestParams& tp) { - return QuicStrCat( + return quiche::QuicheStrCat( ParsedQuicVersionToString(tp.version), "_", (tp.perspective == Perspective::IS_CLIENT ? "client" : "server")); } @@ -97,10 +99,10 @@ std::string data = "data"; EXPECT_CALL(session_, WritevData(_, _, 1, _, _)); EXPECT_CALL(session_, WritevData(_, _, data.length(), _, _)); - qpack_send_stream_->WriteStreamData(QuicStringPiece(data)); + qpack_send_stream_->WriteStreamData(quiche::QuicheStringPiece(data)); EXPECT_CALL(session_, WritevData(_, _, data.length(), _, _)); - qpack_send_stream_->WriteStreamData(QuicStringPiece(data)); + qpack_send_stream_->WriteStreamData(quiche::QuicheStringPiece(data)); EXPECT_CALL(session_, WritevData(_, _, _, _, _)).Times(0); qpack_send_stream_->MaybeSendStreamType(); }
diff --git a/quic/core/qpack/qpack_static_table_test.cc b/quic/core/qpack/qpack_static_table_test.cc index 1742502..a8e7ac2 100644 --- a/quic/core/qpack/qpack_static_table_test.cc +++ b/quic/core/qpack/qpack_static_table_test.cc
@@ -7,8 +7,8 @@ #include <set> #include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -32,7 +32,7 @@ EXPECT_EQ(QpackStaticTableVector().size(), static_index.size()); auto static_name_index = table.GetStaticNameIndex(); - std::set<QuicStringPiece> names; + std::set<quiche::QuicheStringPiece> names; for (auto entry : static_index) { names.insert(entry->name()); }
diff --git a/quic/core/qpack/qpack_stream_receiver.h b/quic/core/qpack/qpack_stream_receiver.h index 48f5aa30..01c2d5f 100644 --- a/quic/core/qpack/qpack_stream_receiver.h +++ b/quic/core/qpack/qpack_stream_receiver.h
@@ -6,7 +6,7 @@ #define QUICHE_QUIC_CORE_QPACK_QPACK_STREAM_RECEIVER_H_ #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -16,7 +16,7 @@ virtual ~QpackStreamReceiver() = default; // Decode data. - virtual void Decode(QuicStringPiece data) = 0; + virtual void Decode(quiche::QuicheStringPiece data) = 0; }; } // namespace quic
diff --git a/quic/core/qpack/qpack_stream_sender_delegate.h b/quic/core/qpack/qpack_stream_sender_delegate.h index 616df98..524b756 100644 --- a/quic/core/qpack/qpack_stream_sender_delegate.h +++ b/quic/core/qpack/qpack_stream_sender_delegate.h
@@ -6,7 +6,7 @@ #define QUICHE_QUIC_CORE_QPACK_QPACK_STREAM_SENDER_DELEGATE_H_ #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -16,7 +16,7 @@ virtual ~QpackStreamSenderDelegate() = default; // Write data on the unidirectional stream. - virtual void WriteStreamData(QuicStringPiece data) = 0; + virtual void WriteStreamData(quiche::QuicheStringPiece data) = 0; }; } // namespace quic
diff --git a/quic/core/qpack/value_splitting_header_list.cc b/quic/core/qpack/value_splitting_header_list.cc index c1387b9..65d1b99 100644 --- a/quic/core/qpack/value_splitting_header_list.cc +++ b/quic/core/qpack/value_splitting_header_list.cc
@@ -3,6 +3,7 @@ // found in the LICENSE file. #include "net/third_party/quiche/src/quic/core/qpack/value_splitting_header_list.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace { @@ -36,7 +37,7 @@ const ValueSplittingHeaderList::const_iterator& ValueSplittingHeaderList::const_iterator::operator++() { - if (value_end_ == QuicStringPiece::npos) { + if (value_end_ == quiche::QuicheStringPiece::npos) { // This was the last frament within |*header_list_iterator_|, // move on to the next header element of |header_list_|. ++header_list_iterator_; @@ -60,14 +61,15 @@ } void ValueSplittingHeaderList::const_iterator::UpdateHeaderField() { - DCHECK(value_start_ != QuicStringPiece::npos); + DCHECK(value_start_ != quiche::QuicheStringPiece::npos); if (header_list_iterator_ == header_list_->end()) { return; } - const QuicStringPiece name = header_list_iterator_->first; - const QuicStringPiece original_value = header_list_iterator_->second; + const quiche::QuicheStringPiece name = header_list_iterator_->first; + const quiche::QuicheStringPiece original_value = + header_list_iterator_->second; if (name == kCookieKey) { value_end_ = original_value.find(kCookieSeparator, value_start_); @@ -75,12 +77,12 @@ value_end_ = original_value.find(kNonCookieSeparator, value_start_); } - const QuicStringPiece value = + const quiche::QuicheStringPiece value = original_value.substr(value_start_, value_end_ - value_start_); header_field_ = std::make_pair(name, value); // Skip character after ';' separator if it is a space. - if (name == kCookieKey && value_end_ != QuicStringPiece::npos && + if (name == kCookieKey && value_end_ != quiche::QuicheStringPiece::npos && value_end_ + 1 < original_value.size() && original_value[value_end_ + 1] == kOptionalSpaceAfterCookieSeparator) { ++value_end_;
diff --git a/quic/core/qpack/value_splitting_header_list.h b/quic/core/qpack/value_splitting_header_list.h index fee3043..446548a 100644 --- a/quic/core/qpack/value_splitting_header_list.h +++ b/quic/core/qpack/value_splitting_header_list.h
@@ -6,7 +6,7 @@ #define QUICHE_QUIC_CORE_QPACK_VALUE_SPLITTING_HEADER_LIST_H_ #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" namespace quic { @@ -40,8 +40,8 @@ const spdy::SpdyHeaderBlock* const header_list_; spdy::SpdyHeaderBlock::const_iterator header_list_iterator_; - QuicStringPiece::size_type value_start_; - QuicStringPiece::size_type value_end_; + quiche::QuicheStringPiece::size_type value_start_; + quiche::QuicheStringPiece::size_type value_end_; value_type header_field_; };
diff --git a/quic/core/qpack/value_splitting_header_list_test.cc b/quic/core/qpack/value_splitting_header_list_test.cc index bab5238..ef69aad 100644 --- a/quic/core/qpack/value_splitting_header_list_test.cc +++ b/quic/core/qpack/value_splitting_header_list_test.cc
@@ -6,6 +6,7 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_arraysize.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test { @@ -16,7 +17,7 @@ TEST(ValueSplittingHeaderListTest, Comparison) { spdy::SpdyHeaderBlock block; - block["foo"] = QuicStringPiece("bar\0baz", 7); + block["foo"] = quiche::QuicheStringPiece("bar\0baz", 7); block["baz"] = "qux"; block["cookie"] = "foo; bar"; @@ -84,7 +85,7 @@ TEST(ValueSplittingHeaderListTest, Split) { struct { const char* name; - QuicStringPiece value; + quiche::QuicheStringPiece value; std::vector<const char*> expected_values; } kTestData[]{ // Empty value. @@ -130,9 +131,9 @@ TEST(ValueSplittingHeaderListTest, MultipleFields) { spdy::SpdyHeaderBlock block; - block["foo"] = QuicStringPiece("bar\0baz\0", 8); + block["foo"] = quiche::QuicheStringPiece("bar\0baz\0", 8); block["cookie"] = "foo; bar"; - block["bar"] = QuicStringPiece("qux\0foo", 7); + block["bar"] = quiche::QuicheStringPiece("qux\0foo", 7); ValueSplittingHeaderList headers(&block); EXPECT_THAT(headers, ElementsAre(Pair("foo", "bar"), Pair("foo", "baz"),