Replace quiche::QuicheStringPiece with absl::string_view. PiperOrigin-RevId: 336771408 Change-Id: I8ba3008a73a53520b3f6646aa7f698e25e0ecacf
diff --git a/spdy/core/http2_frame_decoder_adapter.h b/spdy/core/http2_frame_decoder_adapter.h index 1ac20c2..a75ab23 100644 --- a/spdy/core/http2_frame_decoder_adapter.h +++ b/spdy/core/http2_frame_decoder_adapter.h
@@ -11,10 +11,10 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/http2/decoder/http2_frame_decoder.h" #include "net/third_party/quiche/src/common/platform/api/quiche_export.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/spdy/core/hpack/hpack_decoder_adapter.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_header_table.h" #include "net/third_party/quiche/src/spdy/core/spdy_alt_svc_wire_format.h" @@ -494,7 +494,7 @@ // Called when an ALTSVC frame has been parsed. virtual void OnAltSvc( SpdyStreamId /*stream_id*/, - quiche::QuicheStringPiece /*origin*/, + absl::string_view /*origin*/, const SpdyAltSvcWireFormat::AlternativeServiceVector& /*altsvc_vector*/) { }
diff --git a/spdy/core/mock_spdy_framer_visitor.h b/spdy/core/mock_spdy_framer_visitor.h index e54c869..31ed952 100644 --- a/spdy/core/mock_spdy_framer_visitor.h +++ b/spdy/core/mock_spdy_framer_visitor.h
@@ -9,7 +9,7 @@ #include <memory> #include <utility> -#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" #include "net/third_party/quiche/src/spdy/core/http2_frame_decoder_adapter.h" #include "net/third_party/quiche/src/spdy/core/spdy_test_utils.h" @@ -90,7 +90,7 @@ void, OnAltSvc, (SpdyStreamId stream_id, - quiche::QuicheStringPiece origin, + absl::string_view origin, const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector), (override)); MOCK_METHOD(void,
diff --git a/spdy/core/spdy_alt_svc_wire_format.cc b/spdy/core/spdy_alt_svc_wire_format.cc index 7f7ca29..ac85b9c 100644 --- a/spdy/core/spdy_alt_svc_wire_format.cc +++ b/spdy/core/spdy_alt_svc_wire_format.cc
@@ -17,8 +17,8 @@ namespace { template <class T> -bool ParsePositiveIntegerImpl(quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, +bool ParsePositiveIntegerImpl(absl::string_view::const_iterator c, + absl::string_view::const_iterator end, T* value) { *value = 0; for (; c != end && std::isdigit(*c); ++c) { @@ -57,20 +57,20 @@ // static bool SpdyAltSvcWireFormat::ParseHeaderFieldValue( - quiche::QuicheStringPiece value, + absl::string_view value, AlternativeServiceVector* altsvc_vector) { // Empty value is invalid according to the specification. if (value.empty()) { return false; } altsvc_vector->clear(); - if (value == quiche::QuicheStringPiece("clear")) { + if (value == absl::string_view("clear")) { return true; } - quiche::QuicheStringPiece::const_iterator c = value.begin(); + absl::string_view::const_iterator c = value.begin(); while (c != value.end()) { // Parse protocol-id. - quiche::QuicheStringPiece::const_iterator percent_encoded_protocol_id_end = + absl::string_view::const_iterator percent_encoded_protocol_id_end = std::find(c, value.end(), '='); std::string protocol_id; if (percent_encoded_protocol_id_end == c || @@ -91,7 +91,7 @@ return false; } ++c; - quiche::QuicheStringPiece::const_iterator alt_authority_begin = c; + absl::string_view::const_iterator alt_authority_begin = c; for (; c != value.end() && *c != '"'; ++c) { // Decode backslash encoding. if (*c != '\\') { @@ -115,7 +115,7 @@ // Parse parameters. uint32_t max_age = 86400; VersionVector version; - quiche::QuicheStringPiece::const_iterator parameters_end = + absl::string_view::const_iterator parameters_end = std::find(c, value.end(), ','); while (c != parameters_end) { SkipWhiteSpace(&c, parameters_end); @@ -140,7 +140,7 @@ } ++c; SkipWhiteSpace(&c, parameters_end); - quiche::QuicheStringPiece::const_iterator parameter_value_begin = c; + absl::string_view::const_iterator parameter_value_begin = c; for (; c != parameters_end && *c != ';' && *c != ' ' && *c != '\t'; ++c) { } if (c == parameter_value_begin) { @@ -164,10 +164,9 @@ } ++c; parameters_end = std::find(c, value.end(), ','); - quiche::QuicheStringPiece::const_iterator v_begin = - parameter_value_begin + 1; + absl::string_view::const_iterator v_begin = parameter_value_begin + 1; while (v_begin < c) { - quiche::QuicheStringPiece::const_iterator v_end = v_begin; + absl::string_view::const_iterator v_end = v_begin; while (v_end < c - 1 && *v_end != ',') { ++v_end; } @@ -196,10 +195,9 @@ // hq=":443";quic=51303338 // ... will be stored in |versions| as 0x51303338. uint32_t quic_version; - if (!SpdyHexDecodeToUInt32( - quiche::QuicheStringPiece(&*parameter_value_begin, - c - parameter_value_begin), - &quic_version) || + if (!SpdyHexDecodeToUInt32(absl::string_view(&*parameter_value_begin, + c - parameter_value_begin), + &quic_version) || quic_version == 0) { return false; } @@ -295,17 +293,16 @@ // static void SpdyAltSvcWireFormat::SkipWhiteSpace( - quiche::QuicheStringPiece::const_iterator* c, - quiche::QuicheStringPiece::const_iterator end) { + absl::string_view::const_iterator* c, + absl::string_view::const_iterator end) { for (; *c != end && (**c == ' ' || **c == '\t'); ++*c) { } } // static -bool SpdyAltSvcWireFormat::PercentDecode( - quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, - std::string* output) { +bool SpdyAltSvcWireFormat::PercentDecode(absl::string_view::const_iterator c, + absl::string_view::const_iterator end, + std::string* output) { output->clear(); for (; c != end; ++c) { if (*c != '%') { @@ -331,8 +328,8 @@ // static bool SpdyAltSvcWireFormat::ParseAltAuthority( - quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, + absl::string_view::const_iterator c, + absl::string_view::const_iterator end, std::string* host, uint16_t* port) { host->clear(); @@ -378,16 +375,16 @@ // static bool SpdyAltSvcWireFormat::ParsePositiveInteger16( - quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, + absl::string_view::const_iterator c, + absl::string_view::const_iterator end, uint16_t* value) { return ParsePositiveIntegerImpl<uint16_t>(c, end, value); } // static bool SpdyAltSvcWireFormat::ParsePositiveInteger32( - quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, + absl::string_view::const_iterator c, + absl::string_view::const_iterator end, uint32_t* value) { return ParsePositiveIntegerImpl<uint32_t>(c, end, value); }
diff --git a/spdy/core/spdy_alt_svc_wire_format.h b/spdy/core/spdy_alt_svc_wire_format.h index 4d25450..30462fe 100644 --- a/spdy/core/spdy_alt_svc_wire_format.h +++ b/spdy/core/spdy_alt_svc_wire_format.h
@@ -14,8 +14,8 @@ #include <string> #include <vector> +#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" #include "net/third_party/quiche/src/spdy/platform/api/spdy_containers.h" namespace spdy { @@ -60,29 +60,27 @@ typedef std::vector<AlternativeService> AlternativeServiceVector; friend class test::SpdyAltSvcWireFormatPeer; - static bool ParseHeaderFieldValue(quiche::QuicheStringPiece value, + static bool ParseHeaderFieldValue(absl::string_view value, AlternativeServiceVector* altsvc_vector); static std::string SerializeHeaderFieldValue( const AlternativeServiceVector& altsvc_vector); private: - static void SkipWhiteSpace(quiche::QuicheStringPiece::const_iterator* c, - quiche::QuicheStringPiece::const_iterator end); - static bool PercentDecode(quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, + static void SkipWhiteSpace(absl::string_view::const_iterator* c, + absl::string_view::const_iterator end); + static bool PercentDecode(absl::string_view::const_iterator c, + absl::string_view::const_iterator end, std::string* output); - static bool ParseAltAuthority(quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, + static bool ParseAltAuthority(absl::string_view::const_iterator c, + absl::string_view::const_iterator end, std::string* host, uint16_t* port); - static bool ParsePositiveInteger16( - quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, - uint16_t* value); - static bool ParsePositiveInteger32( - quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, - uint32_t* value); + static bool ParsePositiveInteger16(absl::string_view::const_iterator c, + absl::string_view::const_iterator end, + uint16_t* value); + static bool ParsePositiveInteger32(absl::string_view::const_iterator c, + absl::string_view::const_iterator end, + uint32_t* value); }; } // namespace spdy
diff --git a/spdy/core/spdy_alt_svc_wire_format_test.cc b/spdy/core/spdy_alt_svc_wire_format_test.cc index d80de7d..a4127c8 100644 --- a/spdy/core/spdy_alt_svc_wire_format_test.cc +++ b/spdy/core/spdy_alt_svc_wire_format_test.cc
@@ -14,31 +14,29 @@ // Expose all private methods of class SpdyAltSvcWireFormat. class SpdyAltSvcWireFormatPeer { public: - static void SkipWhiteSpace(quiche::QuicheStringPiece::const_iterator* c, - quiche::QuicheStringPiece::const_iterator end) { + static void SkipWhiteSpace(absl::string_view::const_iterator* c, + absl::string_view::const_iterator end) { SpdyAltSvcWireFormat::SkipWhiteSpace(c, end); } - static bool PercentDecode(quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, + static bool PercentDecode(absl::string_view::const_iterator c, + absl::string_view::const_iterator end, std::string* output) { return SpdyAltSvcWireFormat::PercentDecode(c, end, output); } - static bool ParseAltAuthority(quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, + static bool ParseAltAuthority(absl::string_view::const_iterator c, + absl::string_view::const_iterator end, std::string* host, uint16_t* port) { return SpdyAltSvcWireFormat::ParseAltAuthority(c, end, host, port); } - static bool ParsePositiveInteger16( - quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, - uint16_t* max_age) { + static bool ParsePositiveInteger16(absl::string_view::const_iterator c, + absl::string_view::const_iterator end, + uint16_t* max_age) { return SpdyAltSvcWireFormat::ParsePositiveInteger16(c, end, max_age); } - static bool ParsePositiveInteger32( - quiche::QuicheStringPiece::const_iterator c, - quiche::QuicheStringPiece::const_iterator end, - uint32_t* max_age) { + static bool ParsePositiveInteger32(absl::string_view::const_iterator c, + absl::string_view::const_iterator end, + uint32_t* max_age) { return SpdyAltSvcWireFormat::ParsePositiveInteger32(c, end, max_age); } }; @@ -389,8 +387,8 @@ // Test SkipWhiteSpace(). TEST(SpdyAltSvcWireFormatTest, SkipWhiteSpace) { - quiche::QuicheStringPiece input("a \tb "); - quiche::QuicheStringPiece::const_iterator c = input.begin(); + absl::string_view input("a \tb "); + absl::string_view::const_iterator c = input.begin(); test::SpdyAltSvcWireFormatPeer::SkipWhiteSpace(&c, input.end()); ASSERT_EQ(input.begin(), c); ++c; @@ -403,19 +401,19 @@ // Test PercentDecode() on valid input. TEST(SpdyAltSvcWireFormatTest, PercentDecodeValid) { - quiche::QuicheStringPiece input(""); + absl::string_view input(""); std::string output; ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::PercentDecode( input.begin(), input.end(), &output)); EXPECT_EQ("", output); - input = quiche::QuicheStringPiece("foo"); + input = absl::string_view("foo"); output.clear(); ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::PercentDecode( input.begin(), input.end(), &output)); EXPECT_EQ("foo", output); - input = quiche::QuicheStringPiece("%2ca%5Cb"); + input = absl::string_view("%2ca%5Cb"); output.clear(); ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::PercentDecode( input.begin(), input.end(), &output)); @@ -426,7 +424,7 @@ TEST(SpdyAltSvcWireFormatTest, PercentDecodeInvalid) { const char* invalid_input_array[] = {"a%", "a%x", "a%b", "%J22", "%9z"}; for (const char* invalid_input : invalid_input_array) { - quiche::QuicheStringPiece input(invalid_input); + absl::string_view input(invalid_input); std::string output; EXPECT_FALSE(test::SpdyAltSvcWireFormatPeer::PercentDecode( input.begin(), input.end(), &output)) @@ -436,7 +434,7 @@ // Test ParseAltAuthority() on valid input. TEST(SpdyAltSvcWireFormatTest, ParseAltAuthorityValid) { - quiche::QuicheStringPiece input(":42"); + absl::string_view input(":42"); std::string host; uint16_t port; ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParseAltAuthority( @@ -444,13 +442,13 @@ EXPECT_TRUE(host.empty()); EXPECT_EQ(42, port); - input = quiche::QuicheStringPiece("foo:137"); + input = absl::string_view("foo:137"); ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParseAltAuthority( input.begin(), input.end(), &host, &port)); EXPECT_EQ("foo", host); EXPECT_EQ(137, port); - input = quiche::QuicheStringPiece("[2003:8:0:16::509d:9615]:443"); + input = absl::string_view("[2003:8:0:16::509d:9615]:443"); ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParseAltAuthority( input.begin(), input.end(), &host, &port)); EXPECT_EQ("[2003:8:0:16::509d:9615]", host); @@ -477,7 +475,7 @@ "[2003:8:0:16::509d:9615:443", "2003:8:0:16::509d:9615]:443"}; for (const char* invalid_input : invalid_input_array) { - quiche::QuicheStringPiece input(invalid_input); + absl::string_view input(invalid_input); std::string host; uint16_t port; EXPECT_FALSE(test::SpdyAltSvcWireFormatPeer::ParseAltAuthority( @@ -488,13 +486,13 @@ // Test ParseInteger() on valid input. TEST(SpdyAltSvcWireFormatTest, ParseIntegerValid) { - quiche::QuicheStringPiece input("3"); + absl::string_view input("3"); uint16_t value; ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value)); EXPECT_EQ(3, value); - input = quiche::QuicheStringPiece("1337"); + input = absl::string_view("1337"); ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value)); EXPECT_EQ(1337, value); @@ -505,7 +503,7 @@ TEST(SpdyAltSvcWireFormatTest, ParseIntegerInvalid) { const char* invalid_input_array[] = {"", " ", "a", "0", "00", "1 ", "12b"}; for (const char* invalid_input : invalid_input_array) { - quiche::QuicheStringPiece input(invalid_input); + absl::string_view input(invalid_input); uint16_t value; EXPECT_FALSE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value)) @@ -516,39 +514,39 @@ // Test ParseIntegerValid() around overflow limit. TEST(SpdyAltSvcWireFormatTest, ParseIntegerOverflow) { // Largest possible uint16_t value. - quiche::QuicheStringPiece input("65535"); + absl::string_view input("65535"); uint16_t value16; ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value16)); EXPECT_EQ(65535, value16); // Overflow uint16_t, ParsePositiveInteger16() should return false. - input = quiche::QuicheStringPiece("65536"); + input = absl::string_view("65536"); ASSERT_FALSE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value16)); // However, even if overflow is not checked for, 65536 overflows to 0, which // returns false anyway. Check for a larger number which overflows to 1. - input = quiche::QuicheStringPiece("65537"); + input = absl::string_view("65537"); ASSERT_FALSE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value16)); // Largest possible uint32_t value. - input = quiche::QuicheStringPiece("4294967295"); + input = absl::string_view("4294967295"); uint32_t value32; ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger32( input.begin(), input.end(), &value32)); EXPECT_EQ(4294967295, value32); // Overflow uint32_t, ParsePositiveInteger32() should return false. - input = quiche::QuicheStringPiece("4294967296"); + input = absl::string_view("4294967296"); ASSERT_FALSE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger32( input.begin(), input.end(), &value32)); // However, even if overflow is not checked for, 4294967296 overflows to 0, // which returns false anyway. Check for a larger number which overflows to // 1. - input = quiche::QuicheStringPiece("4294967297"); + input = absl::string_view("4294967297"); ASSERT_FALSE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger32( input.begin(), input.end(), &value32)); }
diff --git a/spdy/core/spdy_deframer_visitor.cc b/spdy/core/spdy_deframer_visitor.cc index 9e20e3e..f5d3646 100644 --- a/spdy/core/spdy_deframer_visitor.cc +++ b/spdy/core/spdy_deframer_visitor.cc
@@ -11,8 +11,8 @@ #include <limits> #include <memory> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/http2/platform/api/http2_macros.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_constants.h" #include "net/third_party/quiche/src/spdy/core/mock_spdy_framer_visitor.h" #include "net/third_party/quiche/src/spdy/core/spdy_frame_reader.h" @@ -138,7 +138,7 @@ // alphabetical order for ease of navigation, and are not in same order // as in SpdyFramerVisitorInterface. void OnAltSvc(SpdyStreamId stream_id, - quiche::QuicheStringPiece origin, + absl::string_view origin, const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) override; void OnContinuation(SpdyStreamId stream_id, bool end) override; @@ -185,8 +185,7 @@ // Callbacks defined in SpdyHeadersHandlerInterface. void OnHeaderBlockStart() override; - void OnHeader(quiche::QuicheStringPiece key, - quiche::QuicheStringPiece value) override; + void OnHeader(absl::string_view key, absl::string_view value) override; void OnHeaderBlockEnd(size_t header_bytes_parsed, size_t compressed_header_bytes_parsed) override; @@ -411,7 +410,7 @@ void SpdyTestDeframerImpl::OnAltSvc( SpdyStreamId stream_id, - quiche::QuicheStringPiece origin, + absl::string_view origin, const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) { SPDY_DVLOG(1) << "OnAltSvc stream_id: " << stream_id; CHECK_EQ(frame_type_, UNSET) @@ -757,8 +756,8 @@ got_hpack_end_ = false; } -void SpdyTestDeframerImpl::OnHeader(quiche::QuicheStringPiece key, - quiche::QuicheStringPiece value) { +void SpdyTestDeframerImpl::OnHeader(absl::string_view key, + absl::string_view value) { CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION || frame_type_ == PUSH_PROMISE) << " frame_type_=" << Http2FrameTypeToString(frame_type_);
diff --git a/spdy/core/spdy_deframer_visitor.h b/spdy/core/spdy_deframer_visitor.h index 2753523..f17df98 100644 --- a/spdy/core/spdy_deframer_visitor.h +++ b/spdy/core/spdy_deframer_visitor.h
@@ -45,7 +45,7 @@ // framer.set_visitor(the_deframer.get()); // // // Process frames. -// QuicheStringPiece input = ... +// absl::string_view input = ... // while (!input.empty() && !framer.HasError()) { // size_t consumed = framer.ProcessInput(input.data(), input.size()); // input.remove_prefix(consumed);
diff --git a/spdy/core/spdy_frame_builder.cc b/spdy/core/spdy_frame_builder.cc index 492cd43..93fb284 100644 --- a/spdy/core/spdy_frame_builder.cc +++ b/spdy/core/spdy_frame_builder.cc
@@ -120,8 +120,7 @@ return success; } -bool SpdyFrameBuilder::WriteStringPiece32( - const quiche::QuicheStringPiece value) { +bool SpdyFrameBuilder::WriteStringPiece32(const absl::string_view value) { if (!WriteUInt32(value.size())) { return false; }
diff --git a/spdy/core/spdy_frame_builder.h b/spdy/core/spdy_frame_builder.h index 4853d44..f840099 100644 --- a/spdy/core/spdy_frame_builder.h +++ b/spdy/core/spdy_frame_builder.h
@@ -9,8 +9,8 @@ #include <cstdint> #include <memory> +#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" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" #include "net/third_party/quiche/src/spdy/core/zero_copy_output_buffer.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_bug_tracker.h" @@ -100,7 +100,7 @@ return (WriteBytes(&upper, sizeof(upper)) && WriteBytes(&lower, sizeof(lower))); } - bool WriteStringPiece32(const quiche::QuicheStringPiece value); + bool WriteStringPiece32(const absl::string_view value); bool WriteBytes(const void* data, uint32_t data_len); private:
diff --git a/spdy/core/spdy_frame_builder_test.cc b/spdy/core/spdy_frame_builder_test.cc index b109323..8f6a7b4 100644 --- a/spdy/core/spdy_frame_builder_test.cc +++ b/spdy/core/spdy_frame_builder_test.cc
@@ -48,8 +48,8 @@ SpdySerializedFrame frame(builder.take()); char expected[kBuilderSize]; memset(expected, ~1, kBuilderSize); - EXPECT_EQ(quiche::QuicheStringPiece(expected, kBuilderSize), - quiche::QuicheStringPiece(frame.data(), kBuilderSize)); + EXPECT_EQ(absl::string_view(expected, kBuilderSize), + absl::string_view(frame.data(), kBuilderSize)); } // Verifies that SpdyFrameBuilder::GetWritableBuffer() can be used to build a @@ -66,8 +66,8 @@ SpdySerializedFrame frame(output.Begin(), kBuilderSize, false); char expected[kBuilderSize]; memset(expected, ~1, kBuilderSize); - EXPECT_EQ(quiche::QuicheStringPiece(expected, kBuilderSize), - quiche::QuicheStringPiece(frame.data(), kBuilderSize)); + EXPECT_EQ(absl::string_view(expected, kBuilderSize), + absl::string_view(frame.data(), kBuilderSize)); } // Verifies the case that the buffer's capacity is too small.
diff --git a/spdy/core/spdy_frame_reader.cc b/spdy/core/spdy_frame_reader.cc index 253f906..a76beb3 100644 --- a/spdy/core/spdy_frame_reader.cc +++ b/spdy/core/spdy_frame_reader.cc
@@ -109,7 +109,7 @@ return true; } -bool SpdyFrameReader::ReadStringPiece16(quiche::QuicheStringPiece* result) { +bool SpdyFrameReader::ReadStringPiece16(absl::string_view* result) { // Read resultant length. uint16_t result_len; if (!ReadUInt16(&result_len)) { @@ -124,7 +124,7 @@ } // Set result. - *result = quiche::QuicheStringPiece(data_ + ofs_, result_len); + *result = absl::string_view(data_ + ofs_, result_len); // Iterate. ofs_ += result_len; @@ -132,7 +132,7 @@ return true; } -bool SpdyFrameReader::ReadStringPiece32(quiche::QuicheStringPiece* result) { +bool SpdyFrameReader::ReadStringPiece32(absl::string_view* result) { // Read resultant length. uint32_t result_len; if (!ReadUInt32(&result_len)) { @@ -147,7 +147,7 @@ } // Set result. - *result = quiche::QuicheStringPiece(data_ + ofs_, result_len); + *result = absl::string_view(data_ + ofs_, result_len); // Iterate. ofs_ += result_len;
diff --git a/spdy/core/spdy_frame_reader.h b/spdy/core/spdy_frame_reader.h index 0ed5be4..e097ee3 100644 --- a/spdy/core/spdy_frame_reader.h +++ b/spdy/core/spdy_frame_reader.h
@@ -7,8 +7,8 @@ #include <cstdint> +#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 spdy { @@ -73,7 +73,7 @@ // // Forwards the internal iterator on success. // Returns true on success, false otherwise. - bool ReadStringPiece16(quiche::QuicheStringPiece* result); + bool ReadStringPiece16(absl::string_view* result); // Reads a string prefixed with 32-bit length into the given output parameter. // @@ -82,7 +82,7 @@ // // Forwards the internal iterator on success. // Returns true on success, false otherwise. - bool ReadStringPiece32(quiche::QuicheStringPiece* result); + bool ReadStringPiece32(absl::string_view* result); // Reads a given number of bytes into the given buffer. The buffer // must be of adequate size.
diff --git a/spdy/core/spdy_frame_reader_test.cc b/spdy/core/spdy_frame_reader_test.cc index 0bbe7f6..2a79caf 100644 --- a/spdy/core/spdy_frame_reader_test.cc +++ b/spdy/core/spdy_frame_reader_test.cc
@@ -67,7 +67,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - quiche::QuicheStringPiece stringpiece_val; + absl::string_view stringpiece_val; EXPECT_TRUE(frame_reader.ReadStringPiece16(&stringpiece_val)); EXPECT_FALSE(frame_reader.IsDoneReading()); EXPECT_EQ(0, stringpiece_val.compare("Hi")); @@ -90,7 +90,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - quiche::QuicheStringPiece stringpiece_val; + absl::string_view stringpiece_val; EXPECT_TRUE(frame_reader.ReadStringPiece32(&stringpiece_val)); EXPECT_FALSE(frame_reader.IsDoneReading()); EXPECT_EQ(0, stringpiece_val.compare("foo")); @@ -142,7 +142,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - quiche::QuicheStringPiece stringpiece_val; + absl::string_view stringpiece_val; EXPECT_FALSE(frame_reader.ReadStringPiece16(&stringpiece_val)); // Also make sure that trying to read a uint16_t, which technically could @@ -161,7 +161,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - quiche::QuicheStringPiece stringpiece_val; + absl::string_view stringpiece_val; EXPECT_FALSE(frame_reader.ReadStringPiece16(&stringpiece_val)); // Also make sure that trying to read a uint16_t, which technically could @@ -181,7 +181,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - quiche::QuicheStringPiece stringpiece_val; + absl::string_view stringpiece_val; EXPECT_FALSE(frame_reader.ReadStringPiece32(&stringpiece_val)); // Also make sure that trying to read a uint16_t, which technically could @@ -200,7 +200,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - quiche::QuicheStringPiece stringpiece_val; + absl::string_view stringpiece_val; EXPECT_FALSE(frame_reader.ReadStringPiece32(&stringpiece_val)); // Also make sure that trying to read a uint16_t, which technically could @@ -222,12 +222,12 @@ char dest1[3] = {}; EXPECT_TRUE(frame_reader.ReadBytes(&dest1, QUICHE_ARRAYSIZE(dest1))); EXPECT_FALSE(frame_reader.IsDoneReading()); - EXPECT_EQ("foo", quiche::QuicheStringPiece(dest1, QUICHE_ARRAYSIZE(dest1))); + EXPECT_EQ("foo", absl::string_view(dest1, QUICHE_ARRAYSIZE(dest1))); char dest2[2] = {}; EXPECT_TRUE(frame_reader.ReadBytes(&dest2, QUICHE_ARRAYSIZE(dest2))); EXPECT_TRUE(frame_reader.IsDoneReading()); - EXPECT_EQ("Hi", quiche::QuicheStringPiece(dest2, QUICHE_ARRAYSIZE(dest2))); + EXPECT_EQ("Hi", absl::string_view(dest2, QUICHE_ARRAYSIZE(dest2))); } TEST(SpdyFrameReaderTest, ReadBytesWithBufferTooSmall) {
diff --git a/spdy/core/spdy_framer.h b/spdy/core/spdy_framer.h index f16e3bd..99c2037 100644 --- a/spdy/core/spdy_framer.h +++ b/spdy/core/spdy_framer.h
@@ -13,8 +13,8 @@ #include <string> #include <utility> +#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" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_encoder.h" #include "net/third_party/quiche/src/spdy/core/spdy_alt_svc_wire_format.h" #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h"
diff --git a/spdy/core/spdy_framer_test.cc b/spdy/core/spdy_framer_test.cc index ee05143..864ea7d 100644 --- a/spdy/core/spdy_framer_test.cc +++ b/spdy/core/spdy_framer_test.cc
@@ -287,7 +287,7 @@ SPDY_VLOG(1) << "OnStreamFrameData(" << stream_id << ", data, " << len << ", " << ") data:\n" - << SpdyHexDump(quiche::QuicheStringPiece(data, len)); + << SpdyHexDump(absl::string_view(data, len)); EXPECT_EQ(header_stream_id_, stream_id); data_bytes_ += len; @@ -403,7 +403,7 @@ } void OnAltSvc(SpdyStreamId stream_id, - quiche::QuicheStringPiece origin, + absl::string_view origin, const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) override { SPDY_VLOG(1) << "OnAltSvc(" << stream_id << ", \"" << origin @@ -1125,7 +1125,7 @@ control_frame.size()); EXPECT_THAT(visitor.headers_, testing::ElementsAre(testing::Pair( - "name", quiche::QuicheStringPiece(value)))); + "name", absl::string_view(value)))); } TEST_P(SpdyFramerTest, CompressEmptyHeaders) { @@ -1315,7 +1315,7 @@ const char bytes[] = "this is a test test test test test!"; SpdyDataIR data_ir(/* stream_id = */ 1, - quiche::QuicheStringPiece(bytes, QUICHE_ARRAYSIZE(bytes))); + absl::string_view(bytes, QUICHE_ARRAYSIZE(bytes))); data_ir.set_fin(true); SpdySerializedFrame send_frame(framer_.SerializeData(data_ir)); @@ -4298,8 +4298,8 @@ SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector; altsvc_vector.push_back(altsvc1); altsvc_vector.push_back(altsvc2); - EXPECT_CALL(visitor, OnAltSvc(kStreamId, quiche::QuicheStringPiece("o_r|g!n"), - altsvc_vector)); + EXPECT_CALL(visitor, + OnAltSvc(kStreamId, absl::string_view("o_r|g!n"), altsvc_vector)); SpdyAltSvcIR altsvc_ir(kStreamId); altsvc_ir.set_origin("o_r|g!n"); @@ -4333,8 +4333,8 @@ SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector; altsvc_vector.push_back(altsvc1); altsvc_vector.push_back(altsvc2); - EXPECT_CALL(visitor, OnAltSvc(kStreamId, quiche::QuicheStringPiece(""), - altsvc_vector)); + EXPECT_CALL(visitor, + OnAltSvc(kStreamId, absl::string_view(""), altsvc_vector)); SpdyAltSvcIR altsvc_ir(kStreamId); altsvc_ir.add_altsvc(altsvc1); @@ -4770,8 +4770,7 @@ SpdyFramer framer(SpdyFramer::DISABLE_COMPRESSION); const char bytes[] = "this is a very short data frame"; - SpdyDataIR data_ir(1, - quiche::QuicheStringPiece(bytes, QUICHE_ARRAYSIZE(bytes))); + SpdyDataIR data_ir(1, absl::string_view(bytes, QUICHE_ARRAYSIZE(bytes))); CheckFrameAndIRSize(&data_ir, &framer, &output_); SpdyRstStreamIR rst_ir(/* stream_id = */ 1, ERROR_CODE_PROTOCOL_ERROR);
diff --git a/spdy/core/spdy_header_block.cc b/spdy/core/spdy_header_block.cc index d7e3faa..ebb7918 100644 --- a/spdy/core/spdy_header_block.cc +++ b/spdy/core/spdy_header_block.cc
@@ -27,21 +27,20 @@ const char kCookieKey[] = "cookie"; const char kNullSeparator = 0; -quiche::QuicheStringPiece SeparatorForKey(quiche::QuicheStringPiece key) { +absl::string_view SeparatorForKey(absl::string_view key) { if (key == kCookieKey) { - static quiche::QuicheStringPiece cookie_separator = "; "; + static absl::string_view cookie_separator = "; "; return cookie_separator; } else { - return quiche::QuicheStringPiece(&kNullSeparator, 1); + return absl::string_view(&kNullSeparator, 1); } } } // namespace -SpdyHeaderBlock::HeaderValue::HeaderValue( - SpdyHeaderStorage* storage, - quiche::QuicheStringPiece key, - quiche::QuicheStringPiece initial_value) +SpdyHeaderBlock::HeaderValue::HeaderValue(SpdyHeaderStorage* storage, + absl::string_view key, + absl::string_view initial_value) : storage_(storage), fragments_({initial_value}), pair_({key, {}}), @@ -71,10 +70,9 @@ SpdyHeaderBlock::HeaderValue::~HeaderValue() = default; -quiche::QuicheStringPiece SpdyHeaderBlock::HeaderValue::ConsolidatedValue() - const { +absl::string_view SpdyHeaderBlock::HeaderValue::ConsolidatedValue() const { if (fragments_.empty()) { - return quiche::QuicheStringPiece(); + return absl::string_view(); } if (fragments_.size() > 1) { fragments_ = { @@ -83,12 +81,12 @@ return fragments_[0]; } -void SpdyHeaderBlock::HeaderValue::Append(quiche::QuicheStringPiece fragment) { +void SpdyHeaderBlock::HeaderValue::Append(absl::string_view fragment) { size_ += (fragment.size() + separator_size_); fragments_.push_back(fragment); } -const std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece>& +const std::pair<absl::string_view, absl::string_view>& SpdyHeaderBlock::HeaderValue::as_pair() const { pair_.second = ConsolidatedValue(); return pair_; @@ -103,7 +101,7 @@ SpdyHeaderBlock::ValueProxy::ValueProxy( SpdyHeaderBlock* block, SpdyHeaderBlock::MapType::iterator lookup_result, - const quiche::QuicheStringPiece key, + const absl::string_view key, size_t* spdy_header_block_value_size) : block_(block), lookup_result_(lookup_result), @@ -142,7 +140,7 @@ } SpdyHeaderBlock::ValueProxy& SpdyHeaderBlock::ValueProxy::operator=( - quiche::QuicheStringPiece value) { + absl::string_view value) { *spdy_header_block_value_size_ += value.size(); SpdyHeaderStorage* storage = &block_->storage_; if (lookup_result_ == block_->map_.end()) { @@ -160,8 +158,7 @@ return *this; } -bool SpdyHeaderBlock::ValueProxy::operator==( - quiche::QuicheStringPiece value) const { +bool SpdyHeaderBlock::ValueProxy::operator==(absl::string_view value) const { if (lookup_result_ == block_->map_.end()) { return false; } else { @@ -232,7 +229,7 @@ return output; } -void SpdyHeaderBlock::erase(quiche::QuicheStringPiece key) { +void SpdyHeaderBlock::erase(absl::string_view key) { auto iter = map_.find(key); if (iter != map_.end()) { SPDY_DVLOG(1) << "Erasing header with name: " << key; @@ -268,13 +265,13 @@ } SpdyHeaderBlock::ValueProxy SpdyHeaderBlock::operator[]( - const quiche::QuicheStringPiece key) { + const absl::string_view key) { SPDY_DVLOG(2) << "Operator[] saw key: " << key; - quiche::QuicheStringPiece out_key; + absl::string_view out_key; auto iter = map_.find(key); if (iter == map_.end()) { // We write the key first, to assure that the ValueProxy has a - // reference to a valid QuicheStringPiece in its operator=. + // reference to a valid absl::string_view in its operator=. out_key = WriteKey(key); SPDY_DVLOG(2) << "Key written as: " << std::hex << static_cast<const void*>(key.data()) << ", " << std::dec @@ -285,9 +282,8 @@ return ValueProxy(this, iter, out_key, &value_size_); } -void SpdyHeaderBlock::AppendValueOrAddHeader( - const quiche::QuicheStringPiece key, - const quiche::QuicheStringPiece value) { +void SpdyHeaderBlock::AppendValueOrAddHeader(const absl::string_view key, + const absl::string_view value) { value_size_ += value.size(); auto iter = map_.find(key); @@ -309,15 +305,14 @@ return SpdyEstimateMemoryUsage(storage_); } -void SpdyHeaderBlock::AppendHeader(const quiche::QuicheStringPiece key, - const quiche::QuicheStringPiece value) { +void SpdyHeaderBlock::AppendHeader(const absl::string_view key, + const absl::string_view value) { auto backed_key = WriteKey(key); map_.emplace(std::make_pair( backed_key, HeaderValue(&storage_, backed_key, storage_.Write(value)))); } -quiche::QuicheStringPiece SpdyHeaderBlock::WriteKey( - const quiche::QuicheStringPiece key) { +absl::string_view SpdyHeaderBlock::WriteKey(const absl::string_view key) { key_size_ += key.size(); return storage_.Write(key); }
diff --git a/spdy/core/spdy_header_block.h b/spdy/core/spdy_header_block.h index 2348551..1faf34d 100644 --- a/spdy/core/spdy_header_block.h +++ b/spdy/core/spdy_header_block.h
@@ -13,8 +13,8 @@ #include <utility> #include <vector> +#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" #include "net/third_party/quiche/src/spdy/core/spdy_header_storage.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_containers.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_macros.h" @@ -39,9 +39,9 @@ // names and values. This data structure preserves insertion order. // // Under the hood, this data structure uses large, contiguous blocks of memory -// to store names and values. Lookups may be performed with QuicheStringPiece -// keys, and values are returned as QuicheStringPieces (via ValueProxy, below). -// Value QuicheStringPieces are valid as long as the SpdyHeaderBlock exists; +// to store names and values. Lookups may be performed with absl::string_view +// keys, and values are returned as absl::string_views (via ValueProxy, below). +// Value absl::string_views are valid as long as the SpdyHeaderBlock exists; // allocated memory is never freed until SpdyHeaderBlock's destruction. // // This implementation does not make much of an effort to minimize wasted space. @@ -53,8 +53,8 @@ class QUICHE_EXPORT_PRIVATE HeaderValue { public: HeaderValue(SpdyHeaderStorage* storage, - quiche::QuicheStringPiece key, - quiche::QuicheStringPiece initial_value); + absl::string_view key, + absl::string_view initial_value); // Moves are allowed. HeaderValue(HeaderValue&& other); @@ -69,11 +69,10 @@ ~HeaderValue(); // Consumes at most |fragment.size()| bytes of memory. - void Append(quiche::QuicheStringPiece fragment); + void Append(absl::string_view fragment); - quiche::QuicheStringPiece value() const { return as_pair().second; } - const std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece>& - as_pair() const; + absl::string_view value() const { return as_pair().second; } + const std::pair<absl::string_view, absl::string_view>& as_pair() const; // Size estimate including separators. Used when keys are erased from // SpdyHeaderBlock. @@ -82,37 +81,34 @@ private: // May allocate a large contiguous region of memory to hold the concatenated // fragments and separators. - quiche::QuicheStringPiece ConsolidatedValue() const; + absl::string_view ConsolidatedValue() const; mutable SpdyHeaderStorage* storage_; - mutable std::vector<quiche::QuicheStringPiece> fragments_; + mutable std::vector<absl::string_view> fragments_; // The first element is the key; the second is the consolidated value. - mutable std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece> - pair_; + mutable std::pair<absl::string_view, absl::string_view> pair_; size_t size_ = 0; size_t separator_size_ = 0; }; - typedef SpdyLinkedHashMap<quiche::QuicheStringPiece, + typedef SpdyLinkedHashMap<absl::string_view, HeaderValue, SpdyStringPieceCaseHash, SpdyStringPieceCaseEq> MapType; public: - typedef std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece> - value_type; + typedef std::pair<absl::string_view, absl::string_view> value_type; - // Provides iteration over a sequence of std::pair<QuicheStringPiece, - // QuicheStringPiece>, even though the underlying MapType::value_type is + // Provides iteration over a sequence of std::pair<absl::string_view, + // absl::string_view>, even though the underlying MapType::value_type is // different. Dereferencing the iterator will result in memory allocation for // multi-value headers. class QUICHE_EXPORT_PRIVATE iterator { public: // The following type definitions fulfill the requirements for iterator // implementations. - typedef std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece> - value_type; + typedef std::pair<absl::string_view, absl::string_view> value_type; typedef value_type& reference; typedef value_type* pointer; typedef std::forward_iterator_tag iterator_category; @@ -184,13 +180,11 @@ const_iterator end() const { return wrap_const_iterator(map_.end()); } bool empty() const { return map_.empty(); } size_t size() const { return map_.size(); } - iterator find(quiche::QuicheStringPiece key) { - return wrap_iterator(map_.find(key)); - } - const_iterator find(quiche::QuicheStringPiece key) const { + iterator find(absl::string_view key) { return wrap_iterator(map_.find(key)); } + const_iterator find(absl::string_view key) const { return wrap_const_iterator(map_.find(key)); } - void erase(quiche::QuicheStringPiece key); + void erase(absl::string_view key); // Clears both our MapType member and the memory used to hold headers. void clear(); @@ -205,8 +199,8 @@ // existing header value, NUL ("\0") separated unless the key is cookie, in // which case the separator is "; ". // If there is no such key, a new header with the key and value is added. - void AppendValueOrAddHeader(const quiche::QuicheStringPiece key, - const quiche::QuicheStringPiece value); + void AppendValueOrAddHeader(const absl::string_view key, + const absl::string_view value); // This object provides automatic conversions that allow SpdyHeaderBlock to be // nearly a drop-in replacement for @@ -225,10 +219,10 @@ ValueProxy& operator=(const ValueProxy& other) = delete; // Assignment modifies the underlying SpdyHeaderBlock. - ValueProxy& operator=(quiche::QuicheStringPiece value); + ValueProxy& operator=(absl::string_view value); - // Provides easy comparison against QuicheStringPiece. - bool operator==(quiche::QuicheStringPiece value) const; + // Provides easy comparison against absl::string_view. + bool operator==(absl::string_view value) const; std::string as_string() const; @@ -238,19 +232,18 @@ ValueProxy(SpdyHeaderBlock* block, SpdyHeaderBlock::MapType::iterator lookup_result, - const quiche::QuicheStringPiece key, + const absl::string_view key, size_t* spdy_header_block_value_size); SpdyHeaderBlock* block_; SpdyHeaderBlock::MapType::iterator lookup_result_; - quiche::QuicheStringPiece key_; + absl::string_view key_; size_t* spdy_header_block_value_size_; bool valid_; }; // Allows either lookup or mutation of the value associated with a key. - SPDY_MUST_USE_RESULT ValueProxy - operator[](const quiche::QuicheStringPiece key); + SPDY_MUST_USE_RESULT ValueProxy operator[](const absl::string_view key); // Returns the estimate of dynamically allocated memory in bytes. size_t EstimateMemoryUsage() const; @@ -285,12 +278,11 @@ #endif // SPDY_HEADER_DEBUG } - void AppendHeader(const quiche::QuicheStringPiece key, - const quiche::QuicheStringPiece value); - quiche::QuicheStringPiece WriteKey(const quiche::QuicheStringPiece key); + void AppendHeader(const absl::string_view key, const absl::string_view value); + absl::string_view WriteKey(const absl::string_view key); size_t bytes_allocated() const; - // QuicheStringPieces held by |map_| point to memory owned by |storage_|. + // absl::string_views held by |map_| point to memory owned by |storage_|. MapType map_; SpdyHeaderStorage storage_;
diff --git a/spdy/core/spdy_header_block_test.cc b/spdy/core/spdy_header_block_test.cc index b670c2a..a8dbe01 100644 --- a/spdy/core/spdy_header_block_test.cc +++ b/spdy/core/spdy_header_block_test.cc
@@ -17,14 +17,13 @@ class ValueProxyPeer { public: - static quiche::QuicheStringPiece key(SpdyHeaderBlock::ValueProxy* p) { + static absl::string_view key(SpdyHeaderBlock::ValueProxy* p) { return p->key_; } }; -std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece> Pair( - quiche::QuicheStringPiece k, - quiche::QuicheStringPiece v) { +std::pair<absl::string_view, absl::string_view> Pair(absl::string_view k, + absl::string_view v) { return std::make_pair(k, v); } @@ -42,19 +41,19 @@ TEST(SpdyHeaderBlockTest, KeyMemoryReclaimedOnLookup) { SpdyHeaderBlock block; - quiche::QuicheStringPiece copied_key1; + absl::string_view copied_key1; { auto proxy1 = block["some key name"]; copied_key1 = ValueProxyPeer::key(&proxy1); } - quiche::QuicheStringPiece copied_key2; + absl::string_view copied_key2; { auto proxy2 = block["some other key name"]; copied_key2 = ValueProxyPeer::key(&proxy2); } // Because proxy1 was never used to modify the block, the memory used for the // key could be reclaimed and used for the second call to operator[]. - // Therefore, we expect the pointers of the two QuicheStringPieces to be + // Therefore, we expect the pointers of the two absl::string_views to be // equal. EXPECT_EQ(copied_key1.data(), copied_key2.data()); @@ -199,19 +198,19 @@ block.AppendValueOrAddHeader("foo", "bar"); const auto& val = block["foo"]; const char expected[] = "foo\0bar"; - EXPECT_TRUE(quiche::QuicheStringPiece(expected, 7) == val); - EXPECT_TRUE(val == quiche::QuicheStringPiece(expected, 7)); - EXPECT_FALSE(quiche::QuicheStringPiece(expected, 3) == val); - EXPECT_FALSE(val == quiche::QuicheStringPiece(expected, 3)); + EXPECT_TRUE(absl::string_view(expected, 7) == val); + EXPECT_TRUE(val == absl::string_view(expected, 7)); + EXPECT_FALSE(absl::string_view(expected, 3) == val); + EXPECT_FALSE(val == absl::string_view(expected, 3)); const char not_expected[] = "foo\0barextra"; - EXPECT_FALSE(quiche::QuicheStringPiece(not_expected, 12) == val); - EXPECT_FALSE(val == quiche::QuicheStringPiece(not_expected, 12)); + EXPECT_FALSE(absl::string_view(not_expected, 12) == val); + EXPECT_FALSE(val == absl::string_view(not_expected, 12)); const auto& val2 = block["foo2"]; - EXPECT_FALSE(quiche::QuicheStringPiece(expected, 7) == val2); - EXPECT_FALSE(val2 == quiche::QuicheStringPiece(expected, 7)); - EXPECT_FALSE(quiche::QuicheStringPiece("") == val2); - EXPECT_FALSE(val2 == quiche::QuicheStringPiece("")); + EXPECT_FALSE(absl::string_view(expected, 7) == val2); + EXPECT_FALSE(val2 == absl::string_view(expected, 7)); + EXPECT_FALSE(absl::string_view("") == val2); + EXPECT_FALSE(val2 == absl::string_view("")); } // This test demonstrates that the SpdyHeaderBlock data structure does not place
diff --git a/spdy/core/spdy_header_storage.cc b/spdy/core/spdy_header_storage.cc index 90493e1..29ed0a4 100644 --- a/spdy/core/spdy_header_storage.cc +++ b/spdy/core/spdy_header_storage.cc
@@ -14,34 +14,33 @@ SpdyHeaderStorage::SpdyHeaderStorage() : arena_(kDefaultStorageBlockSize) {} -quiche::QuicheStringPiece SpdyHeaderStorage::Write( - const quiche::QuicheStringPiece s) { - return quiche::QuicheStringPiece(arena_.Memdup(s.data(), s.size()), s.size()); +absl::string_view SpdyHeaderStorage::Write(const absl::string_view s) { + return absl::string_view(arena_.Memdup(s.data(), s.size()), s.size()); } -void SpdyHeaderStorage::Rewind(const quiche::QuicheStringPiece s) { +void SpdyHeaderStorage::Rewind(const absl::string_view s) { arena_.Free(const_cast<char*>(s.data()), s.size()); } -quiche::QuicheStringPiece SpdyHeaderStorage::WriteFragments( - const std::vector<quiche::QuicheStringPiece>& fragments, - quiche::QuicheStringPiece separator) { +absl::string_view SpdyHeaderStorage::WriteFragments( + const std::vector<absl::string_view>& fragments, + absl::string_view separator) { if (fragments.empty()) { - return quiche::QuicheStringPiece(); + return absl::string_view(); } size_t total_size = separator.size() * (fragments.size() - 1); - for (const quiche::QuicheStringPiece& fragment : fragments) { + for (const absl::string_view& fragment : fragments) { total_size += fragment.size(); } char* dst = arena_.Alloc(total_size); size_t written = Join(dst, fragments, separator); DCHECK_EQ(written, total_size); - return quiche::QuicheStringPiece(dst, total_size); + return absl::string_view(dst, total_size); } size_t Join(char* dst, - const std::vector<quiche::QuicheStringPiece>& fragments, - quiche::QuicheStringPiece separator) { + const std::vector<absl::string_view>& fragments, + absl::string_view separator) { if (fragments.empty()) { return 0; }
diff --git a/spdy/core/spdy_header_storage.h b/spdy/core/spdy_header_storage.h index aace3c0..4e5a6ab 100644 --- a/spdy/core/spdy_header_storage.h +++ b/spdy/core/spdy_header_storage.h
@@ -1,15 +1,15 @@ #ifndef QUICHE_SPDY_CORE_SPDY_HEADER_STORAGE_H_ #define QUICHE_SPDY_CORE_SPDY_HEADER_STORAGE_H_ +#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" #include "net/third_party/quiche/src/spdy/core/spdy_simple_arena.h" namespace spdy { -// This class provides a backing store for QuicheStringPieces. It previously +// This class provides a backing store for absl::string_views. It previously // used custom allocation logic, but now uses an UnsafeArena instead. It has the -// property that QuicheStringPieces that refer to data in SpdyHeaderStorage are +// property that absl::string_views that refer to data in SpdyHeaderStorage are // never invalidated until the SpdyHeaderStorage is deleted or Clear() is // called. // @@ -26,20 +26,20 @@ SpdyHeaderStorage(SpdyHeaderStorage&& other) = default; SpdyHeaderStorage& operator=(SpdyHeaderStorage&& other) = default; - quiche::QuicheStringPiece Write(quiche::QuicheStringPiece s); + absl::string_view Write(absl::string_view s); // If |s| points to the most recent allocation from arena_, the arena will // reclaim the memory. Otherwise, this method is a no-op. - void Rewind(quiche::QuicheStringPiece s); + void Rewind(absl::string_view s); void Clear() { arena_.Reset(); } // Given a list of fragments and a separator, writes the fragments joined by - // the separator to a contiguous region of memory. Returns a QuicheStringPiece + // the separator to a contiguous region of memory. Returns a absl::string_view // pointing to the region of memory. - quiche::QuicheStringPiece WriteFragments( - const std::vector<quiche::QuicheStringPiece>& fragments, - quiche::QuicheStringPiece separator); + absl::string_view WriteFragments( + const std::vector<absl::string_view>& fragments, + absl::string_view separator); size_t bytes_allocated() const { return arena_.status().bytes_allocated(); } @@ -53,8 +53,8 @@ // enough to hold the result. Returns the number of bytes written. QUICHE_EXPORT_PRIVATE size_t Join(char* dst, - const std::vector<quiche::QuicheStringPiece>& fragments, - quiche::QuicheStringPiece separator); + const std::vector<absl::string_view>& fragments, + absl::string_view separator); } // namespace spdy
diff --git a/spdy/core/spdy_header_storage_test.cc b/spdy/core/spdy_header_storage_test.cc index 71af6be..af8cd06 100644 --- a/spdy/core/spdy_header_storage_test.cc +++ b/spdy/core/spdy_header_storage_test.cc
@@ -6,29 +6,29 @@ namespace test { TEST(JoinTest, JoinEmpty) { - std::vector<quiche::QuicheStringPiece> empty; - quiche::QuicheStringPiece separator = ", "; + std::vector<absl::string_view> empty; + absl::string_view separator = ", "; char buf[10] = ""; size_t written = Join(buf, empty, separator); EXPECT_EQ(0u, written); } TEST(JoinTest, JoinOne) { - std::vector<quiche::QuicheStringPiece> v = {"one"}; - quiche::QuicheStringPiece separator = ", "; + std::vector<absl::string_view> v = {"one"}; + absl::string_view separator = ", "; char buf[15]; size_t written = Join(buf, v, separator); EXPECT_EQ(3u, written); - EXPECT_EQ("one", quiche::QuicheStringPiece(buf, written)); + EXPECT_EQ("one", absl::string_view(buf, written)); } TEST(JoinTest, JoinMultiple) { - std::vector<quiche::QuicheStringPiece> v = {"one", "two", "three"}; - quiche::QuicheStringPiece separator = ", "; + std::vector<absl::string_view> v = {"one", "two", "three"}; + absl::string_view separator = ", "; char buf[15]; size_t written = Join(buf, v, separator); EXPECT_EQ(15u, written); - EXPECT_EQ("one, two, three", quiche::QuicheStringPiece(buf, written)); + EXPECT_EQ("one, two, three", absl::string_view(buf, written)); } } // namespace test
diff --git a/spdy/core/spdy_headers_handler_interface.h b/spdy/core/spdy_headers_handler_interface.h index 8709977..39bda07 100644 --- a/spdy/core/spdy_headers_handler_interface.h +++ b/spdy/core/spdy_headers_handler_interface.h
@@ -7,8 +7,8 @@ #include <stddef.h> +#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 spdy { @@ -25,8 +25,7 @@ // A callback method which notifies on a header key value pair. Multiple // values for a given key will be emitted as multiple calls to OnHeader. - virtual void OnHeader(quiche::QuicheStringPiece key, - quiche::QuicheStringPiece value) = 0; + virtual void OnHeader(absl::string_view key, absl::string_view value) = 0; // A callback method which notifies when the parser finishes handling a // header block (i.e. the containing frame has the END_HEADERS flag set).
diff --git a/spdy/core/spdy_no_op_visitor.h b/spdy/core/spdy_no_op_visitor.h index 93a3235..26bab9c 100644 --- a/spdy/core/spdy_no_op_visitor.h +++ b/spdy/core/spdy_no_op_visitor.h
@@ -11,7 +11,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/spdy/core/http2_frame_decoder_adapter.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" @@ -61,7 +61,7 @@ bool /*end*/) override {} void OnContinuation(SpdyStreamId /*stream_id*/, bool /*end*/) override {} void OnAltSvc(SpdyStreamId /*stream_id*/, - quiche::QuicheStringPiece /*origin*/, + absl::string_view /*origin*/, const SpdyAltSvcWireFormat::AlternativeServiceVector& /*altsvc_vector*/) override {} void OnPriority(SpdyStreamId /*stream_id*/, @@ -82,8 +82,8 @@ // SpdyHeadersHandlerInterface methods: void OnHeaderBlockStart() override {} - void OnHeader(quiche::QuicheStringPiece /*key*/, - quiche::QuicheStringPiece /*value*/) override {} + void OnHeader(absl::string_view /*key*/, + absl::string_view /*value*/) override {} void OnHeaderBlockEnd(size_t /* uncompressed_header_bytes */, size_t /* compressed_header_bytes */) override {} };
diff --git a/spdy/core/spdy_pinnable_buffer_piece.h b/spdy/core/spdy_pinnable_buffer_piece.h index fe9639f..2822410 100644 --- a/spdy/core/spdy_pinnable_buffer_piece.h +++ b/spdy/core/spdy_pinnable_buffer_piece.h
@@ -9,8 +9,8 @@ #include <memory> +#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 spdy { @@ -27,8 +27,8 @@ const char* buffer() const { return buffer_; } - explicit operator quiche::QuicheStringPiece() const { - return quiche::QuicheStringPiece(buffer_, length_); + explicit operator absl::string_view() const { + return absl::string_view(buffer_, length_); } // Allocates and copies the buffer to internal storage.
diff --git a/spdy/core/spdy_pinnable_buffer_piece_test.cc b/spdy/core/spdy_pinnable_buffer_piece_test.cc index b30a7c0..42329d7 100644 --- a/spdy/core/spdy_pinnable_buffer_piece_test.cc +++ b/spdy/core/spdy_pinnable_buffer_piece_test.cc
@@ -31,16 +31,14 @@ EXPECT_TRUE(reader.ReadN(6, &piece)); // Piece points to underlying prefix storage. - EXPECT_EQ(quiche::QuicheStringPiece("foobar"), - quiche::QuicheStringPiece(piece)); + EXPECT_EQ(absl::string_view("foobar"), absl::string_view(piece)); EXPECT_FALSE(piece.IsPinned()); EXPECT_EQ(prefix_.data(), piece.buffer()); piece.Pin(); // Piece now points to allocated storage. - EXPECT_EQ(quiche::QuicheStringPiece("foobar"), - quiche::QuicheStringPiece(piece)); + EXPECT_EQ(absl::string_view("foobar"), absl::string_view(piece)); EXPECT_TRUE(piece.IsPinned()); EXPECT_NE(prefix_.data(), piece.buffer()); @@ -58,24 +56,22 @@ piece1.Pin(); - EXPECT_EQ(quiche::QuicheStringPiece("foob"), - quiche::QuicheStringPiece(piece1)); + EXPECT_EQ(absl::string_view("foob"), absl::string_view(piece1)); EXPECT_TRUE(piece1.IsPinned()); - EXPECT_EQ(quiche::QuicheStringPiece("ar"), quiche::QuicheStringPiece(piece2)); + EXPECT_EQ(absl::string_view("ar"), absl::string_view(piece2)); EXPECT_FALSE(piece2.IsPinned()); piece1.Swap(&piece2); - EXPECT_EQ(quiche::QuicheStringPiece("ar"), quiche::QuicheStringPiece(piece1)); + EXPECT_EQ(absl::string_view("ar"), absl::string_view(piece1)); EXPECT_FALSE(piece1.IsPinned()); - EXPECT_EQ(quiche::QuicheStringPiece("foob"), - quiche::QuicheStringPiece(piece2)); + EXPECT_EQ(absl::string_view("foob"), absl::string_view(piece2)); EXPECT_TRUE(piece2.IsPinned()); SpdyPinnableBufferPiece empty; piece2.Swap(&empty); - EXPECT_EQ(quiche::QuicheStringPiece(""), quiche::QuicheStringPiece(piece2)); + EXPECT_EQ(absl::string_view(""), absl::string_view(piece2)); EXPECT_FALSE(piece2.IsPinned()); }
diff --git a/spdy/core/spdy_prefixed_buffer_reader_test.cc b/spdy/core/spdy_prefixed_buffer_reader_test.cc index d48fde1..8355956 100644 --- a/spdy/core/spdy_prefixed_buffer_reader_test.cc +++ b/spdy/core/spdy_prefixed_buffer_reader_test.cc
@@ -6,7 +6,7 @@ #include <string> -#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 { @@ -46,8 +46,7 @@ EXPECT_FALSE(reader.ReadN(10, &piece)); // Not enough buffer. EXPECT_TRUE(reader.ReadN(6, &piece)); EXPECT_FALSE(piece.IsPinned()); - EXPECT_EQ(quiche::QuicheStringPiece("foobar"), - quiche::QuicheStringPiece(piece)); + EXPECT_EQ(absl::string_view("foobar"), absl::string_view(piece)); EXPECT_EQ(0u, reader.Available()); } @@ -70,8 +69,7 @@ EXPECT_FALSE(reader.ReadN(10, &piece)); // Not enough buffer. EXPECT_TRUE(reader.ReadN(6, &piece)); EXPECT_FALSE(piece.IsPinned()); - EXPECT_EQ(quiche::QuicheStringPiece("foobar"), - quiche::QuicheStringPiece(piece)); + EXPECT_EQ(absl::string_view("foobar"), absl::string_view(piece)); EXPECT_EQ(0u, reader.Available()); } @@ -94,8 +92,7 @@ EXPECT_FALSE(reader.ReadN(10, &piece)); // Not enough buffer. EXPECT_TRUE(reader.ReadN(6, &piece)); EXPECT_TRUE(piece.IsPinned()); - EXPECT_EQ(quiche::QuicheStringPiece("foobar"), - quiche::QuicheStringPiece(piece)); + EXPECT_EQ(absl::string_view("foobar"), absl::string_view(piece)); EXPECT_EQ(0u, reader.Available()); } @@ -115,12 +112,12 @@ EXPECT_EQ(6u, reader.Available()); EXPECT_TRUE(reader.ReadN(3, &piece)); - EXPECT_EQ(quiche::QuicheStringPiece("fhi"), quiche::QuicheStringPiece(piece)); + EXPECT_EQ(absl::string_view("fhi"), absl::string_view(piece)); EXPECT_TRUE(piece.IsPinned()); EXPECT_EQ(3u, reader.Available()); EXPECT_TRUE(reader.ReadN(2, &piece)); - EXPECT_EQ(quiche::QuicheStringPiece("jk"), quiche::QuicheStringPiece(piece)); + EXPECT_EQ(absl::string_view("jk"), absl::string_view(piece)); EXPECT_FALSE(piece.IsPinned()); EXPECT_EQ(1u, reader.Available());
diff --git a/spdy/core/spdy_protocol.cc b/spdy/core/spdy_protocol.cc index a4a72d6..53901ab 100644 --- a/spdy/core/spdy_protocol.cc +++ b/spdy/core/spdy_protocol.cc
@@ -281,7 +281,7 @@ SpdyFrameWithHeaderBlockIR::~SpdyFrameWithHeaderBlockIR() = default; -SpdyDataIR::SpdyDataIR(SpdyStreamId stream_id, quiche::QuicheStringPiece data) +SpdyDataIR::SpdyDataIR(SpdyStreamId stream_id, absl::string_view data) : SpdyFrameWithFinIR(stream_id), data_(nullptr), data_len_(0), @@ -291,7 +291,7 @@ } SpdyDataIR::SpdyDataIR(SpdyStreamId stream_id, const char* data) - : SpdyDataIR(stream_id, quiche::QuicheStringPiece(data)) {} + : SpdyDataIR(stream_id, absl::string_view(data)) {} SpdyDataIR::SpdyDataIR(SpdyStreamId stream_id, std::string data) : SpdyFrameWithFinIR(stream_id), @@ -377,7 +377,7 @@ SpdyGoAwayIR::SpdyGoAwayIR(SpdyStreamId last_good_stream_id, SpdyErrorCode error_code, - quiche::QuicheStringPiece description) + absl::string_view description) : description_(description) { set_last_good_stream_id(last_good_stream_id); set_error_code(error_code); @@ -388,7 +388,7 @@ const char* description) : SpdyGoAwayIR(last_good_stream_id, error_code, - quiche::QuicheStringPiece(description)) {} + absl::string_view(description)) {} SpdyGoAwayIR::SpdyGoAwayIR(SpdyStreamId last_good_stream_id, SpdyErrorCode error_code,
diff --git a/spdy/core/spdy_protocol.h b/spdy/core/spdy_protocol.h index 0bf8bb9..4c9c79a 100644 --- a/spdy/core/spdy_protocol.h +++ b/spdy/core/spdy_protocol.h
@@ -19,8 +19,8 @@ #include <string> #include <utility> +#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" #include "net/third_party/quiche/src/spdy/core/spdy_alt_svc_wire_format.h" #include "net/third_party/quiche/src/spdy/core/spdy_bitmasks.h" #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" @@ -497,8 +497,7 @@ // Deep copy. header_block_ = std::move(header_block); } - void SetHeader(quiche::QuicheStringPiece name, - quiche::QuicheStringPiece value) { + void SetHeader(absl::string_view name, absl::string_view value) { header_block_[name] = value; } @@ -516,7 +515,7 @@ class QUICHE_EXPORT_PRIVATE SpdyDataIR : public SpdyFrameWithFinIR { public: // Performs a deep copy on data. - SpdyDataIR(SpdyStreamId stream_id, quiche::QuicheStringPiece data); + SpdyDataIR(SpdyStreamId stream_id, absl::string_view data); // Performs a deep copy on data. SpdyDataIR(SpdyStreamId stream_id, const char* data); @@ -547,14 +546,14 @@ } // Deep-copy of data (keep private copy). - void SetDataDeep(quiche::QuicheStringPiece data) { + void SetDataDeep(absl::string_view data) { data_store_ = std::make_unique<std::string>(data.data(), data.size()); data_ = data_store_->data(); data_len_ = data.size(); } // Shallow-copy of data (do not keep private copy). - void SetDataShallow(quiche::QuicheStringPiece data) { + void SetDataShallow(absl::string_view data) { data_store_.reset(); data_ = data.data(); data_len_ = data.size(); @@ -660,7 +659,7 @@ // this SpdyGoAwayIR. SpdyGoAwayIR(SpdyStreamId last_good_stream_id, SpdyErrorCode error_code, - quiche::QuicheStringPiece description); + absl::string_view description); // References description, doesn't copy it, so description must outlast // this SpdyGoAwayIR. @@ -689,7 +688,7 @@ error_code_ = error_code; } - const quiche::QuicheStringPiece& description() const { return description_; } + const absl::string_view& description() const { return description_; } void Visit(SpdyFrameVisitor* visitor) const override; @@ -701,7 +700,7 @@ SpdyStreamId last_good_stream_id_; SpdyErrorCode error_code_; const std::string description_store_; - const quiche::QuicheStringPiece description_; + const absl::string_view description_; }; class QUICHE_EXPORT_PRIVATE SpdyHeadersIR : public SpdyFrameWithHeaderBlockIR {
diff --git a/spdy/core/spdy_protocol_test.cc b/spdy/core/spdy_protocol_test.cc index c952bce..f4cbc42 100644 --- a/spdy/core/spdy_protocol_test.cc +++ b/spdy/core/spdy_protocol_test.cc
@@ -226,8 +226,8 @@ TEST(SpdyDataIRTest, Construct) { // Confirm that it makes a string of zero length from a - // QuicheStringPiece(nullptr). - quiche::QuicheStringPiece s1; + // absl::string_view(nullptr). + absl::string_view s1; SpdyDataIR d1(/* stream_id = */ 1, s1); EXPECT_EQ(0u, d1.data_len()); EXPECT_NE(nullptr, d1.data()); @@ -235,8 +235,8 @@ // Confirms makes a copy of char array. const char s2[] = "something"; SpdyDataIR d2(/* stream_id = */ 2, s2); - EXPECT_EQ(quiche::QuicheStringPiece(d2.data(), d2.data_len()), s2); - EXPECT_NE(quiche::QuicheStringPiece(d1.data(), d1.data_len()), s2); + EXPECT_EQ(absl::string_view(d2.data(), d2.data_len()), s2); + EXPECT_NE(absl::string_view(d1.data(), d1.data_len()), s2); EXPECT_EQ((int)d1.data_len(), d1.flow_control_window_consumed()); // Confirm copies a const string. @@ -249,20 +249,18 @@ std::string bar = "bar"; SpdyDataIR d4(/* stream_id = */ 4, bar); EXPECT_EQ("bar", bar); - EXPECT_EQ("bar", quiche::QuicheStringPiece(d4.data(), d4.data_len())); + EXPECT_EQ("bar", absl::string_view(d4.data(), d4.data_len())); // Confirm moves an rvalue reference. Note that the test string "baz" is too // short to trigger the move optimization, and instead a copy occurs. std::string baz = "the quick brown fox"; SpdyDataIR d5(/* stream_id = */ 5, std::move(baz)); EXPECT_EQ("", baz); - EXPECT_EQ(quiche::QuicheStringPiece(d5.data(), d5.data_len()), - "the quick brown fox"); + EXPECT_EQ(absl::string_view(d5.data(), d5.data_len()), "the quick brown fox"); // Confirms makes a copy of string literal. SpdyDataIR d7(/* stream_id = */ 7, "something else"); - EXPECT_EQ(quiche::QuicheStringPiece(d7.data(), d7.data_len()), - "something else"); + EXPECT_EQ(absl::string_view(d7.data(), d7.data_len()), "something else"); SpdyDataIR d8(/* stream_id = */ 8, "shawarma"); d8.set_padding_len(20);
diff --git a/spdy/core/spdy_protocol_test_utils.cc b/spdy/core/spdy_protocol_test_utils.cc index 7390f50..37199f6 100644 --- a/spdy/core/spdy_protocol_test_utils.cc +++ b/spdy/core/spdy_protocol_test_utils.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" namespace spdy { namespace test { @@ -47,8 +47,8 @@ if (expected.data() == nullptr) { VERIFY_EQ(nullptr, actual.data()); } else { - VERIFY_EQ(quiche::QuicheStringPiece(expected.data(), expected.data_len()), - quiche::QuicheStringPiece(actual.data(), actual.data_len())); + VERIFY_EQ(absl::string_view(expected.data(), expected.data_len()), + absl::string_view(actual.data(), actual.data_len())); } VERIFY_SUCCESS(VerifySpdyFrameWithPaddingIREquals(expected, actual)); return ::testing::AssertionSuccess();
diff --git a/spdy/core/spdy_simple_arena_test.cc b/spdy/core/spdy_simple_arena_test.cc index 7e66567..b9e9f75 100644 --- a/spdy/core/spdy_simple_arena_test.cc +++ b/spdy/core/spdy_simple_arena_test.cc
@@ -7,7 +7,7 @@ #include <string> #include <vector> -#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 { @@ -27,7 +27,7 @@ char* c = arena.Memdup(kTestString, length); EXPECT_NE(nullptr, c); EXPECT_NE(c, kTestString); - EXPECT_EQ(quiche::QuicheStringPiece(c, length), kTestString); + EXPECT_EQ(absl::string_view(c, length), kTestString); } TEST(SpdySimpleArenaTest, MemdupLargeString) { @@ -36,7 +36,7 @@ char* c = arena.Memdup(kTestString, length); EXPECT_NE(nullptr, c); EXPECT_NE(c, kTestString); - EXPECT_EQ(quiche::QuicheStringPiece(c, length), kTestString); + EXPECT_EQ(absl::string_view(c, length), kTestString); } TEST(SpdySimpleArenaTest, MultipleBlocks) { @@ -44,9 +44,9 @@ std::vector<std::string> strings = { "One decently long string.", "Another string.", "A third string that will surely go in a different block."}; - std::vector<quiche::QuicheStringPiece> copies; + std::vector<absl::string_view> copies; for (const std::string& s : strings) { - quiche::QuicheStringPiece sp(arena.Memdup(s.data(), s.size()), s.size()); + absl::string_view sp(arena.Memdup(s.data(), s.size()), s.size()); copies.push_back(sp); } EXPECT_EQ(strings.size(), copies.size()); @@ -63,7 +63,7 @@ c = arena.Memdup(kTestString, length); EXPECT_NE(nullptr, c); EXPECT_NE(c, kTestString); - EXPECT_EQ(quiche::QuicheStringPiece(c, length), kTestString); + EXPECT_EQ(absl::string_view(c, length), kTestString); } TEST(SpdySimpleArenaTest, Free) { @@ -102,7 +102,7 @@ EXPECT_EQ(c1 + length, c2); EXPECT_EQ(c2 + 2 * length, c3); EXPECT_EQ(c3 + 3 * length, c4); - EXPECT_EQ(quiche::QuicheStringPiece(c4, length), kTestString); + EXPECT_EQ(absl::string_view(c4, length), kTestString); } TEST(SpdySimpleArenaTest, Realloc) { @@ -113,28 +113,28 @@ char* c2 = arena.Realloc(c1, length, 2 * length); EXPECT_TRUE(c1); EXPECT_EQ(c1, c2); - EXPECT_EQ(quiche::QuicheStringPiece(c1, length), kTestString); + EXPECT_EQ(absl::string_view(c1, length), kTestString); // Multiple reallocs. char* c3 = arena.Memdup(kTestString, length); EXPECT_EQ(c2 + 2 * length, c3); - EXPECT_EQ(quiche::QuicheStringPiece(c3, length), kTestString); + EXPECT_EQ(absl::string_view(c3, length), kTestString); char* c4 = arena.Realloc(c3, length, 2 * length); EXPECT_EQ(c3, c4); - EXPECT_EQ(quiche::QuicheStringPiece(c4, length), kTestString); + EXPECT_EQ(absl::string_view(c4, length), kTestString); char* c5 = arena.Realloc(c4, 2 * length, 3 * length); EXPECT_EQ(c4, c5); - EXPECT_EQ(quiche::QuicheStringPiece(c5, length), kTestString); + EXPECT_EQ(absl::string_view(c5, length), kTestString); char* c6 = arena.Memdup(kTestString, length); EXPECT_EQ(c5 + 3 * length, c6); - EXPECT_EQ(quiche::QuicheStringPiece(c6, length), kTestString); + EXPECT_EQ(absl::string_view(c6, length), kTestString); // Realloc that does not fit in the remainder of the first block. char* c7 = arena.Realloc(c6, length, kDefaultBlockSize); - EXPECT_EQ(quiche::QuicheStringPiece(c7, length), kTestString); + EXPECT_EQ(absl::string_view(c7, length), kTestString); arena.Free(c7, kDefaultBlockSize); char* c8 = arena.Memdup(kTestString, length); EXPECT_NE(c6, c7); EXPECT_EQ(c7, c8); - EXPECT_EQ(quiche::QuicheStringPiece(c8, length), kTestString); + EXPECT_EQ(absl::string_view(c8, length), kTestString); } } // namespace
diff --git a/spdy/core/spdy_test_utils.cc b/spdy/core/spdy_test_utils.cc index 1d8db97..cf926b4 100644 --- a/spdy/core/spdy_test_utils.cc +++ b/spdy/core/spdy_test_utils.cc
@@ -104,8 +104,8 @@ block_.clear(); } -void TestHeadersHandler::OnHeader(quiche::QuicheStringPiece name, - quiche::QuicheStringPiece value) { +void TestHeadersHandler::OnHeader(absl::string_view name, + absl::string_view value) { block_.AppendValueOrAddHeader(name, value); }
diff --git a/spdy/core/spdy_test_utils.h b/spdy/core/spdy_test_utils.h index b3c3aa5..aaaa65a 100644 --- a/spdy/core/spdy_test_utils.h +++ b/spdy/core/spdy_test_utils.h
@@ -9,7 +9,7 @@ #include <cstdint> #include <string> -#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/spdy/core/spdy_header_block.h" #include "net/third_party/quiche/src/spdy/core/spdy_headers_handler_interface.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" @@ -17,7 +17,7 @@ namespace spdy { -inline bool operator==(quiche::QuicheStringPiece x, +inline bool operator==(absl::string_view x, const SpdyHeaderBlock::ValueProxy& y) { return y.operator==(x); } @@ -49,8 +49,7 @@ void OnHeaderBlockStart() override; - void OnHeader(quiche::QuicheStringPiece name, - quiche::QuicheStringPiece value) override; + void OnHeader(absl::string_view name, absl::string_view value) override; void OnHeaderBlockEnd(size_t header_bytes_parsed, size_t compressed_header_bytes_parsed) override;