Replace quiche::QuicheStringPiece with absl::string_view.
PiperOrigin-RevId: 336819830
Change-Id: Ib3e47a9e3ad9c563a60434b41be492e85e6e4038
diff --git a/http2/hpack/hpack_string.cc b/http2/hpack/hpack_string.cc
index cb22f51..a68bd8b 100644
--- a/http2/hpack/hpack_string.cc
+++ b/http2/hpack/hpack_string.cc
@@ -12,33 +12,32 @@
namespace http2 {
HpackString::HpackString(const char* data) : str_(data) {}
-HpackString::HpackString(quiche::QuicheStringPiece str)
- : str_(std::string(str)) {}
+HpackString::HpackString(absl::string_view str) : str_(std::string(str)) {}
HpackString::HpackString(std::string str) : str_(std::move(str)) {}
HpackString::HpackString(const HpackString& other) = default;
HpackString::~HpackString() = default;
-quiche::QuicheStringPiece HpackString::ToStringPiece() const {
+absl::string_view HpackString::ToStringPiece() const {
return str_;
}
bool HpackString::operator==(const HpackString& other) const {
return str_ == other.str_;
}
-bool HpackString::operator==(quiche::QuicheStringPiece str) const {
+bool HpackString::operator==(absl::string_view str) const {
return str == str_;
}
-bool operator==(quiche::QuicheStringPiece a, const HpackString& b) {
+bool operator==(absl::string_view a, const HpackString& b) {
return b == a;
}
-bool operator!=(quiche::QuicheStringPiece a, const HpackString& b) {
+bool operator!=(absl::string_view a, const HpackString& b) {
return !(b == a);
}
bool operator!=(const HpackString& a, const HpackString& b) {
return !(a == b);
}
-bool operator!=(const HpackString& a, quiche::QuicheStringPiece b) {
+bool operator!=(const HpackString& a, absl::string_view b) {
return !(a == b);
}
std::ostream& operator<<(std::ostream& out, const HpackString& v) {
@@ -51,8 +50,8 @@
HTTP2_DVLOG(3) << DebugString() << " ctor";
}
-HpackStringPair::HpackStringPair(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value)
+HpackStringPair::HpackStringPair(absl::string_view name,
+ absl::string_view 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 6789187..3af2348 100644
--- a/http2/hpack/hpack_string.h
+++ b/http2/hpack/hpack_string.h
@@ -15,15 +15,15 @@
#include <iosfwd>
#include <string>
+#include "absl/strings/string_view.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_export.h"
-#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace http2 {
class QUICHE_EXPORT_PRIVATE HpackString {
public:
explicit HpackString(const char* data);
- explicit HpackString(quiche::QuicheStringPiece str);
+ explicit HpackString(absl::string_view str);
explicit HpackString(std::string str);
HpackString(const HpackString& other);
@@ -34,31 +34,30 @@
size_t size() const { return str_.size(); }
const std::string& ToString() const { return str_; }
- quiche::QuicheStringPiece ToStringPiece() const;
+ absl::string_view ToStringPiece() const;
bool operator==(const HpackString& other) const;
- bool operator==(quiche::QuicheStringPiece str) const;
+ bool operator==(absl::string_view str) const;
private:
std::string str_;
};
-QUICHE_EXPORT_PRIVATE bool operator==(quiche::QuicheStringPiece a,
+QUICHE_EXPORT_PRIVATE bool operator==(absl::string_view a,
const HpackString& b);
-QUICHE_EXPORT_PRIVATE bool operator!=(quiche::QuicheStringPiece a,
+QUICHE_EXPORT_PRIVATE bool operator!=(absl::string_view a,
const HpackString& b);
QUICHE_EXPORT_PRIVATE bool operator!=(const HpackString& a,
const HpackString& b);
QUICHE_EXPORT_PRIVATE bool operator!=(const HpackString& a,
- quiche::QuicheStringPiece b);
+ absl::string_view b);
QUICHE_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& out,
const HpackString& v);
struct QUICHE_EXPORT_PRIVATE HpackStringPair {
HpackStringPair(const HpackString& name, const HpackString& value);
- HpackStringPair(quiche::QuicheStringPiece name,
- quiche::QuicheStringPiece value);
+ HpackStringPair(absl::string_view name, absl::string_view 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 8d49b25..ee24115 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();
- quiche::QuicheStringPiece not_expected_sp(not_expected_str);
+ absl::string_view 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 quiche::QuicheStringPiece expected_sp(expected_str);
+ const absl::string_view expected_sp(expected_str);
VERIFY_EQ(*actual, expected_ptr);
VERIFY_EQ(*actual, expected_sp);
@@ -91,12 +91,12 @@
}
TEST_F(HpackStringTest, StringPieceConstructor) {
- quiche::QuicheStringPiece sp0(kStr0);
+ absl::string_view sp0(kStr0);
HpackString hs0(sp0);
EXPECT_TRUE(VerifyEqual(&hs0, kStr0));
EXPECT_TRUE(VerifyNotEqual(&hs0, kStr1));
- quiche::QuicheStringPiece sp1(kStr1);
+ absl::string_view sp1(kStr1);
HpackString hs1(sp1);
EXPECT_TRUE(VerifyEqual(&hs1, kStr1));
EXPECT_TRUE(VerifyNotEqual(&hs1, kStr0));
@@ -115,7 +115,7 @@
}
TEST_F(HpackStringTest, CopyConstructor) {
- quiche::QuicheStringPiece sp0(kStr0);
+ absl::string_view sp0(kStr0);
HpackString hs0(sp0);
HpackString hs1(hs0);
EXPECT_EQ(hs0, hs1);
@@ -128,7 +128,7 @@
}
TEST_F(HpackStringTest, MoveConstructor) {
- quiche::QuicheStringPiece sp0(kStr0);
+ absl::string_view sp0(kStr0);
HpackString hs0(sp0);
EXPECT_TRUE(VerifyEqual(&hs0, kStr0));
EXPECT_TRUE(VerifyNotEqual(&hs0, ""));
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;