Replace quiche::QuicheStringPiece with absl::string_view. PiperOrigin-RevId: 336819830 Change-Id: Ib3e47a9e3ad9c563a60434b41be492e85e6e4038
diff --git a/http2/test_tools/frame_parts.cc b/http2/test_tools/frame_parts.cc index 7b25299..95ea34d 100644 --- a/http2/test_tools/frame_parts.cc +++ b/http2/test_tools/frame_parts.cc
@@ -51,14 +51,14 @@ } FrameParts::FrameParts(const Http2FrameHeader& header, - quiche::QuicheStringPiece payload) + absl::string_view 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, - quiche::QuicheStringPiece payload, + absl::string_view payload, size_t total_pad_length) : FrameParts(header, payload) { HTTP2_VLOG(1) << "FrameParts with total_pad_length=" << total_pad_length; @@ -117,8 +117,8 @@ } } -void FrameParts::SetAltSvcExpected(quiche::QuicheStringPiece origin, - quiche::QuicheStringPiece value) { +void FrameParts::SetAltSvcExpected(absl::string_view origin, + absl::string_view value) { altsvc_origin_.append(origin.data(), origin.size()); altsvc_value_.append(value.data(), value.size()); opt_altsvc_origin_length_ = origin.size(); @@ -140,7 +140,7 @@ HTTP2_VLOG(1) << "OnDataPayload: len=" << len << "; frame_header_: " << frame_header_; ASSERT_TRUE(InFrameOfType(Http2FrameType::DATA)) << *this; - ASSERT_TRUE(AppendString(quiche::QuicheStringPiece(data, len), &payload_, + ASSERT_TRUE(AppendString(absl::string_view(data, len), &payload_, &opt_payload_length_)); } @@ -172,7 +172,7 @@ ASSERT_TRUE(got_start_callback_); ASSERT_FALSE(got_end_callback_); ASSERT_TRUE(FrameCanHaveHpackPayload(frame_header_)) << *this; - ASSERT_TRUE(AppendString(quiche::QuicheStringPiece(data, len), &payload_, + ASSERT_TRUE(AppendString(absl::string_view(data, len), &payload_, &opt_payload_length_)); } @@ -216,8 +216,8 @@ HTTP2_VLOG(1) << "OnPadding: skipped_length=" << skipped_length; ASSERT_TRUE(InPaddedFrame()) << *this; ASSERT_TRUE(opt_pad_length_); - ASSERT_TRUE(AppendString(quiche::QuicheStringPiece(pad, skipped_length), - &padding_, &opt_pad_length_)); + ASSERT_TRUE(AppendString(absl::string_view(pad, skipped_length), &padding_, + &opt_pad_length_)); } void FrameParts::OnRstStream(const Http2FrameHeader& header, @@ -313,7 +313,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(quiche::QuicheStringPiece(data, len), &payload_, + ASSERT_TRUE(AppendString(absl::string_view(data, len), &payload_, &opt_payload_length_)); } @@ -348,14 +348,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(quiche::QuicheStringPiece(data, len), - &altsvc_origin_, &opt_altsvc_origin_length_)); + ASSERT_TRUE(AppendString(absl::string_view(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(quiche::QuicheStringPiece(data, len), &altsvc_value_, + ASSERT_TRUE(AppendString(absl::string_view(data, len), &altsvc_value_, &opt_altsvc_value_length_)); } @@ -378,7 +378,7 @@ ASSERT_FALSE(IsSupportedHttp2FrameType(frame_header_.type)) << *this; ASSERT_TRUE(got_start_callback_); ASSERT_FALSE(got_end_callback_); - ASSERT_TRUE(AppendString(quiche::QuicheStringPiece(data, len), &payload_, + ASSERT_TRUE(AppendString(absl::string_view(data, len), &payload_, &opt_payload_length_)); } @@ -507,7 +507,7 @@ } AssertionResult FrameParts::AppendString( - quiche::QuicheStringPiece source, + absl::string_view source, std::string* target, quiche::QuicheOptional<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 68e5482..ca242b1 100644 --- a/http2/test_tools/frame_parts.h +++ b/http2/test_tools/frame_parts.h
@@ -16,12 +16,12 @@ #include <string> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/http2/decoder/http2_frame_decoder_listener.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/http2/platform/api/http2_logging.h" #include "net/third_party/quiche/src/common/platform/api/quiche_optional.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 { @@ -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, quiche::QuicheStringPiece payload); + FrameParts(const Http2FrameHeader& header, absl::string_view payload); // For use in tests where the expected frame has a variable size payload // and may be padded. FrameParts(const Http2FrameHeader& header, - quiche::QuicheStringPiece payload, + absl::string_view payload, size_t total_pad_length); // Copy constructor. @@ -58,8 +58,7 @@ void SetTotalPadLength(size_t total_pad_length); // Set the origin and value expected in an ALTSVC frame. - void SetAltSvcExpected(quiche::QuicheStringPiece origin, - quiche::QuicheStringPiece value); + void SetAltSvcExpected(absl::string_view origin, absl::string_view value); // Http2FrameDecoderListener methods: bool OnFrameHeader(const Http2FrameHeader& header) override; @@ -217,7 +216,7 @@ // 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( - quiche::QuicheStringPiece source, + absl::string_view source, std::string* target, quiche::QuicheOptional<size_t>* opt_length);
diff --git a/http2/test_tools/http2_random.cc b/http2/test_tools/http2_random.cc index df20364..5fb2f7d 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(quiche::QuicheStringPiece key) { +Http2Random::Http2Random(absl::string_view key) { std::string decoded_key = Http2HexDecode(key); CHECK_EQ(sizeof(key_), decoded_key.size()); memcpy(key_, decoded_key.data(), sizeof(key_)); @@ -58,9 +58,8 @@ return value.f - 1.0; } -std::string Http2Random::RandStringWithAlphabet( - int length, - quiche::QuicheStringPiece alphabet) { +std::string Http2Random::RandStringWithAlphabet(int length, + absl::string_view 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 9f046a1..4fe2a51 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/common/platform/api/quiche_string_piece.h" +#include "absl/strings/string_view.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(quiche::QuicheStringPiece key); + explicit Http2Random(absl::string_view key); std::string Key() const; void FillRandom(void* buffer, size_t buffer_size); @@ -67,8 +67,7 @@ // Return a random string consisting of the characters from the specified // alphabet. - std::string RandStringWithAlphabet(int length, - quiche::QuicheStringPiece alphabet); + std::string RandStringWithAlphabet(int length, absl::string_view alphabet); // STL UniformRandomNumberGenerator implementation. using result_type = uint64_t;