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, ""));