Replace QuicheStringPiece with absl::string_view PiperOrigin-RevId: 336140540 Change-Id: I17376a578dabba9119a6e977a323a300fce7a814
diff --git a/quic/core/http/end_to_end_test.cc b/quic/core/http/end_to_end_test.cc index ac8868f..cb2e5b3 100644 --- a/quic/core/http/end_to_end_test.cc +++ b/quic/core/http/end_to_end_test.cc
@@ -11,6 +11,7 @@ #include <utility> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" #include "net/third_party/quiche/src/quic/core/http/http_constants.h" #include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_stream.h" @@ -65,7 +66,6 @@ #include "net/third_party/quiche/src/quic/tools/quic_simple_client_stream.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using spdy::kV3LowestPriority; @@ -465,9 +465,9 @@ } } - void AddToCache(quiche::QuicheStringPiece path, + void AddToCache(absl::string_view path, int response_code, - quiche::QuicheStringPiece body) { + absl::string_view body) { memory_cache_backend_.AddSimpleResponse(server_hostname_, path, response_code, body); } @@ -4288,7 +4288,7 @@ ASSERT_LT(0, client_session->GetCurrentLargestMessagePayload()); std::string message_string(kMaxOutgoingPacketSize, 'a'); - quiche::QuicheStringPiece message_buffer(message_string); + absl::string_view message_buffer(message_string); QuicRandom* random = QuicConnectionPeer::GetHelper(client_connection)->GetRandomGenerator(); QuicMemSliceStorage storage(nullptr, 0, nullptr, 0); @@ -4298,7 +4298,7 @@ EXPECT_EQ(MessageResult(MESSAGE_STATUS_SUCCESS, 1), client_session->SendMessage(MakeSpan( client_connection->helper()->GetStreamSendBufferAllocator(), - quiche::QuicheStringPiece( + absl::string_view( message_buffer.data(), client_session->GetCurrentLargestMessagePayload()), &storage))); @@ -4312,8 +4312,7 @@ 1; MessageResult result = client_session->SendMessage(MakeSpan( client_connection->helper()->GetStreamSendBufferAllocator(), - quiche::QuicheStringPiece(message_buffer.data(), message_length), - &storage)); + absl::string_view(message_buffer.data(), message_length), &storage)); if (result.status == MESSAGE_STATUS_BLOCKED) { // Connection is write blocked. break; @@ -4327,7 +4326,7 @@ client_session ->SendMessage(MakeSpan( client_connection->helper()->GetStreamSendBufferAllocator(), - quiche::QuicheStringPiece( + absl::string_view( message_buffer.data(), client_session->GetCurrentLargestMessagePayload() + 1), &storage))
diff --git a/quic/core/http/http_decoder.cc b/quic/core/http/http_decoder.cc index d142201..066592f 100644 --- a/quic/core/http/http_decoder.cc +++ b/quic/core/http/http_decoder.cc
@@ -6,6 +6,7 @@ #include <cstdint> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/http2/http2_constants.h" #include "net/third_party/quiche/src/quic/core/http/http_frames.h" #include "net/third_party/quiche/src/quic/core/quic_data_reader.h" @@ -14,7 +15,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_fallthrough.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -53,7 +53,7 @@ return false; } - quiche::QuicheStringPiece frame_contents; + absl::string_view frame_contents; if (!reader.ReadStringPieceVarInt62(&frame_contents)) { QUIC_DLOG(ERROR) << "Failed to read SETTINGS frame contents"; return false; @@ -258,7 +258,7 @@ case static_cast<uint64_t>(HttpFrameType::DATA): { QuicByteCount bytes_to_read = std::min<QuicByteCount>( remaining_frame_length_, reader->BytesRemaining()); - quiche::QuicheStringPiece payload; + absl::string_view payload; bool success = reader->ReadStringPiece(&payload, bytes_to_read); DCHECK(success); DCHECK(!payload.empty()); @@ -269,7 +269,7 @@ case static_cast<uint64_t>(HttpFrameType::HEADERS): { QuicByteCount bytes_to_read = std::min<QuicByteCount>( remaining_frame_length_, reader->BytesRemaining()); - quiche::QuicheStringPiece payload; + absl::string_view payload; bool success = reader->ReadStringPiece(&payload, bytes_to_read); DCHECK(success); DCHECK(!payload.empty()); @@ -342,7 +342,7 @@ if (bytes_to_read == 0) { break; } - quiche::QuicheStringPiece payload; + absl::string_view payload; bool success = reader->ReadStringPiece(&payload, bytes_to_read); DCHECK(success); DCHECK(!payload.empty()); @@ -367,7 +367,7 @@ default: { QuicByteCount bytes_to_read = std::min<QuicByteCount>( remaining_frame_length_, reader->BytesRemaining()); - quiche::QuicheStringPiece payload; + absl::string_view payload; bool success = reader->ReadStringPiece(&payload, bytes_to_read); DCHECK(success); DCHECK(!payload.empty()); @@ -483,7 +483,7 @@ void HttpDecoder::DiscardFramePayload(QuicDataReader* reader) { QuicByteCount bytes_to_read = std::min<QuicByteCount>( remaining_frame_length_, reader->BytesRemaining()); - quiche::QuicheStringPiece payload; + absl::string_view payload; bool success = reader->ReadStringPiece(&payload, bytes_to_read); DCHECK(success); remaining_frame_length_ -= payload.length(); @@ -596,8 +596,7 @@ return false; } - quiche::QuicheStringPiece priority_field_value = - reader->ReadRemainingPayload(); + absl::string_view priority_field_value = reader->ReadRemainingPayload(); frame->priority_field_value = std::string(priority_field_value.data(), priority_field_value.size());
diff --git a/quic/core/http/http_decoder.h b/quic/core/http/http_decoder.h index 82535f7..77937f5 100644 --- a/quic/core/http/http_decoder.h +++ b/quic/core/http/http_decoder.h
@@ -7,11 +7,11 @@ #include <cstdint> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/http_frames.h" #include "net/third_party/quiche/src/quic/core/quic_error_codes.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -62,7 +62,7 @@ // Called when part of the payload of a DATA frame has been read. May be // called multiple times for a single frame. |payload| is guaranteed to be // non-empty. - virtual bool OnDataFramePayload(quiche::QuicheStringPiece payload) = 0; + virtual bool OnDataFramePayload(absl::string_view payload) = 0; // Called when a DATA frame has been completely processed. virtual bool OnDataFrameEnd() = 0; @@ -74,7 +74,7 @@ // Called when part of the payload of a HEADERS frame has been read. May be // called multiple times for a single frame. |payload| is guaranteed to be // non-empty. - virtual bool OnHeadersFramePayload(quiche::QuicheStringPiece payload) = 0; + virtual bool OnHeadersFramePayload(absl::string_view payload) = 0; // Called when a HEADERS frame has been completely processed. virtual bool OnHeadersFrameEnd() = 0; @@ -91,8 +91,7 @@ // Called when part of the header block of a PUSH_PROMISE frame has been // read. May be called multiple times for a single frame. |payload| is // guaranteed to be non-empty. - virtual bool OnPushPromiseFramePayload( - quiche::QuicheStringPiece payload) = 0; + virtual bool OnPushPromiseFramePayload(absl::string_view payload) = 0; // Called when a PUSH_PROMISE frame has been completely processed. virtual bool OnPushPromiseFrameEnd() = 0; @@ -113,7 +112,7 @@ // Called when part of the payload of the unknown frame has been read. May // be called multiple times for a single frame. |payload| is guaranteed to // be non-empty. - virtual bool OnUnknownFramePayload(quiche::QuicheStringPiece payload) = 0; + virtual bool OnUnknownFramePayload(absl::string_view payload) = 0; // Called when the unknown frame has been completely processed. virtual bool OnUnknownFrameEnd() = 0; };
diff --git a/quic/core/http/http_decoder_test.cc b/quic/core/http/http_decoder_test.cc index fb29d7b..9b6c4e2 100644 --- a/quic/core/http/http_decoder_test.cc +++ b/quic/core/http/http_decoder_test.cc
@@ -7,6 +7,7 @@ #include <memory> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/http_encoder.h" #include "net/third_party/quiche/src/quic/core/http/http_frames.h" #include "net/third_party/quiche/src/quic/core/quic_data_writer.h" @@ -15,7 +16,6 @@ #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using ::testing::_; @@ -62,7 +62,7 @@ (override)); MOCK_METHOD(bool, OnDataFramePayload, - (quiche::QuicheStringPiece payload), + (absl::string_view payload), (override)); MOCK_METHOD(bool, OnDataFrameEnd, (), (override)); @@ -72,7 +72,7 @@ (override)); MOCK_METHOD(bool, OnHeadersFramePayload, - (quiche::QuicheStringPiece payload), + (absl::string_view payload), (override)); MOCK_METHOD(bool, OnHeadersFrameEnd, (), (override)); @@ -88,7 +88,7 @@ (override)); MOCK_METHOD(bool, OnPushPromiseFramePayload, - (quiche::QuicheStringPiece payload), + (absl::string_view payload), (override)); MOCK_METHOD(bool, OnPushPromiseFrameEnd, (), (override)); @@ -109,7 +109,7 @@ (override)); MOCK_METHOD(bool, OnUnknownFramePayload, - (quiche::QuicheStringPiece payload), + (absl::string_view payload), (override)); MOCK_METHOD(bool, OnUnknownFrameEnd, (), (override)); }; @@ -147,13 +147,13 @@ } // Process |input| in a single call to HttpDecoder::ProcessInput(). - QuicByteCount ProcessInput(quiche::QuicheStringPiece input) { + QuicByteCount ProcessInput(absl::string_view input) { return decoder_.ProcessInput(input.data(), input.size()); } // Feed |input| to |decoder_| one character at a time, // verifying that each character gets processed. - void ProcessInputCharByChar(quiche::QuicheStringPiece input) { + void ProcessInputCharByChar(absl::string_view input) { for (char c : input) { EXPECT_EQ(1u, decoder_.ProcessInput(&c, 1)); } @@ -161,8 +161,7 @@ // Append garbage to |input|, then process it in a single call to // HttpDecoder::ProcessInput(). Verify that garbage is not read. - QuicByteCount ProcessInputWithGarbageAppended( - quiche::QuicheStringPiece input) { + QuicByteCount ProcessInputWithGarbageAppended(absl::string_view input) { std::string input_with_garbage_appended = quiche::QuicheStrCat(input, "blahblah"); QuicByteCount processed_bytes = ProcessInput(input_with_garbage_appended); @@ -267,7 +266,7 @@ EXPECT_CALL(visitor_, OnPushPromiseFrameStart(2)).WillOnce(Return(false)); EXPECT_CALL(visitor_, OnPushPromiseFramePushId(257, 8, 7)) .WillOnce(Return(false)); - quiche::QuicheStringPiece remaining_input(input); + absl::string_view remaining_input(input); QuicByteCount processed_bytes = ProcessInputWithGarbageAppended(remaining_input); EXPECT_EQ(2u, processed_bytes); @@ -276,8 +275,7 @@ EXPECT_EQ(8u, processed_bytes); remaining_input = remaining_input.substr(processed_bytes); - EXPECT_CALL(visitor_, - OnPushPromiseFramePayload(quiche::QuicheStringPiece("Headers"))) + EXPECT_CALL(visitor_, OnPushPromiseFramePayload(absl::string_view("Headers"))) .WillOnce(Return(false)); processed_bytes = ProcessInputWithGarbageAppended(remaining_input); EXPECT_EQ(remaining_input.size(), processed_bytes); @@ -291,7 +289,7 @@ EXPECT_CALL(visitor_, OnPushPromiseFrameStart(2)); EXPECT_CALL(visitor_, OnPushPromiseFramePushId(257, 8, 7)); EXPECT_CALL(visitor_, - OnPushPromiseFramePayload(quiche::QuicheStringPiece("Headers"))); + OnPushPromiseFramePayload(absl::string_view("Headers"))); EXPECT_CALL(visitor_, OnPushPromiseFrameEnd()); EXPECT_EQ(input.size(), ProcessInput(input)); EXPECT_THAT(decoder_.error(), IsQuicNoError()); @@ -300,20 +298,13 @@ // Process the frame incrementally. EXPECT_CALL(visitor_, OnPushPromiseFrameStart(2)); EXPECT_CALL(visitor_, OnPushPromiseFramePushId(257, 8, 7)); - EXPECT_CALL(visitor_, - OnPushPromiseFramePayload(quiche::QuicheStringPiece("H"))); - EXPECT_CALL(visitor_, - OnPushPromiseFramePayload(quiche::QuicheStringPiece("e"))); - EXPECT_CALL(visitor_, - OnPushPromiseFramePayload(quiche::QuicheStringPiece("a"))); - EXPECT_CALL(visitor_, - OnPushPromiseFramePayload(quiche::QuicheStringPiece("d"))); - EXPECT_CALL(visitor_, - OnPushPromiseFramePayload(quiche::QuicheStringPiece("e"))); - EXPECT_CALL(visitor_, - OnPushPromiseFramePayload(quiche::QuicheStringPiece("r"))); - EXPECT_CALL(visitor_, - OnPushPromiseFramePayload(quiche::QuicheStringPiece("s"))); + EXPECT_CALL(visitor_, OnPushPromiseFramePayload(absl::string_view("H"))); + EXPECT_CALL(visitor_, OnPushPromiseFramePayload(absl::string_view("e"))); + EXPECT_CALL(visitor_, OnPushPromiseFramePayload(absl::string_view("a"))); + EXPECT_CALL(visitor_, OnPushPromiseFramePayload(absl::string_view("d"))); + EXPECT_CALL(visitor_, OnPushPromiseFramePayload(absl::string_view("e"))); + EXPECT_CALL(visitor_, OnPushPromiseFramePayload(absl::string_view("r"))); + EXPECT_CALL(visitor_, OnPushPromiseFramePayload(absl::string_view("s"))); EXPECT_CALL(visitor_, OnPushPromiseFrameEnd()); ProcessInputCharByChar(input); EXPECT_THAT(decoder_.error(), IsQuicNoError()); @@ -323,7 +314,7 @@ EXPECT_CALL(visitor_, OnPushPromiseFrameStart(2)); EXPECT_CALL(visitor_, OnPushPromiseFramePushId(257, 8, 7)); EXPECT_CALL(visitor_, - OnPushPromiseFramePayload(quiche::QuicheStringPiece("Headers"))); + OnPushPromiseFramePayload(absl::string_view("Headers"))); EXPECT_CALL(visitor_, OnPushPromiseFrameEnd()); ProcessInputCharByChar(input.substr(0, 9)); EXPECT_EQ(8u, ProcessInput(input.substr(9))); @@ -408,7 +399,7 @@ frame.values[256] = 4; // Visitor pauses processing. - quiche::QuicheStringPiece remaining_input(input); + absl::string_view remaining_input(input); EXPECT_CALL(visitor_, OnSettingsFrameStart(2)).WillOnce(Return(false)); QuicByteCount processed_bytes = ProcessInputWithGarbageAppended(remaining_input); @@ -499,13 +490,13 @@ // Visitor pauses processing. EXPECT_CALL(visitor_, OnDataFrameStart(2, 5)).WillOnce(Return(false)); - quiche::QuicheStringPiece remaining_input(input); + absl::string_view remaining_input(input); QuicByteCount processed_bytes = ProcessInputWithGarbageAppended(remaining_input); EXPECT_EQ(2u, processed_bytes); remaining_input = remaining_input.substr(processed_bytes); - EXPECT_CALL(visitor_, OnDataFramePayload(quiche::QuicheStringPiece("Data!"))) + EXPECT_CALL(visitor_, OnDataFramePayload(absl::string_view("Data!"))) .WillOnce(Return(false)); processed_bytes = ProcessInputWithGarbageAppended(remaining_input); EXPECT_EQ(remaining_input.size(), processed_bytes); @@ -517,7 +508,7 @@ // Process the full frame. EXPECT_CALL(visitor_, OnDataFrameStart(2, 5)); - EXPECT_CALL(visitor_, OnDataFramePayload(quiche::QuicheStringPiece("Data!"))); + EXPECT_CALL(visitor_, OnDataFramePayload(absl::string_view("Data!"))); EXPECT_CALL(visitor_, OnDataFrameEnd()); EXPECT_EQ(input.size(), ProcessInput(input)); EXPECT_THAT(decoder_.error(), IsQuicNoError()); @@ -525,11 +516,11 @@ // Process the frame incrementally. EXPECT_CALL(visitor_, OnDataFrameStart(2, 5)); - EXPECT_CALL(visitor_, OnDataFramePayload(quiche::QuicheStringPiece("D"))); - EXPECT_CALL(visitor_, OnDataFramePayload(quiche::QuicheStringPiece("a"))); - EXPECT_CALL(visitor_, OnDataFramePayload(quiche::QuicheStringPiece("t"))); - EXPECT_CALL(visitor_, OnDataFramePayload(quiche::QuicheStringPiece("a"))); - EXPECT_CALL(visitor_, OnDataFramePayload(quiche::QuicheStringPiece("!"))); + EXPECT_CALL(visitor_, OnDataFramePayload(absl::string_view("D"))); + EXPECT_CALL(visitor_, OnDataFramePayload(absl::string_view("a"))); + EXPECT_CALL(visitor_, OnDataFramePayload(absl::string_view("t"))); + EXPECT_CALL(visitor_, OnDataFramePayload(absl::string_view("a"))); + EXPECT_CALL(visitor_, OnDataFramePayload(absl::string_view("!"))); EXPECT_CALL(visitor_, OnDataFrameEnd()); ProcessInputCharByChar(input); EXPECT_THAT(decoder_.error(), IsQuicNoError()); @@ -557,7 +548,7 @@ EXPECT_EQ("", decoder_.error_detail()); // Send data. - EXPECT_CALL(visitor_, OnDataFramePayload(quiche::QuicheStringPiece(input))); + EXPECT_CALL(visitor_, OnDataFramePayload(absl::string_view(input))); EXPECT_CALL(visitor_, OnDataFrameEnd()); EXPECT_EQ(2048u, decoder_.ProcessInput(input.data(), 2048)); EXPECT_THAT(decoder_.error(), IsQuicNoError()); @@ -628,14 +619,13 @@ // Visitor pauses processing. EXPECT_CALL(visitor_, OnHeadersFrameStart(2, 7)).WillOnce(Return(false)); - quiche::QuicheStringPiece remaining_input(input); + absl::string_view remaining_input(input); QuicByteCount processed_bytes = ProcessInputWithGarbageAppended(remaining_input); EXPECT_EQ(2u, processed_bytes); remaining_input = remaining_input.substr(processed_bytes); - EXPECT_CALL(visitor_, - OnHeadersFramePayload(quiche::QuicheStringPiece("Headers"))) + EXPECT_CALL(visitor_, OnHeadersFramePayload(absl::string_view("Headers"))) .WillOnce(Return(false)); processed_bytes = ProcessInputWithGarbageAppended(remaining_input); EXPECT_EQ(remaining_input.size(), processed_bytes); @@ -647,8 +637,7 @@ // Process the full frame. EXPECT_CALL(visitor_, OnHeadersFrameStart(2, 7)); - EXPECT_CALL(visitor_, - OnHeadersFramePayload(quiche::QuicheStringPiece("Headers"))); + EXPECT_CALL(visitor_, OnHeadersFramePayload(absl::string_view("Headers"))); EXPECT_CALL(visitor_, OnHeadersFrameEnd()); EXPECT_EQ(input.size(), ProcessInput(input)); EXPECT_THAT(decoder_.error(), IsQuicNoError()); @@ -656,13 +645,13 @@ // Process the frame incrementally. EXPECT_CALL(visitor_, OnHeadersFrameStart(2, 7)); - EXPECT_CALL(visitor_, OnHeadersFramePayload(quiche::QuicheStringPiece("H"))); - EXPECT_CALL(visitor_, OnHeadersFramePayload(quiche::QuicheStringPiece("e"))); - EXPECT_CALL(visitor_, OnHeadersFramePayload(quiche::QuicheStringPiece("a"))); - EXPECT_CALL(visitor_, OnHeadersFramePayload(quiche::QuicheStringPiece("d"))); - EXPECT_CALL(visitor_, OnHeadersFramePayload(quiche::QuicheStringPiece("e"))); - EXPECT_CALL(visitor_, OnHeadersFramePayload(quiche::QuicheStringPiece("r"))); - EXPECT_CALL(visitor_, OnHeadersFramePayload(quiche::QuicheStringPiece("s"))); + EXPECT_CALL(visitor_, OnHeadersFramePayload(absl::string_view("H"))); + EXPECT_CALL(visitor_, OnHeadersFramePayload(absl::string_view("e"))); + EXPECT_CALL(visitor_, OnHeadersFramePayload(absl::string_view("a"))); + EXPECT_CALL(visitor_, OnHeadersFramePayload(absl::string_view("d"))); + EXPECT_CALL(visitor_, OnHeadersFramePayload(absl::string_view("e"))); + EXPECT_CALL(visitor_, OnHeadersFramePayload(absl::string_view("r"))); + EXPECT_CALL(visitor_, OnHeadersFramePayload(absl::string_view("s"))); EXPECT_CALL(visitor_, OnHeadersFrameEnd()); ProcessInputCharByChar(input); EXPECT_THAT(decoder_.error(), IsQuicNoError()); @@ -818,10 +807,9 @@ // Visitor pauses processing, maybe because header decompression is blocked. EXPECT_CALL(visitor_, OnHeadersFrameStart(2, 7)); - EXPECT_CALL(visitor_, - OnHeadersFramePayload(quiche::QuicheStringPiece("Headers"))); + EXPECT_CALL(visitor_, OnHeadersFramePayload(absl::string_view("Headers"))); EXPECT_CALL(visitor_, OnHeadersFrameEnd()).WillOnce(Return(false)); - quiche::QuicheStringPiece remaining_input(input); + absl::string_view remaining_input(input); QuicByteCount processed_bytes = ProcessInputWithGarbageAppended(remaining_input); EXPECT_EQ(9u, processed_bytes); @@ -829,7 +817,7 @@ // Process DATA frame. EXPECT_CALL(visitor_, OnDataFrameStart(2, 5)); - EXPECT_CALL(visitor_, OnDataFramePayload(quiche::QuicheStringPiece("Data!"))); + EXPECT_CALL(visitor_, OnDataFramePayload(absl::string_view("Data!"))); EXPECT_CALL(visitor_, OnDataFrameEnd()); processed_bytes = ProcessInput(remaining_input); @@ -878,7 +866,7 @@ HttpDecoder decoder(&visitor_); EXPECT_CALL(visitor_, OnError(&decoder)); - quiche::QuicheStringPiece input(test_data.input); + absl::string_view input(test_data.input); decoder.ProcessInput(input.data(), input.size()); EXPECT_THAT(decoder.error(), IsError(QUIC_HTTP_FRAME_ERROR)); EXPECT_EQ(test_data.error_message, decoder.error_detail()); @@ -887,7 +875,7 @@ HttpDecoder decoder(&visitor_); EXPECT_CALL(visitor_, OnError(&decoder)); - quiche::QuicheStringPiece input(test_data.input); + absl::string_view input(test_data.input); for (auto c : input) { decoder.ProcessInput(&c, 1); } @@ -983,7 +971,7 @@ // Visitor pauses processing. EXPECT_CALL(visitor_, OnPriorityUpdateFrameStart(2)).WillOnce(Return(false)); - quiche::QuicheStringPiece remaining_input(input1); + absl::string_view remaining_input(input1); QuicByteCount processed_bytes = ProcessInputWithGarbageAppended(remaining_input); EXPECT_EQ(2u, processed_bytes);
diff --git a/quic/core/http/http_frames.h b/quic/core/http/http_frames.h index 159b250..00df2bc 100644 --- a/quic/core/http/http_frames.h +++ b/quic/core/http/http_frames.h
@@ -9,11 +9,11 @@ #include <map> #include <ostream> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_string_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_framer.h" namespace quic { @@ -34,7 +34,7 @@ // DATA frames (type=0x0) convey arbitrary, variable-length sequences of // octets associated with an HTTP request or response payload. struct QUIC_EXPORT_PRIVATE DataFrame { - quiche::QuicheStringPiece data; + absl::string_view data; }; // 7.2.2. HEADERS @@ -42,7 +42,7 @@ // The HEADERS frame (type=0x1) is used to carry a header block, // compressed using QPACK. struct QUIC_EXPORT_PRIVATE HeadersFrame { - quiche::QuicheStringPiece headers; + absl::string_view headers; }; // 7.2.3. CANCEL_PUSH @@ -98,7 +98,7 @@ // set from server to client, as in HTTP/2. struct QUIC_EXPORT_PRIVATE PushPromiseFrame { PushId push_id; - quiche::QuicheStringPiece headers; + absl::string_view headers; bool operator==(const PushPromiseFrame& rhs) const { return push_id == rhs.push_id && headers == rhs.headers;
diff --git a/quic/core/http/quic_header_list.cc b/quic/core/http/quic_header_list.cc index cbfc2e9..5282f2d 100644 --- a/quic/core/http/quic_header_list.cc +++ b/quic/core/http/quic_header_list.cc
@@ -7,10 +7,10 @@ #include <limits> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" #include "net/third_party/quiche/src/quic/core/quic_packets.h" #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -36,8 +36,7 @@ << "OnHeaderBlockStart called more than once!"; } -void QuicHeaderList::OnHeader(quiche::QuicheStringPiece name, - quiche::QuicheStringPiece value) { +void QuicHeaderList::OnHeader(absl::string_view name, absl::string_view value) { // Avoid infinite buffering of headers. No longer store headers // once the current headers are over the limit. if (current_header_list_size_ < max_header_list_size_) {
diff --git a/quic/core/http/quic_header_list.h b/quic/core/http/quic_header_list.h index 0ed8ae8..bc3a73b 100644 --- a/quic/core/http/quic_header_list.h +++ b/quic/core/http/quic_header_list.h
@@ -10,10 +10,10 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_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_block.h" #include "net/third_party/quiche/src/spdy/core/spdy_headers_handler_interface.h" @@ -36,8 +36,7 @@ // From SpdyHeadersHandlerInteface. 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 uncompressed_header_bytes, size_t compressed_header_bytes) override;
diff --git a/quic/core/http/quic_headers_stream_test.cc b/quic/core/http/quic_headers_stream_test.cc index 9e1b08a..bedde94 100644 --- a/quic/core/http/quic_headers_stream_test.cc +++ b/quic/core/http/quic_headers_stream_test.cc
@@ -11,6 +11,7 @@ #include <utility> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" #include "net/third_party/quiche/src/quic/core/quic_data_writer.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" @@ -25,7 +26,6 @@ #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_endian.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/http2_frame_decoder_adapter.h" #include "net/third_party/quiche/src/spdy/core/spdy_alt_svc_wire_format.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" @@ -150,7 +150,7 @@ void, OnAltSvc, (SpdyStreamId stream_id, - quiche::QuicheStringPiece origin, + absl::string_view origin, const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector), (override)); MOCK_METHOD(void, @@ -271,7 +271,7 @@ return true; } - void SaveHeaderDataStringPiece(quiche::QuicheStringPiece data) { + void SaveHeaderDataStringPiece(absl::string_view data) { saved_header_data_.append(data.data(), data.length()); }
diff --git a/quic/core/http/quic_receive_control_stream.cc b/quic/core/http/quic_receive_control_stream.cc index 1367a95..493ad0d 100644 --- a/quic/core/http/quic_receive_control_stream.cc +++ b/quic/core/http/quic_receive_control_stream.cc
@@ -6,13 +6,13 @@ #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/http_constants.h" #include "net/third_party/quiche/src/quic/core/http/http_decoder.h" #include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { @@ -142,7 +142,7 @@ } bool QuicReceiveControlStream::OnDataFramePayload( - quiche::QuicheStringPiece /*payload*/) { + absl::string_view /*payload*/) { OnWrongFrame("Data"); return false; } @@ -161,7 +161,7 @@ } bool QuicReceiveControlStream::OnHeadersFramePayload( - quiche::QuicheStringPiece /*payload*/) { + absl::string_view /*payload*/) { OnWrongFrame("Headers"); return false; } @@ -186,7 +186,7 @@ } bool QuicReceiveControlStream::OnPushPromiseFramePayload( - quiche::QuicheStringPiece /*payload*/) { + absl::string_view /*payload*/) { OnWrongFrame("Push Promise"); return false; } @@ -221,13 +221,13 @@ continue; } - quiche::QuicheStringPiece key = key_and_value[0]; + absl::string_view key = key_and_value[0]; quiche::QuicheTextUtils::RemoveLeadingAndTrailingWhitespace(&key); if (key != "u") { continue; } - quiche::QuicheStringPiece value = key_and_value[1]; + absl::string_view value = key_and_value[1]; int urgency; if (!quiche::QuicheTextUtils::StringToInt(value, &urgency) || urgency < 0 || urgency > 7) { @@ -269,7 +269,7 @@ } bool QuicReceiveControlStream::OnUnknownFramePayload( - quiche::QuicheStringPiece /*payload*/) { + absl::string_view /*payload*/) { // Ignore unknown frame types. return true; } @@ -279,8 +279,7 @@ return true; } -void QuicReceiveControlStream::OnWrongFrame( - quiche::QuicheStringPiece frame_type) { +void QuicReceiveControlStream::OnWrongFrame(absl::string_view frame_type) { OnUnrecoverableError( QUIC_HTTP_FRAME_UNEXPECTED_ON_CONTROL_STREAM, quiche::QuicheStrCat(frame_type, " frame received on control stream"));
diff --git a/quic/core/http/quic_receive_control_stream.h b/quic/core/http/quic_receive_control_stream.h index 7fd02b4..2654bb8 100644 --- a/quic/core/http/quic_receive_control_stream.h +++ b/quic/core/http/quic_receive_control_stream.h
@@ -42,24 +42,24 @@ bool OnSettingsFrame(const SettingsFrame& frame) override; bool OnDataFrameStart(QuicByteCount header_length, QuicByteCount payload_length) override; - bool OnDataFramePayload(quiche::QuicheStringPiece payload) override; + bool OnDataFramePayload(absl::string_view payload) override; bool OnDataFrameEnd() override; bool OnHeadersFrameStart(QuicByteCount header_length, QuicByteCount payload_length) override; - bool OnHeadersFramePayload(quiche::QuicheStringPiece payload) override; + bool OnHeadersFramePayload(absl::string_view payload) override; bool OnHeadersFrameEnd() override; bool OnPushPromiseFrameStart(QuicByteCount header_length) override; bool OnPushPromiseFramePushId(PushId push_id, QuicByteCount push_id_length, QuicByteCount header_block_length) override; - bool OnPushPromiseFramePayload(quiche::QuicheStringPiece payload) override; + bool OnPushPromiseFramePayload(absl::string_view payload) override; bool OnPushPromiseFrameEnd() override; bool OnPriorityUpdateFrameStart(QuicByteCount header_length) override; bool OnPriorityUpdateFrame(const PriorityUpdateFrame& frame) override; bool OnUnknownFrameStart(uint64_t frame_type, QuicByteCount header_length, QuicByteCount payload_length) override; - bool OnUnknownFramePayload(quiche::QuicheStringPiece payload) override; + bool OnUnknownFramePayload(absl::string_view payload) override; bool OnUnknownFrameEnd() override; void SetUnblocked() { sequencer()->SetUnblocked(); } @@ -67,7 +67,7 @@ QuicSpdySession* spdy_session() { return spdy_session_; } private: - void OnWrongFrame(quiche::QuicheStringPiece frame_type); + void OnWrongFrame(absl::string_view frame_type); // False until a SETTINGS frame is received. bool settings_frame_received_;
diff --git a/quic/core/http/quic_receive_control_stream_test.cc b/quic/core/http/quic_receive_control_stream_test.cc index 5ee5f50..4aa3063 100644 --- a/quic/core/http/quic_receive_control_stream_test.cc +++ b/quic/core/http/quic_receive_control_stream_test.cc
@@ -4,6 +4,7 @@ #include "net/third_party/quiche/src/quic/core/http/quic_receive_control_stream.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/http_constants.h" #include "net/third_party/quiche/src/quic/core/qpack/qpack_header_table.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" @@ -13,7 +14,6 @@ #include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" #include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { @@ -96,7 +96,7 @@ session_.transport_version(), 3); char type[] = {kControlStream}; - QuicStreamFrame data1(id, false, 0, quiche::QuicheStringPiece(type, 1)); + QuicStreamFrame data1(id, false, 0, absl::string_view(type, 1)); session_.OnStreamFrame(data1); receive_control_stream_ =
diff --git a/quic/core/http/quic_send_control_stream.cc b/quic/core/http/quic_send_control_stream.cc index c7f1b38..9540763 100644 --- a/quic/core/http/quic_send_control_stream.cc +++ b/quic/core/http/quic_send_control_stream.cc
@@ -6,6 +6,7 @@ #include <cstdint> #include <memory> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" #include "net/third_party/quiche/src/quic/core/http/http_constants.h" #include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" @@ -14,7 +15,6 @@ #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -47,8 +47,8 @@ char data[sizeof(kControlStream)]; QuicDataWriter writer(QUICHE_ARRAYSIZE(data), data); writer.WriteVarInt62(kControlStream); - WriteOrBufferData(quiche::QuicheStringPiece(writer.data(), writer.length()), - false, nullptr); + WriteOrBufferData(absl::string_view(writer.data(), writer.length()), false, + nullptr); SettingsFrame settings = settings_; // https://tools.ietf.org/html/draft-ietf-quic-http-25#section-7.2.4.1 @@ -72,7 +72,7 @@ if (spdy_session_->debug_visitor()) { spdy_session_->debug_visitor()->OnSettingsFrameSent(settings); } - WriteOrBufferData(quiche::QuicheStringPiece(buffer.get(), frame_length), + WriteOrBufferData(absl::string_view(buffer.get(), frame_length), /*fin = */ false, nullptr); settings_sent_ = true; @@ -81,7 +81,7 @@ // discarded. A greasing frame is added here. std::unique_ptr<char[]> grease; QuicByteCount grease_length = HttpEncoder::SerializeGreasingFrame(&grease); - WriteOrBufferData(quiche::QuicheStringPiece(grease.get(), grease_length), + WriteOrBufferData(absl::string_view(grease.get(), grease_length), /*fin = */ false, nullptr); } @@ -99,8 +99,8 @@ HttpEncoder::SerializePriorityUpdateFrame(priority_update, &buffer); QUIC_DVLOG(1) << "Control Stream " << id() << " is writing " << priority_update; - WriteOrBufferData(quiche::QuicheStringPiece(buffer.get(), frame_length), - false, nullptr); + WriteOrBufferData(absl::string_view(buffer.get(), frame_length), false, + nullptr); } void QuicSendControlStream::SendMaxPushIdFrame(PushId max_push_id) { @@ -117,7 +117,7 @@ std::unique_ptr<char[]> buffer; QuicByteCount frame_length = HttpEncoder::SerializeMaxPushIdFrame(frame, &buffer); - WriteOrBufferData(quiche::QuicheStringPiece(buffer.get(), frame_length), + WriteOrBufferData(absl::string_view(buffer.get(), frame_length), /*fin = */ false, nullptr); } @@ -140,8 +140,8 @@ std::unique_ptr<char[]> buffer; QuicByteCount frame_length = HttpEncoder::SerializeGoAwayFrame(frame, &buffer); - WriteOrBufferData(quiche::QuicheStringPiece(buffer.get(), frame_length), - false, nullptr); + WriteOrBufferData(absl::string_view(buffer.get(), frame_length), false, + nullptr); } } // namespace quic
diff --git a/quic/core/http/quic_send_control_stream_test.cc b/quic/core/http/quic_send_control_stream_test.cc index 284708d..a9077a9 100644 --- a/quic/core/http/quic_send_control_stream_test.cc +++ b/quic/core/http/quic_send_control_stream_test.cc
@@ -6,11 +6,11 @@ #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" #include "net/third_party/quiche/src/quic/test_tools/quic_config_peer.h" #include "net/third_party/quiche/src/quic/test_tools/quic_spdy_session_peer.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { @@ -154,7 +154,7 @@ send_control_stream_->MaybeSendSettingsFrame(); EXPECT_EQ(expected_write_data, - quiche::QuicheStringPiece(writer.data(), writer.length())); + absl::string_view(writer.data(), writer.length())); } TEST_P(QuicSendControlStreamTest, WriteSettingsOnlyOnce) {
diff --git a/quic/core/http/quic_server_session_base_test.cc b/quic/core/http/quic_server_session_base_test.cc index a0ac44a..8cfa01b 100644 --- a/quic/core/http/quic_server_session_base_test.cc +++ b/quic/core/http/quic_server_session_base_test.cc
@@ -9,6 +9,7 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_server_config.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" @@ -39,7 +40,6 @@ #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/quic/tools/quic_memory_cache_backend.h" #include "net/third_party/quiche/src/quic/tools/quic_simple_server_stream.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using testing::_; using testing::StrictMock; @@ -237,7 +237,7 @@ // Open a stream, then reset it. // Send two bytes of payload to open it. QuicStreamFrame data1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece("HT")); + absl::string_view("HT")); session_->OnStreamFrame(data1); EXPECT_EQ(1u, QuicSessionPeer::GetNumOpenDynamicStreams(session_.get())); @@ -292,7 +292,7 @@ EXPECT_EQ(0u, QuicSessionPeer::GetNumOpenDynamicStreams(session_.get())); // Send two bytes of payload. QuicStreamFrame data1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece("HT")); + absl::string_view("HT")); session_->OnStreamFrame(data1); // The stream should never be opened, now that the reset is received. @@ -303,9 +303,9 @@ TEST_P(QuicServerSessionBaseTest, AcceptClosedStream) { // Send (empty) compressed headers followed by two bytes of data. QuicStreamFrame frame1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece("\1\0\0\0\0\0\0\0HT")); + absl::string_view("\1\0\0\0\0\0\0\0HT")); QuicStreamFrame frame2(GetNthClientInitiatedBidirectionalId(1), false, 0, - quiche::QuicheStringPiece("\3\0\0\0\0\0\0\0HT")); + absl::string_view("\3\0\0\0\0\0\0\0HT")); session_->OnStreamFrame(frame1); session_->OnStreamFrame(frame2); EXPECT_EQ(2u, QuicSessionPeer::GetNumOpenDynamicStreams(session_.get())); @@ -333,9 +333,9 @@ // past the reset point of stream 3. As it's a closed stream we just drop the // data on the floor, but accept the packet because it has data for stream 5. QuicStreamFrame frame3(GetNthClientInitiatedBidirectionalId(0), false, 2, - quiche::QuicheStringPiece("TP")); + absl::string_view("TP")); QuicStreamFrame frame4(GetNthClientInitiatedBidirectionalId(1), false, 2, - quiche::QuicheStringPiece("TP")); + absl::string_view("TP")); session_->OnStreamFrame(frame3); session_->OnStreamFrame(frame4); // The stream should never be opened, now that the reset is received.
diff --git a/quic/core/http/quic_spdy_client_session_test.cc b/quic/core/http/quic_spdy_client_session_test.cc index 4917a42..3f946f6 100644 --- a/quic/core/http/quic_spdy_client_session_test.cc +++ b/quic/core/http/quic_spdy_client_session_test.cc
@@ -9,6 +9,7 @@ #include <utility> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/null_decrypter.h" #include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" #include "net/third_party/quiche/src/quic/core/http/http_constants.h" @@ -38,7 +39,6 @@ #include "net/third_party/quiche/src/quic/test_tools/simple_session_cache.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using spdy::SpdyHeaderBlock; using ::testing::_; @@ -448,7 +448,7 @@ connection_->transport_version(), 3); char type[] = {0x00}; - QuicStreamFrame data1(id, false, 0, quiche::QuicheStringPiece(type, 1)); + QuicStreamFrame data1(id, false, 0, absl::string_view(type, 1)); session_->OnStreamFrame(data1); } else { id = QuicUtils::GetHeadersStreamId(connection_->transport_version()); @@ -478,7 +478,7 @@ connection_->transport_version(), 3); char type[] = {0x00}; - QuicStreamFrame data1(id, false, 0, quiche::QuicheStringPiece(type, 1)); + QuicStreamFrame data1(id, false, 0, absl::string_view(type, 1)); session_->OnStreamFrame(data1); } else { id = QuicUtils::GetHeadersStreamId(connection_->transport_version());
diff --git a/quic/core/http/quic_spdy_client_stream.cc b/quic/core/http/quic_spdy_client_stream.cc index f50e756..f4bbca5 100644 --- a/quic/core/http/quic_spdy_client_stream.cc +++ b/quic/core/http/quic_spdy_client_stream.cc
@@ -6,12 +6,12 @@ #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/quic_client_promised_info.h" #include "net/third_party/quiche/src/quic/core/http/quic_spdy_client_session.h" #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" #include "net/third_party/quiche/src/quic/core/quic_alarm.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.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" using spdy::SpdyHeaderBlock; @@ -158,7 +158,7 @@ } size_t QuicSpdyClientStream::SendRequest(SpdyHeaderBlock headers, - quiche::QuicheStringPiece body, + absl::string_view body, bool fin) { QuicConnection::ScopedPacketFlusher flusher(session_->connection()); bool send_fin_with_headers = fin && body.empty();
diff --git a/quic/core/http/quic_spdy_client_stream.h b/quic/core/http/quic_spdy_client_stream.h index dfb9270..e426db7 100644 --- a/quic/core/http/quic_spdy_client_stream.h +++ b/quic/core/http/quic_spdy_client_stream.h
@@ -8,9 +8,9 @@ #include <cstddef> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/quic_spdy_stream.h" #include "net/third_party/quiche/src/quic/core/quic_packets.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_framer.h" namespace quic { @@ -52,7 +52,7 @@ // Serializes the headers and body, sends it to the server, and // returns the number of bytes sent. size_t SendRequest(spdy::SpdyHeaderBlock headers, - quiche::QuicheStringPiece body, + absl::string_view body, bool fin); // Returns the response data.
diff --git a/quic/core/http/quic_spdy_session.cc b/quic/core/http/quic_spdy_session.cc index 4f1795d..eacfe00 100644 --- a/quic/core/http/quic_spdy_session.cc +++ b/quic/core/http/quic_spdy_session.cc
@@ -10,6 +10,7 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/http_constants.h" #include "net/third_party/quiche/src/quic/core/http/quic_headers_stream.h" #include "net/third_party/quiche/src/quic/core/quic_error_codes.h" @@ -24,7 +25,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_stack_trace.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/spdy/core/http2_frame_decoder_adapter.h" @@ -476,8 +476,7 @@ max_inbound_header_list_size_; } -void QuicSpdySession::OnDecoderStreamError( - quiche::QuicheStringPiece error_message) { +void QuicSpdySession::OnDecoderStreamError(absl::string_view error_message) { DCHECK(VersionUsesHttp3(transport_version())); CloseConnectionWithDetails( @@ -485,8 +484,7 @@ quiche::QuicheStrCat("Decoder stream error: ", error_message)); } -void QuicSpdySession::OnEncoderStreamError( - quiche::QuicheStringPiece error_message) { +void QuicSpdySession::OnEncoderStreamError(absl::string_view error_message) { DCHECK(VersionUsesHttp3(transport_version())); CloseConnectionWithDetails( @@ -646,7 +644,7 @@ SpdyPriorityIR priority_frame(id, parent_stream_id, weight, exclusive); SpdySerializedFrame frame(spdy_framer_.SerializeFrame(priority_frame)); headers_stream()->WriteOrBufferData( - quiche::QuicheStringPiece(frame.data(), frame.size()), false, nullptr); + absl::string_view(frame.data(), frame.size()), false, nullptr); return frame.size(); } @@ -777,7 +775,7 @@ SpdySerializedFrame frame(spdy_framer_.SerializeFrame(push_promise)); headers_stream()->WriteOrBufferData( - quiche::QuicheStringPiece(frame.data(), frame.size()), false, nullptr); + absl::string_view(frame.data(), frame.size()), false, nullptr); return; } @@ -903,7 +901,7 @@ } SpdySerializedFrame frame(spdy_framer_.SerializeFrame(headers_frame)); headers_stream()->WriteOrBufferData( - quiche::QuicheStringPiece(frame.data(), frame.size()), false, + absl::string_view(frame.data(), frame.size()), false, std::move(ack_listener)); // Calculate compressed header block size without framing overhead. @@ -1467,7 +1465,7 @@ } void QuicSpdySession::CloseConnectionOnDuplicateHttp3UnidirectionalStreams( - quiche::QuicheStringPiece type) { + absl::string_view type) { QUIC_PEER_BUG << quiche::QuicheStrCat("Received a duplicate ", type, " stream: Closing connection."); CloseConnectionWithDetails(
diff --git a/quic/core/http/quic_spdy_session.h b/quic/core/http/quic_spdy_session.h index db8fc6b..f51072d 100644 --- a/quic/core/http/quic_spdy_session.h +++ b/quic/core/http/quic_spdy_session.h
@@ -9,6 +9,7 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/http_frames.h" #include "net/third_party/quiche/src/quic/core/http/quic_header_list.h" #include "net/third_party/quiche/src/quic/core/http/quic_headers_stream.h" @@ -27,7 +28,6 @@ #include "net/third_party/quiche/src/quic/core/quic_versions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_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/http2_frame_decoder_adapter.h" namespace quic { @@ -154,10 +154,10 @@ void Initialize() override; // QpackEncoder::DecoderStreamErrorDelegate implementation. - void OnDecoderStreamError(quiche::QuicheStringPiece error_message) override; + void OnDecoderStreamError(absl::string_view error_message) override; // QpackDecoder::EncoderStreamErrorDelegate implementation. - void OnEncoderStreamError(quiche::QuicheStringPiece error_message) override; + void OnEncoderStreamError(absl::string_view error_message) override; // Called by |headers_stream_| when headers with a priority have been // received for a stream. This method will only be called for server streams. @@ -485,7 +485,7 @@ const spdy::SpdyStreamPrecedence& precedence); void CloseConnectionOnDuplicateHttp3UnidirectionalStreams( - quiche::QuicheStringPiece type); + absl::string_view type); // Sends any data which should be sent at the start of a connection, including // the initial SETTINGS frame, and (when IETF QUIC is used) also a MAX_PUSH_ID
diff --git a/quic/core/http/quic_spdy_session_test.cc b/quic/core/http/quic_spdy_session_test.cc index 46a5456..8af0087 100644 --- a/quic/core/http/quic_spdy_session_test.cc +++ b/quic/core/http/quic_spdy_session_test.cc
@@ -10,6 +10,7 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" #include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" #include "net/third_party/quiche/src/quic/core/frames/quic_stream_frame.h" @@ -43,7 +44,6 @@ #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_endian.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/spdy/core/spdy_framer.h" @@ -1258,7 +1258,7 @@ CompleteHandshake(); // Send two bytes of payload. QuicStreamFrame data1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece("HT")); + absl::string_view("HT")); session_.OnStreamFrame(data1); EXPECT_EQ(1u, QuicSessionPeer::GetNumOpenDynamicStreams(&session_)); @@ -1309,14 +1309,14 @@ id = GetNthClientInitiatedUnidirectionalStreamId(transport_version(), 3); char type[] = {kControlStream}; - QuicStreamFrame data1(id, false, 0, quiche::QuicheStringPiece(type, 1)); + QuicStreamFrame data1(id, false, 0, absl::string_view(type, 1)); session_.OnStreamFrame(data1); } else { id = QuicUtils::GetHeadersStreamId(transport_version()); } // Send two bytes of payload. - QuicStreamFrame data1(id, true, 0, quiche::QuicheStringPiece("HT")); + QuicStreamFrame data1(id, true, 0, absl::string_view("HT")); EXPECT_CALL(*connection_, CloseConnection( QUIC_INVALID_STREAM_ID, "Attempt to close a static stream", @@ -1333,7 +1333,7 @@ id = GetNthClientInitiatedUnidirectionalStreamId(transport_version(), 3); char type[] = {kControlStream}; - QuicStreamFrame data1(id, false, 0, quiche::QuicheStringPiece(type, 1)); + QuicStreamFrame data1(id, false, 0, absl::string_view(type, 1)); session_.OnStreamFrame(data1); expected_error = QUIC_HTTP_CLOSED_CRITICAL_STREAM; error_message = "RESET_STREAM received for receive control stream"; @@ -1356,7 +1356,7 @@ TEST_P(QuicSpdySessionTestServer, OnStreamFrameInvalidStreamId) { // Send two bytes of payload. QuicStreamFrame data1(QuicUtils::GetInvalidStreamId(transport_version()), - true, 0, quiche::QuicheStringPiece("HT")); + true, 0, absl::string_view("HT")); EXPECT_CALL(*connection_, CloseConnection( QUIC_INVALID_STREAM_ID, "Received data for an invalid stream", @@ -1679,7 +1679,7 @@ // FIN or a RST_STREAM from the client. const QuicStreamId kNextId = QuicUtils::StreamIdDelta(transport_version()); for (QuicStreamId i = kFirstStreamId; i < kFinalStreamId; i += kNextId) { - QuicStreamFrame data1(i, false, 0, quiche::QuicheStringPiece("HT")); + QuicStreamFrame data1(i, false, 0, absl::string_view("HT")); session_.OnStreamFrame(data1); CloseStream(i); } @@ -1701,8 +1701,7 @@ _)); } // Create one more data streams to exceed limit of open stream. - QuicStreamFrame data1(kFinalStreamId, false, 0, - quiche::QuicheStringPiece("HT")); + QuicStreamFrame data1(kFinalStreamId, false, 0, absl::string_view("HT")); session_.OnStreamFrame(data1); } @@ -1737,7 +1736,7 @@ const QuicStreamId kFinalStreamId = GetNthClientInitiatedBidirectionalId(kMaxStreams + 1); for (QuicStreamId i = kFirstStreamId; i < kFinalStreamId; i += IdDelta()) { - QuicStreamFrame data1(i, true, 0, quiche::QuicheStringPiece("HT")); + QuicStreamFrame data1(i, true, 0, absl::string_view("HT")); session_.OnStreamFrame(data1); EXPECT_EQ(1u, QuicSessionPeer::GetNumOpenDynamicStreams(&session_)); session_.StreamDraining(i, /*unidirectional=*/false); @@ -1757,7 +1756,7 @@ QuicStreamId stream_id = GetNthClientInitiatedUnidirectionalStreamId(transport_version(), 3); char type[] = {kControlStream}; - quiche::QuicheStringPiece stream_type(type, 1); + absl::string_view stream_type(type, 1); QuicStreamOffset offset = 0; QuicStreamFrame data1(stream_id, false, offset, stream_type); @@ -1902,7 +1901,7 @@ QuicStreamPeer::CloseReadSide(stream); // Receive a stream data frame with FIN. - QuicStreamFrame frame(stream_id, true, 0, quiche::QuicheStringPiece()); + QuicStreamFrame frame(stream_id, true, 0, absl::string_view()); session_.OnStreamFrame(frame); EXPECT_TRUE(stream->fin_received()); @@ -1956,8 +1955,8 @@ const QuicMemSlice& slice = QuicStreamSendBufferPeer::CurrentWriteSlice(&send_buffer)->slice; - EXPECT_EQ(quiche::QuicheStringPiece(frame.data(), frame.size()), - quiche::QuicheStringPiece(slice.data(), slice.length())); + EXPECT_EQ(absl::string_view(frame.data(), frame.size()), + absl::string_view(slice.data(), slice.length())); } TEST_P(QuicSpdySessionTestClient, Http3ServerPush) { @@ -2198,7 +2197,7 @@ QuicStreamId receive_control_stream_id = GetNthClientInitiatedUnidirectionalStreamId(transport_version(), 3); char type[] = {kControlStream}; - quiche::QuicheStringPiece stream_type(type, 1); + absl::string_view stream_type(type, 1); QuicStreamOffset offset = 0; QuicStreamFrame data1(receive_control_stream_id, false, offset, stream_type); offset += stream_type.length(); @@ -2264,7 +2263,7 @@ char input[] = {0x04, // type 'a', 'b', 'c'}; // data - quiche::QuicheStringPiece payload(input, QUICHE_ARRAYSIZE(input)); + absl::string_view payload(input, QUICHE_ARRAYSIZE(input)); // This is a server test with a client-initiated unidirectional stream. QuicStreamId stream_id = QuicUtils::GetFirstUnidirectionalStreamId( @@ -2316,7 +2315,7 @@ char input[] = {0x04, // type 'a', 'b', 'c'}; // data - quiche::QuicheStringPiece payload(input, QUICHE_ARRAYSIZE(input)); + absl::string_view payload(input, QUICHE_ARRAYSIZE(input)); // This is a server test with a client-initiated unidirectional stream. QuicStreamId stream_id = QuicUtils::GetFirstUnidirectionalStreamId( @@ -2357,7 +2356,7 @@ char input[] = {0x41, 0x00, // type (256) 'a', 'b', 'c'}; // data - quiche::QuicheStringPiece payload(input, QUICHE_ARRAYSIZE(input)); + absl::string_view payload(input, QUICHE_ARRAYSIZE(input)); // This is a server test with a client-initiated unidirectional stream. QuicStreamId stream_id = QuicUtils::GetFirstUnidirectionalStreamId( @@ -2408,8 +2407,7 @@ GetNthClientInitiatedUnidirectionalStreamId(transport_version(), 3); char type[] = {kControlStream}; - QuicStreamFrame data1(stream_id, false, 0, - quiche::QuicheStringPiece(type, 1)); + QuicStreamFrame data1(stream_id, false, 0, absl::string_view(type, 1)); EXPECT_CALL(debug_visitor, OnPeerControlStreamCreated(stream_id)); session_.OnStreamFrame(data1); EXPECT_EQ(stream_id, @@ -2420,7 +2418,7 @@ settings.values[SETTINGS_MAX_FIELD_SECTION_SIZE] = 5; settings.values[SETTINGS_QPACK_BLOCKED_STREAMS] = 42; std::string data = EncodeSettings(settings); - QuicStreamFrame frame(stream_id, false, 1, quiche::QuicheStringPiece(data)); + QuicStreamFrame frame(stream_id, false, 1, absl::string_view(data)); QpackEncoder* qpack_encoder = session_.qpack_encoder(); QpackHeaderTable* header_table = @@ -2453,9 +2451,8 @@ settings.values[SETTINGS_MAX_FIELD_SECTION_SIZE] = 5; std::string data = EncodeSettings(settings); - QuicStreamFrame data1(stream_id, false, 1, quiche::QuicheStringPiece(data)); - QuicStreamFrame data2(stream_id, false, 0, - quiche::QuicheStringPiece(type, 1)); + QuicStreamFrame data1(stream_id, false, 1, absl::string_view(data)); + QuicStreamFrame data2(stream_id, false, 0, absl::string_view(type, 1)); session_.OnStreamFrame(data1); EXPECT_NE(5u, session_.max_outbound_header_list_size()); @@ -2480,8 +2477,8 @@ QuicByteCount headers_frame_header_length = HttpEncoder::SerializeHeadersFrameHeader(headers_payload.length(), &headers_buffer); - quiche::QuicheStringPiece headers_frame_header(headers_buffer.get(), - headers_frame_header_length); + absl::string_view headers_frame_header(headers_buffer.get(), + headers_frame_header_length); std::string headers = quiche::QuicheStrCat(headers_frame_header, headers_payload); stream->OnStreamFrame(QuicStreamFrame(stream_id, false, 0, headers)); @@ -2515,8 +2512,8 @@ QuicByteCount headers_frame_header_length = HttpEncoder::SerializeHeadersFrameHeader(headers_payload.length(), &headers_buffer); - quiche::QuicheStringPiece headers_frame_header(headers_buffer.get(), - headers_frame_header_length); + absl::string_view headers_frame_header(headers_buffer.get(), + headers_frame_header_length); std::string headers = quiche::QuicheStrCat(headers_frame_header, headers_payload); stream->OnStreamFrame(QuicStreamFrame(stream_id, false, 0, headers)); @@ -2673,12 +2670,12 @@ GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 0); char type1[] = {kControlStream}; - QuicStreamFrame data1(id1, false, 0, quiche::QuicheStringPiece(type1, 1)); + QuicStreamFrame data1(id1, false, 0, absl::string_view(type1, 1)); EXPECT_CALL(debug_visitor, OnPeerControlStreamCreated(id1)); session_.OnStreamFrame(data1); QuicStreamId id2 = GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 1); - QuicStreamFrame data2(id2, false, 0, quiche::QuicheStringPiece(type1, 1)); + QuicStreamFrame data2(id2, false, 0, absl::string_view(type1, 1)); EXPECT_CALL(debug_visitor, OnPeerControlStreamCreated(id2)).Times(0); EXPECT_CALL(*connection_, CloseConnection(QUIC_HTTP_DUPLICATE_UNIDIRECTIONAL_STREAM, @@ -2691,13 +2688,13 @@ GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 2); char type2[]{kQpackEncoderStream}; - QuicStreamFrame data3(id3, false, 0, quiche::QuicheStringPiece(type2, 1)); + QuicStreamFrame data3(id3, false, 0, absl::string_view(type2, 1)); EXPECT_CALL(debug_visitor, OnPeerQpackEncoderStreamCreated(id3)); session_.OnStreamFrame(data3); QuicStreamId id4 = GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 3); - QuicStreamFrame data4(id4, false, 0, quiche::QuicheStringPiece(type2, 1)); + QuicStreamFrame data4(id4, false, 0, absl::string_view(type2, 1)); EXPECT_CALL(debug_visitor, OnPeerQpackEncoderStreamCreated(id4)).Times(0); EXPECT_CALL(*connection_, CloseConnection(QUIC_HTTP_DUPLICATE_UNIDIRECTIONAL_STREAM, @@ -2710,13 +2707,13 @@ GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 4); char type3[]{kQpackDecoderStream}; - QuicStreamFrame data5(id5, false, 0, quiche::QuicheStringPiece(type3, 1)); + QuicStreamFrame data5(id5, false, 0, absl::string_view(type3, 1)); EXPECT_CALL(debug_visitor, OnPeerQpackDecoderStreamCreated(id5)); session_.OnStreamFrame(data5); QuicStreamId id6 = GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 5); - QuicStreamFrame data6(id6, false, 0, quiche::QuicheStringPiece(type3, 1)); + QuicStreamFrame data6(id6, false, 0, absl::string_view(type3, 1)); EXPECT_CALL(debug_visitor, OnPeerQpackDecoderStreamCreated(id6)).Times(0); EXPECT_CALL(*connection_, CloseConnection(QUIC_HTTP_DUPLICATE_UNIDIRECTIONAL_STREAM, @@ -2817,7 +2814,7 @@ QuicStreamId receive_control_stream_id = GetNthServerInitiatedUnidirectionalStreamId(transport_version(), 3); char type[] = {kControlStream}; - quiche::QuicheStringPiece stream_type(type, 1); + absl::string_view stream_type(type, 1); QuicStreamOffset offset = 0; QuicStreamFrame data1(receive_control_stream_id, /* fin = */ false, offset, stream_type); @@ -2841,7 +2838,7 @@ auto frame_length = HttpEncoder::SerializeCancelPushFrame(cancel_push, &buffer); QuicStreamFrame data3(receive_control_stream_id, /* fin = */ false, offset, - quiche::QuicheStringPiece(buffer.get(), frame_length)); + absl::string_view(buffer.get(), frame_length)); EXPECT_CALL(debug_visitor, OnCancelPushFrameReceived(_)); session_.OnStreamFrame(data3); } @@ -2942,9 +2939,8 @@ QuicStreamId stream_id = GetNthClientInitiatedUnidirectionalStreamId(transport_version(), i + 1); const QuicByteCount data_length = 1; - QuicStreamFrame data( - stream_id, false, 0, - quiche::QuicheStringPiece(&kTestData[i].type, data_length)); + QuicStreamFrame data(stream_id, false, 0, + absl::string_view(&kTestData[i].type, data_length)); session_.OnStreamFrame(data); EXPECT_CALL(*connection_, CloseConnection(QUIC_HTTP_CLOSED_CRITICAL_STREAM, @@ -3029,7 +3025,7 @@ QuicStreamId receive_control_stream_id = GetNthClientInitiatedUnidirectionalStreamId(transport_version(), 3); char type[] = {kControlStream}; - quiche::QuicheStringPiece stream_type(type, 1); + absl::string_view stream_type(type, 1); QuicStreamOffset offset = 0; QuicStreamFrame data1(receive_control_stream_id, /* fin = */ false, offset, stream_type); @@ -3053,7 +3049,7 @@ auto frame_length = HttpEncoder::SerializeCancelPushFrame(cancel_push, &buffer); QuicStreamFrame data3(receive_control_stream_id, /* fin = */ false, offset, - quiche::QuicheStringPiece(buffer.get(), frame_length)); + absl::string_view(buffer.get(), frame_length)); EXPECT_CALL(debug_visitor, OnCancelPushFrameReceived(_)); session_.OnStreamFrame(data3); }
diff --git a/quic/core/http/quic_spdy_stream.cc b/quic/core/http/quic_spdy_stream.cc index 1c5f964..1a217f5 100644 --- a/quic/core/http/quic_spdy_stream.cc +++ b/quic/core/http/quic_spdy_stream.cc
@@ -8,6 +8,7 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/http_constants.h" #include "net/third_party/quiche/src/quic/core/http/http_decoder.h" #include "net/third_party/quiche/src/quic/core/http/quic_spdy_session.h" @@ -23,7 +24,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_mem_slice_storage.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" @@ -74,7 +74,7 @@ return stream_->OnDataFrameStart(header_length, payload_length); } - bool OnDataFramePayload(quiche::QuicheStringPiece payload) override { + bool OnDataFramePayload(absl::string_view payload) override { DCHECK(!payload.empty()); return stream_->OnDataFramePayload(payload); } @@ -90,7 +90,7 @@ return stream_->OnHeadersFrameStart(header_length, payload_length); } - bool OnHeadersFramePayload(quiche::QuicheStringPiece payload) override { + bool OnHeadersFramePayload(absl::string_view payload) override { DCHECK(!payload.empty()); if (!VersionUsesHttp3(stream_->transport_version())) { CloseConnectionOnWrongFrame("Headers"); @@ -126,7 +126,7 @@ header_block_length); } - bool OnPushPromiseFramePayload(quiche::QuicheStringPiece payload) override { + bool OnPushPromiseFramePayload(absl::string_view payload) override { DCHECK(!payload.empty()); if (!VersionUsesHttp3(stream_->transport_version())) { CloseConnectionOnWrongFrame("Push Promise"); @@ -160,14 +160,14 @@ payload_length); } - bool OnUnknownFramePayload(quiche::QuicheStringPiece payload) override { + bool OnUnknownFramePayload(absl::string_view payload) override { return stream_->OnUnknownFramePayload(payload); } bool OnUnknownFrameEnd() override { return stream_->OnUnknownFrameEnd(); } private: - void CloseConnectionOnWrongFrame(quiche::QuicheStringPiece frame_type) { + void CloseConnectionOnWrongFrame(absl::string_view frame_type) { stream_->OnUnrecoverableError( QUIC_HTTP_FRAME_UNEXPECTED_ON_SPDY_STREAM, quiche::QuicheStrCat(frame_type, " frame received on data stream")); @@ -272,8 +272,8 @@ QUIC_LOG(INFO) << ENDPOINT << "Stream " << id() << " is writing type as server push"; - WriteOrBufferData(quiche::QuicheStringPiece(writer.data(), writer.length()), - false, nullptr); + WriteOrBufferData(absl::string_view(writer.data(), writer.length()), false, + nullptr); } size_t bytes_written = @@ -289,8 +289,7 @@ return bytes_written; } -void QuicSpdyStream::WriteOrBufferBody(quiche::QuicheStringPiece data, - bool fin) { +void QuicSpdyStream::WriteOrBufferBody(absl::string_view data, bool fin) { if (!VersionUsesHttp3(transport_version()) || data.length() == 0) { WriteOrBufferData(data, fin, nullptr); return; @@ -311,8 +310,8 @@ QUIC_DLOG(INFO) << ENDPOINT << "Stream " << id() << " is writing DATA frame header of length " << header_length; - WriteOrBufferData(quiche::QuicheStringPiece(buffer.get(), header_length), - false, nullptr); + WriteOrBufferData(absl::string_view(buffer.get(), header_length), false, + nullptr); // Write body. QUIC_DLOG(INFO) << ENDPOINT << "Stream " << id() @@ -379,8 +378,8 @@ << " is writing Push Promise frame header of length " << push_promise_frame_length << " , with promised id " << frame.push_id; - WriteOrBufferData(quiche::QuicheStringPiece(push_promise_frame_with_id.get(), - push_promise_frame_length), + WriteOrBufferData(absl::string_view(push_promise_frame_with_id.get(), + push_promise_frame_length), /* fin = */ false, /* ack_listener = */ nullptr); // Write response headers. @@ -594,8 +593,7 @@ } } -void QuicSpdyStream::OnHeaderDecodingError( - quiche::QuicheStringPiece error_message) { +void QuicSpdyStream::OnHeaderDecodingError(absl::string_view error_message) { qpack_decoded_headers_accumulator_.reset(); std::string connection_close_error_message = quiche::QuicheStrCat( @@ -641,14 +639,14 @@ if (fin) { OnStreamFrame(QuicStreamFrame(id(), /* fin = */ true, highest_received_byte_offset(), - quiche::QuicheStringPiece())); + absl::string_view())); } return; } if (fin && !rst_sent()) { - OnStreamFrame(QuicStreamFrame(id(), fin, /* offset = */ 0, - quiche::QuicheStringPiece())); + OnStreamFrame( + QuicStreamFrame(id(), fin, /* offset = */ 0, absl::string_view())); } if (FinishedReadingHeaders()) { sequencer()->SetUnblocked(); @@ -703,8 +701,7 @@ const QuicStreamOffset offset = VersionUsesHttp3(transport_version()) ? highest_received_byte_offset() : final_byte_offset; - OnStreamFrame( - QuicStreamFrame(id(), fin, offset, quiche::QuicheStringPiece())); + OnStreamFrame(QuicStreamFrame(id(), fin, offset, absl::string_view())); } } @@ -835,7 +832,7 @@ if (it == header.end()) { return false; } - const quiche::QuicheStringPiece status(it->second); + const absl::string_view status(it->second); if (status.size() != 3) { return false; } @@ -886,7 +883,7 @@ return true; } -bool QuicSpdyStream::OnDataFramePayload(quiche::QuicheStringPiece payload) { +bool QuicSpdyStream::OnDataFramePayload(absl::string_view payload) { DCHECK(VersionUsesHttp3(transport_version())); body_manager_.OnBody(payload); @@ -981,7 +978,7 @@ return true; } -bool QuicSpdyStream::OnHeadersFramePayload(quiche::QuicheStringPiece payload) { +bool QuicSpdyStream::OnHeadersFramePayload(absl::string_view payload) { DCHECK(VersionUsesHttp3(transport_version())); DCHECK(qpack_decoded_headers_accumulator_); @@ -1045,8 +1042,7 @@ return true; } -bool QuicSpdyStream::OnPushPromiseFramePayload( - quiche::QuicheStringPiece payload) { +bool QuicSpdyStream::OnPushPromiseFramePayload(absl::string_view payload) { spdy_session_->OnCompressedFrameSize(payload.length()); return OnHeadersFramePayload(payload); } @@ -1073,7 +1069,7 @@ return true; } -bool QuicSpdyStream::OnUnknownFramePayload(quiche::QuicheStringPiece payload) { +bool QuicSpdyStream::OnUnknownFramePayload(absl::string_view payload) { // Ignore unknown frames, but consume frame payload. QUIC_DVLOG(1) << ENDPOINT << "Discarding " << payload.size() << " bytes of payload of frame of unknown type."; @@ -1117,8 +1113,8 @@ QUIC_DLOG(INFO) << ENDPOINT << "Stream " << id() << " is writing HEADERS frame header of length " << headers_frame_header_length; - WriteOrBufferData(quiche::QuicheStringPiece(headers_frame_header.get(), - headers_frame_header_length), + WriteOrBufferData(absl::string_view(headers_frame_header.get(), + headers_frame_header_length), /* fin = */ false, /* ack_listener = */ nullptr); QUIC_DLOG(INFO) << ENDPOINT << "Stream " << id()
diff --git a/quic/core/http/quic_spdy_stream.h b/quic/core/http/quic_spdy_stream.h index 5a58842..c460b6e 100644 --- a/quic/core/http/quic_spdy_stream.h +++ b/quic/core/http/quic_spdy_stream.h
@@ -15,6 +15,7 @@ #include <list> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/http_decoder.h" #include "net/third_party/quiche/src/quic/core/http/http_encoder.h" #include "net/third_party/quiche/src/quic/core/http/quic_header_list.h" @@ -26,7 +27,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_framer.h" namespace quic { @@ -122,7 +122,7 @@ QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener); // Sends |data| to the peer, or buffers if it can't be sent immediately. - void WriteOrBufferBody(quiche::QuicheStringPiece data, bool fin); + void WriteOrBufferBody(absl::string_view data, bool fin); // Writes the trailers contained in |trailer_block| on the dedicated headers // stream or on this stream, depending on VersionUsesHttp3(). Trailers will @@ -220,7 +220,7 @@ // QpackDecodedHeadersAccumulator::Visitor implementation. void OnHeadersDecoded(QuicHeaderList headers, bool header_list_size_limit_exceeded) override; - void OnHeaderDecodingError(quiche::QuicheStringPiece error_message) override; + void OnHeaderDecodingError(absl::string_view error_message) override; QuicSpdySession* spdy_session() const { return spdy_session_; } @@ -262,22 +262,22 @@ // Called by HttpDecoderVisitor. bool OnDataFrameStart(QuicByteCount header_length, QuicByteCount payload_length); - bool OnDataFramePayload(quiche::QuicheStringPiece payload); + bool OnDataFramePayload(absl::string_view payload); bool OnDataFrameEnd(); bool OnHeadersFrameStart(QuicByteCount header_length, QuicByteCount payload_length); - bool OnHeadersFramePayload(quiche::QuicheStringPiece payload); + bool OnHeadersFramePayload(absl::string_view payload); bool OnHeadersFrameEnd(); bool OnPushPromiseFrameStart(QuicByteCount header_length); bool OnPushPromiseFramePushId(PushId push_id, QuicByteCount push_id_length, QuicByteCount header_block_length); - bool OnPushPromiseFramePayload(quiche::QuicheStringPiece payload); + bool OnPushPromiseFramePayload(absl::string_view payload); bool OnPushPromiseFrameEnd(); bool OnUnknownFrameStart(uint64_t frame_type, QuicByteCount header_length, QuicByteCount payload_length); - bool OnUnknownFramePayload(quiche::QuicheStringPiece payload); + bool OnUnknownFramePayload(absl::string_view payload); bool OnUnknownFrameEnd(); // Given the interval marked by [|offset|, |offset| + |data_length|), return
diff --git a/quic/core/http/quic_spdy_stream_body_manager.cc b/quic/core/http/quic_spdy_stream_body_manager.cc index 1e36aa7..83af51d 100644 --- a/quic/core/http/quic_spdy_stream_body_manager.cc +++ b/quic/core/http/quic_spdy_stream_body_manager.cc
@@ -6,8 +6,8 @@ #include <algorithm> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -28,7 +28,7 @@ return 0; } -void QuicSpdyStreamBodyManager::OnBody(quiche::QuicheStringPiece body) { +void QuicSpdyStreamBodyManager::OnBody(absl::string_view body) { DCHECK(!body.empty()); fragments_.push_back({body, 0}); @@ -46,7 +46,7 @@ } Fragment& fragment = fragments_.front(); - const quiche::QuicheStringPiece body = fragment.body; + const absl::string_view body = fragment.body; if (body.length() > remaining_bytes) { // Consume leading |remaining_bytes| bytes of body. @@ -78,7 +78,7 @@ size_t iov_filled = 0; while (iov_filled < fragments_.size() && iov_filled < iov_len) { - quiche::QuicheStringPiece body = fragments_[iov_filled].body; + absl::string_view body = fragments_[iov_filled].body; iov[iov_filled].iov_base = const_cast<char*>(body.data()); iov[iov_filled].iov_len = body.size(); iov_filled++; @@ -102,7 +102,7 @@ while (!fragments_.empty()) { Fragment& fragment = fragments_.front(); - const quiche::QuicheStringPiece body = fragment.body; + const absl::string_view body = fragment.body; const size_t bytes_to_copy = std::min<size_t>(body.length(), dest_remaining);
diff --git a/quic/core/http/quic_spdy_stream_body_manager.h b/quic/core/http/quic_spdy_stream_body_manager.h index a5afeca..d4afc10 100644 --- a/quic/core/http/quic_spdy_stream_body_manager.h +++ b/quic/core/http/quic_spdy_stream_body_manager.h
@@ -5,13 +5,13 @@ #ifndef QUICHE_QUIC_CORE_HTTP_QUIC_SPDY_STREAM_BODY_MANAGER_H_ #define QUICHE_QUIC_CORE_HTTP_QUIC_SPDY_STREAM_BODY_MANAGER_H_ +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_circular_deque.h" #include "net/third_party/quiche/src/quic/core/quic_constants.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" #include "net/third_party/quiche/src/quic/platform/api/quic_iovec.h" #include "net/third_party/quiche/src/quic/platform/api/quic_macros.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -43,7 +43,7 @@ // Called when body is received. |body| is added to |fragments_|. The data // pointed to by |body| must be kept alive until an OnBodyConsumed() or // ReadBody() call consumes it. |body| must not be empty. - void OnBody(quiche::QuicheStringPiece body); + void OnBody(absl::string_view body); // Internally marks |num_bytes| of body consumed. |num_bytes| might be zero. // Returns the number of bytes that the caller should mark consumed with the @@ -79,7 +79,7 @@ // consumed as soon as all of the body fragment is read. struct QUIC_EXPORT_PRIVATE Fragment { // |body| must not be empty. - quiche::QuicheStringPiece body; + absl::string_view body; // Might be zero. QuicByteCount trailing_non_body_byte_count; };
diff --git a/quic/core/http/quic_spdy_stream_body_manager_test.cc b/quic/core/http/quic_spdy_stream_body_manager_test.cc index 0cdc65a..85d3a2f 100644 --- a/quic/core/http/quic_spdy_stream_body_manager_test.cc +++ b/quic/core/http/quic_spdy_stream_body_manager_test.cc
@@ -8,11 +8,11 @@ #include <numeric> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_expect_bug.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -154,7 +154,7 @@ static_cast<size_t>(body_manager.PeekBody(&iovecs[0], iov_len))); for (size_t iovec_index = 0; iovec_index < iovs_filled; ++iovec_index) { EXPECT_EQ(frame_payloads[iovec_index], - quiche::QuicheStringPiece( + absl::string_view( static_cast<const char*>(iovecs[iovec_index].iov_base), iovecs[iovec_index].iov_len)); }
diff --git a/quic/core/http/quic_spdy_stream_test.cc b/quic/core/http/quic_spdy_stream_test.cc index 1c55c96..0abec1d 100644 --- a/quic/core/http/quic_spdy_stream_test.cc +++ b/quic/core/http/quic_spdy_stream_test.cc
@@ -9,6 +9,7 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" #include "net/third_party/quiche/src/quic/core/http/http_encoder.h" #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" @@ -31,7 +32,6 @@ #include "net/third_party/quiche/src/quic/test_tools/quic_stream_peer.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using spdy::kV3HighestPriority; @@ -307,8 +307,7 @@ // Return QPACK-encoded header block without using the dynamic table. std::string EncodeQpackHeaders( - std::vector<std::pair<quiche::QuicheStringPiece, - quiche::QuicheStringPiece>> headers) { + std::vector<std::pair<absl::string_view, absl::string_view>> headers) { SpdyHeaderBlock header_block; for (const auto& header_field : headers) { header_block.AppendValueOrAddHeader(header_field.first, @@ -408,8 +407,7 @@ // Construct HEADERS frame with QPACK-encoded |headers| without using the // dynamic table. std::string HeadersFrame( - std::vector<std::pair<quiche::QuicheStringPiece, - quiche::QuicheStringPiece>> headers) { + std::vector<std::pair<absl::string_view, absl::string_view>> headers) { return HeadersFrame(EncodeQpackHeaders(headers)); } @@ -420,19 +418,19 @@ } // Construct HEADERS frame with given payload. - std::string HeadersFrame(quiche::QuicheStringPiece payload) { + std::string HeadersFrame(absl::string_view payload) { std::unique_ptr<char[]> headers_buffer; QuicByteCount headers_frame_header_length = HttpEncoder::SerializeHeadersFrameHeader(payload.length(), &headers_buffer); - quiche::QuicheStringPiece headers_frame_header(headers_buffer.get(), - headers_frame_header_length); + absl::string_view headers_frame_header(headers_buffer.get(), + headers_frame_header_length); return quiche::QuicheStrCat(headers_frame_header, payload); } // Construct PUSH_PROMISE frame with given payload. std::string SerializePushPromiseFrame(PushId push_id, - quiche::QuicheStringPiece payload) { + absl::string_view payload) { PushPromiseFrame frame; frame.push_id = push_id; frame.headers = payload; @@ -440,22 +438,21 @@ QuicByteCount push_promise_frame_header_length = HttpEncoder::SerializePushPromiseFrameWithOnlyPushId( frame, &push_promise_buffer); - quiche::QuicheStringPiece push_promise_frame_header( + absl::string_view push_promise_frame_header( push_promise_buffer.get(), push_promise_frame_header_length); return quiche::QuicheStrCat(push_promise_frame_header, payload); } - std::string DataFrame(quiche::QuicheStringPiece payload) { + std::string DataFrame(absl::string_view payload) { std::unique_ptr<char[]> data_buffer; QuicByteCount data_frame_header_length = HttpEncoder::SerializeDataFrameHeader(payload.length(), &data_buffer); - quiche::QuicheStringPiece data_frame_header(data_buffer.get(), - data_frame_header_length); + absl::string_view data_frame_header(data_buffer.get(), + data_frame_header_length); return quiche::QuicheStrCat(data_frame_header, payload); } - std::string UnknownFrame(uint64_t frame_type, - quiche::QuicheStringPiece payload) { + std::string UnknownFrame(uint64_t frame_type, absl::string_view payload) { std::string frame; const size_t length = QuicDataWriter::GetVarInt62Len(frame_type) + QuicDataWriter::GetVarInt62Len(payload.size()) + @@ -646,7 +643,7 @@ EXPECT_EQ(headers, stream_->header_list()); stream_->ConsumeHeaderList(); QuicStreamFrame frame(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); EXPECT_CALL(*connection_, CloseConnection(QUIC_HTTP_FRAME_UNEXPECTED_ON_SPDY_STREAM, _, _)) @@ -712,7 +709,7 @@ EXPECT_EQ(headers, stream_->header_list()); stream_->ConsumeHeaderList(); QuicStreamFrame frame(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); stream_->OnStreamFrame(frame); EXPECT_EQ(QuicHeaderList(), stream_->header_list()); EXPECT_EQ(body, stream_->data()); @@ -729,10 +726,10 @@ stream_->ConsumeHeaderList(); for (size_t offset = 0; offset < data.size(); offset += fragment_size) { size_t remaining_data = data.size() - offset; - quiche::QuicheStringPiece fragment( - data.data() + offset, std::min(fragment_size, remaining_data)); + absl::string_view fragment(data.data() + offset, + std::min(fragment_size, remaining_data)); QuicStreamFrame frame(GetNthClientInitiatedBidirectionalId(0), false, - offset, quiche::QuicheStringPiece(fragment)); + offset, absl::string_view(fragment)); stream_->OnStreamFrame(frame); } ASSERT_EQ(body, stream_->data()) << "fragment_size: " << fragment_size; @@ -749,15 +746,15 @@ ASSERT_EQ(headers, stream_->header_list()); stream_->ConsumeHeaderList(); - quiche::QuicheStringPiece fragment1(data.data(), split_point); + absl::string_view fragment1(data.data(), split_point); QuicStreamFrame frame1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(fragment1)); + absl::string_view(fragment1)); stream_->OnStreamFrame(frame1); - quiche::QuicheStringPiece fragment2(data.data() + split_point, - data.size() - split_point); + absl::string_view fragment2(data.data() + split_point, + data.size() - split_point); QuicStreamFrame frame2(GetNthClientInitiatedBidirectionalId(0), false, - split_point, quiche::QuicheStringPiece(fragment2)); + split_point, absl::string_view(fragment2)); stream_->OnStreamFrame(frame2); ASSERT_EQ(body, stream_->data()) << "split_point: " << split_point; @@ -772,7 +769,7 @@ ProcessHeaders(false, headers_); QuicStreamFrame frame(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); stream_->OnStreamFrame(frame); stream_->ConsumeHeaderList(); @@ -795,7 +792,7 @@ ProcessHeaders(false, headers_); QuicStreamFrame frame(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); stream_->OnStreamFrame(frame); stream_->ConsumeHeaderList(); char buffer[2048]; @@ -819,7 +816,7 @@ ProcessHeaders(false, headers_); QuicStreamFrame frame(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); stream_->OnStreamFrame(frame); stream_->ConsumeHeaderList(); @@ -842,9 +839,9 @@ ProcessHeaders(false, headers_); QuicStreamFrame frame1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data1)); + absl::string_view(data1)); QuicStreamFrame frame2(GetNthClientInitiatedBidirectionalId(0), false, - data1.length(), quiche::QuicheStringPiece(data2)); + data1.length(), absl::string_view(data2)); stream_->OnStreamFrame(frame1); stream_->OnStreamFrame(frame2); stream_->ConsumeHeaderList(); @@ -862,7 +859,7 @@ ProcessHeaders(false, headers_); QuicStreamFrame frame(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); stream_->OnStreamFrame(frame); stream_->ConsumeHeaderList(); @@ -886,7 +883,7 @@ ProcessHeaders(false, headers_); QuicStreamFrame frame(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); stream_->OnStreamFrame(frame); stream_->ConsumeHeaderList(); @@ -971,7 +968,7 @@ ProcessHeaders(false, headers_); QuicStreamFrame frame1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); stream_->OnStreamFrame(frame1); EXPECT_EQ(kWindow - (kWindow / 3) - header_length, QuicStreamPeer::ReceiveWindowSize(stream_)); @@ -980,8 +977,7 @@ // half full. This should all be buffered, decreasing the receive window but // not sending WINDOW_UPDATE. QuicStreamFrame frame2(GetNthClientInitiatedBidirectionalId(0), false, - kWindow / 3 + header_length, - quiche::QuicheStringPiece(data)); + kWindow / 3 + header_length, absl::string_view(data)); stream_->OnStreamFrame(frame2); EXPECT_EQ(kWindow - (2 * kWindow / 3) - 2 * header_length, QuicStreamPeer::ReceiveWindowSize(stream_)); @@ -1017,7 +1013,7 @@ stream_->ConsumeHeaderList(); QuicStreamFrame frame1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); stream_->OnStreamFrame(frame1); EXPECT_EQ(kWindow - (kWindow / 3) - header_length, QuicStreamPeer::ReceiveWindowSize(stream_)); @@ -1027,8 +1023,7 @@ // offset and send a WINDOW_UPDATE. The result will be again an available // window of kWindow bytes. QuicStreamFrame frame2(GetNthClientInitiatedBidirectionalId(0), false, - kWindow / 3 + header_length, - quiche::QuicheStringPiece(data)); + kWindow / 3 + header_length, absl::string_view(data)); EXPECT_CALL(*session_, SendWindowUpdate(_, _)); EXPECT_CALL(*connection_, SendControlFrame(_)); stream_->OnStreamFrame(frame2); @@ -1088,10 +1083,10 @@ } QuicStreamFrame frame1(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); stream_->OnStreamFrame(frame1); QuicStreamFrame frame2(GetNthClientInitiatedBidirectionalId(1), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); stream2_->OnStreamFrame(frame2); // Now receive a further single byte on one stream - again this does not @@ -1101,7 +1096,7 @@ EXPECT_CALL(*connection_, SendControlFrame(_)); QuicStreamFrame frame3(GetNthClientInitiatedBidirectionalId(0), false, body.length() + header_length, - quiche::QuicheStringPiece(data2)); + absl::string_view(data2)); stream_->OnStreamFrame(frame3); } @@ -1122,7 +1117,7 @@ std::string body(kWindow + 1, 'a'); std::string data = UsesHttp3() ? DataFrame(body) : body; QuicStreamFrame frame(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); EXPECT_CALL(*connection_, CloseConnection(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA, _, _)); stream_->OnStreamFrame(frame); @@ -1161,7 +1156,7 @@ EXPECT_LT(data.size(), kStreamWindow); QuicStreamFrame frame(GetNthClientInitiatedBidirectionalId(0), false, 0, - quiche::QuicheStringPiece(data)); + absl::string_view(data)); EXPECT_CALL(*connection_, CloseConnection(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA, _, _)); @@ -2051,7 +2046,7 @@ vec.iov_base = buffer; vec.iov_len = QUICHE_ARRAYSIZE(buffer); size_t bytes_read = stream_->Readv(&vec, 1); - EXPECT_EQ(kDataFramePayload, quiche::QuicheStringPiece(buffer, bytes_read)); + EXPECT_EQ(kDataFramePayload, absl::string_view(buffer, bytes_read)); EXPECT_FALSE(stream_->HasBytesToRead()); } @@ -2484,7 +2479,7 @@ // Create QuicStreamFrame with |payload| // and pass it to stream_->OnStreamFrame(). - void OnStreamFrame(quiche::QuicheStringPiece payload) { + void OnStreamFrame(absl::string_view payload) { QuicStreamFrame frame(stream_->id(), /* fin = */ false, offset_, payload); stream_->OnStreamFrame(frame); offset_ += payload.size(); @@ -2536,12 +2531,11 @@ // All HEADERS frame bytes are consumed even if the frame is not received // completely. - OnStreamFrame( - quiche::QuicheStringPiece(headers).substr(0, headers.size() - 1)); + OnStreamFrame(absl::string_view(headers).substr(0, headers.size() - 1)); EXPECT_EQ(headers.size() - 1, NewlyConsumedBytes()); // The rest of the HEADERS frame is also consumed immediately. - OnStreamFrame(quiche::QuicheStringPiece(headers).substr(headers.size() - 1)); + OnStreamFrame(absl::string_view(headers).substr(headers.size() - 1)); EXPECT_EQ(1u, NewlyConsumedBytes()); // Verify headers. @@ -2549,7 +2543,7 @@ stream_->ConsumeHeaderList(); // DATA frame. - quiche::QuicheStringPiece data_payload(kDataFramePayload); + absl::string_view data_payload(kDataFramePayload); std::string data_frame = DataFrame(data_payload); QuicByteCount data_frame_header_length = data_frame.size() - data_payload.size(); @@ -2568,8 +2562,7 @@ HeadersFrame({std::make_pair("custom-key", "custom-value")}); // No bytes are consumed, because last byte of DATA payload is still buffered. - OnStreamFrame( - quiche::QuicheStringPiece(trailers).substr(0, trailers.size() - 1)); + OnStreamFrame(absl::string_view(trailers).substr(0, trailers.size() - 1)); EXPECT_EQ(0u, NewlyConsumedBytes()); // Reading last byte of DATA payload triggers consumption of all data received @@ -2578,8 +2571,7 @@ EXPECT_EQ(1 + trailers.size() - 1, NewlyConsumedBytes()); // Last byte of trailers is immediately consumed. - OnStreamFrame( - quiche::QuicheStringPiece(trailers).substr(trailers.size() - 1)); + OnStreamFrame(absl::string_view(trailers).substr(trailers.size() - 1)); EXPECT_EQ(1u, NewlyConsumedBytes()); // Verify trailers. @@ -2619,12 +2611,11 @@ // All HEADERS frame bytes are consumed even if the frame is not received // completely. - OnStreamFrame( - quiche::QuicheStringPiece(headers).substr(0, headers.size() - 1)); + OnStreamFrame(absl::string_view(headers).substr(0, headers.size() - 1)); EXPECT_EQ(headers.size() - 1, NewlyConsumedBytes()); // The rest of the HEADERS frame is also consumed immediately. - OnStreamFrame(quiche::QuicheStringPiece(headers).substr(headers.size() - 1)); + OnStreamFrame(absl::string_view(headers).substr(headers.size() - 1)); EXPECT_EQ(1u, NewlyConsumedBytes()); // Verify headers. @@ -2638,7 +2629,7 @@ EXPECT_EQ(unknown_frame2.size(), NewlyConsumedBytes()); // DATA frame. - quiche::QuicheStringPiece data_payload(kDataFramePayload); + absl::string_view data_payload(kDataFramePayload); std::string data_frame = DataFrame(data_payload); QuicByteCount data_frame_header_length = data_frame.size() - data_payload.size(); @@ -2663,8 +2654,7 @@ HeadersFrame({std::make_pair("custom-key", "custom-value")}); // No bytes are consumed, because last byte of DATA payload is still buffered. - OnStreamFrame( - quiche::QuicheStringPiece(trailers).substr(0, trailers.size() - 1)); + OnStreamFrame(absl::string_view(trailers).substr(0, trailers.size() - 1)); EXPECT_EQ(0u, NewlyConsumedBytes()); // Reading last byte of DATA payload triggers consumption of all data received @@ -2674,8 +2664,7 @@ NewlyConsumedBytes()); // Last byte of trailers is immediately consumed. - OnStreamFrame( - quiche::QuicheStringPiece(trailers).substr(trailers.size() - 1)); + OnStreamFrame(absl::string_view(trailers).substr(trailers.size() - 1)); EXPECT_EQ(1u, NewlyConsumedBytes()); // Verify trailers.
diff --git a/quic/core/http/spdy_server_push_utils.cc b/quic/core/http/spdy_server_push_utils.cc index 4ba3289..3c89a54 100644 --- a/quic/core/http/spdy_server_push_utils.cc +++ b/quic/core/http/spdy_server_push_utils.cc
@@ -4,8 +4,8 @@ #include "net/third_party/quiche/src/quic/core/http/spdy_server_push_utils.h" +#include "absl/strings/string_view.h" #include "url/gurl.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using spdy::SpdyHeaderBlock; @@ -40,7 +40,7 @@ if (it == headers.end() || it->second.empty()) { return std::string(); } - quiche::QuicheStringPiece scheme = it->second; + absl::string_view scheme = it->second; // RFC 7540, Section 8.2: The server MUST include a value in the // ":authority" pseudo-header field for which the server is authoritative @@ -49,7 +49,7 @@ if (it == headers.end() || it->second.empty()) { return std::string(); } - quiche::QuicheStringPiece authority = it->second; + absl::string_view authority = it->second; // RFC 7540, Section 8.1.2.3 requires that the ":path" pseudo-header MUST // NOT be empty for "http" or "https" URIs; @@ -60,7 +60,7 @@ if (it == headers.end()) { return std::string(); } - quiche::QuicheStringPiece path = it->second; + absl::string_view path = it->second; return GetPushPromiseUrl(scheme, authority, path); } @@ -80,10 +80,9 @@ } // static -std::string SpdyServerPushUtils::GetPushPromiseUrl( - quiche::QuicheStringPiece scheme, - quiche::QuicheStringPiece authority, - quiche::QuicheStringPiece path) { +std::string SpdyServerPushUtils::GetPushPromiseUrl(absl::string_view scheme, + absl::string_view authority, + absl::string_view path) { // RFC 7540, Section 8.1.2.3: The ":path" pseudo-header field includes the // path and query parts of the target URI (the "path-absolute" production // and optionally a '?' character followed by the "query" production (see
diff --git a/quic/core/http/spdy_server_push_utils.h b/quic/core/http/spdy_server_push_utils.h index 16e1ac6..99a834b 100644 --- a/quic/core/http/spdy_server_push_utils.h +++ b/quic/core/http/spdy_server_push_utils.h
@@ -5,8 +5,8 @@ #ifndef QUICHE_QUIC_CORE_HTTP_SPDY_SERVER_PUSH_UTILS_H_ #define QUICHE_QUIC_CORE_HTTP_SPDY_SERVER_PUSH_UTILS_H_ +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_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_block.h" namespace quic { @@ -33,9 +33,9 @@ // Returns a canonical, valid URL for a PUSH_PROMISE with the specified // ":scheme", ":authority", and ":path" header fields, or an empty // string if the resulting URL is not valid or supported. - static std::string GetPushPromiseUrl(quiche::QuicheStringPiece scheme, - quiche::QuicheStringPiece authority, - quiche::QuicheStringPiece path); + static std::string GetPushPromiseUrl(absl::string_view scheme, + absl::string_view authority, + absl::string_view path); }; } // namespace quic
diff --git a/quic/core/http/spdy_utils.cc b/quic/core/http/spdy_utils.cc index 847408d..87025e4 100644 --- a/quic/core/http/spdy_utils.cc +++ b/quic/core/http/spdy_utils.cc
@@ -8,12 +8,12 @@ #include <string> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" @@ -29,10 +29,10 @@ return false; } else { // Check whether multiple values are consistent. - quiche::QuicheStringPiece content_length_header = it->second; - std::vector<quiche::QuicheStringPiece> values = + absl::string_view content_length_header = it->second; + std::vector<absl::string_view> values = quiche::QuicheTextUtils::Split(content_length_header, '\0'); - for (const quiche::QuicheStringPiece& value : values) { + for (const absl::string_view& value : values) { uint64_t new_value; if (!quiche::QuicheTextUtils::StringToUint64(value, &new_value) || !quiche::QuicheTextUtils::IsAllDigits(value)) {
diff --git a/quic/core/http/spdy_utils_test.cc b/quic/core/http/spdy_utils_test.cc index dd8079e..5932d8e 100644 --- a/quic/core/http/spdy_utils_test.cc +++ b/quic/core/http/spdy_utils_test.cc
@@ -5,10 +5,10 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/http/spdy_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" using spdy::SpdyHeaderBlock; @@ -66,14 +66,13 @@ SpdyHeaderBlock block; ASSERT_TRUE( SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); - EXPECT_THAT( - block, - UnorderedElementsAre( - Pair("cookie", " part 1; part 2 ; part3; fin!"), - Pair("passed-through", quiche::QuicheStringPiece("foo\0baz", 7)), - Pair("joined", quiche::QuicheStringPiece("value 1\0value 2", 15)), - Pair("empty", ""), - Pair("empty-joined", quiche::QuicheStringPiece("\0foo\0\0", 6)))); + EXPECT_THAT(block, + UnorderedElementsAre( + Pair("cookie", " part 1; part 2 ; part3; fin!"), + Pair("passed-through", absl::string_view("foo\0baz", 7)), + Pair("joined", absl::string_view("value 1\0value 2", 15)), + Pair("empty", ""), + Pair("empty-joined", absl::string_view("\0foo\0\0", 6)))); EXPECT_EQ(-1, content_length); } @@ -104,11 +103,10 @@ SpdyHeaderBlock block; ASSERT_TRUE( SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); - EXPECT_THAT(block, - UnorderedElementsAre( - Pair("foo", "foovalue"), Pair("bar", "barvalue"), - Pair("content-length", quiche::QuicheStringPiece("9\09", 3)), - Pair("baz", ""))); + EXPECT_THAT(block, UnorderedElementsAre( + Pair("foo", "foovalue"), Pair("bar", "barvalue"), + Pair("content-length", absl::string_view("9\09", 3)), + Pair("baz", ""))); EXPECT_EQ(9, content_length); } @@ -133,11 +131,11 @@ SpdyHeaderBlock block; ASSERT_TRUE( SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); - EXPECT_THAT(block, UnorderedElementsAre( - Pair("foo", "foovalue"), Pair("bar", "barvalue"), - Pair("content-length", - quiche::QuicheStringPiece("9000000000")), - Pair("baz", ""))); + EXPECT_THAT(block, + UnorderedElementsAre( + Pair("foo", "foovalue"), Pair("bar", "barvalue"), + Pair("content-length", absl::string_view("9000000000")), + Pair("baz", ""))); EXPECT_EQ(9000000000, content_length); } @@ -165,11 +163,10 @@ SpdyHeaderBlock block; ASSERT_TRUE( SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); - EXPECT_THAT(block, - UnorderedElementsAre( - Pair("foo", quiche::QuicheStringPiece("foovalue\0boo", 12)), - Pair("bar", "barvalue"), - Pair("baz", quiche::QuicheStringPiece("\0buzz", 5)))); + EXPECT_THAT(block, UnorderedElementsAre( + Pair("foo", absl::string_view("foovalue\0boo", 12)), + Pair("bar", "barvalue"), + Pair("baz", absl::string_view("\0buzz", 5)))); EXPECT_EQ(-1, content_length); } @@ -182,8 +179,8 @@ ASSERT_TRUE( SpdyUtils::CopyAndValidateHeaders(*headers, &content_length, &block)); EXPECT_THAT(block, UnorderedElementsAre(Pair( - "set-cookie", quiche::QuicheStringPiece( - "value1\0value2\0value3", 20)))); + "set-cookie", + absl::string_view("value1\0value2\0value3", 20)))); EXPECT_EQ(-1, content_length); } @@ -325,7 +322,7 @@ block, UnorderedElementsAre( Pair("key", - quiche::QuicheStringPiece( + absl::string_view( "value0\0value1\0\0\0value2\0\0non_contiguous_duplicate", 48)), Pair("other_key", "value")));