Replace quiche::QuicheStringPiece with absl::string_view. PiperOrigin-RevId: 336851769 Change-Id: Ib25a7613bdc156a6128fa3c52c88116bb92395cd
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 56b3527..12dc577 100644 --- a/http2/decoder/payload_decoders/payload_decoder_base_test_util.cc +++ b/http2/decoder/payload_decoders/payload_decoder_base_test_util.cc
@@ -76,7 +76,7 @@ ::testing::AssertionResult PayloadDecoderBaseTest::DecodePayloadAndValidateSeveralWays( - quiche::QuicheStringPiece payload, + absl::string_view payload, Validator validator) { VERIFY_TRUE(frame_header_is_set_); // Cap the payload to be decoded at the declared payload length. This is @@ -86,8 +86,7 @@ // 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 = - quiche::QuicheStringPiece(payload.data(), frame_header_.payload_length); + payload = absl::string_view(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 e46ab58..c907714 100644 --- a/http2/decoder/payload_decoders/payload_decoder_base_test_util.h +++ b/http2/decoder/payload_decoders/payload_decoder_base_test_util.h
@@ -11,6 +11,7 @@ #include <string> +#include "absl/strings/string_view.h" #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/decoder/frame_decoder_state.h" @@ -22,7 +23,6 @@ #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 { @@ -80,7 +80,7 @@ // Given the specified payload (without the common frame header), decode // it with several partitionings of the payload. ::testing::AssertionResult DecodePayloadAndValidateSeveralWays( - quiche::QuicheStringPiece payload, + absl::string_view payload, Validator validator); // TODO(jamessynge): Add helper method for verifying these are both non-zero, @@ -189,7 +189,7 @@ // will be decoded several times with different partitionings of the payload, // and after each the validator will be called. AssertionResult DecodePayloadAndValidateSeveralWays( - quiche::QuicheStringPiece payload, + absl::string_view payload, const FrameParts& expected) { auto validator = [&expected, this]() -> AssertionResult { VERIFY_FALSE(listener_.IsInProgress()); @@ -208,7 +208,7 @@ // std::nullptr_t (not extra validation). template <typename WrappedValidator> ::testing::AssertionResult VerifyDetectsFrameSizeError( - quiche::QuicheStringPiece payload, + absl::string_view payload, const Http2FrameHeader& header, WrappedValidator wrapped_validator) { set_frame_header(header); @@ -247,7 +247,7 @@ // randomly selected flag bits not excluded by FlagsAffectingPayloadDecoding. ::testing::AssertionResult VerifyDetectsMultipleFrameSizeErrors( uint8_t required_flags, - quiche::QuicheStringPiece unpadded_payload, + absl::string_view unpadded_payload, ApproveSize approve_size, int total_pad_length) { // required_flags should come from those that are defined for the frame @@ -305,7 +305,7 @@ // As above, but for frames without padding. ::testing::AssertionResult VerifyDetectsFrameSizeError( uint8_t required_flags, - quiche::QuicheStringPiece unpadded_payload, + absl::string_view unpadded_payload, const ApproveSize& approve_size) { Http2FrameType frame_type = DecoderPeer::FrameType(); uint8_t known_flags = KnownFlagsMaskForFrameType(frame_type); @@ -378,7 +378,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( - quiche::QuicheStringPiece payload, + absl::string_view payload, const Http2FrameHeader& header, size_t expected_missing_length) { set_frame_header(header);
diff --git a/http2/hpack/varint/hpack_varint_decoder_test.cc b/http2/hpack/varint/hpack_varint_decoder_test.cc index 06554e9..5b22f8b 100644 --- a/http2/hpack/varint/hpack_varint_decoder_test.cc +++ b/http2/hpack/varint/hpack_varint_decoder_test.cc
@@ -8,11 +8,11 @@ #include <stddef.h> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.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_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_test.h" using ::testing::AssertionFailure; @@ -31,7 +31,7 @@ suffix_(Http2HexDecode(::testing::get<1>(GetParam()))), prefix_length_(0) {} - void DecodeExpectSuccess(quiche::QuicheStringPiece data, + void DecodeExpectSuccess(absl::string_view data, uint32_t prefix_length, uint64_t expected_value) { Validator validator = [expected_value, this]( @@ -52,8 +52,7 @@ EXPECT_EQ(expected_value, decoder_.value()); } - void DecodeExpectError(quiche::QuicheStringPiece data, - uint32_t prefix_length) { + void DecodeExpectError(absl::string_view data, uint32_t prefix_length) { Validator validator = [](const DecodeBuffer& /*db*/, DecodeStatus status) -> AssertionResult { VERIFY_EQ(DecodeStatus::kDecodeError, status); @@ -64,7 +63,7 @@ } private: - AssertionResult Decode(quiche::QuicheStringPiece data, + AssertionResult Decode(absl::string_view 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 e8a0964..957683f 100644 --- a/http2/hpack/varint/hpack_varint_round_trip_test.cc +++ b/http2/hpack/varint/hpack_varint_round_trip_test.cc
@@ -13,12 +13,12 @@ #include <set> #include <vector> +#include "absl/strings/string_view.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_utils.h" #include "net/third_party/quiche/src/http2/tools/random_decoder_test.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" #include "net/third_party/quiche/src/common/platform/api/quiche_test.h" using ::testing::AssertionFailure; @@ -292,7 +292,7 @@ } TEST_F(HpackVarintRoundTripTest, FromSpec1337) { - DecodeBuffer b(quiche::QuicheStringPiece("\x1f\x9a\x0a")); + DecodeBuffer b(absl::string_view("\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 daed778..08351c4 100644 --- a/http2/http2_constants.cc +++ b/http2/http2_constants.cc
@@ -4,10 +4,10 @@ #include "net/third_party/quiche/src/http2/http2_constants.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/http2/platform/api/http2_logging.h" #include "net/third_party/quiche/src/http2/platform/api/http2_string_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 http2 { @@ -47,8 +47,7 @@ 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](quiche::QuicheStringPiece v, - uint8_t bit) { + auto append_and_clear = [&s, &flags](absl::string_view v, uint8_t bit) { if (!s.empty()) { s.push_back('|'); }
diff --git a/http2/platform/api/http2_string_utils.h b/http2/platform/api/http2_string_utils.h index f14d93a..ec421b7 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 "absl/strings/string_view.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 { @@ -28,15 +28,15 @@ return Http2HexEncodeImpl(bytes, size); } -inline std::string Http2HexDecode(quiche::QuicheStringPiece data) { +inline std::string Http2HexDecode(absl::string_view data) { return Http2HexDecodeImpl(data); } -inline std::string Http2HexDump(quiche::QuicheStringPiece data) { +inline std::string Http2HexDump(absl::string_view data) { return Http2HexDumpImpl(data); } -inline std::string Http2HexEscape(quiche::QuicheStringPiece data) { +inline std::string Http2HexEscape(absl::string_view 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 e3d499c..5cb019d 100644 --- a/http2/platform/api/http2_string_utils_test.cc +++ b/http2/platform/api/http2_string_utils_test.cc
@@ -6,8 +6,8 @@ #include <cstdint> +#include "absl/strings/string_view.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" #include "net/third_party/quiche/src/common/platform/api/quiche_test.h" namespace http2 { @@ -23,7 +23,7 @@ // Single string-like argument. const char kFoo[] = "foo"; const std::string string_foo(kFoo); - const quiche::QuicheStringPiece stringpiece_foo(string_foo); + const absl::string_view stringpiece_foo(string_foo); Http2StrAppend(&output, kFoo); EXPECT_EQ("foo", output); Http2StrAppend(&output, string_foo); @@ -39,7 +39,7 @@ // Two string-like arguments. const char kBar[] = "bar"; - const quiche::QuicheStringPiece stringpiece_bar(kBar); + const absl::string_view stringpiece_bar(kBar); const std::string string_bar(kBar); Http2StrAppend(&output, kFoo, kBar); EXPECT_EQ("foobar", output);
diff --git a/quic/test_tools/quic_test_utils.cc b/quic/test_tools/quic_test_utils.cc index 12befe4..605fe80 100644 --- a/quic/test_tools/quic_test_utils.cc +++ b/quic/test_tools/quic_test_utils.cc
@@ -1585,7 +1585,7 @@ QuicVersionLabel version_label; ParsedQuicVersion parsed_version = ParsedQuicVersion::Unsupported(); QuicConnectionId destination_connection_id, source_connection_id; - quiche::QuicheStringPiece retry_token; + absl::string_view retry_token; std::string detailed_error; QuicErrorCode error = QuicFramer::ParsePublicHeaderDispatcher( encrypted_packet,
diff --git a/spdy/platform/api/spdy_string_utils.h b/spdy/platform/api/spdy_string_utils.h index b023f73..e7ee6a9 100644 --- a/spdy/platform/api/spdy_string_utils.h +++ b/spdy/platform/api/spdy_string_utils.h
@@ -14,7 +14,7 @@ // non-test code. #include "net/third_party/quiche/src/spdy/platform/api/spdy_mem_slice.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "absl/strings/string_view.h" #include "net/spdy/platform/impl/spdy_string_utils_impl.h" namespace spdy { @@ -28,12 +28,11 @@ return SpdyHexDigitToIntImpl(c); } -inline std::string SpdyHexDecode(quiche::QuicheStringPiece data) { +inline std::string SpdyHexDecode(absl::string_view data) { return SpdyHexDecodeImpl(data); } -inline bool SpdyHexDecodeToUInt32(quiche::QuicheStringPiece data, - uint32_t* out) { +inline bool SpdyHexDecodeToUInt32(absl::string_view data, uint32_t* out) { return SpdyHexDecodeToUInt32Impl(data, out); } @@ -45,7 +44,7 @@ return SpdyHexEncodeUInt32AndTrimImpl(data); } -inline std::string SpdyHexDump(quiche::QuicheStringPiece data) { +inline std::string SpdyHexDump(absl::string_view data) { return SpdyHexDumpImpl(data); }
diff --git a/spdy/platform/api/spdy_string_utils_test.cc b/spdy/platform/api/spdy_string_utils_test.cc index 4848bf0..2f8c022 100644 --- a/spdy/platform/api/spdy_string_utils_test.cc +++ b/spdy/platform/api/spdy_string_utils_test.cc
@@ -6,7 +6,7 @@ #include <cstdint> -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/common/platform/api/quiche_test.h" namespace spdy { @@ -22,7 +22,7 @@ // Single string-like argument. const char kFoo[] = "foo"; const std::string string_foo(kFoo); - const quiche::QuicheStringPiece stringpiece_foo(string_foo); + const absl::string_view stringpiece_foo(string_foo); SpdyStrAppend(&output, kFoo); EXPECT_EQ("foo", output); SpdyStrAppend(&output, string_foo); @@ -38,7 +38,7 @@ // Two string-like arguments. const char kBar[] = "bar"; - const quiche::QuicheStringPiece stringpiece_bar(kBar); + const absl::string_view stringpiece_bar(kBar); const std::string string_bar(kBar); SpdyStrAppend(&output, kFoo, kBar); EXPECT_EQ("foobar", output);