Replace quiche::QuicheStringPiece with absl::string_view. PiperOrigin-RevId: 336792322 Change-Id: I930e033b8097de7504a93b906618e69fc65be435
diff --git a/http2/hpack/tools/hpack_block_builder.cc b/http2/hpack/tools/hpack_block_builder.cc index 04dec31..fa0ec4d 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, - quiche::QuicheStringPiece str) { + absl::string_view 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 55de99f..46da803 100644 --- a/http2/hpack/tools/hpack_block_builder.h +++ b/http2/hpack/tools/hpack_block_builder.h
@@ -20,8 +20,8 @@ #include <cstdint> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.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 { @@ -29,7 +29,7 @@ class HpackBlockBuilder { public: - explicit HpackBlockBuilder(quiche::QuicheStringPiece initial_contents) + explicit HpackBlockBuilder(absl::string_view 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, - quiche::QuicheStringPiece value) { + absl::string_view 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, - quiche::QuicheStringPiece name, + absl::string_view name, bool value_is_huffman_encoded, - quiche::QuicheStringPiece value) { + absl::string_view 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, quiche::QuicheStringPiece str); + void AppendString(bool is_huffman_encoded, absl::string_view 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 de35781..d162fba 100644 --- a/http2/hpack/tools/hpack_block_builder_test.cc +++ b/http2/hpack/tools/hpack_block_builder_test.cc
@@ -120,8 +120,7 @@ '\xab', '\x90', '\xf4', '\xff'}; b.AppendNameIndexAndLiteralValue( HpackEntryType::kIndexedLiteralHeader, 1, kCompressed, - quiche::QuicheStringPiece(kHuffmanWwwExampleCom, - sizeof kHuffmanWwwExampleCom)); + absl::string_view(kHuffmanWwwExampleCom, sizeof kHuffmanWwwExampleCom)); EXPECT_EQ(17u, b.size()); // Hex dump of encoded data (copied from RFC): @@ -141,7 +140,7 @@ EXPECT_EQ(1u, b.size()); const char kData[] = {'\x20'}; - quiche::QuicheStringPiece expected(kData, sizeof kData); + absl::string_view expected(kData, sizeof kData); EXPECT_EQ(expected, b.buffer()); } { @@ -150,7 +149,7 @@ EXPECT_EQ(3u, b.size()); const char kData[] = {'\x3f', '\xe1', '\x1f'}; - quiche::QuicheStringPiece expected(kData, sizeof kData); + absl::string_view expected(kData, sizeof kData); EXPECT_EQ(expected, b.buffer()); } { @@ -160,7 +159,7 @@ const char kData[] = {'\x3f', '\xe1', '\x9f', '\x94', '\xa5', '\x8d', '\x1d'}; - quiche::QuicheStringPiece expected(kData, sizeof kData); + absl::string_view 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 31de86d..1087875 100644 --- a/http2/hpack/tools/hpack_example.cc +++ b/http2/hpack/tools/hpack_example.cc
@@ -15,8 +15,7 @@ namespace test { namespace { -void HpackExampleToStringOrDie(quiche::QuicheStringPiece example, - std::string* output) { +void HpackExampleToStringOrDie(absl::string_view example, std::string* output) { while (!example.empty()) { const char c0 = example[0]; if (isxdigit(c0)) { @@ -34,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 == quiche::QuicheStringPiece::npos) { + if (pos == absl::string_view::npos) { // End of input. break; } @@ -50,7 +49,7 @@ } // namespace -std::string HpackExampleToStringOrDie(quiche::QuicheStringPiece example) { +std::string HpackExampleToStringOrDie(absl::string_view 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 e86c116..de203cc 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/common/platform/api/quiche_string_piece.h" +#include "absl/strings/string_view.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(quiche::QuicheStringPiece example); +std::string HpackExampleToStringOrDie(absl::string_view example); } // namespace test } // namespace http2
diff --git a/http2/tools/http2_frame_builder.cc b/http2/tools/http2_frame_builder.cc index c42c215..2ba8778 100644 --- a/http2/tools/http2_frame_builder.cc +++ b/http2/tools/http2_frame_builder.cc
@@ -30,12 +30,12 @@ Append(v); } -void Http2FrameBuilder::Append(quiche::QuicheStringPiece s) { +void Http2FrameBuilder::Append(absl::string_view s) { Http2StrAppend(&buffer_, s); } void Http2FrameBuilder::AppendBytes(const void* data, uint32_t num_bytes) { - Append(quiche::QuicheStringPiece(static_cast<const char*>(data), num_bytes)); + Append(absl::string_view(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(quiche::QuicheStringPiece s, size_t offset) { +void Http2FrameBuilder::WriteAt(absl::string_view s, size_t offset) { ASSERT_LE(offset, buffer_.size()); size_t len = offset + s.size(); if (len > buffer_.size()) { @@ -157,8 +157,7 @@ void Http2FrameBuilder::WriteBytesAt(const void* data, uint32_t num_bytes, size_t offset) { - WriteAt(quiche::QuicheStringPiece(static_cast<const char*>(data), num_bytes), - offset); + WriteAt(absl::string_view(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 724c2b2..a4062de 100644 --- a/http2/tools/http2_frame_builder.h +++ b/http2/tools/http2_frame_builder.h
@@ -18,9 +18,9 @@ #include <cstdint> #include <string> +#include "absl/strings/string_view.h" #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/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(quiche::QuicheStringPiece s); + void Append(absl::string_view 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(quiche::QuicheStringPiece s, size_t offset); + void WriteAt(absl::string_view 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 86acbb8..4e87c49 100644 --- a/http2/tools/random_decoder_test.h +++ b/http2/tools/random_decoder_test.h
@@ -17,12 +17,12 @@ #include <memory> #include <type_traits> +#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/platform/api/http2_logging.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" #include "net/third_party/quiche/src/common/platform/api/quiche_test.h" namespace http2 { @@ -31,9 +31,8 @@ // Some helpers. template <typename T, size_t N> -quiche::QuicheStringPiece ToStringPiece(T (&data)[N]) { - return quiche::QuicheStringPiece(reinterpret_cast<const char*>(data), - N * sizeof(T)); +absl::string_view ToStringPiece(T (&data)[N]) { + return absl::string_view(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 a0af07a..01571ed 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) { - quiche::QuicheStringPiece alpha_lc = "abcdefghijklmnopqrstuvwxyz"; + absl::string_view alpha_lc = "abcdefghijklmnopqrstuvwxyz"; // If the name is short, just make it one word. if (len < 8) { return rng->RandStringWithAlphabet(len, alpha_lc); @@ -20,8 +20,7 @@ // 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. - quiche::QuicheStringPiece alphanumdash_lc = - "abcdefghijklmnopqrstuvwxyz0123456789-"; + absl::string_view alphanumdash_lc = "abcdefghijklmnopqrstuvwxyz0123456789-"; return rng->RandStringWithAlphabet(4, alpha_lc) + rng->RandStringWithAlphabet(len - 4, alphanumdash_lc); }