Remove Http2StringPiece; use QuicheStringPiece instead. gfe-relnote: n/a, no functional change. PiperOrigin-RevId: 285412823 Change-Id: I907a65813e890ce153b93fe5f07721efb3ecc195
diff --git a/http2/decoder/decode_buffer.h b/http2/decoder/decode_buffer.h index 24f252e..e6604f1 100644 --- a/http2/decoder/decode_buffer.h +++ b/http2/decoder/decode_buffer.h
@@ -19,7 +19,7 @@ #include "net/third_party/quiche/src/http2/platform/api/http2_export.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { class DecodeBufferSubset; @@ -35,7 +35,7 @@ const size_t kMaxDecodeBufferLength = 1 << 25; DCHECK_LE(len, kMaxDecodeBufferLength); } - explicit DecodeBuffer(Http2StringPiece s) + explicit DecodeBuffer(quiche::QuicheStringPiece s) : DecodeBuffer(s.data(), s.size()) {} // Constructor for character arrays, typically in tests. For example: // const char input[] = { 0x11 };
diff --git a/http2/decoder/decode_http2_structures_test.cc b/http2/decoder/decode_http2_structures_test.cc index 48b79bd..37246c4 100644 --- a/http2/decoder/decode_http2_structures_test.cc +++ b/http2/decoder/decode_http2_structures_test.cc
@@ -17,9 +17,9 @@ #include "net/third_party/quiche/src/http2/http2_constants.h" #include "net/third_party/quiche/src/http2/http2_structures_test_util.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/test_tools/http2_random.h" #include "net/third_party/quiche/src/http2/tools/http2_frame_builder.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using ::testing::AssertionResult; @@ -28,8 +28,9 @@ namespace { template <typename T, size_t N> -Http2StringPiece ToStringPiece(T (&data)[N]) { - return Http2StringPiece(reinterpret_cast<const char*>(data), N * sizeof(T)); +quiche::QuicheStringPiece ToStringPiece(T (&data)[N]) { + return quiche::QuicheStringPiece(reinterpret_cast<const char*>(data), + N * sizeof(T)); } template <class S> @@ -52,7 +53,8 @@ // Fully decodes the Structure at the start of data, and confirms it matches // *expected (if provided). - void DecodeLeadingStructure(const S* expected, Http2StringPiece data) { + void DecodeLeadingStructure(const S* expected, + quiche::QuicheStringPiece data) { ASSERT_LE(S::EncodedSize(), data.size()); DecodeBuffer db(data); Randomize(&structure_); @@ -65,7 +67,7 @@ template <size_t N> void DecodeLeadingStructure(const char (&data)[N]) { - DecodeLeadingStructure(nullptr, Http2StringPiece(data, N)); + DecodeLeadingStructure(nullptr, quiche::QuicheStringPiece(data, N)); } // Encode the structure |in_s| into bytes, then decode the bytes @@ -291,7 +293,7 @@ }; DecodeLeadingStructure(kData); if (!HasFailure()) { - EXPECT_EQ(Http2StringPiece(kData, 8), + EXPECT_EQ(quiche::QuicheStringPiece(kData, 8), ToStringPiece(structure_.opaque_bytes)); } } @@ -302,7 +304,7 @@ }; DecodeLeadingStructure(kData); if (!HasFailure()) { - EXPECT_EQ(Http2StringPiece(kData, 8), + EXPECT_EQ(quiche::QuicheStringPiece(kData, 8), ToStringPiece(structure_.opaque_bytes)); } } @@ -312,7 +314,7 @@ }; DecodeLeadingStructure(kData); if (!HasFailure()) { - EXPECT_EQ(Http2StringPiece(kData, 8), + EXPECT_EQ(quiche::QuicheStringPiece(kData, 8), ToStringPiece(structure_.opaque_bytes)); } }
diff --git a/http2/decoder/http2_frame_decoder_test.cc b/http2/decoder/http2_frame_decoder_test.cc index 7ed67f3..20e39eb 100644 --- a/http2/decoder/http2_frame_decoder_test.cc +++ b/http2/decoder/http2_frame_decoder_test.cc
@@ -13,12 +13,12 @@ #include "net/third_party/quiche/src/http2/http2_constants.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" #include "net/third_party/quiche/src/http2/platform/api/http2_reconstruct_object.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/platform/api/http2_test_helpers.h" #include "net/third_party/quiche/src/http2/test_tools/frame_parts.h" #include "net/third_party/quiche/src/http2/test_tools/frame_parts_collector_listener.h" #include "net/third_party/quiche/src/http2/test_tools/http2_random.h" #include "net/third_party/quiche/src/http2/tools/random_decoder_test.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using ::testing::AssertionResult; using ::testing::AssertionSuccess; @@ -120,8 +120,9 @@ VERIFY_AND_RETURN_SUCCESS(expected.VerifyEquals(*collector_.frame(0))); } - AssertionResult DecodePayloadAndValidateSeveralWays(Http2StringPiece payload, - Validator validator) { + AssertionResult DecodePayloadAndValidateSeveralWays( + quiche::QuicheStringPiece payload, + Validator validator) { DecodeBuffer db(payload); bool start_decoding_requires_non_empty = false; return DecodeAndValidateSeveralWays(&db, start_decoding_requires_non_empty, @@ -133,7 +134,7 @@ // payload will be decoded several times with different partitionings // of the payload, and after each the validator will be called. AssertionResult DecodePayloadAndValidateSeveralWays( - Http2StringPiece payload, + quiche::QuicheStringPiece payload, const FrameParts& expected) { auto validator = [&expected, this](const DecodeBuffer& input, DecodeStatus status) -> AssertionResult { @@ -164,16 +165,16 @@ AssertionResult DecodePayloadAndValidateSeveralWays( const char (&buf)[N], const FrameParts& expected) { - return DecodePayloadAndValidateSeveralWays(Http2StringPiece(buf, N), - expected); + return DecodePayloadAndValidateSeveralWays( + quiche::QuicheStringPiece(buf, N), expected); } template <size_t N> AssertionResult DecodePayloadAndValidateSeveralWays( const char (&buf)[N], const Http2FrameHeader& header) { - return DecodePayloadAndValidateSeveralWays(Http2StringPiece(buf, N), - FrameParts(header)); + return DecodePayloadAndValidateSeveralWays( + quiche::QuicheStringPiece(buf, N), FrameParts(header)); } template <size_t N>
diff --git a/http2/decoder/http2_structure_decoder_test.cc b/http2/decoder/http2_structure_decoder_test.cc index 2545109..09db43e 100644 --- a/http2/decoder/http2_structure_decoder_test.cc +++ b/http2/decoder/http2_structure_decoder_test.cc
@@ -30,10 +30,10 @@ #include "net/third_party/quiche/src/http2/http2_structures_test_util.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" #include "net/third_party/quiche/src/http2/platform/api/http2_reconstruct_object.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/platform/api/http2_test_helpers.h" #include "net/third_party/quiche/src/http2/tools/http2_frame_builder.h" #include "net/third_party/quiche/src/http2/tools/random_decoder_test.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using ::testing::AssertionFailure; using ::testing::AssertionResult; @@ -95,7 +95,7 @@ // Fully decodes the Structure at the start of data, and confirms it matches // *expected (if provided). AssertionResult DecodeLeadingStructure(const S* expected, - Http2StringPiece data) { + quiche::QuicheStringPiece data) { VERIFY_LE(S::EncodedSize(), data.size()); DecodeBuffer original(data); @@ -147,7 +147,7 @@ template <size_t N> AssertionResult DecodeLeadingStructure(const char (&data)[N]) { VERIFY_AND_RETURN_SUCCESS( - DecodeLeadingStructure(nullptr, Http2StringPiece(data, N))); + DecodeLeadingStructure(nullptr, quiche::QuicheStringPiece(data, N))); } template <size_t N>
diff --git a/http2/decoder/payload_decoders/payload_decoder_base_test_util.cc b/http2/decoder/payload_decoders/payload_decoder_base_test_util.cc index ba6d04a..8e94f03 100644 --- a/http2/decoder/payload_decoders/payload_decoder_base_test_util.cc +++ b/http2/decoder/payload_decoders/payload_decoder_base_test_util.cc
@@ -75,7 +75,7 @@ ::testing::AssertionResult PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays( - Http2StringPiece payload, + quiche::QuicheStringPiece payload, Validator validator) { VERIFY_TRUE(frame_header_is_set_); // Cap the payload to be decoded at the declared payload length. This is @@ -85,7 +85,8 @@ // Note that it is OK if the payload is too short; the validator may be // designed to check for that. if (payload.size() > frame_header_.payload_length) { - payload = Http2StringPiece(payload.data(), frame_header_.payload_length); + payload = + quiche::QuicheStringPiece(payload.data(), frame_header_.payload_length); } DecodeBuffer db(payload); ResetDecodeSpeedCounters();
diff --git a/http2/decoder/payload_decoders/payload_decoder_base_test_util.h b/http2/decoder/payload_decoders/payload_decoder_base_test_util.h index 5de0d1b..faa99fd 100644 --- a/http2/decoder/payload_decoders/payload_decoder_base_test_util.h +++ b/http2/decoder/payload_decoders/payload_decoder_base_test_util.h
@@ -21,10 +21,10 @@ #include "net/third_party/quiche/src/http2/http2_structures.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" #include "net/third_party/quiche/src/http2/platform/api/http2_reconstruct_object.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/test_tools/frame_parts.h" #include "net/third_party/quiche/src/http2/tools/http2_frame_builder.h" #include "net/third_party/quiche/src/http2/tools/random_decoder_test.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { @@ -82,7 +82,7 @@ // Given the specified payload (without the common frame header), decode // it with several partitionings of the payload. ::testing::AssertionResult DecodePayloadAndValidateSeveralWays( - Http2StringPiece payload, + quiche::QuicheStringPiece payload, Validator validator); // TODO(jamessynge): Add helper method for verifying these are both non-zero, @@ -191,7 +191,7 @@ // will be decoded several times with different partitionings of the payload, // and after each the validator will be called. AssertionResult DecodePayloadAndValidateSeveralWays( - Http2StringPiece payload, + quiche::QuicheStringPiece payload, const FrameParts& expected) { auto validator = [&expected, this]() -> AssertionResult { VERIFY_FALSE(listener_.IsInProgress()); @@ -210,7 +210,7 @@ // std::nullptr_t (not extra validation). template <typename WrappedValidator> ::testing::AssertionResult VerifyDetectsFrameSizeError( - Http2StringPiece payload, + quiche::QuicheStringPiece payload, const Http2FrameHeader& header, WrappedValidator wrapped_validator) { set_frame_header(header); @@ -249,7 +249,7 @@ // randomly selected flag bits not excluded by FlagsAffectingPayloadDecoding. ::testing::AssertionResult VerifyDetectsMultipleFrameSizeErrors( uint8_t required_flags, - Http2StringPiece unpadded_payload, + quiche::QuicheStringPiece unpadded_payload, ApproveSize approve_size, int total_pad_length) { // required_flags should come from those that are defined for the frame @@ -307,7 +307,7 @@ // As above, but for frames without padding. ::testing::AssertionResult VerifyDetectsFrameSizeError( uint8_t required_flags, - Http2StringPiece unpadded_payload, + quiche::QuicheStringPiece unpadded_payload, const ApproveSize& approve_size) { Http2FrameType frame_type = DecoderPeer::FrameType(); uint8_t known_flags = KnownFlagsMaskForFrameType(frame_type); @@ -386,7 +386,7 @@ // amount of missing padding is as specified. header.IsPadded must be true, // and the payload must be empty or the PadLength field must be too large. ::testing::AssertionResult VerifyDetectsPaddingTooLong( - Http2StringPiece payload, + quiche::QuicheStringPiece payload, const Http2FrameHeader& header, size_t expected_missing_length) { set_frame_header(header);
diff --git a/http2/hpack/decoder/hpack_block_collector.cc b/http2/hpack/decoder/hpack_block_collector.cc index 3490ca7..325a60c 100644 --- a/http2/hpack/decoder/hpack_block_collector.cc +++ b/http2/hpack/decoder/hpack_block_collector.cc
@@ -112,7 +112,7 @@ HpackEntryType expected_type, size_t expected_index, bool expected_value_huffman, - Http2StringPiece expected_value) const { + quiche::QuicheStringPiece expected_value) const { VERIFY_TRUE(pending_entry_.IsClear()); VERIFY_EQ(1u, entries_.size()); VERIFY_TRUE(entries_.front().ValidateLiteralValueHeader( @@ -122,9 +122,9 @@ AssertionResult HpackBlockCollector::ValidateSoleLiteralNameValueHeader( HpackEntryType expected_type, bool expected_name_huffman, - Http2StringPiece expected_name, + quiche::QuicheStringPiece expected_name, bool expected_value_huffman, - Http2StringPiece expected_value) const { + quiche::QuicheStringPiece expected_value) const { VERIFY_TRUE(pending_entry_.IsClear()); VERIFY_EQ(1u, entries_.size()); VERIFY_TRUE(entries_.front().ValidateLiteralNameValueHeader(
diff --git a/http2/hpack/decoder/hpack_block_collector.h b/http2/hpack/decoder/hpack_block_collector.h index 0d8f811..8246de4 100644 --- a/http2/hpack/decoder/hpack_block_collector.h +++ b/http2/hpack/decoder/hpack_block_collector.h
@@ -23,8 +23,8 @@ #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_entry_decoder_listener.h" #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.h" #include "net/third_party/quiche/src/http2/hpack/tools/hpack_block_builder.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/test_tools/http2_random.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { @@ -97,16 +97,16 @@ HpackEntryType expected_type, size_t expected_index, bool expected_value_huffman, - Http2StringPiece expected_value) const; + quiche::QuicheStringPiece expected_value) const; // Return AssertionSuccess if there is just one entry, and it is a Header // with a literal name and literal value. ::testing::AssertionResult ValidateSoleLiteralNameValueHeader( HpackEntryType expected_type, bool expected_name_huffman, - Http2StringPiece expected_name, + quiche::QuicheStringPiece expected_name, bool expected_value_huffman, - Http2StringPiece expected_value) const; + quiche::QuicheStringPiece expected_value) const; bool IsNotPending() const { return pending_entry_.IsClear(); } bool IsClear() const { return IsNotPending() && entries_.empty(); }
diff --git a/http2/hpack/decoder/hpack_block_decoder_test.cc b/http2/hpack/decoder/hpack_block_decoder_test.cc index 4988b5c..aeb6c48 100644 --- a/http2/hpack/decoder/hpack_block_decoder_test.cc +++ b/http2/hpack/decoder/hpack_block_decoder_test.cc
@@ -15,10 +15,10 @@ #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.h" #include "net/third_party/quiche/src/http2/hpack/tools/hpack_block_builder.h" #include "net/third_party/quiche/src/http2/hpack/tools/hpack_example.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/platform/api/http2_test_helpers.h" #include "net/third_party/quiche/src/http2/test_tools/http2_random.h" #include "net/third_party/quiche/src/http2/tools/random_decoder_test.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using ::testing::AssertionSuccess; @@ -66,7 +66,7 @@ } AssertionResult DecodeHpackExampleAndValidateSeveralWays( - Http2StringPiece hpack_example, + quiche::QuicheStringPiece hpack_example, Validator validator) { std::string input = HpackExampleToStringOrDie(hpack_example); DecodeBuffer db(input);
diff --git a/http2/hpack/decoder/hpack_decoder.cc b/http2/hpack/decoder/hpack_decoder.cc index f2f8584..1421c7c 100644 --- a/http2/hpack/decoder/hpack_decoder.cc +++ b/http2/hpack/decoder/hpack_decoder.cc
@@ -109,7 +109,7 @@ return Http2EstimateMemoryUsage(entry_buffer_); } -void HpackDecoder::ReportError(Http2StringPiece error_message) { +void HpackDecoder::ReportError(quiche::QuicheStringPiece error_message) { HTTP2_DVLOG(3) << "HpackDecoder::ReportError is new=" << (!error_detected_ ? "true" : "false") << ", error_message: " << error_message;
diff --git a/http2/hpack/decoder/hpack_decoder.h b/http2/hpack/decoder/hpack_decoder.h index e173bc6..663fef6 100644 --- a/http2/hpack/decoder/hpack_decoder.h +++ b/http2/hpack/decoder/hpack_decoder.h
@@ -30,7 +30,7 @@ #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_decoder_tables.h" #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_whole_entry_buffer.h" #include "net/third_party/quiche/src/http2/platform/api/http2_export.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { @@ -102,7 +102,7 @@ friend class test::HpackDecoderPeer; // Reports an error to the listener IF this is the first error detected. - void ReportError(Http2StringPiece error_message); + void ReportError(quiche::QuicheStringPiece error_message); // The decompressor state, as defined by HPACK (i.e. the static and dynamic // tables).
diff --git a/http2/hpack/decoder/hpack_decoder_listener.cc b/http2/hpack/decoder/hpack_decoder_listener.cc index 8afa8aa..60341a0 100644 --- a/http2/hpack/decoder/hpack_decoder_listener.cc +++ b/http2/hpack/decoder/hpack_decoder_listener.cc
@@ -18,7 +18,7 @@ const HpackString& value) {} void HpackDecoderNoOpListener::OnHeaderListEnd() {} void HpackDecoderNoOpListener::OnHeaderErrorDetected( - Http2StringPiece error_message) {} + quiche::QuicheStringPiece error_message) {} // static HpackDecoderNoOpListener* HpackDecoderNoOpListener::NoOpListener() {
diff --git a/http2/hpack/decoder/hpack_decoder_listener.h b/http2/hpack/decoder/hpack_decoder_listener.h index fa68591..2db8157 100644 --- a/http2/hpack/decoder/hpack_decoder_listener.h +++ b/http2/hpack/decoder/hpack_decoder_listener.h
@@ -11,7 +11,7 @@ #include "net/third_party/quiche/src/http2/hpack/hpack_string.h" #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.h" #include "net/third_party/quiche/src/http2/platform/api/http2_export.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { @@ -39,7 +39,8 @@ // OnHeaderErrorDetected is called if an error is detected while decoding. // error_message may be used in a GOAWAY frame as the Opaque Data. - virtual void OnHeaderErrorDetected(Http2StringPiece error_message) = 0; + virtual void OnHeaderErrorDetected( + quiche::QuicheStringPiece error_message) = 0; }; // A no-op implementation of HpackDecoderListener, useful for ignoring @@ -55,7 +56,7 @@ const HpackString& name, const HpackString& value) override; void OnHeaderListEnd() override; - void OnHeaderErrorDetected(Http2StringPiece error_message) override; + void OnHeaderErrorDetected(quiche::QuicheStringPiece error_message) override; // Returns a listener that ignores all the calls. static HpackDecoderNoOpListener* NoOpListener();
diff --git a/http2/hpack/decoder/hpack_decoder_state.cc b/http2/hpack/decoder/hpack_decoder_state.cc index 921d48c..c01ae74 100644 --- a/http2/hpack/decoder/hpack_decoder_state.cc +++ b/http2/hpack/decoder/hpack_decoder_state.cc
@@ -185,7 +185,8 @@ lowest_header_table_size_ = final_header_table_size_; } -void HpackDecoderState::OnHpackDecodeError(Http2StringPiece error_message) { +void HpackDecoderState::OnHpackDecodeError( + quiche::QuicheStringPiece error_message) { HTTP2_DVLOG(2) << "HpackDecoderState::OnHpackDecodeError " << error_message; if (!error_detected_) { ReportError(error_message); @@ -206,7 +207,7 @@ } } -void HpackDecoderState::ReportError(Http2StringPiece error_message) { +void HpackDecoderState::ReportError(quiche::QuicheStringPiece error_message) { HTTP2_DVLOG(2) << "HpackDecoderState::ReportError is new=" << (!error_detected_ ? "true" : "false") << ", error_message: " << error_message;
diff --git a/http2/hpack/decoder/hpack_decoder_state.h b/http2/hpack/decoder/hpack_decoder_state.h index fd34179..0139b31 100644 --- a/http2/hpack/decoder/hpack_decoder_state.h +++ b/http2/hpack/decoder/hpack_decoder_state.h
@@ -22,7 +22,7 @@ #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_whole_entry_listener.h" #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.h" #include "net/third_party/quiche/src/http2/platform/api/http2_export.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { @@ -76,7 +76,7 @@ HpackDecoderStringBuffer* name_buffer, HpackDecoderStringBuffer* value_buffer) override; void OnDynamicTableSizeUpdate(size_t size) override; - void OnHpackDecodeError(Http2StringPiece error_message) override; + void OnHpackDecodeError(quiche::QuicheStringPiece error_message) override; // OnHeaderBlockEnd notifies this object that an entire HPACK block has been // decoded, which might have extended into CONTINUATION blocks. @@ -94,7 +94,7 @@ friend class test::HpackDecoderStatePeer; // Reports an error to the listener IF this is the first error detected. - void ReportError(Http2StringPiece error_message); + void ReportError(quiche::QuicheStringPiece error_message); // The static and dynamic HPACK tables. HpackDecoderTables decoder_tables_;
diff --git a/http2/hpack/decoder/hpack_decoder_state_test.cc b/http2/hpack/decoder/hpack_decoder_state_test.cc index cbc4224..743d0d9 100644 --- a/http2/hpack/decoder/hpack_decoder_state_test.cc +++ b/http2/hpack/decoder/hpack_decoder_state_test.cc
@@ -15,8 +15,8 @@ #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.h" #include "net/third_party/quiche/src/http2/http2_constants.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/platform/api/http2_test_helpers.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using ::testing::AssertionResult; using ::testing::AssertionSuccess; @@ -44,7 +44,8 @@ const HpackString& name, const HpackString& value)); MOCK_METHOD0(OnHeaderListEnd, void()); - MOCK_METHOD1(OnHeaderErrorDetected, void(Http2StringPiece error_message)); + MOCK_METHOD1(OnHeaderErrorDetected, + void(quiche::QuicheStringPiece error_message)); }; enum StringBacking { STATIC, UNBUFFERED, BUFFERED }; @@ -517,8 +518,8 @@ TEST_F(HpackDecoderStateTest, ErrorsSuppressCallbacks) { SendStartAndVerifyCallback(); - EXPECT_CALL(listener_, - OnHeaderErrorDetected(Http2StringPiece("Huffman decode error."))); + EXPECT_CALL(listener_, OnHeaderErrorDetected(quiche::QuicheStringPiece( + "Huffman decode error."))); decoder_state_.OnHpackDecodeError("Huffman decode error."); // Further decoded entries are ignored.
diff --git a/http2/hpack/decoder/hpack_decoder_string_buffer.cc b/http2/hpack/decoder/hpack_decoder_string_buffer.cc index 6a20008..d38ea9f 100644 --- a/http2/hpack/decoder/hpack_decoder_string_buffer.cc +++ b/http2/hpack/decoder/hpack_decoder_string_buffer.cc
@@ -60,7 +60,8 @@ state_ = State::RESET; } -void HpackDecoderStringBuffer::Set(Http2StringPiece value, bool is_static) { +void HpackDecoderStringBuffer::Set(quiche::QuicheStringPiece value, + bool is_static) { HTTP2_DVLOG(2) << "HpackDecoderStringBuffer::Set"; DCHECK_EQ(state_, State::RESET); value_ = value; @@ -100,7 +101,7 @@ backing_ = Backing::RESET; // OnData is not called for empty (zero length) strings, so make sure that // value_ is cleared. - value_ = Http2StringPiece(); + value_ = quiche::QuicheStringPiece(); } } @@ -113,7 +114,7 @@ if (is_huffman_encoded_) { DCHECK_EQ(backing_, Backing::BUFFERED); - return decoder_.Decode(Http2StringPiece(data, len), &buffer_); + return decoder_.Decode(quiche::QuicheStringPiece(data, len), &buffer_); } if (backing_ == Backing::RESET) { @@ -121,7 +122,7 @@ // don't copy the string. If we later find that the HPACK entry is split // across input buffers, then we'll copy the string into buffer_. if (remaining_len_ == 0) { - value_ = Http2StringPiece(data, len); + value_ = quiche::QuicheStringPiece(data, len); backing_ = Backing::UNBUFFERED; return true; } @@ -187,7 +188,7 @@ return IsBuffered() ? buffer_.size() : 0; } -Http2StringPiece HpackDecoderStringBuffer::str() const { +quiche::QuicheStringPiece HpackDecoderStringBuffer::str() const { HTTP2_DVLOG(3) << "HpackDecoderStringBuffer::str"; DCHECK_EQ(state_, State::COMPLETE); return value_;
diff --git a/http2/hpack/decoder/hpack_decoder_string_buffer.h b/http2/hpack/decoder/hpack_decoder_string_buffer.h index d8dce6c..94c46d5 100644 --- a/http2/hpack/decoder/hpack_decoder_string_buffer.h +++ b/http2/hpack/decoder/hpack_decoder_string_buffer.h
@@ -16,7 +16,7 @@ #include "net/third_party/quiche/src/http2/hpack/huffman/hpack_huffman_decoder.h" #include "net/third_party/quiche/src/http2/platform/api/http2_export.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { @@ -32,7 +32,7 @@ HpackDecoderStringBuffer& operator=(const HpackDecoderStringBuffer&) = delete; void Reset(); - void Set(Http2StringPiece value, bool is_static); + void Set(quiche::QuicheStringPiece value, bool is_static); // Note that for Huffman encoded strings the length of the string after // decoding may be larger (expected), the same or even smaller; the latter @@ -47,11 +47,11 @@ // Accessors for the completely collected string (i.e. Set or OnEnd has just // been called, and no reset of the state has occurred). - // Returns a Http2StringPiece pointing to the backing store for the string, + // Returns a QuicheStringPiece pointing to the backing store for the string, // either the internal buffer or the original transport buffer (e.g. for a // literal value that wasn't Huffman encoded, and that wasn't split across // transport buffers). - Http2StringPiece str() const; + quiche::QuicheStringPiece str() const; // Returns the completely collected string by value, using std::move in an // effort to avoid unnecessary copies. ReleaseString() must not be called @@ -72,10 +72,10 @@ // (e.g. if Huffman encoded, buffer_ is storage for the decoded string). std::string buffer_; - // The Http2StringPiece to be returned by HpackDecoderStringBuffer::str(). If + // The QuicheStringPiece to be returned by HpackDecoderStringBuffer::str(). If // a string has been collected, but not buffered, value_ points to that // string. - Http2StringPiece value_; + quiche::QuicheStringPiece value_; // The decoder to use if the string is Huffman encoded. HpackHuffmanDecoder decoder_;
diff --git a/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc b/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc index ec807c8..9c30db7 100644 --- a/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc +++ b/http2/hpack/decoder/hpack_decoder_string_buffer_test.cc
@@ -47,7 +47,7 @@ }; TEST_F(HpackDecoderStringBufferTest, SetStatic) { - Http2StringPiece data("static string"); + quiche::QuicheStringPiece data("static string"); EXPECT_EQ(state(), State::RESET); EXPECT_TRUE(VerifyLogHasSubstrs({"state=RESET"})); @@ -72,7 +72,7 @@ } TEST_F(HpackDecoderStringBufferTest, PlainWhole) { - Http2StringPiece data("some text."); + quiche::QuicheStringPiece data("some text."); HTTP2_LOG(INFO) << buf_; EXPECT_EQ(state(), State::RESET); @@ -93,8 +93,8 @@ EXPECT_TRUE(VerifyLogHasSubstrs( {"state=COMPLETE", "backing=UNBUFFERED", "value: some text."})); - // We expect that the string buffer points to the passed in Http2StringPiece's - // backing store. + // We expect that the string buffer points to the passed in + // QuicheStringPiece's backing store. EXPECT_EQ(data.data(), buf_.str().data()); // Now force it to buffer the string, after which it will still have the same @@ -110,9 +110,9 @@ } TEST_F(HpackDecoderStringBufferTest, PlainSplit) { - Http2StringPiece data("some text."); - Http2StringPiece part1 = data.substr(0, 1); - Http2StringPiece part2 = data.substr(1); + quiche::QuicheStringPiece data("some text."); + quiche::QuicheStringPiece part1 = data.substr(0, 1); + quiche::QuicheStringPiece part2 = data.substr(1); EXPECT_EQ(state(), State::RESET); buf_.OnStart(/*huffman_encoded*/ false, data.size()); @@ -138,7 +138,7 @@ EXPECT_EQ(buf_.BufferedLength(), data.size()); HTTP2_LOG(INFO) << buf_; - Http2StringPiece buffered = buf_.str(); + quiche::QuicheStringPiece buffered = buf_.str(); EXPECT_EQ(data, buffered); EXPECT_NE(data.data(), buffered.data()); @@ -153,7 +153,7 @@ TEST_F(HpackDecoderStringBufferTest, HuffmanWhole) { std::string encoded = Http2HexDecode("f1e3c2e5f23a6ba0ab90f4ff"); - Http2StringPiece decoded("www.example.com"); + quiche::QuicheStringPiece decoded("www.example.com"); EXPECT_EQ(state(), State::RESET); buf_.OnStart(/*huffman_encoded*/ true, encoded.size()); @@ -180,7 +180,7 @@ std::string encoded = Http2HexDecode("f1e3c2e5f23a6ba0ab90f4ff"); std::string part1 = encoded.substr(0, 5); std::string part2 = encoded.substr(5); - Http2StringPiece decoded("www.example.com"); + quiche::QuicheStringPiece decoded("www.example.com"); EXPECT_EQ(state(), State::RESET); buf_.OnStart(/*huffman_encoded*/ true, encoded.size());
diff --git a/http2/hpack/decoder/hpack_decoder_test.cc b/http2/hpack/decoder/hpack_decoder_test.cc index 9734bdd..f2ff8c2 100644 --- a/http2/hpack/decoder/hpack_decoder_test.cc +++ b/http2/hpack/decoder/hpack_decoder_test.cc
@@ -70,7 +70,8 @@ const HpackString& name, const HpackString& value)); MOCK_METHOD0(OnHeaderListEnd, void()); - MOCK_METHOD1(OnHeaderErrorDetected, void(Http2StringPiece error_message)); + MOCK_METHOD1(OnHeaderErrorDetected, + void(quiche::QuicheStringPiece error_message)); }; class HpackDecoderTest : public ::testing::TestWithParam<bool>, @@ -119,7 +120,7 @@ // OnHeaderErrorDetected is called if an error is detected while decoding. // error_message may be used in a GOAWAY frame as the Opaque Data. - void OnHeaderErrorDetected(Http2StringPiece error_message) override { + void OnHeaderErrorDetected(quiche::QuicheStringPiece error_message) override { ASSERT_TRUE(saw_start_); error_messages_.push_back(std::string(error_message)); // No further callbacks should be made at this point, so replace 'this' as @@ -129,7 +130,7 @@ HpackDecoderPeer::GetDecoderState(&decoder_), &mock_listener_); } - AssertionResult DecodeBlock(Http2StringPiece block) { + AssertionResult DecodeBlock(quiche::QuicheStringPiece block) { HTTP2_VLOG(1) << "HpackDecoderTest::DecodeBlock"; VERIFY_FALSE(decoder_.error_detected());
diff --git a/http2/hpack/decoder/hpack_entry_collector.cc b/http2/hpack/decoder/hpack_entry_collector.cc index 7706bd6..80d4f92 100644 --- a/http2/hpack/decoder/hpack_entry_collector.cc +++ b/http2/hpack/decoder/hpack_entry_collector.cc
@@ -166,7 +166,7 @@ HpackEntryType expected_type, size_t expected_index, bool expected_value_huffman, - Http2StringPiece expected_value) const { + quiche::QuicheStringPiece expected_value) const { VERIFY_TRUE(started_); VERIFY_TRUE(ended_); VERIFY_EQ(expected_type, header_type_); @@ -179,9 +179,9 @@ AssertionResult HpackEntryCollector::ValidateLiteralNameValueHeader( HpackEntryType expected_type, bool expected_name_huffman, - Http2StringPiece expected_name, + quiche::QuicheStringPiece expected_name, bool expected_value_huffman, - Http2StringPiece expected_value) const { + quiche::QuicheStringPiece expected_value) const { VERIFY_TRUE(started_); VERIFY_TRUE(ended_); VERIFY_EQ(expected_type, header_type_);
diff --git a/http2/hpack/decoder/hpack_entry_collector.h b/http2/hpack/decoder/hpack_entry_collector.h index 6b27b7b..abf9d97 100644 --- a/http2/hpack/decoder/hpack_entry_collector.h +++ b/http2/hpack/decoder/hpack_entry_collector.h
@@ -20,7 +20,7 @@ #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_string_collector.h" #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.h" #include "net/third_party/quiche/src/http2/hpack/tools/hpack_block_builder.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { @@ -85,16 +85,16 @@ HpackEntryType expected_type, size_t expected_index, bool expected_value_huffman, - Http2StringPiece expected_value) const; + quiche::QuicheStringPiece expected_value) const; // Returns success if collected a Header with an literal name and literal // value. ::testing::AssertionResult ValidateLiteralNameValueHeader( HpackEntryType expected_type, bool expected_name_huffman, - Http2StringPiece expected_name, + quiche::QuicheStringPiece expected_name, bool expected_value_huffman, - Http2StringPiece expected_value) const; + quiche::QuicheStringPiece expected_value) const; // Returns success if collected a Dynamic Table Size Update, // with the specified size.
diff --git a/http2/hpack/decoder/hpack_string_collector.cc b/http2/hpack/decoder/hpack_string_collector.cc index e903755..0b18178 100644 --- a/http2/hpack/decoder/hpack_string_collector.cc +++ b/http2/hpack/decoder/hpack_string_collector.cc
@@ -66,7 +66,7 @@ } void HpackStringCollector::OnStringData(const char* data, size_t length) { - Http2StringPiece sp(data, length); + quiche::QuicheStringPiece sp(data, length); EXPECT_TRUE(IsInProgress()) << ToString(); EXPECT_LE(sp.size(), len) << ToString(); Http2StrAppend(&s, sp); @@ -80,7 +80,7 @@ } ::testing::AssertionResult HpackStringCollector::Collected( - Http2StringPiece str, + quiche::QuicheStringPiece str, bool is_huffman_encoded) const { VERIFY_TRUE(HasEnded()); VERIFY_EQ(str.size(), len);
diff --git a/http2/hpack/decoder/hpack_string_collector.h b/http2/hpack/decoder/hpack_string_collector.h index d56abee..8326a57 100644 --- a/http2/hpack/decoder/hpack_string_collector.h +++ b/http2/hpack/decoder/hpack_string_collector.h
@@ -14,7 +14,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_string_decoder_listener.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { @@ -40,7 +40,7 @@ void OnStringData(const char* data, size_t length) override; void OnStringEnd() override; - ::testing::AssertionResult Collected(Http2StringPiece str, + ::testing::AssertionResult Collected(quiche::QuicheStringPiece str, bool is_huffman_encoded) const; std::string ToString() const;
diff --git a/http2/hpack/decoder/hpack_string_decoder_test.cc b/http2/hpack/decoder/hpack_string_decoder_test.cc index ceeebca..6c81b57 100644 --- a/http2/hpack/decoder/hpack_string_decoder_test.cc +++ b/http2/hpack/decoder/hpack_string_decoder_test.cc
@@ -10,10 +10,10 @@ #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_string_collector.h" #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_string_decoder_listener.h" #include "net/third_party/quiche/src/http2/hpack/tools/hpack_block_builder.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/platform/api/http2_test_helpers.h" #include "net/third_party/quiche/src/http2/test_tools/http2_random.h" #include "net/third_party/quiche/src/http2/tools/random_decoder_test.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using ::testing::AssertionResult; @@ -43,13 +43,13 @@ return decoder_.Resume(b, &listener_); } - AssertionResult Collected(Http2StringPiece s, bool huffman_encoded) { + AssertionResult Collected(quiche::QuicheStringPiece s, bool huffman_encoded) { HTTP2_VLOG(1) << collector_; return collector_.Collected(s, huffman_encoded); } // expected_str is a std::string rather than a const std::string& or - // Http2StringPiece so that the lambda makes a copy of the string, and thus + // QuicheStringPiece so that the lambda makes a copy of the string, and thus // the string to be passed to Collected outlives the call to MakeValidator. Validator MakeValidator(const std::string& expected_str, bool expected_huffman) { @@ -111,7 +111,7 @@ { Validator validator = ValidateDoneAndOffset(11, MakeValidator("start end.", kUncompressed)); - Http2StringPiece data("\x0astart end."); + quiche::QuicheStringPiece data("\x0astart end."); DecodeBuffer b(data); EXPECT_TRUE( DecodeAndValidateSeveralWays(&b, kMayReturnZeroOnFirst, validator));
diff --git a/http2/hpack/decoder/hpack_whole_entry_buffer.cc b/http2/hpack/decoder/hpack_whole_entry_buffer.cc index dea6698..1f1f4f0 100644 --- a/http2/hpack/decoder/hpack_whole_entry_buffer.cc +++ b/http2/hpack/decoder/hpack_whole_entry_buffer.cc
@@ -67,7 +67,7 @@ void HpackWholeEntryBuffer::OnNameData(const char* data, size_t len) { HTTP2_DVLOG(2) << "HpackWholeEntryBuffer::OnNameData: len=" << len << " data:\n" - << Http2HexDump(Http2StringPiece(data, len)); + << Http2HexDump(quiche::QuicheStringPiece(data, len)); DCHECK_EQ(maybe_name_index_, 0u); if (!error_detected_ && !name_.OnData(data, len)) { ReportError("Error decoding HPACK entry name."); @@ -100,7 +100,7 @@ void HpackWholeEntryBuffer::OnValueData(const char* data, size_t len) { HTTP2_DVLOG(2) << "HpackWholeEntryBuffer::OnValueData: len=" << len << " data:\n" - << Http2HexDump(Http2StringPiece(data, len)); + << Http2HexDump(quiche::QuicheStringPiece(data, len)); if (!error_detected_ && !value_.OnData(data, len)) { ReportError("Error decoding HPACK entry value."); } @@ -131,7 +131,8 @@ listener_->OnDynamicTableSizeUpdate(size); } -void HpackWholeEntryBuffer::ReportError(Http2StringPiece error_message) { +void HpackWholeEntryBuffer::ReportError( + quiche::QuicheStringPiece error_message) { if (!error_detected_) { HTTP2_DVLOG(1) << "HpackWholeEntryBuffer::ReportError: " << error_message; error_detected_ = true;
diff --git a/http2/hpack/decoder/hpack_whole_entry_buffer.h b/http2/hpack/decoder/hpack_whole_entry_buffer.h index 61bf583..814c1b4 100644 --- a/http2/hpack/decoder/hpack_whole_entry_buffer.h +++ b/http2/hpack/decoder/hpack_whole_entry_buffer.h
@@ -17,7 +17,7 @@ #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_whole_entry_listener.h" #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.h" #include "net/third_party/quiche/src/http2/platform/api/http2_export.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { @@ -79,7 +79,7 @@ void OnDynamicTableSizeUpdate(size_t size) override; private: - void ReportError(Http2StringPiece error_message); + void ReportError(quiche::QuicheStringPiece error_message); HpackWholeEntryListener* listener_; HpackDecoderStringBuffer name_, value_;
diff --git a/http2/hpack/decoder/hpack_whole_entry_buffer_test.cc b/http2/hpack/decoder/hpack_whole_entry_buffer_test.cc index 0265e9c..4ac82ea 100644 --- a/http2/hpack/decoder/hpack_whole_entry_buffer_test.cc +++ b/http2/hpack/decoder/hpack_whole_entry_buffer_test.cc
@@ -37,7 +37,8 @@ HpackDecoderStringBuffer* name_buffer, HpackDecoderStringBuffer* value_buffer)); MOCK_METHOD1(OnDynamicTableSizeUpdate, void(size_t size)); - MOCK_METHOD1(OnHpackDecodeError, void(Http2StringPiece error_message)); + MOCK_METHOD1(OnHpackDecodeError, + void(quiche::QuicheStringPiece error_message)); }; class HpackWholeEntryBufferTest : public ::testing::Test {
diff --git a/http2/hpack/decoder/hpack_whole_entry_listener.cc b/http2/hpack/decoder/hpack_whole_entry_listener.cc index b92e64a..69cf122 100644 --- a/http2/hpack/decoder/hpack_whole_entry_listener.cc +++ b/http2/hpack/decoder/hpack_whole_entry_listener.cc
@@ -21,7 +21,7 @@ HpackDecoderStringBuffer* value_buffer) {} void HpackWholeEntryNoOpListener::OnDynamicTableSizeUpdate(size_t size) {} void HpackWholeEntryNoOpListener::OnHpackDecodeError( - Http2StringPiece error_message) {} + quiche::QuicheStringPiece error_message) {} // static HpackWholeEntryNoOpListener* HpackWholeEntryNoOpListener::NoOpListener() {
diff --git a/http2/hpack/decoder/hpack_whole_entry_listener.h b/http2/hpack/decoder/hpack_whole_entry_listener.h index 2e559ce..eabe34a 100644 --- a/http2/hpack/decoder/hpack_whole_entry_listener.h +++ b/http2/hpack/decoder/hpack_whole_entry_listener.h
@@ -14,7 +14,7 @@ #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_decoder_string_buffer.h" #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.h" #include "net/third_party/quiche/src/http2/platform/api/http2_export.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { @@ -51,7 +51,7 @@ // OnHpackDecodeError is called if an error is detected while decoding. // error_message may be used in a GOAWAY frame as the Opaque Data. - virtual void OnHpackDecodeError(Http2StringPiece error_message) = 0; + virtual void OnHpackDecodeError(quiche::QuicheStringPiece error_message) = 0; }; // A no-op implementation of HpackWholeEntryDecoderListener, useful for ignoring @@ -69,7 +69,7 @@ HpackDecoderStringBuffer* name_buffer, HpackDecoderStringBuffer* value_buffer) override; void OnDynamicTableSizeUpdate(size_t size) override; - void OnHpackDecodeError(Http2StringPiece error_message) override; + void OnHpackDecodeError(quiche::QuicheStringPiece error_message) override; // Returns a listener that ignores all the calls. static HpackWholeEntryNoOpListener* NoOpListener();
diff --git a/http2/hpack/hpack_string.cc b/http2/hpack/hpack_string.cc index 85ba812..77ae5a3 100644 --- a/http2/hpack/hpack_string.cc +++ b/http2/hpack/hpack_string.cc
@@ -12,32 +12,33 @@ namespace http2 { HpackString::HpackString(const char* data) : str_(data) {} -HpackString::HpackString(Http2StringPiece str) : str_(std::string(str)) {} +HpackString::HpackString(quiche::QuicheStringPiece str) + : str_(std::string(str)) {} HpackString::HpackString(std::string str) : str_(std::move(str)) {} HpackString::HpackString(const HpackString& other) = default; HpackString::~HpackString() = default; -Http2StringPiece HpackString::ToStringPiece() const { +quiche::QuicheStringPiece HpackString::ToStringPiece() const { return str_; } bool HpackString::operator==(const HpackString& other) const { return str_ == other.str_; } -bool HpackString::operator==(Http2StringPiece str) const { +bool HpackString::operator==(quiche::QuicheStringPiece str) const { return str == str_; } -bool operator==(Http2StringPiece a, const HpackString& b) { +bool operator==(quiche::QuicheStringPiece a, const HpackString& b) { return b == a; } -bool operator!=(Http2StringPiece a, const HpackString& b) { +bool operator!=(quiche::QuicheStringPiece a, const HpackString& b) { return !(b == a); } bool operator!=(const HpackString& a, const HpackString& b) { return !(a == b); } -bool operator!=(const HpackString& a, Http2StringPiece b) { +bool operator!=(const HpackString& a, quiche::QuicheStringPiece b) { return !(a == b); } std::ostream& operator<<(std::ostream& out, const HpackString& v) { @@ -50,7 +51,8 @@ HTTP2_DVLOG(3) << DebugString() << " ctor"; } -HpackStringPair::HpackStringPair(Http2StringPiece name, Http2StringPiece value) +HpackStringPair::HpackStringPair(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) : name(name), value(value) { HTTP2_DVLOG(3) << DebugString() << " ctor"; }
diff --git a/http2/hpack/hpack_string.h b/http2/hpack/hpack_string.h index e1535f7..9aac58e 100644 --- a/http2/hpack/hpack_string.h +++ b/http2/hpack/hpack_string.h
@@ -16,14 +16,14 @@ #include <string> #include "net/third_party/quiche/src/http2/platform/api/http2_export.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { class HTTP2_EXPORT_PRIVATE HpackString { public: explicit HpackString(const char* data); - explicit HpackString(Http2StringPiece str); + explicit HpackString(quiche::QuicheStringPiece str); explicit HpackString(std::string str); HpackString(const HpackString& other); @@ -34,27 +34,31 @@ size_t size() const { return str_.size(); } const std::string& ToString() const { return str_; } - Http2StringPiece ToStringPiece() const; + quiche::QuicheStringPiece ToStringPiece() const; bool operator==(const HpackString& other) const; - bool operator==(Http2StringPiece str) const; + bool operator==(quiche::QuicheStringPiece str) const; private: std::string str_; }; -HTTP2_EXPORT_PRIVATE bool operator==(Http2StringPiece a, const HpackString& b); -HTTP2_EXPORT_PRIVATE bool operator!=(Http2StringPiece a, const HpackString& b); +HTTP2_EXPORT_PRIVATE bool operator==(quiche::QuicheStringPiece a, + const HpackString& b); +HTTP2_EXPORT_PRIVATE bool operator!=(quiche::QuicheStringPiece a, + const HpackString& b); HTTP2_EXPORT_PRIVATE bool operator!=(const HpackString& a, const HpackString& b); -HTTP2_EXPORT_PRIVATE bool operator!=(const HpackString& a, Http2StringPiece b); +HTTP2_EXPORT_PRIVATE bool operator!=(const HpackString& a, + quiche::QuicheStringPiece b); HTTP2_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out, const HpackString& v); struct HTTP2_EXPORT_PRIVATE HpackStringPair { HpackStringPair(const HpackString& name, const HpackString& value); - HpackStringPair(Http2StringPiece name, Http2StringPiece value); + HpackStringPair(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value); ~HpackStringPair(); // Returns the size of a header entry with this name and value, per the RFC:
diff --git a/http2/hpack/hpack_string_test.cc b/http2/hpack/hpack_string_test.cc index 9230ecc..0673f5e 100644 --- a/http2/hpack/hpack_string_test.cc +++ b/http2/hpack/hpack_string_test.cc
@@ -28,7 +28,7 @@ AssertionResult VerifyNotEqual(HpackString* actual, const std::string& not_expected_str) { const char* not_expected_ptr = not_expected_str.c_str(); - Http2StringPiece not_expected_sp(not_expected_str); + quiche::QuicheStringPiece not_expected_sp(not_expected_str); VERIFY_NE(*actual, not_expected_ptr); VERIFY_NE(*actual, not_expected_sp); @@ -56,7 +56,7 @@ VERIFY_EQ(actual->size(), expected_str.size()); const char* expected_ptr = expected_str.c_str(); - const Http2StringPiece expected_sp(expected_str); + const quiche::QuicheStringPiece expected_sp(expected_str); VERIFY_EQ(*actual, expected_ptr); VERIFY_EQ(*actual, expected_sp); @@ -91,12 +91,12 @@ } TEST_F(HpackStringTest, StringPieceConstructor) { - Http2StringPiece sp0(kStr0); + quiche::QuicheStringPiece sp0(kStr0); HpackString hs0(sp0); EXPECT_TRUE(VerifyEqual(&hs0, kStr0)); EXPECT_TRUE(VerifyNotEqual(&hs0, kStr1)); - Http2StringPiece sp1(kStr1); + quiche::QuicheStringPiece sp1(kStr1); HpackString hs1(sp1); EXPECT_TRUE(VerifyEqual(&hs1, kStr1)); EXPECT_TRUE(VerifyNotEqual(&hs1, kStr0)); @@ -115,7 +115,7 @@ } TEST_F(HpackStringTest, CopyConstructor) { - Http2StringPiece sp0(kStr0); + quiche::QuicheStringPiece sp0(kStr0); HpackString hs0(sp0); HpackString hs1(hs0); EXPECT_EQ(hs0, hs1); @@ -128,7 +128,7 @@ } TEST_F(HpackStringTest, MoveConstructor) { - Http2StringPiece sp0(kStr0); + quiche::QuicheStringPiece sp0(kStr0); HpackString hs0(sp0); EXPECT_TRUE(VerifyEqual(&hs0, kStr0)); EXPECT_TRUE(VerifyNotEqual(&hs0, ""));
diff --git a/http2/hpack/huffman/hpack_huffman_decoder.cc b/http2/hpack/huffman/hpack_huffman_decoder.cc index 71ce855..18bff72 100644 --- a/http2/hpack/huffman/hpack_huffman_decoder.cc +++ b/http2/hpack/huffman/hpack_huffman_decoder.cc
@@ -356,7 +356,7 @@ count_ = 0; } -size_t HuffmanBitBuffer::AppendBytes(Http2StringPiece input) { +size_t HuffmanBitBuffer::AppendBytes(quiche::QuicheStringPiece input) { HuffmanAccumulatorBitCount free_cnt = free_count(); size_t bytes_available = input.size(); if (free_cnt < 8 || bytes_available == 0) { @@ -414,7 +414,8 @@ HpackHuffmanDecoder::~HpackHuffmanDecoder() = default; -bool HpackHuffmanDecoder::Decode(Http2StringPiece input, std::string* output) { +bool HpackHuffmanDecoder::Decode(quiche::QuicheStringPiece input, + std::string* output) { HTTP2_DVLOG(1) << "HpackHuffmanDecoder::Decode"; // Fill bit_buffer_ from input.
diff --git a/http2/hpack/huffman/hpack_huffman_decoder.h b/http2/hpack/huffman/hpack_huffman_decoder.h index 065fe85..73c0162 100644 --- a/http2/hpack/huffman/hpack_huffman_decoder.h +++ b/http2/hpack/huffman/hpack_huffman_decoder.h
@@ -19,7 +19,7 @@ #include <string> #include "net/third_party/quiche/src/http2/platform/api/http2_export.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { @@ -47,7 +47,7 @@ // Add as many whole bytes to the accumulator (accumulator_) as possible, // returning the number of bytes added. - size_t AppendBytes(Http2StringPiece input); + size_t AppendBytes(quiche::QuicheStringPiece input); // Get the bits of the accumulator. HuffmanAccumulator value() const { return accumulator_; } @@ -109,7 +109,7 @@ // will contain the leading bits of the code for that symbol, but not the // final bits of that code. // Note that output should be empty, but that it is not cleared by Decode(). - bool Decode(Http2StringPiece input, std::string* output); + bool Decode(quiche::QuicheStringPiece input, std::string* output); // Is what remains in the bit_buffer_ valid at the end of an encoded string? // Call after passing the the final portion of a Huffman string to Decode,
diff --git a/http2/hpack/huffman/hpack_huffman_decoder_test.cc b/http2/hpack/huffman/hpack_huffman_decoder_test.cc index f1bed3c..e5a6e28 100644 --- a/http2/hpack/huffman/hpack_huffman_decoder_test.cc +++ b/http2/hpack/huffman/hpack_huffman_decoder_test.cc
@@ -36,7 +36,7 @@ s.push_back('\x11'); s.push_back('\x22'); s.push_back('\x33'); - Http2StringPiece sp(s); + quiche::QuicheStringPiece sp(s); HuffmanBitBuffer bb; sp.remove_prefix(bb.AppendBytes(sp)); @@ -85,7 +85,7 @@ s.push_back('\x11'); s.push_back('\x22'); s.push_back('\x33'); - Http2StringPiece sp(s); + quiche::QuicheStringPiece sp(s); HuffmanBitBuffer bb; sp.remove_prefix(bb.AppendBytes(sp)); @@ -117,7 +117,7 @@ s.push_back('\xbb'); s.push_back('\xcc'); s.push_back('\xdd'); - Http2StringPiece sp(s); + quiche::QuicheStringPiece sp(s); HuffmanBitBuffer bb; sp.remove_prefix(bb.AppendBytes(sp)); @@ -161,10 +161,10 @@ DecodeStatus ResumeDecoding(DecodeBuffer* b) override { input_bytes_seen_ += b->Remaining(); - Http2StringPiece sp(b->cursor(), b->Remaining()); + quiche::QuicheStringPiece sp(b->cursor(), b->Remaining()); if (decoder_.Decode(sp, &output_buffer_)) { b->AdvanceCursor(b->Remaining()); - // Successfully decoded (or buffered) the bytes in Http2StringPiece. + // Successfully decoded (or buffered) the bytes in QuicheStringPiece. EXPECT_LE(input_bytes_seen_, input_bytes_expected_); // Have we reached the end of the encoded string? if (input_bytes_expected_ == input_bytes_seen_) {
diff --git a/http2/hpack/huffman/hpack_huffman_encoder.cc b/http2/hpack/huffman/hpack_huffman_encoder.cc index 8a5dee9..8b3f29f 100644 --- a/http2/hpack/huffman/hpack_huffman_encoder.cc +++ b/http2/hpack/huffman/hpack_huffman_encoder.cc
@@ -11,7 +11,7 @@ namespace http2 { -size_t ExactHuffmanSize(Http2StringPiece plain) { +size_t ExactHuffmanSize(quiche::QuicheStringPiece plain) { size_t bits = 0; for (const uint8_t c : plain) { bits += HuffmanSpecTables::kCodeLengths[c]; @@ -19,7 +19,7 @@ return (bits + 7) / 8; } -size_t BoundedHuffmanSize(Http2StringPiece plain) { +size_t BoundedHuffmanSize(quiche::QuicheStringPiece plain) { // TODO(jamessynge): Determine whether we should set the min size for Huffman // encoding much higher (i.e. if less than N, then the savings isn't worth // the cost of encoding and decoding). Of course, we need to decide on a @@ -61,7 +61,7 @@ return (bits + 7) / 8; } -void HuffmanEncode(Http2StringPiece plain, std::string* huffman) { +void HuffmanEncode(quiche::QuicheStringPiece plain, std::string* huffman) { DCHECK(huffman != nullptr); huffman->clear(); // Note that this doesn't release memory. uint64_t bit_buffer = 0; // High-bit is next bit to output. Not clear if that
diff --git a/http2/hpack/huffman/hpack_huffman_encoder.h b/http2/hpack/huffman/hpack_huffman_encoder.h index 247aaff..f7a8e94 100644 --- a/http2/hpack/huffman/hpack_huffman_encoder.h +++ b/http2/hpack/huffman/hpack_huffman_encoder.h
@@ -12,13 +12,13 @@ #include <string> #include "net/third_party/quiche/src/http2/platform/api/http2_export.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { // Returns the size of the Huffman encoding of |plain|, which may be greater // than plain.size(). Mostly present for testing. -HTTP2_EXPORT_PRIVATE size_t ExactHuffmanSize(Http2StringPiece plain); +HTTP2_EXPORT_PRIVATE size_t ExactHuffmanSize(quiche::QuicheStringPiece plain); // Returns the size of the Huffman encoding of |plain|, unless it is greater // than or equal to plain.size(), in which case a value greater than or equal to @@ -26,13 +26,13 @@ // it doesn't read as much of the input string in the event that the string is // not compressible by HuffmanEncode (i.e. when the encoding is longer than the // original string, it stops reading the input string as soon as it knows that). -HTTP2_EXPORT_PRIVATE size_t BoundedHuffmanSize(Http2StringPiece plain); +HTTP2_EXPORT_PRIVATE size_t BoundedHuffmanSize(quiche::QuicheStringPiece plain); // Encode the plain text string |plain| with the Huffman encoding defined in // the HPACK RFC, 7541. |*huffman| does not have to be empty, it is cleared at // the beginning of this function. This allows reusing the same string object // across multiple invocations. -HTTP2_EXPORT_PRIVATE void HuffmanEncode(Http2StringPiece plain, +HTTP2_EXPORT_PRIVATE void HuffmanEncode(quiche::QuicheStringPiece plain, std::string* huffman); } // namespace http2
diff --git a/http2/hpack/huffman/hpack_huffman_transcoder_test.cc b/http2/hpack/huffman/hpack_huffman_transcoder_test.cc index 9781094..b7407a3 100644 --- a/http2/hpack/huffman/hpack_huffman_transcoder_test.cc +++ b/http2/hpack/huffman/hpack_huffman_transcoder_test.cc
@@ -11,9 +11,9 @@ #include "net/third_party/quiche/src/http2/decoder/decode_status.h" #include "net/third_party/quiche/src/http2/hpack/huffman/hpack_huffman_decoder.h" #include "net/third_party/quiche/src/http2/hpack/huffman/hpack_huffman_encoder.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" #include "net/third_party/quiche/src/http2/tools/random_decoder_test.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using ::testing::AssertionResult; using ::testing::AssertionSuccess; @@ -52,10 +52,10 @@ DecodeStatus ResumeDecoding(DecodeBuffer* b) override { input_bytes_seen_ += b->Remaining(); - Http2StringPiece sp(b->cursor(), b->Remaining()); + quiche::QuicheStringPiece sp(b->cursor(), b->Remaining()); if (decoder_.Decode(sp, &output_buffer_)) { b->AdvanceCursor(b->Remaining()); - // Successfully decoded (or buffered) the bytes in Http2StringPiece. + // Successfully decoded (or buffered) the bytes in QuicheStringPiece. EXPECT_LE(input_bytes_seen_, input_bytes_expected_); // Have we reached the end of the encoded string? if (input_bytes_expected_ == input_bytes_seen_) { @@ -71,8 +71,8 @@ } AssertionResult TranscodeAndValidateSeveralWays( - Http2StringPiece plain, - Http2StringPiece expected_huffman) { + quiche::QuicheStringPiece plain, + quiche::QuicheStringPiece expected_huffman) { std::string encoded; HuffmanEncode(plain, &encoded); if (expected_huffman.size() > 0 || plain.empty()) { @@ -90,7 +90,8 @@ ValidateDoneAndEmpty(validator)); } - AssertionResult TranscodeAndValidateSeveralWays(Http2StringPiece plain) { + AssertionResult TranscodeAndValidateSeveralWays( + quiche::QuicheStringPiece plain) { return TranscodeAndValidateSeveralWays(plain, ""); }
diff --git a/http2/hpack/tools/hpack_block_builder.cc b/http2/hpack/tools/hpack_block_builder.cc index 5b2ab75..3175c1d 100644 --- a/http2/hpack/tools/hpack_block_builder.cc +++ b/http2/hpack/tools/hpack_block_builder.cc
@@ -55,7 +55,7 @@ } void HpackBlockBuilder::AppendString(bool is_huffman_encoded, - Http2StringPiece str) { + quiche::QuicheStringPiece str) { uint8_t high_bits = is_huffman_encoded ? 0x80 : 0; uint8_t prefix_length = 7; AppendHighBitsAndVarint(high_bits, prefix_length, str.size());
diff --git a/http2/hpack/tools/hpack_block_builder.h b/http2/hpack/tools/hpack_block_builder.h index 59c3805..b96d262 100644 --- a/http2/hpack/tools/hpack_block_builder.h +++ b/http2/hpack/tools/hpack_block_builder.h
@@ -22,14 +22,14 @@ #include "testing/gtest/include/gtest/gtest.h" #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { class HpackBlockBuilder { public: - explicit HpackBlockBuilder(Http2StringPiece initial_contents) + explicit HpackBlockBuilder(quiche::QuicheStringPiece initial_contents) : buffer_(initial_contents.data(), initial_contents.size()) {} HpackBlockBuilder() {} ~HpackBlockBuilder() {} @@ -51,7 +51,7 @@ void AppendNameIndexAndLiteralValue(HpackEntryType entry_type, uint64_t name_index, bool value_is_huffman_encoded, - Http2StringPiece value) { + quiche::QuicheStringPiece value) { // name_index==0 would indicate that the entry includes a literal name. // Call AppendLiteralNameAndValue in that case. EXPECT_NE(0u, name_index); @@ -61,9 +61,9 @@ void AppendLiteralNameAndValue(HpackEntryType entry_type, bool name_is_huffman_encoded, - Http2StringPiece name, + quiche::QuicheStringPiece name, bool value_is_huffman_encoded, - Http2StringPiece value) { + quiche::QuicheStringPiece value) { AppendEntryTypeAndVarint(entry_type, 0); AppendString(name_is_huffman_encoded, name); AppendString(value_is_huffman_encoded, value); @@ -84,7 +84,7 @@ // Append a header string (i.e. a header name or value) in HPACK format. // Does NOT perform Huffman encoding. - void AppendString(bool is_huffman_encoded, Http2StringPiece str); + void AppendString(bool is_huffman_encoded, quiche::QuicheStringPiece str); private: std::string buffer_;
diff --git a/http2/hpack/tools/hpack_block_builder_test.cc b/http2/hpack/tools/hpack_block_builder_test.cc index bba363f..21f161e 100644 --- a/http2/hpack/tools/hpack_block_builder_test.cc +++ b/http2/hpack/tools/hpack_block_builder_test.cc
@@ -120,7 +120,8 @@ '\xab', '\x90', '\xf4', '\xff'}; b.AppendNameIndexAndLiteralValue( HpackEntryType::kIndexedLiteralHeader, 1, kCompressed, - Http2StringPiece(kHuffmanWwwExampleCom, sizeof kHuffmanWwwExampleCom)); + quiche::QuicheStringPiece(kHuffmanWwwExampleCom, + sizeof kHuffmanWwwExampleCom)); EXPECT_EQ(17u, b.size()); // Hex dump of encoded data (copied from RFC): @@ -140,7 +141,7 @@ EXPECT_EQ(1u, b.size()); const char kData[] = {'\x20'}; - Http2StringPiece expected(kData, sizeof kData); + quiche::QuicheStringPiece expected(kData, sizeof kData); EXPECT_EQ(expected, b.buffer()); } { @@ -149,7 +150,7 @@ EXPECT_EQ(3u, b.size()); const char kData[] = {'\x3f', '\xe1', '\x1f'}; - Http2StringPiece expected(kData, sizeof kData); + quiche::QuicheStringPiece expected(kData, sizeof kData); EXPECT_EQ(expected, b.buffer()); } { @@ -159,7 +160,7 @@ const char kData[] = {'\x3f', '\xe1', '\x9f', '\x94', '\xa5', '\x8d', '\x1d'}; - Http2StringPiece expected(kData, sizeof kData); + quiche::QuicheStringPiece expected(kData, sizeof kData); EXPECT_EQ(expected, b.buffer()); } }
diff --git a/http2/hpack/tools/hpack_example.cc b/http2/hpack/tools/hpack_example.cc index 52d84f9..5e0e40c 100644 --- a/http2/hpack/tools/hpack_example.cc +++ b/http2/hpack/tools/hpack_example.cc
@@ -14,7 +14,8 @@ namespace test { namespace { -void HpackExampleToStringOrDie(Http2StringPiece example, std::string* output) { +void HpackExampleToStringOrDie(quiche::QuicheStringPiece example, + std::string* output) { while (!example.empty()) { const char c0 = example[0]; if (isxdigit(c0)) { @@ -32,7 +33,7 @@ if (!example.empty() && example[0] == '|') { // Start of a comment. Skip to end of line or of input. auto pos = example.find('\n'); - if (pos == Http2StringPiece::npos) { + if (pos == quiche::QuicheStringPiece::npos) { // End of input. break; } @@ -48,7 +49,7 @@ } // namespace -std::string HpackExampleToStringOrDie(Http2StringPiece example) { +std::string HpackExampleToStringOrDie(quiche::QuicheStringPiece example) { std::string output; HpackExampleToStringOrDie(example, &output); return output;
diff --git a/http2/hpack/tools/hpack_example.h b/http2/hpack/tools/hpack_example.h index 0371e17..e86c116 100644 --- a/http2/hpack/tools/hpack_example.h +++ b/http2/hpack/tools/hpack_example.h
@@ -7,7 +7,7 @@ #include <string> -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" // Parses HPACK examples in the format seen in the HPACK specification, // RFC 7541. For example: @@ -24,7 +24,7 @@ namespace http2 { namespace test { -std::string HpackExampleToStringOrDie(Http2StringPiece example); +std::string HpackExampleToStringOrDie(quiche::QuicheStringPiece example); } // namespace test } // namespace http2
diff --git a/http2/hpack/varint/hpack_varint_decoder_test.cc b/http2/hpack/varint/hpack_varint_decoder_test.cc index 07cb51b..336349c 100644 --- a/http2/hpack/varint/hpack_varint_decoder_test.cc +++ b/http2/hpack/varint/hpack_varint_decoder_test.cc
@@ -11,9 +11,9 @@ #include "testing/gtest/include/gtest/gtest.h" #include "net/third_party/quiche/src/http2/platform/api/http2_arraysize.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" #include "net/third_party/quiche/src/http2/tools/random_decoder_test.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using ::testing::AssertionFailure; using ::testing::AssertionSuccess; @@ -31,7 +31,7 @@ suffix_(Http2HexDecode(::testing::get<1>(GetParam()))), prefix_length_(0) {} - void DecodeExpectSuccess(Http2StringPiece data, + void DecodeExpectSuccess(quiche::QuicheStringPiece data, uint32_t prefix_length, uint64_t expected_value) { Validator validator = [expected_value, this]( @@ -52,7 +52,8 @@ EXPECT_EQ(expected_value, decoder_.value()); } - void DecodeExpectError(Http2StringPiece data, uint32_t prefix_length) { + void DecodeExpectError(quiche::QuicheStringPiece data, + uint32_t prefix_length) { Validator validator = [](const DecodeBuffer& db, DecodeStatus status) -> AssertionResult { VERIFY_EQ(DecodeStatus::kDecodeError, status); @@ -63,7 +64,7 @@ } private: - AssertionResult Decode(Http2StringPiece data, + AssertionResult Decode(quiche::QuicheStringPiece data, uint32_t prefix_length, const Validator validator) { prefix_length_ = prefix_length;
diff --git a/http2/hpack/varint/hpack_varint_round_trip_test.cc b/http2/hpack/varint/hpack_varint_round_trip_test.cc index a5318fb..58fc2c3 100644 --- a/http2/hpack/varint/hpack_varint_round_trip_test.cc +++ b/http2/hpack/varint/hpack_varint_round_trip_test.cc
@@ -16,9 +16,9 @@ #include "testing/gtest/include/gtest/gtest.h" #include "net/third_party/quiche/src/http2/hpack/tools/hpack_block_builder.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" #include "net/third_party/quiche/src/http2/tools/random_decoder_test.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using ::testing::AssertionFailure; using ::testing::AssertionSuccess; @@ -291,7 +291,7 @@ } TEST_F(HpackVarintRoundTripTest, FromSpec1337) { - DecodeBuffer b(Http2StringPiece("\x1f\x9a\x0a")); + DecodeBuffer b(quiche::QuicheStringPiece("\x1f\x9a\x0a")); uint32_t prefix_length = 5; uint8_t p = b.DecodeUInt8(); EXPECT_EQ(1u, b.Offset());
diff --git a/http2/http2_constants.cc b/http2/http2_constants.cc index 38f8ab5..37df919 100644 --- a/http2/http2_constants.cc +++ b/http2/http2_constants.cc
@@ -5,8 +5,8 @@ #include "net/third_party/quiche/src/http2/http2_constants.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/platform/api/http2_string_utils.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { @@ -46,7 +46,8 @@ std::string s; // Closure to append flag name |v| to the std::string |s|, // and to clear |bit| from |flags|. - auto append_and_clear = [&s, &flags](Http2StringPiece v, uint8_t bit) { + auto append_and_clear = [&s, &flags](quiche::QuicheStringPiece v, + uint8_t bit) { if (!s.empty()) { s.push_back('|'); }
diff --git a/http2/platform/api/http2_string_piece.h b/http2/platform/api/http2_string_piece.h deleted file mode 100644 index 92fb3ef..0000000 --- a/http2/platform/api/http2_string_piece.h +++ /dev/null
@@ -1,16 +0,0 @@ -// Copyright (c) 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef QUICHE_HTTP2_PLATFORM_API_HTTP2_STRING_PIECE_H_ -#define QUICHE_HTTP2_PLATFORM_API_HTTP2_STRING_PIECE_H_ - -#include "net/http2/platform/impl/http2_string_piece_impl.h" - -namespace http2 { - -using Http2StringPiece = Http2StringPieceImpl; - -} // namespace http2 - -#endif // QUICHE_HTTP2_PLATFORM_API_HTTP2_STRING_PIECE_H_
diff --git a/http2/platform/api/http2_string_utils.h b/http2/platform/api/http2_string_utils.h index 1db9d66..4a4e0b8 100644 --- a/http2/platform/api/http2_string_utils.h +++ b/http2/platform/api/http2_string_utils.h
@@ -9,8 +9,8 @@ #include <type_traits> #include <utility> -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/http2/platform/impl/http2_string_utils_impl.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { @@ -33,15 +33,15 @@ return Http2HexEncodeImpl(bytes, size); } -inline std::string Http2HexDecode(Http2StringPiece data) { +inline std::string Http2HexDecode(quiche::QuicheStringPiece data) { return Http2HexDecodeImpl(data); } -inline std::string Http2HexDump(Http2StringPiece data) { +inline std::string Http2HexDump(quiche::QuicheStringPiece data) { return Http2HexDumpImpl(data); } -inline std::string Http2HexEscape(Http2StringPiece data) { +inline std::string Http2HexEscape(quiche::QuicheStringPiece data) { return Http2HexEscapeImpl(data); }
diff --git a/http2/platform/api/http2_string_utils_test.cc b/http2/platform/api/http2_string_utils_test.cc index 6ffc4b4..6f04c9c 100644 --- a/http2/platform/api/http2_string_utils_test.cc +++ b/http2/platform/api/http2_string_utils_test.cc
@@ -7,7 +7,7 @@ #include <cstdint> #include "testing/gtest/include/gtest/gtest.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { @@ -20,14 +20,14 @@ // Single string-like argument. const char kFoo[] = "foo"; const std::string string_foo(kFoo); - const Http2StringPiece stringpiece_foo(string_foo); + const quiche::QuicheStringPiece stringpiece_foo(string_foo); EXPECT_EQ("foo", Http2StrCat(kFoo)); EXPECT_EQ("foo", Http2StrCat(string_foo)); EXPECT_EQ("foo", Http2StrCat(stringpiece_foo)); // Two string-like arguments. const char kBar[] = "bar"; - const Http2StringPiece stringpiece_bar(kBar); + const quiche::QuicheStringPiece stringpiece_bar(kBar); const std::string string_bar(kBar); EXPECT_EQ("foobar", Http2StrCat(kFoo, kBar)); EXPECT_EQ("foobar", Http2StrCat(kFoo, string_bar)); @@ -79,7 +79,7 @@ // Single string-like argument. const char kFoo[] = "foo"; const std::string string_foo(kFoo); - const Http2StringPiece stringpiece_foo(string_foo); + const quiche::QuicheStringPiece stringpiece_foo(string_foo); Http2StrAppend(&output, kFoo); EXPECT_EQ("foo", output); Http2StrAppend(&output, string_foo); @@ -95,7 +95,7 @@ // Two string-like arguments. const char kBar[] = "bar"; - const Http2StringPiece stringpiece_bar(kBar); + const quiche::QuicheStringPiece stringpiece_bar(kBar); const std::string string_bar(kBar); Http2StrAppend(&output, kFoo, kBar); EXPECT_EQ("foobar", output);
diff --git a/http2/test_tools/frame_parts.cc b/http2/test_tools/frame_parts.cc index d9dffa1..32d3a97 100644 --- a/http2/test_tools/frame_parts.cc +++ b/http2/test_tools/frame_parts.cc
@@ -51,14 +51,15 @@ HTTP2_VLOG(1) << "FrameParts, header: " << frame_header_; } -FrameParts::FrameParts(const Http2FrameHeader& header, Http2StringPiece payload) +FrameParts::FrameParts(const Http2FrameHeader& header, + quiche::QuicheStringPiece payload) : FrameParts(header) { HTTP2_VLOG(1) << "FrameParts with payload.size() = " << payload.size(); this->payload_.append(payload.data(), payload.size()); opt_payload_length_ = payload.size(); } FrameParts::FrameParts(const Http2FrameHeader& header, - Http2StringPiece payload, + quiche::QuicheStringPiece payload, size_t total_pad_length) : FrameParts(header, payload) { HTTP2_VLOG(1) << "FrameParts with total_pad_length=" << total_pad_length; @@ -117,8 +118,8 @@ } } -void FrameParts::SetAltSvcExpected(Http2StringPiece origin, - Http2StringPiece value) { +void FrameParts::SetAltSvcExpected(quiche::QuicheStringPiece origin, + quiche::QuicheStringPiece value) { altsvc_origin_.append(origin.data(), origin.size()); altsvc_value_.append(value.data(), value.size()); opt_altsvc_origin_length_ = origin.size(); @@ -140,7 +141,7 @@ HTTP2_VLOG(1) << "OnDataPayload: len=" << len << "; frame_header_: " << frame_header_; ASSERT_TRUE(InFrameOfType(Http2FrameType::DATA)) << *this; - ASSERT_TRUE(AppendString(Http2StringPiece(data, len), &payload_, + ASSERT_TRUE(AppendString(quiche::QuicheStringPiece(data, len), &payload_, &opt_payload_length_)); } @@ -172,7 +173,7 @@ ASSERT_TRUE(got_start_callback_); ASSERT_FALSE(got_end_callback_); ASSERT_TRUE(FrameCanHaveHpackPayload(frame_header_)) << *this; - ASSERT_TRUE(AppendString(Http2StringPiece(data, len), &payload_, + ASSERT_TRUE(AppendString(quiche::QuicheStringPiece(data, len), &payload_, &opt_payload_length_)); } @@ -216,8 +217,8 @@ HTTP2_VLOG(1) << "OnPadding: skipped_length=" << skipped_length; ASSERT_TRUE(InPaddedFrame()) << *this; ASSERT_TRUE(opt_pad_length_); - ASSERT_TRUE(AppendString(Http2StringPiece(pad, skipped_length), &padding_, - &opt_pad_length_)); + ASSERT_TRUE(AppendString(quiche::QuicheStringPiece(pad, skipped_length), + &padding_, &opt_pad_length_)); } void FrameParts::OnRstStream(const Http2FrameHeader& header, @@ -313,7 +314,7 @@ void FrameParts::OnGoAwayOpaqueData(const char* data, size_t len) { HTTP2_VLOG(1) << "OnGoAwayOpaqueData: len=" << len; ASSERT_TRUE(InFrameOfType(Http2FrameType::GOAWAY)) << *this; - ASSERT_TRUE(AppendString(Http2StringPiece(data, len), &payload_, + ASSERT_TRUE(AppendString(quiche::QuicheStringPiece(data, len), &payload_, &opt_payload_length_)); } @@ -348,14 +349,14 @@ void FrameParts::OnAltSvcOriginData(const char* data, size_t len) { HTTP2_VLOG(1) << "OnAltSvcOriginData: len=" << len; ASSERT_TRUE(InFrameOfType(Http2FrameType::ALTSVC)) << *this; - ASSERT_TRUE(AppendString(Http2StringPiece(data, len), &altsvc_origin_, - &opt_altsvc_origin_length_)); + ASSERT_TRUE(AppendString(quiche::QuicheStringPiece(data, len), + &altsvc_origin_, &opt_altsvc_origin_length_)); } void FrameParts::OnAltSvcValueData(const char* data, size_t len) { HTTP2_VLOG(1) << "OnAltSvcValueData: len=" << len; ASSERT_TRUE(InFrameOfType(Http2FrameType::ALTSVC)) << *this; - ASSERT_TRUE(AppendString(Http2StringPiece(data, len), &altsvc_value_, + ASSERT_TRUE(AppendString(quiche::QuicheStringPiece(data, len), &altsvc_value_, &opt_altsvc_value_length_)); } @@ -378,7 +379,7 @@ ASSERT_FALSE(IsSupportedHttp2FrameType(frame_header_.type)) << *this; ASSERT_TRUE(got_start_callback_); ASSERT_FALSE(got_end_callback_); - ASSERT_TRUE(AppendString(Http2StringPiece(data, len), &payload_, + ASSERT_TRUE(AppendString(quiche::QuicheStringPiece(data, len), &payload_, &opt_payload_length_)); } @@ -506,7 +507,7 @@ return AssertionSuccess(); } -AssertionResult FrameParts::AppendString(Http2StringPiece source, +AssertionResult FrameParts::AppendString(quiche::QuicheStringPiece source, std::string* target, Http2Optional<size_t>* opt_length) { target->append(source.data(), source.size());
diff --git a/http2/test_tools/frame_parts.h b/http2/test_tools/frame_parts.h index 598a687..2d54143 100644 --- a/http2/test_tools/frame_parts.h +++ b/http2/test_tools/frame_parts.h
@@ -22,7 +22,7 @@ #include "net/third_party/quiche/src/http2/http2_structures.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" #include "net/third_party/quiche/src/http2/platform/api/http2_optional.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { @@ -34,12 +34,12 @@ explicit FrameParts(const Http2FrameHeader& header); // For use in tests where the expected frame has a variable size payload. - FrameParts(const Http2FrameHeader& header, Http2StringPiece payload); + FrameParts(const Http2FrameHeader& header, quiche::QuicheStringPiece payload); // For use in tests where the expected frame has a variable size payload // and may be padded. FrameParts(const Http2FrameHeader& header, - Http2StringPiece payload, + quiche::QuicheStringPiece payload, size_t total_pad_length); // Copy constructor. @@ -58,7 +58,8 @@ void SetTotalPadLength(size_t total_pad_length); // Set the origin and value expected in an ALTSVC frame. - void SetAltSvcExpected(Http2StringPiece origin, Http2StringPiece value); + void SetAltSvcExpected(quiche::QuicheStringPiece origin, + quiche::QuicheStringPiece value); // Http2FrameDecoderListener methods: bool OnFrameHeader(const Http2FrameHeader& header) override; @@ -207,7 +208,7 @@ // Append source to target. If opt_length is not nullptr, then verifies that // the optional has a value (i.e. that the necessary On*Start method has been // called), and that target is not longer than opt_length->value(). - ::testing::AssertionResult AppendString(Http2StringPiece source, + ::testing::AssertionResult AppendString(quiche::QuicheStringPiece source, std::string* target, Http2Optional<size_t>* opt_length);
diff --git a/http2/test_tools/http2_random.cc b/http2/test_tools/http2_random.cc index 6b61a58..df20364 100644 --- a/http2/test_tools/http2_random.cc +++ b/http2/test_tools/http2_random.cc
@@ -16,7 +16,7 @@ HTTP2_LOG(INFO) << "Initialized test RNG with the following key: " << Key(); } -Http2Random::Http2Random(Http2StringPiece key) { +Http2Random::Http2Random(quiche::QuicheStringPiece key) { std::string decoded_key = Http2HexDecode(key); CHECK_EQ(sizeof(key_), decoded_key.size()); memcpy(key_, decoded_key.data(), sizeof(key_)); @@ -58,8 +58,9 @@ return value.f - 1.0; } -std::string Http2Random::RandStringWithAlphabet(int length, - Http2StringPiece alphabet) { +std::string Http2Random::RandStringWithAlphabet( + int length, + quiche::QuicheStringPiece alphabet) { std::string result; result.resize(length); for (int i = 0; i < length; i++) {
diff --git a/http2/test_tools/http2_random.h b/http2/test_tools/http2_random.h index 774212c..9f046a1 100644 --- a/http2/test_tools/http2_random.h +++ b/http2/test_tools/http2_random.h
@@ -11,7 +11,7 @@ #include <random> #include <string> -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { @@ -28,7 +28,7 @@ // Reproducible random number generation: by using the same key, the same // sequence of results is obtained. - explicit Http2Random(Http2StringPiece key); + explicit Http2Random(quiche::QuicheStringPiece key); std::string Key() const; void FillRandom(void* buffer, size_t buffer_size); @@ -67,7 +67,8 @@ // Return a random string consisting of the characters from the specified // alphabet. - std::string RandStringWithAlphabet(int length, Http2StringPiece alphabet); + std::string RandStringWithAlphabet(int length, + quiche::QuicheStringPiece alphabet); // STL UniformRandomNumberGenerator implementation. using result_type = uint64_t;
diff --git a/http2/tools/http2_frame_builder.cc b/http2/tools/http2_frame_builder.cc index 1dfcdeb..1f1af16 100644 --- a/http2/tools/http2_frame_builder.cc +++ b/http2/tools/http2_frame_builder.cc
@@ -30,12 +30,12 @@ Append(v); } -void Http2FrameBuilder::Append(Http2StringPiece s) { +void Http2FrameBuilder::Append(quiche::QuicheStringPiece s) { Http2StrAppend(&buffer_, s); } void Http2FrameBuilder::AppendBytes(const void* data, uint32_t num_bytes) { - Append(Http2StringPiece(static_cast<const char*>(data), num_bytes)); + Append(quiche::QuicheStringPiece(static_cast<const char*>(data), num_bytes)); } void Http2FrameBuilder::AppendZeroes(size_t num_zero_bytes) { @@ -143,7 +143,7 @@ // Methods for changing existing buffer contents. -void Http2FrameBuilder::WriteAt(Http2StringPiece s, size_t offset) { +void Http2FrameBuilder::WriteAt(quiche::QuicheStringPiece s, size_t offset) { ASSERT_LE(offset, buffer_.size()); size_t len = offset + s.size(); if (len > buffer_.size()) { @@ -157,7 +157,8 @@ void Http2FrameBuilder::WriteBytesAt(const void* data, uint32_t num_bytes, size_t offset) { - WriteAt(Http2StringPiece(static_cast<const char*>(data), num_bytes), offset); + WriteAt(quiche::QuicheStringPiece(static_cast<const char*>(data), num_bytes), + offset); } void Http2FrameBuilder::WriteUInt24At(uint32_t value, size_t offset) {
diff --git a/http2/tools/http2_frame_builder.h b/http2/tools/http2_frame_builder.h index 70d5f44..724c2b2 100644 --- a/http2/tools/http2_frame_builder.h +++ b/http2/tools/http2_frame_builder.h
@@ -20,7 +20,7 @@ #include "net/third_party/quiche/src/http2/http2_constants.h" #include "net/third_party/quiche/src/http2/http2_structures.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { @@ -39,7 +39,7 @@ // Methods for appending to the end of the buffer. // Append a sequence of bytes from various sources. - void Append(Http2StringPiece s); + void Append(quiche::QuicheStringPiece s); void AppendBytes(const void* data, uint32_t num_bytes); // Append an array of type T[N] to the string. Intended for tests with arrays @@ -80,7 +80,7 @@ // Methods for changing existing buffer contents (mostly focused on updating // the payload length). - void WriteAt(Http2StringPiece s, size_t offset); + void WriteAt(quiche::QuicheStringPiece s, size_t offset); void WriteBytesAt(const void* data, uint32_t num_bytes, size_t offset); void WriteUInt24At(uint32_t value, size_t offset);
diff --git a/http2/tools/random_decoder_test.h b/http2/tools/random_decoder_test.h index ef31d01..40b1e44 100644 --- a/http2/tools/random_decoder_test.h +++ b/http2/tools/random_decoder_test.h
@@ -21,9 +21,9 @@ #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/http2/platform/api/http2_logging.h" -#include "net/third_party/quiche/src/http2/platform/api/http2_string_piece.h" #include "net/third_party/quiche/src/http2/platform/api/http2_test_helpers.h" #include "net/third_party/quiche/src/http2/test_tools/http2_random.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace http2 { namespace test { @@ -31,8 +31,9 @@ // Some helpers. template <typename T, size_t N> -Http2StringPiece ToStringPiece(T (&data)[N]) { - return Http2StringPiece(reinterpret_cast<const char*>(data), N * sizeof(T)); +quiche::QuicheStringPiece ToStringPiece(T (&data)[N]) { + return quiche::QuicheStringPiece(reinterpret_cast<const char*>(data), + N * sizeof(T)); } // Overwrite the enum with some random value, probably not a valid value for
diff --git a/http2/tools/random_util.cc b/http2/tools/random_util.cc index a7d95c4..a0af07a 100644 --- a/http2/tools/random_util.cc +++ b/http2/tools/random_util.cc
@@ -12,7 +12,7 @@ // Here "word" means something that starts with a lower-case letter, and has // zero or more additional characters that are numbers or lower-case letters. std::string GenerateHttp2HeaderName(size_t len, Http2Random* rng) { - Http2StringPiece alpha_lc = "abcdefghijklmnopqrstuvwxyz"; + quiche::QuicheStringPiece alpha_lc = "abcdefghijklmnopqrstuvwxyz"; // If the name is short, just make it one word. if (len < 8) { return rng->RandStringWithAlphabet(len, alpha_lc); @@ -20,7 +20,8 @@ // If the name is longer, ensure it starts with a word, and after that may // have any character in alphanumdash_lc. 4 is arbitrary, could be as low // as 1. - Http2StringPiece alphanumdash_lc = "abcdefghijklmnopqrstuvwxyz0123456789-"; + quiche::QuicheStringPiece alphanumdash_lc = + "abcdefghijklmnopqrstuvwxyz0123456789-"; return rng->RandStringWithAlphabet(4, alpha_lc) + rng->RandStringWithAlphabet(len - 4, alphanumdash_lc); }