Remove SpdyStringPiece; use QuicheStringPiece instead. gfe-relnote: n/a, no functional change. PiperOrigin-RevId: 288029999 Change-Id: If83322cadaac9647f246fa8ef18f5ce870995aa3
diff --git a/spdy/core/hpack/hpack_decoder_adapter.cc b/spdy/core/hpack/hpack_decoder_adapter.cc index b3bce70..fd5a5be 100644 --- a/spdy/core/hpack/hpack_decoder_adapter.cc +++ b/spdy/core/hpack/hpack_decoder_adapter.cc
@@ -171,7 +171,7 @@ } void HpackDecoderAdapter::ListenerAdapter::OnHeaderErrorDetected( - SpdyStringPiece error_message) { + quiche::QuicheStringPiece error_message) { SPDY_VLOG(1) << error_message; }
diff --git a/spdy/core/hpack/hpack_decoder_adapter.h b/spdy/core/hpack/hpack_decoder_adapter.h index cdea661..1d5c7b2 100644 --- a/spdy/core/hpack/hpack_decoder_adapter.h +++ b/spdy/core/hpack/hpack_decoder_adapter.h
@@ -18,11 +18,11 @@ #include "net/third_party/quiche/src/http2/hpack/decoder/hpack_decoder_tables.h" #include "net/third_party/quiche/src/http2/hpack/hpack_string.h" #include "net/third_party/quiche/src/http2/hpack/http2_hpack_constants.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_header_table.h" #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" #include "net/third_party/quiche/src/spdy/core/spdy_headers_handler_interface.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { namespace test { @@ -108,7 +108,8 @@ void OnHeader(const http2::HpackString& name, const http2::HpackString& value) override; void OnHeaderListEnd() override; - void OnHeaderErrorDetected(SpdyStringPiece error_message) override; + void OnHeaderErrorDetected( + quiche::QuicheStringPiece error_message) override; // Override the HpackDecoderTablesDebugListener methods: int64_t OnEntryInserted(const http2::HpackStringPair& entry,
diff --git a/spdy/core/hpack/hpack_decoder_adapter_test.cc b/spdy/core/hpack/hpack_decoder_adapter_test.cc index 88318fb..f1bfe0c 100644 --- a/spdy/core/hpack/hpack_decoder_adapter_test.cc +++ b/spdy/core/hpack/hpack_decoder_adapter_test.cc
@@ -65,7 +65,8 @@ explicit HpackDecoderAdapterPeer(HpackDecoderAdapter* decoder) : decoder_(decoder) {} - void HandleHeaderRepresentation(SpdyStringPiece name, SpdyStringPiece value) { + void HandleHeaderRepresentation(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { decoder_->listener_adapter_.OnHeader(HpackString(name), HpackString(value)); } @@ -132,7 +133,7 @@ } } - bool HandleControlFrameHeadersData(SpdyStringPiece str) { + bool HandleControlFrameHeadersData(quiche::QuicheStringPiece str) { SPDY_VLOG(3) << "HandleControlFrameHeadersData:\n" << SpdyHexDump(str); bytes_passed_in_ += str.size(); return decoder_.HandleControlFrameHeadersData(str.data(), str.size()); @@ -146,7 +147,8 @@ return rc; } - bool DecodeHeaderBlock(SpdyStringPiece str, bool check_decoded_size = true) { + bool DecodeHeaderBlock(quiche::QuicheStringPiece str, + bool check_decoded_size = true) { // Don't call this again if HandleControlFrameHeadersData failed previously. EXPECT_FALSE(decode_has_failed_); HandleControlFrameHeadersStart(); @@ -223,7 +225,8 @@ return size; } - const SpdyHeaderBlock& DecodeBlockExpectingSuccess(SpdyStringPiece str) { + const SpdyHeaderBlock& DecodeBlockExpectingSuccess( + quiche::QuicheStringPiece str) { EXPECT_TRUE(DecodeHeaderBlock(str)); return decoded_block(); } @@ -429,12 +432,13 @@ // Resulting decoded headers are in the same order as the inputs. EXPECT_THAT( decoded_block(), - ElementsAre(Pair("cookie", " part 1; part 2 ; part3; fin!"), - Pair("passed-through", SpdyStringPiece("foo\0baz", 7)), - Pair("joined", "not joined"), - Pair("joineD", SpdyStringPiece("value 1\0value 2", 15)), - Pair("empty", ""), - Pair("empty-joined", SpdyStringPiece("\0foo\0\0", 6)))); + ElementsAre( + Pair("cookie", " part 1; part 2 ; part3; fin!"), + Pair("passed-through", quiche::QuicheStringPiece("foo\0baz", 7)), + Pair("joined", "not joined"), + Pair("joineD", quiche::QuicheStringPiece("value 1\0value 2", 15)), + Pair("empty", ""), + Pair("empty-joined", quiche::QuicheStringPiece("\0foo\0\0", 6)))); } // Decoding indexed static table field should work. @@ -499,7 +503,7 @@ output_stream.AppendUint32(126); output_stream.TakeString(&input); - EXPECT_TRUE(DecodeHeaderBlock(SpdyStringPiece(input))); + EXPECT_TRUE(DecodeHeaderBlock(quiche::QuicheStringPiece(input))); EXPECT_EQ(126u, decoder_peer_.header_table_size_limit()); } { @@ -509,7 +513,7 @@ output_stream.AppendUint32(kDefaultHeaderTableSizeSetting); output_stream.TakeString(&input); - EXPECT_TRUE(DecodeHeaderBlock(SpdyStringPiece(input))); + EXPECT_TRUE(DecodeHeaderBlock(quiche::QuicheStringPiece(input))); EXPECT_EQ(kDefaultHeaderTableSizeSetting, decoder_peer_.header_table_size_limit()); } @@ -520,7 +524,7 @@ output_stream.AppendUint32(kDefaultHeaderTableSizeSetting + 1); output_stream.TakeString(&input); - EXPECT_FALSE(DecodeHeaderBlock(SpdyStringPiece(input))); + EXPECT_FALSE(DecodeHeaderBlock(quiche::QuicheStringPiece(input))); EXPECT_EQ(kDefaultHeaderTableSizeSetting, decoder_peer_.header_table_size_limit()); } @@ -538,7 +542,7 @@ output_stream.AppendUint32(122); output_stream.TakeString(&input); - EXPECT_TRUE(DecodeHeaderBlock(SpdyStringPiece(input))); + EXPECT_TRUE(DecodeHeaderBlock(quiche::QuicheStringPiece(input))); EXPECT_EQ(122u, decoder_peer_.header_table_size_limit()); } } @@ -558,7 +562,7 @@ output_stream.TakeString(&input); - EXPECT_FALSE(DecodeHeaderBlock(SpdyStringPiece(input))); + EXPECT_FALSE(DecodeHeaderBlock(quiche::QuicheStringPiece(input))); EXPECT_EQ(10u, decoder_peer_.header_table_size_limit()); } } @@ -577,7 +581,7 @@ output_stream.TakeString(&input); - EXPECT_FALSE(DecodeHeaderBlock(SpdyStringPiece(input))); + EXPECT_FALSE(DecodeHeaderBlock(quiche::QuicheStringPiece(input))); EXPECT_EQ(kDefaultHeaderTableSizeSetting, decoder_peer_.header_table_size_limit()); } @@ -600,7 +604,7 @@ output_stream.TakeString(&input); - EXPECT_FALSE(DecodeHeaderBlock(SpdyStringPiece(input))); + EXPECT_FALSE(DecodeHeaderBlock(quiche::QuicheStringPiece(input))); EXPECT_EQ(60u, decoder_peer_.header_table_size_limit()); } } @@ -612,7 +616,7 @@ // name. const char input[] = "\x04\x0c/sample/path\x00\x06:path2\x0e/sample/path/2"; const SpdyHeaderBlock& header_set = DecodeBlockExpectingSuccess( - SpdyStringPiece(input, QUICHE_ARRAYSIZE(input) - 1)); + quiche::QuicheStringPiece(input, QUICHE_ARRAYSIZE(input) - 1)); SpdyHeaderBlock expected_header_set; expected_header_set[":path"] = "/sample/path"; @@ -625,7 +629,7 @@ TEST_P(HpackDecoderAdapterTest, LiteralHeaderIncrementalIndexing) { const char input[] = "\x44\x0c/sample/path\x40\x06:path2\x0e/sample/path/2"; const SpdyHeaderBlock& header_set = DecodeBlockExpectingSuccess( - SpdyStringPiece(input, QUICHE_ARRAYSIZE(input) - 1)); + quiche::QuicheStringPiece(input, QUICHE_ARRAYSIZE(input) - 1)); SpdyHeaderBlock expected_header_set; expected_header_set[":path"] = "/sample/path"; @@ -638,23 +642,23 @@ EXPECT_TRUE(EncodeAndDecodeDynamicTableSizeUpdates(0, 0)); // Name is the last static index. Works. - EXPECT_TRUE(DecodeHeaderBlock(SpdyStringPiece("\x7d\x03ooo"))); + EXPECT_TRUE(DecodeHeaderBlock(quiche::QuicheStringPiece("\x7d\x03ooo"))); // Name is one beyond the last static index. Fails. - EXPECT_FALSE(DecodeHeaderBlock(SpdyStringPiece("\x7e\x03ooo"))); + EXPECT_FALSE(DecodeHeaderBlock(quiche::QuicheStringPiece("\x7e\x03ooo"))); } TEST_P(HpackDecoderAdapterTest, LiteralHeaderNoIndexingInvalidNameIndex) { // Name is the last static index. Works. - EXPECT_TRUE(DecodeHeaderBlock(SpdyStringPiece("\x0f\x2e\x03ooo"))); + EXPECT_TRUE(DecodeHeaderBlock(quiche::QuicheStringPiece("\x0f\x2e\x03ooo"))); // Name is one beyond the last static index. Fails. - EXPECT_FALSE(DecodeHeaderBlock(SpdyStringPiece("\x0f\x2f\x03ooo"))); + EXPECT_FALSE(DecodeHeaderBlock(quiche::QuicheStringPiece("\x0f\x2f\x03ooo"))); } TEST_P(HpackDecoderAdapterTest, LiteralHeaderNeverIndexedInvalidNameIndex) { // Name is the last static index. Works. - EXPECT_TRUE(DecodeHeaderBlock(SpdyStringPiece("\x1f\x2e\x03ooo"))); + EXPECT_TRUE(DecodeHeaderBlock(quiche::QuicheStringPiece("\x1f\x2e\x03ooo"))); // Name is one beyond the last static index. Fails. - EXPECT_FALSE(DecodeHeaderBlock(SpdyStringPiece("\x1f\x2f\x03ooo"))); + EXPECT_FALSE(DecodeHeaderBlock(quiche::QuicheStringPiece("\x1f\x2f\x03ooo"))); } TEST_P(HpackDecoderAdapterTest, TruncatedIndex) { @@ -1051,10 +1055,10 @@ hbb.AppendDynamicTableSizeUpdate(0); hbb.AppendDynamicTableSizeUpdate(63); - const SpdyStringPiece name("some-name"); - const SpdyStringPiece value1("some-value"); - const SpdyStringPiece value2("another-value"); - const SpdyStringPiece value3("yet-another-value"); + const quiche::QuicheStringPiece name("some-name"); + const quiche::QuicheStringPiece value1("some-value"); + const quiche::QuicheStringPiece value2("another-value"); + const quiche::QuicheStringPiece value3("yet-another-value"); // Add an entry that will become the first in the dynamic table, entry 62. hbb.AppendLiteralNameAndValue(HpackEntryType::kIndexedLiteralHeader, false,
diff --git a/spdy/core/hpack/hpack_encoder.cc b/spdy/core/hpack/hpack_encoder.cc index 368754e..3835047 100644 --- a/spdy/core/hpack/hpack_encoder.cc +++ b/spdy/core/hpack/hpack_encoder.cc
@@ -56,10 +56,12 @@ namespace { // The default header listener. -void NoOpListener(SpdyStringPiece /*name*/, SpdyStringPiece /*value*/) {} +void NoOpListener(quiche::QuicheStringPiece /*name*/, + quiche::QuicheStringPiece /*value*/) {} // The default HPACK indexing policy. -bool DefaultPolicy(SpdyStringPiece name, SpdyStringPiece /* value */) { +bool DefaultPolicy(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece /* value */) { if (name.empty()) { return false; } @@ -188,7 +190,7 @@ EmitString(representation.second); } -void HpackEncoder::EmitString(SpdyStringPiece str) { +void HpackEncoder::EmitString(quiche::QuicheStringPiece str) { size_t encoded_size = enable_compression_ ? huffman_table_.EncodedSize(str) : str.size(); if (encoded_size < str.size()) { @@ -229,19 +231,21 @@ // See Section 8.1.2.5. "Compressing the Cookie Header Field" in the HTTP/2 // specification at https://tools.ietf.org/html/draft-ietf-httpbis-http2-14. // Cookie values are split into individually-encoded HPACK representations. - SpdyStringPiece cookie_value = cookie.second; + quiche::QuicheStringPiece cookie_value = cookie.second; // Consume leading and trailing whitespace if present. - SpdyStringPiece::size_type first = cookie_value.find_first_not_of(" \t"); - SpdyStringPiece::size_type last = cookie_value.find_last_not_of(" \t"); - if (first == SpdyStringPiece::npos) { - cookie_value = SpdyStringPiece(); + quiche::QuicheStringPiece::size_type first = + cookie_value.find_first_not_of(" \t"); + quiche::QuicheStringPiece::size_type last = + cookie_value.find_last_not_of(" \t"); + if (first == quiche::QuicheStringPiece::npos) { + cookie_value = quiche::QuicheStringPiece(); } else { cookie_value = cookie_value.substr(first, (last - first) + 1); } for (size_t pos = 0;;) { size_t end = cookie_value.find(";", pos); - if (end == SpdyStringPiece::npos) { + if (end == quiche::QuicheStringPiece::npos) { out->push_back(std::make_pair(cookie.first, cookie_value.substr(pos))); break; } @@ -261,12 +265,12 @@ Representations* out) { size_t pos = 0; size_t end = 0; - while (end != SpdyStringPiece::npos) { + while (end != quiche::QuicheStringPiece::npos) { end = header_field.second.find('\0', pos); out->push_back(std::make_pair( header_field.first, header_field.second.substr( - pos, end == SpdyStringPiece::npos ? end : end - pos))); + pos, end == quiche::QuicheStringPiece::npos ? end : end - pos))); pos = end + 1; } }
diff --git a/spdy/core/hpack/hpack_encoder.h b/spdy/core/hpack/hpack_encoder.h index 03c9d92..115908b 100644 --- a/spdy/core/hpack/hpack_encoder.h +++ b/spdy/core/hpack/hpack_encoder.h
@@ -14,11 +14,11 @@ #include <utility> #include <vector> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_header_table.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_output_stream.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" // An HpackEncoder encodes header sets as outlined in // http://tools.ietf.org/html/rfc7541. @@ -33,16 +33,19 @@ class SPDY_EXPORT_PRIVATE HpackEncoder { public: - using Representation = std::pair<SpdyStringPiece, SpdyStringPiece>; + using Representation = + std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece>; using Representations = std::vector<Representation>; // Callers may provide a HeaderListener to be informed of header name-value // pairs processed by this encoder. - using HeaderListener = std::function<void(SpdyStringPiece, SpdyStringPiece)>; + using HeaderListener = + std::function<void(quiche::QuicheStringPiece, quiche::QuicheStringPiece)>; // An indexing policy should return true if the provided header name-value // pair should be inserted into the HPACK dynamic table. - using IndexingPolicy = std::function<bool(SpdyStringPiece, SpdyStringPiece)>; + using IndexingPolicy = + std::function<bool(quiche::QuicheStringPiece, quiche::QuicheStringPiece)>; // |table| is an initialized HPACK Huffman table, having an // externally-managed lifetime which spans beyond HpackEncoder. @@ -123,7 +126,7 @@ void EmitLiteral(const Representation& representation); // Emits a Huffman or identity string (whichever is smaller). - void EmitString(SpdyStringPiece str); + void EmitString(quiche::QuicheStringPiece str); // Emits the current dynamic table size if the table size was recently // updated and we have not yet emitted it (Section 6.3).
diff --git a/spdy/core/hpack/hpack_encoder_test.cc b/spdy/core/hpack/hpack_encoder_test.cc index b905214..a96ff69 100644 --- a/spdy/core/hpack/hpack_encoder_test.cc +++ b/spdy/core/hpack/hpack_encoder_test.cc
@@ -41,12 +41,12 @@ const HpackHuffmanTable& huffman_table() const { return encoder_->huffman_table_; } - void EmitString(SpdyStringPiece str) { encoder_->EmitString(str); } + void EmitString(quiche::QuicheStringPiece str) { encoder_->EmitString(str); } void TakeString(std::string* out) { encoder_->output_stream_.TakeString(out); } - static void CookieToCrumbs(SpdyStringPiece cookie, - std::vector<SpdyStringPiece>* out) { + static void CookieToCrumbs(quiche::QuicheStringPiece cookie, + std::vector<quiche::QuicheStringPiece>* out) { Representations tmp; HpackEncoder::CookieToCrumbs(std::make_pair("", cookie), &tmp); @@ -55,8 +55,9 @@ out->push_back(tmp[i].second); } } - static void DecomposeRepresentation(SpdyStringPiece value, - std::vector<SpdyStringPiece>* out) { + static void DecomposeRepresentation( + quiche::QuicheStringPiece value, + std::vector<quiche::QuicheStringPiece>* out) { Representations tmp; HpackEncoder::DecomposeRepresentation(std::make_pair("foobar", value), &tmp); @@ -148,11 +149,12 @@ peer_.table()->SetMaxSize(peer_.table()->size()); } - void SaveHeaders(SpdyStringPiece name, SpdyStringPiece value) { - SpdyStringPiece n(headers_storage_.Memdup(name.data(), name.size()), - name.size()); - SpdyStringPiece v(headers_storage_.Memdup(value.data(), value.size()), - value.size()); + void SaveHeaders(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { + quiche::QuicheStringPiece n( + headers_storage_.Memdup(name.data(), name.size()), name.size()); + quiche::QuicheStringPiece v( + headers_storage_.Memdup(value.data(), value.size()), value.size()); headers_observed_.push_back(std::make_pair(n, v)); } @@ -161,24 +163,26 @@ expected_.AppendUint32(index); } void ExpectIndexedLiteral(const HpackEntry* key_entry, - SpdyStringPiece value) { + quiche::QuicheStringPiece value) { expected_.AppendPrefix(kLiteralIncrementalIndexOpcode); expected_.AppendUint32(IndexOf(key_entry)); ExpectString(&expected_, value); } - void ExpectIndexedLiteral(SpdyStringPiece name, SpdyStringPiece value) { + void ExpectIndexedLiteral(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { expected_.AppendPrefix(kLiteralIncrementalIndexOpcode); expected_.AppendUint32(0); ExpectString(&expected_, name); ExpectString(&expected_, value); } - void ExpectNonIndexedLiteral(SpdyStringPiece name, SpdyStringPiece value) { + void ExpectNonIndexedLiteral(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { expected_.AppendPrefix(kLiteralNoIndexOpcode); expected_.AppendUint32(0); ExpectString(&expected_, name); ExpectString(&expected_, value); } - void ExpectString(HpackOutputStream* stream, SpdyStringPiece str) { + void ExpectString(HpackOutputStream* stream, quiche::QuicheStringPiece str) { const HpackHuffmanTable& huffman_table = peer_.huffman_table(); size_t encoded_size = peer_.compression_enabled() ? huffman_table.EncodedSize(str) @@ -244,7 +248,8 @@ const HpackEntry* cookie_c_; SpdySimpleArena headers_storage_; - std::vector<std::pair<SpdyStringPiece, SpdyStringPiece>> headers_observed_; + std::vector<std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece>> + headers_observed_; HpackOutputStream expected_; EncodeStrategy strategy_ = kDefault; @@ -252,15 +257,16 @@ TEST_F(HpackEncoderTestBase, EncodeRepresentations) { encoder_.SetHeaderListener( - [this](SpdyStringPiece name, SpdyStringPiece value) { + [this](quiche::QuicheStringPiece name, quiche::QuicheStringPiece value) { this->SaveHeaders(name, value); }); - const std::vector<std::pair<SpdyStringPiece, SpdyStringPiece>> header_list = { - {"cookie", "val1; val2;val3"}, - {":path", "/home"}, - {"accept", "text/html, text/plain,application/xml"}, - {"cookie", "val4"}, - {"withnul", SpdyStringPiece("one\0two", 7)}}; + const std::vector< + std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece>> + header_list = {{"cookie", "val1; val2;val3"}, + {":path", "/home"}, + {"accept", "text/html, text/plain,application/xml"}, + {"cookie", "val4"}, + {"withnul", quiche::QuicheStringPiece("one\0two", 7)}}; ExpectNonIndexedLiteral(":path", "/home"); ExpectIndexedLiteral(peer_.table()->GetByName("cookie"), "val1"); ExpectIndexedLiteral(peer_.table()->GetByName("cookie"), "val2"); @@ -268,7 +274,7 @@ ExpectIndexedLiteral(peer_.table()->GetByName("accept"), "text/html, text/plain,application/xml"); ExpectIndexedLiteral(peer_.table()->GetByName("cookie"), "val4"); - ExpectIndexedLiteral("withnul", SpdyStringPiece("one\0two", 7)); + ExpectIndexedLiteral("withnul", quiche::QuicheStringPiece("one\0two", 7)); CompareWithExpectedEncoding(header_list); EXPECT_THAT( @@ -277,7 +283,7 @@ Pair("cookie", "val2"), Pair("cookie", "val3"), Pair("accept", "text/html, text/plain,application/xml"), Pair("cookie", "val4"), - Pair("withnul", SpdyStringPiece("one\0two", 7)))); + Pair("withnul", quiche::QuicheStringPiece("one\0two", 7)))); } class HpackEncoderTest : public HpackEncoderTestBase, @@ -297,7 +303,7 @@ TEST_P(HpackEncoderTest, SingleDynamicIndex) { encoder_.SetHeaderListener( - [this](SpdyStringPiece name, SpdyStringPiece value) { + [this](quiche::QuicheStringPiece name, quiche::QuicheStringPiece value) { this->SaveHeaders(name, value); }); @@ -418,7 +424,7 @@ TEST_P(HpackEncoderTest, EncodingWithoutCompression) { encoder_.SetHeaderListener( - [this](SpdyStringPiece name, SpdyStringPiece value) { + [this](quiche::QuicheStringPiece name, quiche::QuicheStringPiece value) { this->SaveHeaders(name, value); }); encoder_.DisableCompression(); @@ -446,10 +452,11 @@ if (strategy_ == kRepresentations) { EXPECT_THAT( headers_observed_, - ElementsAre(Pair(":path", "/index.html"), Pair("cookie", "foo=bar"), - Pair("cookie", "baz=bing"), - Pair("hello", SpdyStringPiece("goodbye\0aloha", 13)), - Pair("multivalue", "value1, value2"))); + ElementsAre( + Pair(":path", "/index.html"), Pair("cookie", "foo=bar"), + Pair("cookie", "baz=bing"), + Pair("hello", quiche::QuicheStringPiece("goodbye\0aloha", 13)), + Pair("multivalue", "value1, value2"))); } else { EXPECT_THAT( headers_observed_, @@ -462,7 +469,7 @@ TEST_P(HpackEncoderTest, MultipleEncodingPasses) { encoder_.SetHeaderListener( - [this](SpdyStringPiece name, SpdyStringPiece value) { + [this](quiche::QuicheStringPiece name, quiche::QuicheStringPiece value) { this->SaveHeaders(name, value); }); @@ -558,7 +565,7 @@ TEST_P(HpackEncoderTest, CookieToCrumbs) { test::HpackEncoderPeer peer(nullptr); - std::vector<SpdyStringPiece> out; + std::vector<quiche::QuicheStringPiece> out; // Leading and trailing whitespace is consumed. A space after ';' is consumed. // All other spaces remain. ';' at beginning and end of string produce empty @@ -592,7 +599,7 @@ TEST_P(HpackEncoderTest, DecomposeRepresentation) { test::HpackEncoderPeer peer(nullptr); - std::vector<SpdyStringPiece> out; + std::vector<quiche::QuicheStringPiece> out; peer.DecomposeRepresentation("", &out); EXPECT_THAT(out, ElementsAre("")); @@ -600,16 +607,19 @@ peer.DecomposeRepresentation("foobar", &out); EXPECT_THAT(out, ElementsAre("foobar")); - peer.DecomposeRepresentation(SpdyStringPiece("foo\0bar", 7), &out); + peer.DecomposeRepresentation(quiche::QuicheStringPiece("foo\0bar", 7), &out); EXPECT_THAT(out, ElementsAre("foo", "bar")); - peer.DecomposeRepresentation(SpdyStringPiece("\0foo\0bar", 8), &out); + peer.DecomposeRepresentation(quiche::QuicheStringPiece("\0foo\0bar", 8), + &out); EXPECT_THAT(out, ElementsAre("", "foo", "bar")); - peer.DecomposeRepresentation(SpdyStringPiece("foo\0bar\0", 8), &out); + peer.DecomposeRepresentation(quiche::QuicheStringPiece("foo\0bar\0", 8), + &out); EXPECT_THAT(out, ElementsAre("foo", "bar", "")); - peer.DecomposeRepresentation(SpdyStringPiece("\0foo\0bar\0", 9), &out); + peer.DecomposeRepresentation(quiche::QuicheStringPiece("\0foo\0bar\0", 9), + &out); EXPECT_THAT(out, ElementsAre("", "foo", "bar", "")); }
diff --git a/spdy/core/hpack/hpack_entry.cc b/spdy/core/hpack/hpack_entry.cc index 0965739..c96e35c 100644 --- a/spdy/core/hpack/hpack_entry.cc +++ b/spdy/core/hpack/hpack_entry.cc
@@ -12,8 +12,8 @@ const size_t HpackEntry::kSizeOverhead = 32; -HpackEntry::HpackEntry(SpdyStringPiece name, - SpdyStringPiece value, +HpackEntry::HpackEntry(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value, bool is_static, size_t insertion_index) : name_(name.data(), name.size()), @@ -24,7 +24,8 @@ type_(is_static ? STATIC : DYNAMIC), time_added_(0) {} -HpackEntry::HpackEntry(SpdyStringPiece name, SpdyStringPiece value) +HpackEntry::HpackEntry(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) : name_ref_(name), value_ref_(value), insertion_index_(0), @@ -43,8 +44,8 @@ } else { name_ = other.name_; value_ = other.value_; - name_ref_ = SpdyStringPiece(name_.data(), name_.size()); - value_ref_ = SpdyStringPiece(value_.data(), value_.size()); + name_ref_ = quiche::QuicheStringPiece(name_.data(), name_.size()); + value_ref_ = quiche::QuicheStringPiece(value_.data(), value_.size()); } } @@ -60,15 +61,16 @@ } name_ = other.name_; value_ = other.value_; - name_ref_ = SpdyStringPiece(name_.data(), name_.size()); - value_ref_ = SpdyStringPiece(value_.data(), value_.size()); + name_ref_ = quiche::QuicheStringPiece(name_.data(), name_.size()); + value_ref_ = quiche::QuicheStringPiece(value_.data(), value_.size()); return *this; } HpackEntry::~HpackEntry() = default; // static -size_t HpackEntry::Size(SpdyStringPiece name, SpdyStringPiece value) { +size_t HpackEntry::Size(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { return name.size() + value.size() + kSizeOverhead; } size_t HpackEntry::Size() const {
diff --git a/spdy/core/hpack/hpack_entry.h b/spdy/core/hpack/hpack_entry.h index 50ac3a7..d36bce4 100644 --- a/spdy/core/hpack/hpack_entry.h +++ b/spdy/core/hpack/hpack_entry.h
@@ -9,8 +9,8 @@ #include <cstdint> #include <string> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" // All section references below are to // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 @@ -34,15 +34,15 @@ // The combination of |is_static| and |insertion_index| allows an // HpackEntryTable to determine the index of an HpackEntry in O(1) time. // Copies |name| and |value|. - HpackEntry(SpdyStringPiece name, - SpdyStringPiece value, + HpackEntry(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value, bool is_static, size_t insertion_index); // Create a 'lookup' entry (only) suitable for querying a HpackEntrySet. The // instance InsertionIndex() always returns 0 and IsLookup() returns true. // The memory backing |name| and |value| must outlive this object. - HpackEntry(SpdyStringPiece name, SpdyStringPiece value); + HpackEntry(quiche::QuicheStringPiece name, quiche::QuicheStringPiece value); HpackEntry(const HpackEntry& other); HpackEntry& operator=(const HpackEntry& other); @@ -53,8 +53,8 @@ ~HpackEntry(); - SpdyStringPiece name() const { return name_ref_; } - SpdyStringPiece value() const { return value_ref_; } + quiche::QuicheStringPiece name() const { return name_ref_; } + quiche::QuicheStringPiece value() const { return value_ref_; } // Returns whether this entry is a member of the static (as opposed to // dynamic) table. @@ -67,7 +67,8 @@ size_t InsertionIndex() const { return insertion_index_; } // Returns the size of an entry as defined in 5.1. - static size_t Size(SpdyStringPiece name, SpdyStringPiece value); + static size_t Size(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value); size_t Size() const; std::string GetDebugString() const; @@ -91,8 +92,8 @@ // These members are always valid. For DYNAMIC and STATIC entries, they // always point to |name_| and |value_|. - SpdyStringPiece name_ref_; - SpdyStringPiece value_ref_; + quiche::QuicheStringPiece name_ref_; + quiche::QuicheStringPiece value_ref_; // The entry's index in the total set of entries ever inserted into the header // table.
diff --git a/spdy/core/hpack/hpack_header_table.cc b/spdy/core/hpack/hpack_header_table.cc index 17f91cd..67a0a5f 100644 --- a/spdy/core/hpack/hpack_header_table.cc +++ b/spdy/core/hpack/hpack_header_table.cc
@@ -16,7 +16,7 @@ size_t HpackHeaderTable::EntryHasher::operator()( const HpackEntry* entry) const { - return SpdyHashStringPair(entry->name(), entry->value()); + return quiche::QuicheHashStringPair(entry->name(), entry->value()); } bool HpackHeaderTable::EntriesEq::operator()(const HpackEntry* lhs, @@ -60,7 +60,7 @@ return nullptr; } -const HpackEntry* HpackHeaderTable::GetByName(SpdyStringPiece name) { +const HpackEntry* HpackHeaderTable::GetByName(quiche::QuicheStringPiece name) { { auto it = static_name_index_.find(name); if (it != static_name_index_.end()) { @@ -80,8 +80,9 @@ return nullptr; } -const HpackEntry* HpackHeaderTable::GetByNameAndValue(SpdyStringPiece name, - SpdyStringPiece value) { +const HpackEntry* HpackHeaderTable::GetByNameAndValue( + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { HpackEntry query(name, value); { auto it = static_index_.find(&query); @@ -127,8 +128,8 @@ SetMaxSize(settings_size_bound_); } -void HpackHeaderTable::EvictionSet(SpdyStringPiece name, - SpdyStringPiece value, +void HpackHeaderTable::EvictionSet(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value, EntryTable::iterator* begin_out, EntryTable::iterator* end_out) { size_t eviction_count = EvictionCountForEntry(name, value); @@ -136,8 +137,9 @@ *end_out = dynamic_entries_.end(); } -size_t HpackHeaderTable::EvictionCountForEntry(SpdyStringPiece name, - SpdyStringPiece value) const { +size_t HpackHeaderTable::EvictionCountForEntry( + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) const { size_t available_size = max_size_ - size_; size_t entry_size = HpackEntry::Size(name, value); @@ -183,8 +185,9 @@ } } -const HpackEntry* HpackHeaderTable::TryAddEntry(SpdyStringPiece name, - SpdyStringPiece value) { +const HpackEntry* HpackHeaderTable::TryAddEntry( + quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { Evict(EvictionCountForEntry(name, value)); size_t entry_size = HpackEntry::Size(name, value);
diff --git a/spdy/core/hpack/hpack_header_table.h b/spdy/core/hpack/hpack_header_table.h index 7ff49f3..3f532ac 100644 --- a/spdy/core/hpack/hpack_header_table.h +++ b/spdy/core/hpack/hpack_header_table.h
@@ -10,11 +10,11 @@ #include <deque> #include <memory> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_entry.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_containers.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_macros.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" // All section references below are to http://tools.ietf.org/html/rfc7541. @@ -67,8 +67,9 @@ bool operator()(const HpackEntry* lhs, const HpackEntry* rhs) const; }; using UnorderedEntrySet = SpdyHashSet<HpackEntry*, EntryHasher, EntriesEq>; - using NameToEntryMap = - SpdyHashMap<SpdyStringPiece, const HpackEntry*, SpdyStringPieceHash>; + using NameToEntryMap = SpdyHashMap<quiche::QuicheStringPiece, + const HpackEntry*, + quiche::QuicheStringPieceHash>; HpackHeaderTable(); HpackHeaderTable(const HpackHeaderTable&) = delete; @@ -88,11 +89,11 @@ const HpackEntry* GetByIndex(size_t index); // Returns the lowest-value entry having |name|, or NULL. - const HpackEntry* GetByName(SpdyStringPiece name); + const HpackEntry* GetByName(quiche::QuicheStringPiece name); // Returns the lowest-index matching entry, or NULL. - const HpackEntry* GetByNameAndValue(SpdyStringPiece name, - SpdyStringPiece value); + const HpackEntry* GetByNameAndValue(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value); // Returns the index of an entry within this header table. size_t IndexOf(const HpackEntry* entry) const; @@ -108,8 +109,8 @@ // Determine the set of entries which would be evicted by the insertion // of |name| & |value| into the table, as per section 4.4. No eviction // actually occurs. The set is returned via range [begin_out, end_out). - void EvictionSet(SpdyStringPiece name, - SpdyStringPiece value, + void EvictionSet(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value, EntryTable::iterator* begin_out, EntryTable::iterator* end_out); @@ -117,7 +118,8 @@ // and |value| must not be owned by an entry which could be evicted. The // added HpackEntry is returned, or NULL is returned if all entries were // evicted and the empty table is of insufficent size for the representation. - const HpackEntry* TryAddEntry(SpdyStringPiece name, SpdyStringPiece value); + const HpackEntry* TryAddEntry(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value); void DebugLogTableState() const SPDY_UNUSED; @@ -130,8 +132,8 @@ private: // Returns number of evictions required to enter |name| & |value|. - size_t EvictionCountForEntry(SpdyStringPiece name, - SpdyStringPiece value) const; + size_t EvictionCountForEntry(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) const; // Returns number of evictions required to reclaim |reclaim_size| table size. size_t EvictionCountToReclaim(size_t reclaim_size) const;
diff --git a/spdy/core/hpack/hpack_header_table_test.cc b/spdy/core/hpack/hpack_header_table_test.cc index a7d2482..4f77587 100644 --- a/spdy/core/hpack/hpack_header_table_test.cc +++ b/spdy/core/hpack/hpack_header_table_test.cc
@@ -33,8 +33,8 @@ size_t index_size() { return table_->static_index_.size() + table_->dynamic_index_.size(); } - std::vector<HpackEntry*> EvictionSet(SpdyStringPiece name, - SpdyStringPiece value) { + std::vector<HpackEntry*> EvictionSet(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { HpackHeaderTable::EntryTable::iterator begin, end; table_->EvictionSet(name, value, &begin, &end); std::vector<HpackEntry*> result; @@ -45,7 +45,8 @@ } size_t total_insertions() { return table_->total_insertions_; } size_t dynamic_entries_count() { return table_->dynamic_entries_.size(); } - size_t EvictionCountForEntry(SpdyStringPiece name, SpdyStringPiece value) { + size_t EvictionCountForEntry(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { return table_->EvictionCountForEntry(name, value); } size_t EvictionCountToReclaim(size_t reclaim_size) { @@ -53,7 +54,8 @@ } void Evict(size_t count) { return table_->Evict(count); } - void AddDynamicEntry(SpdyStringPiece name, SpdyStringPiece value) { + void AddDynamicEntry(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { table_->dynamic_entries_.push_back( HpackEntry(name, value, false, table_->total_insertions_++)); }
diff --git a/spdy/core/hpack/hpack_huffman_table.cc b/spdy/core/hpack/hpack_huffman_table.cc index 3c637a4..eb799d0 100644 --- a/spdy/core/hpack/hpack_huffman_table.cc +++ b/spdy/core/hpack/hpack_huffman_table.cc
@@ -96,7 +96,7 @@ return !code_by_id_.empty(); } -void HpackHuffmanTable::EncodeString(SpdyStringPiece in, +void HpackHuffmanTable::EncodeString(quiche::QuicheStringPiece in, HpackOutputStream* out) const { size_t bit_remnant = 0; for (size_t i = 0; i != in.size(); i++) { @@ -129,7 +129,7 @@ } } -size_t HpackHuffmanTable::EncodedSize(SpdyStringPiece in) const { +size_t HpackHuffmanTable::EncodedSize(quiche::QuicheStringPiece in) const { size_t bit_count = 0; for (size_t i = 0; i != in.size(); i++) { uint16_t symbol_id = static_cast<uint8_t>(in[i]);
diff --git a/spdy/core/hpack/hpack_huffman_table.h b/spdy/core/hpack/hpack_huffman_table.h index a01c62f..abf8caa 100644 --- a/spdy/core/hpack/hpack_huffman_table.h +++ b/spdy/core/hpack/hpack_huffman_table.h
@@ -9,9 +9,9 @@ #include <cstdint> #include <vector> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_constants.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { @@ -45,10 +45,10 @@ // Encodes the input string to the output stream using the table's Huffman // context. - void EncodeString(SpdyStringPiece in, HpackOutputStream* out) const; + void EncodeString(quiche::QuicheStringPiece in, HpackOutputStream* out) const; // Returns the encoded size of the input string. - size_t EncodedSize(SpdyStringPiece in) const; + size_t EncodedSize(quiche::QuicheStringPiece in) const; // Returns the estimate of dynamically allocated memory in bytes. size_t EstimateMemoryUsage() const;
diff --git a/spdy/core/hpack/hpack_huffman_table_test.cc b/spdy/core/hpack/hpack_huffman_table_test.cc index bc38f6d..abcebf8 100644 --- a/spdy/core/hpack/hpack_huffman_table_test.cc +++ b/spdy/core/hpack/hpack_huffman_table_test.cc
@@ -42,7 +42,7 @@ protected: GenericHuffmanTableTest() : table_(), peer_(table_) {} - std::string EncodeString(SpdyStringPiece input) { + std::string EncodeString(quiche::QuicheStringPiece input) { std::string result; HpackOutputStream output_stream; table_.EncodeString(input, &output_stream); @@ -171,10 +171,12 @@ EXPECT_EQ(0b10011000, peer_.pad_bits()); char input_storage[] = {2, 3, 2, 7, 4}; - SpdyStringPiece input(input_storage, QUICHE_ARRAYSIZE(input_storage)); + quiche::QuicheStringPiece input(input_storage, + QUICHE_ARRAYSIZE(input_storage)); // By symbol: (2) 00 (3) 010 (2) 00 (7) 10010 (4) 10000 (6 as pad) 1001100. char expect_storage[] = {0b00010001, 0b00101000, 0b01001100}; - SpdyStringPiece expect(expect_storage, QUICHE_ARRAYSIZE(expect_storage)); + quiche::QuicheStringPiece expect(expect_storage, + QUICHE_ARRAYSIZE(expect_storage)); EXPECT_EQ(expect, EncodeString(input)); } @@ -256,7 +258,7 @@ for (size_t i = 0; i != 256; i++) { char c = static_cast<char>(i); char storage[3] = {c, c, c}; - SpdyStringPiece input(storage, QUICHE_ARRAYSIZE(storage)); + quiche::QuicheStringPiece input(storage, QUICHE_ARRAYSIZE(storage)); std::string buffer_in = EncodeString(input); std::string buffer_out; DecodeString(buffer_in, &buffer_out); @@ -270,7 +272,7 @@ storage[i] = static_cast<char>(i); storage[511 - i] = static_cast<char>(i); } - SpdyStringPiece input(storage, QUICHE_ARRAYSIZE(storage)); + quiche::QuicheStringPiece input(storage, QUICHE_ARRAYSIZE(storage)); std::string buffer_in = EncodeString(input); std::string buffer_out; DecodeString(buffer_in, &buffer_out);
diff --git a/spdy/core/hpack/hpack_output_stream.cc b/spdy/core/hpack/hpack_output_stream.cc index 4ceaece..5c2dd68 100644 --- a/spdy/core/hpack/hpack_output_stream.cc +++ b/spdy/core/hpack/hpack_output_stream.cc
@@ -41,7 +41,7 @@ AppendBits(prefix.bits, prefix.bit_size); } -void HpackOutputStream::AppendBytes(SpdyStringPiece buffer) { +void HpackOutputStream::AppendBytes(quiche::QuicheStringPiece buffer) { DCHECK_EQ(bit_offset_, 0u); buffer_.append(buffer.data(), buffer.size()); }
diff --git a/spdy/core/hpack/hpack_output_stream.h b/spdy/core/hpack/hpack_output_stream.h index 5e65139..9b64554 100644 --- a/spdy/core/hpack/hpack_output_stream.h +++ b/spdy/core/hpack/hpack_output_stream.h
@@ -9,9 +9,9 @@ #include <map> #include <string> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_constants.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" // All section references below are to // http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-08 @@ -37,7 +37,7 @@ void AppendPrefix(HpackPrefix prefix); // Directly appends |buffer|. - void AppendBytes(SpdyStringPiece buffer); + void AppendBytes(quiche::QuicheStringPiece buffer); // Appends the given integer using the representation described in // 6.1. If the internal buffer ends on a byte boundary, the prefix
diff --git a/spdy/core/hpack/hpack_static_table.cc b/spdy/core/hpack/hpack_static_table.cc index eea1d9e..e8b07f1 100644 --- a/spdy/core/hpack/hpack_static_table.cc +++ b/spdy/core/hpack/hpack_static_table.cc
@@ -4,11 +4,11 @@ #include "net/third_party/quiche/src/spdy/core/hpack/hpack_static_table.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_constants.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_entry.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_estimate_memory_usage.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_logging.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { @@ -24,8 +24,8 @@ for (const HpackStaticEntry* it = static_entry_table; it != static_entry_table + static_entry_count; ++it) { static_entries_.push_back( - HpackEntry(SpdyStringPiece(it->name, it->name_len), - SpdyStringPiece(it->value, it->value_len), + HpackEntry(quiche::QuicheStringPiece(it->name, it->name_len), + quiche::QuicheStringPiece(it->value, it->value_len), true, // is_static total_insertions)); HpackEntry* entry = &static_entries_.back();
diff --git a/spdy/core/hpack/hpack_static_table_test.cc b/spdy/core/hpack/hpack_static_table_test.cc index 3f51955..4cd310f 100644 --- a/spdy/core/hpack/hpack_static_table_test.cc +++ b/spdy/core/hpack/hpack_static_table_test.cc
@@ -7,8 +7,8 @@ #include <set> #include <vector> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_constants.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_test.h" namespace spdy { @@ -39,7 +39,7 @@ HpackHeaderTable::NameToEntryMap static_name_index = table_.GetStaticNameIndex(); - std::set<SpdyStringPiece> names; + std::set<quiche::QuicheStringPiece> names; for (auto* entry : static_index) { names.insert(entry->name()); }
diff --git a/spdy/core/http2_frame_decoder_adapter.h b/spdy/core/http2_frame_decoder_adapter.h index 93da684..b1e16b1 100644 --- a/spdy/core/http2_frame_decoder_adapter.h +++ b/spdy/core/http2_frame_decoder_adapter.h
@@ -13,12 +13,12 @@ #include "net/third_party/quiche/src/http2/decoder/http2_frame_decoder.h" #include "net/third_party/quiche/src/http2/platform/api/http2_optional.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_decoder_adapter.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_header_table.h" #include "net/third_party/quiche/src/spdy/core/spdy_alt_svc_wire_format.h" #include "net/third_party/quiche/src/spdy/core/spdy_headers_handler_interface.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { @@ -473,7 +473,7 @@ // Called when an ALTSVC frame has been parsed. virtual void OnAltSvc( SpdyStreamId /*stream_id*/, - SpdyStringPiece /*origin*/, + quiche::QuicheStringPiece /*origin*/, const SpdyAltSvcWireFormat::AlternativeServiceVector& /*altsvc_vector*/) { }
diff --git a/spdy/core/mock_spdy_framer_visitor.h b/spdy/core/mock_spdy_framer_visitor.h index 8600f5c..3425187 100644 --- a/spdy/core/mock_spdy_framer_visitor.h +++ b/spdy/core/mock_spdy_framer_visitor.h
@@ -9,9 +9,9 @@ #include <memory> #include <utility> +#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_test_utils.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_test.h" namespace spdy { @@ -61,7 +61,7 @@ MOCK_METHOD2(OnContinuation, void(SpdyStreamId stream_id, bool end)); MOCK_METHOD3(OnAltSvc, void(SpdyStreamId stream_id, - SpdyStringPiece origin, + quiche::QuicheStringPiece origin, const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector)); MOCK_METHOD4(OnPriority,
diff --git a/spdy/core/spdy_alt_svc_wire_format.cc b/spdy/core/spdy_alt_svc_wire_format.cc index fcbfd16..2f90ab3 100644 --- a/spdy/core/spdy_alt_svc_wire_format.cc +++ b/spdy/core/spdy_alt_svc_wire_format.cc
@@ -16,8 +16,8 @@ namespace { template <class T> -bool ParsePositiveIntegerImpl(SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, +bool ParsePositiveIntegerImpl(quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, T* value) { *value = 0; for (; c != end && std::isdigit(*c); ++c) { @@ -56,20 +56,20 @@ // static bool SpdyAltSvcWireFormat::ParseHeaderFieldValue( - SpdyStringPiece value, + quiche::QuicheStringPiece value, AlternativeServiceVector* altsvc_vector) { // Empty value is invalid according to the specification. if (value.empty()) { return false; } altsvc_vector->clear(); - if (value == SpdyStringPiece("clear")) { + if (value == quiche::QuicheStringPiece("clear")) { return true; } - SpdyStringPiece::const_iterator c = value.begin(); + quiche::QuicheStringPiece::const_iterator c = value.begin(); while (c != value.end()) { // Parse protocol-id. - SpdyStringPiece::const_iterator percent_encoded_protocol_id_end = + quiche::QuicheStringPiece::const_iterator percent_encoded_protocol_id_end = std::find(c, value.end(), '='); std::string protocol_id; if (percent_encoded_protocol_id_end == c || @@ -90,7 +90,7 @@ return false; } ++c; - SpdyStringPiece::const_iterator alt_authority_begin = c; + quiche::QuicheStringPiece::const_iterator alt_authority_begin = c; for (; c != value.end() && *c != '"'; ++c) { // Decode backslash encoding. if (*c != '\\') { @@ -114,7 +114,7 @@ // Parse parameters. uint32_t max_age = 86400; VersionVector version; - SpdyStringPiece::const_iterator parameters_end = + quiche::QuicheStringPiece::const_iterator parameters_end = std::find(c, value.end(), ','); while (c != parameters_end) { SkipWhiteSpace(&c, parameters_end); @@ -139,7 +139,7 @@ } ++c; SkipWhiteSpace(&c, parameters_end); - SpdyStringPiece::const_iterator parameter_value_begin = c; + quiche::QuicheStringPiece::const_iterator parameter_value_begin = c; for (; c != parameters_end && *c != ';' && *c != ' ' && *c != '\t'; ++c) { } if (c == parameter_value_begin) { @@ -163,9 +163,10 @@ } ++c; parameters_end = std::find(c, value.end(), ','); - SpdyStringPiece::const_iterator v_begin = parameter_value_begin + 1; + quiche::QuicheStringPiece::const_iterator v_begin = + parameter_value_begin + 1; while (v_begin < c) { - SpdyStringPiece::const_iterator v_end = v_begin; + quiche::QuicheStringPiece::const_iterator v_end = v_begin; while (v_end < c - 1 && *v_end != ',') { ++v_end; } @@ -194,9 +195,10 @@ // hq=":443";quic=51303338 // ... will be stored in |versions| as 0x51303338. uint32_t quic_version; - if (!SpdyHexDecodeToUInt32(SpdyStringPiece(parameter_value_begin, - c - parameter_value_begin), - &quic_version) || + if (!SpdyHexDecodeToUInt32( + quiche::QuicheStringPiece(parameter_value_begin, + c - parameter_value_begin), + &quic_version) || quic_version == 0) { return false; } @@ -291,16 +293,18 @@ } // static -void SpdyAltSvcWireFormat::SkipWhiteSpace(SpdyStringPiece::const_iterator* c, - SpdyStringPiece::const_iterator end) { +void SpdyAltSvcWireFormat::SkipWhiteSpace( + quiche::QuicheStringPiece::const_iterator* c, + quiche::QuicheStringPiece::const_iterator end) { for (; *c != end && (**c == ' ' || **c == '\t'); ++*c) { } } // static -bool SpdyAltSvcWireFormat::PercentDecode(SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, - std::string* output) { +bool SpdyAltSvcWireFormat::PercentDecode( + quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, + std::string* output) { output->clear(); for (; c != end; ++c) { if (*c != '%') { @@ -326,8 +330,8 @@ // static bool SpdyAltSvcWireFormat::ParseAltAuthority( - SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, + quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, std::string* host, uint16_t* port) { host->clear(); @@ -373,16 +377,16 @@ // static bool SpdyAltSvcWireFormat::ParsePositiveInteger16( - SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, + quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, uint16_t* value) { return ParsePositiveIntegerImpl<uint16_t>(c, end, value); } // static bool SpdyAltSvcWireFormat::ParsePositiveInteger32( - SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, + quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, uint32_t* value) { return ParsePositiveIntegerImpl<uint32_t>(c, end, value); }
diff --git a/spdy/core/spdy_alt_svc_wire_format.h b/spdy/core/spdy_alt_svc_wire_format.h index 13142ef..6c3e7af 100644 --- a/spdy/core/spdy_alt_svc_wire_format.h +++ b/spdy/core/spdy_alt_svc_wire_format.h
@@ -14,9 +14,9 @@ #include <string> #include <vector> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_containers.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { @@ -60,27 +60,29 @@ typedef std::vector<AlternativeService> AlternativeServiceVector; friend class test::SpdyAltSvcWireFormatPeer; - static bool ParseHeaderFieldValue(SpdyStringPiece value, + static bool ParseHeaderFieldValue(quiche::QuicheStringPiece value, AlternativeServiceVector* altsvc_vector); static std::string SerializeHeaderFieldValue( const AlternativeServiceVector& altsvc_vector); private: - static void SkipWhiteSpace(SpdyStringPiece::const_iterator* c, - SpdyStringPiece::const_iterator end); - static bool PercentDecode(SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, + static void SkipWhiteSpace(quiche::QuicheStringPiece::const_iterator* c, + quiche::QuicheStringPiece::const_iterator end); + static bool PercentDecode(quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, std::string* output); - static bool ParseAltAuthority(SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, + static bool ParseAltAuthority(quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, std::string* host, uint16_t* port); - static bool ParsePositiveInteger16(SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, - uint16_t* value); - static bool ParsePositiveInteger32(SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, - uint32_t* value); + static bool ParsePositiveInteger16( + quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, + uint16_t* value); + static bool ParsePositiveInteger32( + quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, + uint32_t* value); }; } // namespace spdy
diff --git a/spdy/core/spdy_alt_svc_wire_format_test.cc b/spdy/core/spdy_alt_svc_wire_format_test.cc index 7b5e0bb..6dc4bab 100644 --- a/spdy/core/spdy_alt_svc_wire_format_test.cc +++ b/spdy/core/spdy_alt_svc_wire_format_test.cc
@@ -14,29 +14,31 @@ // Expose all private methods of class SpdyAltSvcWireFormat. class SpdyAltSvcWireFormatPeer { public: - static void SkipWhiteSpace(SpdyStringPiece::const_iterator* c, - SpdyStringPiece::const_iterator end) { + static void SkipWhiteSpace(quiche::QuicheStringPiece::const_iterator* c, + quiche::QuicheStringPiece::const_iterator end) { SpdyAltSvcWireFormat::SkipWhiteSpace(c, end); } - static bool PercentDecode(SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, + static bool PercentDecode(quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, std::string* output) { return SpdyAltSvcWireFormat::PercentDecode(c, end, output); } - static bool ParseAltAuthority(SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, + static bool ParseAltAuthority(quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, std::string* host, uint16_t* port) { return SpdyAltSvcWireFormat::ParseAltAuthority(c, end, host, port); } - static bool ParsePositiveInteger16(SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, - uint16_t* max_age) { + static bool ParsePositiveInteger16( + quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, + uint16_t* max_age) { return SpdyAltSvcWireFormat::ParsePositiveInteger16(c, end, max_age); } - static bool ParsePositiveInteger32(SpdyStringPiece::const_iterator c, - SpdyStringPiece::const_iterator end, - uint32_t* max_age) { + static bool ParsePositiveInteger32( + quiche::QuicheStringPiece::const_iterator c, + quiche::QuicheStringPiece::const_iterator end, + uint32_t* max_age) { return SpdyAltSvcWireFormat::ParsePositiveInteger32(c, end, max_age); } }; @@ -387,8 +389,8 @@ // Test SkipWhiteSpace(). TEST(SpdyAltSvcWireFormatTest, SkipWhiteSpace) { - SpdyStringPiece input("a \tb "); - SpdyStringPiece::const_iterator c = input.begin(); + quiche::QuicheStringPiece input("a \tb "); + quiche::QuicheStringPiece::const_iterator c = input.begin(); test::SpdyAltSvcWireFormatPeer::SkipWhiteSpace(&c, input.end()); ASSERT_EQ(input.begin(), c); ++c; @@ -401,19 +403,19 @@ // Test PercentDecode() on valid input. TEST(SpdyAltSvcWireFormatTest, PercentDecodeValid) { - SpdyStringPiece input(""); + quiche::QuicheStringPiece input(""); std::string output; ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::PercentDecode( input.begin(), input.end(), &output)); EXPECT_EQ("", output); - input = SpdyStringPiece("foo"); + input = quiche::QuicheStringPiece("foo"); output.clear(); ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::PercentDecode( input.begin(), input.end(), &output)); EXPECT_EQ("foo", output); - input = SpdyStringPiece("%2ca%5Cb"); + input = quiche::QuicheStringPiece("%2ca%5Cb"); output.clear(); ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::PercentDecode( input.begin(), input.end(), &output)); @@ -424,7 +426,7 @@ TEST(SpdyAltSvcWireFormatTest, PercentDecodeInvalid) { const char* invalid_input_array[] = {"a%", "a%x", "a%b", "%J22", "%9z"}; for (const char* invalid_input : invalid_input_array) { - SpdyStringPiece input(invalid_input); + quiche::QuicheStringPiece input(invalid_input); std::string output; EXPECT_FALSE(test::SpdyAltSvcWireFormatPeer::PercentDecode( input.begin(), input.end(), &output)) @@ -434,7 +436,7 @@ // Test ParseAltAuthority() on valid input. TEST(SpdyAltSvcWireFormatTest, ParseAltAuthorityValid) { - SpdyStringPiece input(":42"); + quiche::QuicheStringPiece input(":42"); std::string host; uint16_t port; ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParseAltAuthority( @@ -442,13 +444,13 @@ EXPECT_TRUE(host.empty()); EXPECT_EQ(42, port); - input = SpdyStringPiece("foo:137"); + input = quiche::QuicheStringPiece("foo:137"); ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParseAltAuthority( input.begin(), input.end(), &host, &port)); EXPECT_EQ("foo", host); EXPECT_EQ(137, port); - input = SpdyStringPiece("[2003:8:0:16::509d:9615]:443"); + input = quiche::QuicheStringPiece("[2003:8:0:16::509d:9615]:443"); ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParseAltAuthority( input.begin(), input.end(), &host, &port)); EXPECT_EQ("[2003:8:0:16::509d:9615]", host); @@ -475,7 +477,7 @@ "[2003:8:0:16::509d:9615:443", "2003:8:0:16::509d:9615]:443"}; for (const char* invalid_input : invalid_input_array) { - SpdyStringPiece input(invalid_input); + quiche::QuicheStringPiece input(invalid_input); std::string host; uint16_t port; EXPECT_FALSE(test::SpdyAltSvcWireFormatPeer::ParseAltAuthority( @@ -486,13 +488,13 @@ // Test ParseInteger() on valid input. TEST(SpdyAltSvcWireFormatTest, ParseIntegerValid) { - SpdyStringPiece input("3"); + quiche::QuicheStringPiece input("3"); uint16_t value; ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value)); EXPECT_EQ(3, value); - input = SpdyStringPiece("1337"); + input = quiche::QuicheStringPiece("1337"); ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value)); EXPECT_EQ(1337, value); @@ -503,7 +505,7 @@ TEST(SpdyAltSvcWireFormatTest, ParseIntegerInvalid) { const char* invalid_input_array[] = {"", " ", "a", "0", "00", "1 ", "12b"}; for (const char* invalid_input : invalid_input_array) { - SpdyStringPiece input(invalid_input); + quiche::QuicheStringPiece input(invalid_input); uint16_t value; EXPECT_FALSE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value)) @@ -514,39 +516,39 @@ // Test ParseIntegerValid() around overflow limit. TEST(SpdyAltSvcWireFormatTest, ParseIntegerOverflow) { // Largest possible uint16_t value. - SpdyStringPiece input("65535"); + quiche::QuicheStringPiece input("65535"); uint16_t value16; ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value16)); EXPECT_EQ(65535, value16); // Overflow uint16_t, ParsePositiveInteger16() should return false. - input = SpdyStringPiece("65536"); + input = quiche::QuicheStringPiece("65536"); ASSERT_FALSE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value16)); // However, even if overflow is not checked for, 65536 overflows to 0, which // returns false anyway. Check for a larger number which overflows to 1. - input = SpdyStringPiece("65537"); + input = quiche::QuicheStringPiece("65537"); ASSERT_FALSE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger16( input.begin(), input.end(), &value16)); // Largest possible uint32_t value. - input = SpdyStringPiece("4294967295"); + input = quiche::QuicheStringPiece("4294967295"); uint32_t value32; ASSERT_TRUE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger32( input.begin(), input.end(), &value32)); EXPECT_EQ(4294967295, value32); // Overflow uint32_t, ParsePositiveInteger32() should return false. - input = SpdyStringPiece("4294967296"); + input = quiche::QuicheStringPiece("4294967296"); ASSERT_FALSE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger32( input.begin(), input.end(), &value32)); // However, even if overflow is not checked for, 4294967296 overflows to 0, // which returns false anyway. Check for a larger number which overflows to // 1. - input = SpdyStringPiece("4294967297"); + input = quiche::QuicheStringPiece("4294967297"); ASSERT_FALSE(test::SpdyAltSvcWireFormatPeer::ParsePositiveInteger32( input.begin(), input.end(), &value32)); }
diff --git a/spdy/core/spdy_deframer_visitor.cc b/spdy/core/spdy_deframer_visitor.cc index e49b755..10e5e85 100644 --- a/spdy/core/spdy_deframer_visitor.cc +++ b/spdy/core/spdy_deframer_visitor.cc
@@ -12,6 +12,7 @@ #include <memory> #include "net/third_party/quiche/src/http2/platform/api/http2_macros.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_constants.h" #include "net/third_party/quiche/src/spdy/core/mock_spdy_framer_visitor.h" #include "net/third_party/quiche/src/spdy/core/spdy_frame_reader.h" @@ -19,7 +20,6 @@ #include "net/third_party/quiche/src/spdy/core/spdy_test_utils.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_flags.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_logging.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" using ::testing::AssertionFailure; using ::testing::AssertionResult; @@ -138,7 +138,7 @@ // alphabetical order for ease of navigation, and are not in same order // as in SpdyFramerVisitorInterface. void OnAltSvc(SpdyStreamId stream_id, - SpdyStringPiece origin, + quiche::QuicheStringPiece origin, const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) override; void OnContinuation(SpdyStreamId stream_id, bool end) override; @@ -184,7 +184,8 @@ // Callbacks defined in SpdyHeadersHandlerInterface. void OnHeaderBlockStart() override; - void OnHeader(SpdyStringPiece key, SpdyStringPiece value) override; + void OnHeader(quiche::QuicheStringPiece key, + quiche::QuicheStringPiece value) override; void OnHeaderBlockEnd(size_t header_bytes_parsed, size_t compressed_header_bytes_parsed) override; @@ -409,7 +410,7 @@ void SpdyTestDeframerImpl::OnAltSvc( SpdyStreamId stream_id, - SpdyStringPiece origin, + quiche::QuicheStringPiece origin, const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) { SPDY_DVLOG(1) << "OnAltSvc stream_id: " << stream_id; CHECK_EQ(frame_type_, UNSET) @@ -754,8 +755,8 @@ got_hpack_end_ = false; } -void SpdyTestDeframerImpl::OnHeader(SpdyStringPiece key, - SpdyStringPiece value) { +void SpdyTestDeframerImpl::OnHeader(quiche::QuicheStringPiece key, + quiche::QuicheStringPiece value) { CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION || frame_type_ == PUSH_PROMISE) << " frame_type_=" << Http2FrameTypeToString(frame_type_);
diff --git a/spdy/core/spdy_deframer_visitor.h b/spdy/core/spdy_deframer_visitor.h index f36daac..2753523 100644 --- a/spdy/core/spdy_deframer_visitor.h +++ b/spdy/core/spdy_deframer_visitor.h
@@ -45,7 +45,7 @@ // framer.set_visitor(the_deframer.get()); // // // Process frames. -// SpdyStringPiece input = ... +// QuicheStringPiece input = ... // while (!input.empty() && !framer.HasError()) { // size_t consumed = framer.ProcessInput(input.data(), input.size()); // input.remove_prefix(consumed);
diff --git a/spdy/core/spdy_frame_builder.cc b/spdy/core/spdy_frame_builder.cc index f4b71d3..492cd43 100644 --- a/spdy/core/spdy_frame_builder.cc +++ b/spdy/core/spdy_frame_builder.cc
@@ -120,7 +120,8 @@ return success; } -bool SpdyFrameBuilder::WriteStringPiece32(const SpdyStringPiece value) { +bool SpdyFrameBuilder::WriteStringPiece32( + const quiche::QuicheStringPiece value) { if (!WriteUInt32(value.size())) { return false; }
diff --git a/spdy/core/spdy_frame_builder.h b/spdy/core/spdy_frame_builder.h index e1dc32b..eb90ddb 100644 --- a/spdy/core/spdy_frame_builder.h +++ b/spdy/core/spdy_frame_builder.h
@@ -9,12 +9,12 @@ #include <cstdint> #include <memory> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" #include "net/third_party/quiche/src/spdy/core/zero_copy_output_buffer.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_bug_tracker.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_endianness_util.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { @@ -100,7 +100,7 @@ return (WriteBytes(&upper, sizeof(upper)) && WriteBytes(&lower, sizeof(lower))); } - bool WriteStringPiece32(const SpdyStringPiece value); + bool WriteStringPiece32(const quiche::QuicheStringPiece value); bool WriteBytes(const void* data, uint32_t data_len); private:
diff --git a/spdy/core/spdy_frame_builder_test.cc b/spdy/core/spdy_frame_builder_test.cc index c5f234e..73ee8e8 100644 --- a/spdy/core/spdy_frame_builder_test.cc +++ b/spdy/core/spdy_frame_builder_test.cc
@@ -48,8 +48,8 @@ SpdySerializedFrame frame(builder.take()); char expected[kBuilderSize]; memset(expected, ~1, kBuilderSize); - EXPECT_EQ(SpdyStringPiece(expected, kBuilderSize), - SpdyStringPiece(frame.data(), kBuilderSize)); + EXPECT_EQ(quiche::QuicheStringPiece(expected, kBuilderSize), + quiche::QuicheStringPiece(frame.data(), kBuilderSize)); } // Verifies that SpdyFrameBuilder::GetWritableBuffer() can be used to build a @@ -66,8 +66,8 @@ SpdySerializedFrame frame(output.Begin(), kBuilderSize, false); char expected[kBuilderSize]; memset(expected, ~1, kBuilderSize); - EXPECT_EQ(SpdyStringPiece(expected, kBuilderSize), - SpdyStringPiece(frame.data(), kBuilderSize)); + EXPECT_EQ(quiche::QuicheStringPiece(expected, kBuilderSize), + quiche::QuicheStringPiece(frame.data(), kBuilderSize)); } // Verifies the case that the buffer's capacity is too small.
diff --git a/spdy/core/spdy_frame_reader.cc b/spdy/core/spdy_frame_reader.cc index b9bf4c1..253f906 100644 --- a/spdy/core/spdy_frame_reader.cc +++ b/spdy/core/spdy_frame_reader.cc
@@ -109,7 +109,7 @@ return true; } -bool SpdyFrameReader::ReadStringPiece16(SpdyStringPiece* result) { +bool SpdyFrameReader::ReadStringPiece16(quiche::QuicheStringPiece* result) { // Read resultant length. uint16_t result_len; if (!ReadUInt16(&result_len)) { @@ -124,7 +124,7 @@ } // Set result. - *result = SpdyStringPiece(data_ + ofs_, result_len); + *result = quiche::QuicheStringPiece(data_ + ofs_, result_len); // Iterate. ofs_ += result_len; @@ -132,7 +132,7 @@ return true; } -bool SpdyFrameReader::ReadStringPiece32(SpdyStringPiece* result) { +bool SpdyFrameReader::ReadStringPiece32(quiche::QuicheStringPiece* result) { // Read resultant length. uint32_t result_len; if (!ReadUInt32(&result_len)) { @@ -147,7 +147,7 @@ } // Set result. - *result = SpdyStringPiece(data_ + ofs_, result_len); + *result = quiche::QuicheStringPiece(data_ + ofs_, result_len); // Iterate. ofs_ += result_len;
diff --git a/spdy/core/spdy_frame_reader.h b/spdy/core/spdy_frame_reader.h index dc6c064..a7136ca 100644 --- a/spdy/core/spdy_frame_reader.h +++ b/spdy/core/spdy_frame_reader.h
@@ -7,8 +7,8 @@ #include <cstdint> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { @@ -73,7 +73,7 @@ // // Forwards the internal iterator on success. // Returns true on success, false otherwise. - bool ReadStringPiece16(SpdyStringPiece* result); + bool ReadStringPiece16(quiche::QuicheStringPiece* result); // Reads a string prefixed with 32-bit length into the given output parameter. // @@ -82,7 +82,7 @@ // // Forwards the internal iterator on success. // Returns true on success, false otherwise. - bool ReadStringPiece32(SpdyStringPiece* result); + bool ReadStringPiece32(quiche::QuicheStringPiece* result); // Reads a given number of bytes into the given buffer. The buffer // must be of adequate size.
diff --git a/spdy/core/spdy_frame_reader_test.cc b/spdy/core/spdy_frame_reader_test.cc index c1ab02e..a3cfe21 100644 --- a/spdy/core/spdy_frame_reader_test.cc +++ b/spdy/core/spdy_frame_reader_test.cc
@@ -67,7 +67,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - SpdyStringPiece stringpiece_val; + quiche::QuicheStringPiece stringpiece_val; EXPECT_TRUE(frame_reader.ReadStringPiece16(&stringpiece_val)); EXPECT_FALSE(frame_reader.IsDoneReading()); EXPECT_EQ(0, stringpiece_val.compare("Hi")); @@ -90,7 +90,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - SpdyStringPiece stringpiece_val; + quiche::QuicheStringPiece stringpiece_val; EXPECT_TRUE(frame_reader.ReadStringPiece32(&stringpiece_val)); EXPECT_FALSE(frame_reader.IsDoneReading()); EXPECT_EQ(0, stringpiece_val.compare("foo")); @@ -142,7 +142,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - SpdyStringPiece stringpiece_val; + quiche::QuicheStringPiece stringpiece_val; EXPECT_FALSE(frame_reader.ReadStringPiece16(&stringpiece_val)); // Also make sure that trying to read a uint16_t, which technically could @@ -161,7 +161,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - SpdyStringPiece stringpiece_val; + quiche::QuicheStringPiece stringpiece_val; EXPECT_FALSE(frame_reader.ReadStringPiece16(&stringpiece_val)); // Also make sure that trying to read a uint16_t, which technically could @@ -181,7 +181,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - SpdyStringPiece stringpiece_val; + quiche::QuicheStringPiece stringpiece_val; EXPECT_FALSE(frame_reader.ReadStringPiece32(&stringpiece_val)); // Also make sure that trying to read a uint16_t, which technically could @@ -200,7 +200,7 @@ SpdyFrameReader frame_reader(kFrameData, QUICHE_ARRAYSIZE(kFrameData)); EXPECT_FALSE(frame_reader.IsDoneReading()); - SpdyStringPiece stringpiece_val; + quiche::QuicheStringPiece stringpiece_val; EXPECT_FALSE(frame_reader.ReadStringPiece32(&stringpiece_val)); // Also make sure that trying to read a uint16_t, which technically could @@ -222,12 +222,12 @@ char dest1[3] = {}; EXPECT_TRUE(frame_reader.ReadBytes(&dest1, QUICHE_ARRAYSIZE(dest1))); EXPECT_FALSE(frame_reader.IsDoneReading()); - EXPECT_EQ("foo", SpdyStringPiece(dest1, QUICHE_ARRAYSIZE(dest1))); + EXPECT_EQ("foo", quiche::QuicheStringPiece(dest1, QUICHE_ARRAYSIZE(dest1))); char dest2[2] = {}; EXPECT_TRUE(frame_reader.ReadBytes(&dest2, QUICHE_ARRAYSIZE(dest2))); EXPECT_TRUE(frame_reader.IsDoneReading()); - EXPECT_EQ("Hi", SpdyStringPiece(dest2, QUICHE_ARRAYSIZE(dest2))); + EXPECT_EQ("Hi", quiche::QuicheStringPiece(dest2, QUICHE_ARRAYSIZE(dest2))); } TEST(SpdyFrameReaderTest, ReadBytesWithBufferTooSmall) {
diff --git a/spdy/core/spdy_framer.h b/spdy/core/spdy_framer.h index 45d1f86..95b7e20 100644 --- a/spdy/core/spdy_framer.h +++ b/spdy/core/spdy_framer.h
@@ -13,6 +13,7 @@ #include <string> #include <utility> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/hpack/hpack_encoder.h" #include "net/third_party/quiche/src/spdy/core/spdy_alt_svc_wire_format.h" #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" @@ -20,7 +21,6 @@ #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" #include "net/third_party/quiche/src/spdy/core/zero_copy_output_buffer.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy {
diff --git a/spdy/core/spdy_framer_test.cc b/spdy/core/spdy_framer_test.cc index dd9f150..d14d293 100644 --- a/spdy/core/spdy_framer_test.cc +++ b/spdy/core/spdy_framer_test.cc
@@ -287,7 +287,7 @@ SPDY_VLOG(1) << "OnStreamFrameData(" << stream_id << ", data, " << len << ", " << ") data:\n" - << SpdyHexDump(SpdyStringPiece(data, len)); + << SpdyHexDump(quiche::QuicheStringPiece(data, len)); EXPECT_EQ(header_stream_id_, stream_id); data_bytes_ += len; @@ -403,7 +403,7 @@ } void OnAltSvc(SpdyStreamId stream_id, - SpdyStringPiece origin, + quiche::QuicheStringPiece origin, const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) override { SPDY_VLOG(1) << "OnAltSvc(" << stream_id << ", \"" << origin @@ -1125,7 +1125,7 @@ control_frame.size()); EXPECT_THAT(visitor.headers_, testing::ElementsAre(testing::Pair( - "name", SpdyStringPiece(value)))); + "name", quiche::QuicheStringPiece(value)))); } TEST_P(SpdyFramerTest, CompressEmptyHeaders) { @@ -1315,7 +1315,7 @@ const char bytes[] = "this is a test test test test test!"; SpdyDataIR data_ir(/* stream_id = */ 1, - SpdyStringPiece(bytes, QUICHE_ARRAYSIZE(bytes))); + quiche::QuicheStringPiece(bytes, QUICHE_ARRAYSIZE(bytes))); data_ir.set_fin(true); SpdySerializedFrame send_frame(framer_.SerializeData(data_ir)); @@ -4298,8 +4298,8 @@ SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector; altsvc_vector.push_back(altsvc1); altsvc_vector.push_back(altsvc2); - EXPECT_CALL(visitor, - OnAltSvc(kStreamId, SpdyStringPiece("o_r|g!n"), altsvc_vector)); + EXPECT_CALL(visitor, OnAltSvc(kStreamId, quiche::QuicheStringPiece("o_r|g!n"), + altsvc_vector)); SpdyAltSvcIR altsvc_ir(kStreamId); altsvc_ir.set_origin("o_r|g!n"); @@ -4333,7 +4333,8 @@ SpdyAltSvcWireFormat::AlternativeServiceVector altsvc_vector; altsvc_vector.push_back(altsvc1); altsvc_vector.push_back(altsvc2); - EXPECT_CALL(visitor, OnAltSvc(kStreamId, SpdyStringPiece(""), altsvc_vector)); + EXPECT_CALL(visitor, OnAltSvc(kStreamId, quiche::QuicheStringPiece(""), + altsvc_vector)); SpdyAltSvcIR altsvc_ir(kStreamId); altsvc_ir.add_altsvc(altsvc1); @@ -4769,7 +4770,8 @@ SpdyFramer framer(SpdyFramer::DISABLE_COMPRESSION); const char bytes[] = "this is a very short data frame"; - SpdyDataIR data_ir(1, SpdyStringPiece(bytes, QUICHE_ARRAYSIZE(bytes))); + SpdyDataIR data_ir(1, + quiche::QuicheStringPiece(bytes, QUICHE_ARRAYSIZE(bytes))); CheckFrameAndIRSize(&data_ir, &framer, &output_); SpdyRstStreamIR rst_ir(/* stream_id = */ 1, ERROR_CODE_PROTOCOL_ERROR);
diff --git a/spdy/core/spdy_header_block.cc b/spdy/core/spdy_header_block.cc index c87bfff..d7e3faa 100644 --- a/spdy/core/spdy_header_block.cc +++ b/spdy/core/spdy_header_block.cc
@@ -27,20 +27,21 @@ const char kCookieKey[] = "cookie"; const char kNullSeparator = 0; -SpdyStringPiece SeparatorForKey(SpdyStringPiece key) { +quiche::QuicheStringPiece SeparatorForKey(quiche::QuicheStringPiece key) { if (key == kCookieKey) { - static SpdyStringPiece cookie_separator = "; "; + static quiche::QuicheStringPiece cookie_separator = "; "; return cookie_separator; } else { - return SpdyStringPiece(&kNullSeparator, 1); + return quiche::QuicheStringPiece(&kNullSeparator, 1); } } } // namespace -SpdyHeaderBlock::HeaderValue::HeaderValue(SpdyHeaderStorage* storage, - SpdyStringPiece key, - SpdyStringPiece initial_value) +SpdyHeaderBlock::HeaderValue::HeaderValue( + SpdyHeaderStorage* storage, + quiche::QuicheStringPiece key, + quiche::QuicheStringPiece initial_value) : storage_(storage), fragments_({initial_value}), pair_({key, {}}), @@ -70,9 +71,10 @@ SpdyHeaderBlock::HeaderValue::~HeaderValue() = default; -SpdyStringPiece SpdyHeaderBlock::HeaderValue::ConsolidatedValue() const { +quiche::QuicheStringPiece SpdyHeaderBlock::HeaderValue::ConsolidatedValue() + const { if (fragments_.empty()) { - return SpdyStringPiece(); + return quiche::QuicheStringPiece(); } if (fragments_.size() > 1) { fragments_ = { @@ -81,12 +83,12 @@ return fragments_[0]; } -void SpdyHeaderBlock::HeaderValue::Append(SpdyStringPiece fragment) { +void SpdyHeaderBlock::HeaderValue::Append(quiche::QuicheStringPiece fragment) { size_ += (fragment.size() + separator_size_); fragments_.push_back(fragment); } -const std::pair<SpdyStringPiece, SpdyStringPiece>& +const std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece>& SpdyHeaderBlock::HeaderValue::as_pair() const { pair_.second = ConsolidatedValue(); return pair_; @@ -101,7 +103,7 @@ SpdyHeaderBlock::ValueProxy::ValueProxy( SpdyHeaderBlock* block, SpdyHeaderBlock::MapType::iterator lookup_result, - const SpdyStringPiece key, + const quiche::QuicheStringPiece key, size_t* spdy_header_block_value_size) : block_(block), lookup_result_(lookup_result), @@ -140,7 +142,7 @@ } SpdyHeaderBlock::ValueProxy& SpdyHeaderBlock::ValueProxy::operator=( - SpdyStringPiece value) { + quiche::QuicheStringPiece value) { *spdy_header_block_value_size_ += value.size(); SpdyHeaderStorage* storage = &block_->storage_; if (lookup_result_ == block_->map_.end()) { @@ -158,7 +160,8 @@ return *this; } -bool SpdyHeaderBlock::ValueProxy::operator==(SpdyStringPiece value) const { +bool SpdyHeaderBlock::ValueProxy::operator==( + quiche::QuicheStringPiece value) const { if (lookup_result_ == block_->map_.end()) { return false; } else { @@ -229,7 +232,7 @@ return output; } -void SpdyHeaderBlock::erase(SpdyStringPiece key) { +void SpdyHeaderBlock::erase(quiche::QuicheStringPiece key) { auto iter = map_.find(key); if (iter != map_.end()) { SPDY_DVLOG(1) << "Erasing header with name: " << key; @@ -265,13 +268,13 @@ } SpdyHeaderBlock::ValueProxy SpdyHeaderBlock::operator[]( - const SpdyStringPiece key) { + const quiche::QuicheStringPiece key) { SPDY_DVLOG(2) << "Operator[] saw key: " << key; - SpdyStringPiece out_key; + quiche::QuicheStringPiece out_key; auto iter = map_.find(key); if (iter == map_.end()) { // We write the key first, to assure that the ValueProxy has a - // reference to a valid SpdyStringPiece in its operator=. + // reference to a valid QuicheStringPiece in its operator=. out_key = WriteKey(key); SPDY_DVLOG(2) << "Key written as: " << std::hex << static_cast<const void*>(key.data()) << ", " << std::dec @@ -282,8 +285,9 @@ return ValueProxy(this, iter, out_key, &value_size_); } -void SpdyHeaderBlock::AppendValueOrAddHeader(const SpdyStringPiece key, - const SpdyStringPiece value) { +void SpdyHeaderBlock::AppendValueOrAddHeader( + const quiche::QuicheStringPiece key, + const quiche::QuicheStringPiece value) { value_size_ += value.size(); auto iter = map_.find(key); @@ -305,14 +309,15 @@ return SpdyEstimateMemoryUsage(storage_); } -void SpdyHeaderBlock::AppendHeader(const SpdyStringPiece key, - const SpdyStringPiece value) { +void SpdyHeaderBlock::AppendHeader(const quiche::QuicheStringPiece key, + const quiche::QuicheStringPiece value) { auto backed_key = WriteKey(key); map_.emplace(std::make_pair( backed_key, HeaderValue(&storage_, backed_key, storage_.Write(value)))); } -SpdyStringPiece SpdyHeaderBlock::WriteKey(const SpdyStringPiece key) { +quiche::QuicheStringPiece SpdyHeaderBlock::WriteKey( + const quiche::QuicheStringPiece key) { key_size_ += key.size(); return storage_.Write(key); }
diff --git a/spdy/core/spdy_header_block.h b/spdy/core/spdy_header_block.h index 56ee1d5..e164478 100644 --- a/spdy/core/spdy_header_block.h +++ b/spdy/core/spdy_header_block.h
@@ -13,11 +13,11 @@ #include <utility> #include <vector> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_header_storage.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_containers.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_macros.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { @@ -30,9 +30,9 @@ // names and values. This data structure preserves insertion order. // // Under the hood, this data structure uses large, contiguous blocks of memory -// to store names and values. Lookups may be performed with SpdyStringPiece -// keys, and values are returned as SpdyStringPieces (via ValueProxy, below). -// Value SpdyStringPieces are valid as long as the SpdyHeaderBlock exists; +// to store names and values. Lookups may be performed with QuicheStringPiece +// keys, and values are returned as QuicheStringPieces (via ValueProxy, below). +// Value QuicheStringPieces are valid as long as the SpdyHeaderBlock exists; // allocated memory is never freed until SpdyHeaderBlock's destruction. // // This implementation does not make much of an effort to minimize wasted space. @@ -44,8 +44,8 @@ class SPDY_EXPORT_PRIVATE HeaderValue { public: HeaderValue(SpdyHeaderStorage* storage, - SpdyStringPiece key, - SpdyStringPiece initial_value); + quiche::QuicheStringPiece key, + quiche::QuicheStringPiece initial_value); // Moves are allowed. HeaderValue(HeaderValue&& other); @@ -60,10 +60,11 @@ ~HeaderValue(); // Consumes at most |fragment.size()| bytes of memory. - void Append(SpdyStringPiece fragment); + void Append(quiche::QuicheStringPiece fragment); - SpdyStringPiece value() const { return as_pair().second; } - const std::pair<SpdyStringPiece, SpdyStringPiece>& as_pair() const; + quiche::QuicheStringPiece value() const { return as_pair().second; } + const std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece>& + as_pair() const; // Size estimate including separators. Used when keys are erased from // SpdyHeaderBlock. @@ -72,34 +73,37 @@ private: // May allocate a large contiguous region of memory to hold the concatenated // fragments and separators. - SpdyStringPiece ConsolidatedValue() const; + quiche::QuicheStringPiece ConsolidatedValue() const; mutable SpdyHeaderStorage* storage_; - mutable std::vector<SpdyStringPiece> fragments_; + mutable std::vector<quiche::QuicheStringPiece> fragments_; // The first element is the key; the second is the consolidated value. - mutable std::pair<SpdyStringPiece, SpdyStringPiece> pair_; + mutable std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece> + pair_; size_t size_ = 0; size_t separator_size_ = 0; }; - typedef SpdyLinkedHashMap<SpdyStringPiece, + typedef SpdyLinkedHashMap<quiche::QuicheStringPiece, HeaderValue, - SpdyStringPieceHash, - std::equal_to<SpdyStringPiece>> + quiche::QuicheStringPieceHash, + std::equal_to<quiche::QuicheStringPiece>> MapType; public: - typedef std::pair<SpdyStringPiece, SpdyStringPiece> value_type; + typedef std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece> + value_type; - // Provides iteration over a sequence of std::pair<SpdyStringPiece, - // SpdyStringPiece>, even though the underlying MapType::value_type is + // Provides iteration over a sequence of std::pair<QuicheStringPiece, + // QuicheStringPiece>, even though the underlying MapType::value_type is // different. Dereferencing the iterator will result in memory allocation for // multi-value headers. class SPDY_EXPORT_PRIVATE iterator { public: // The following type definitions fulfill the requirements for iterator // implementations. - typedef std::pair<SpdyStringPiece, SpdyStringPiece> value_type; + typedef std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece> + value_type; typedef value_type& reference; typedef value_type* pointer; typedef std::forward_iterator_tag iterator_category; @@ -159,11 +163,13 @@ const_iterator end() const { return const_iterator(map_.end()); } bool empty() const { return map_.empty(); } size_t size() const { return map_.size(); } - iterator find(SpdyStringPiece key) { return iterator(map_.find(key)); } - const_iterator find(SpdyStringPiece key) const { + iterator find(quiche::QuicheStringPiece key) { + return iterator(map_.find(key)); + } + const_iterator find(quiche::QuicheStringPiece key) const { return const_iterator(map_.find(key)); } - void erase(SpdyStringPiece key); + void erase(quiche::QuicheStringPiece key); // Clears both our MapType member and the memory used to hold headers. void clear(); @@ -178,8 +184,8 @@ // existing header value, NUL ("\0") separated unless the key is cookie, in // which case the separator is "; ". // If there is no such key, a new header with the key and value is added. - void AppendValueOrAddHeader(const SpdyStringPiece key, - const SpdyStringPiece value); + void AppendValueOrAddHeader(const quiche::QuicheStringPiece key, + const quiche::QuicheStringPiece value); // This object provides automatic conversions that allow SpdyHeaderBlock to be // nearly a drop-in replacement for @@ -198,10 +204,10 @@ ValueProxy& operator=(const ValueProxy& other) = delete; // Assignment modifies the underlying SpdyHeaderBlock. - ValueProxy& operator=(SpdyStringPiece value); + ValueProxy& operator=(quiche::QuicheStringPiece value); - // Provides easy comparison against SpdyStringPiece. - bool operator==(SpdyStringPiece value) const; + // Provides easy comparison against QuicheStringPiece. + bool operator==(quiche::QuicheStringPiece value) const; std::string as_string() const; @@ -211,18 +217,19 @@ ValueProxy(SpdyHeaderBlock* block, SpdyHeaderBlock::MapType::iterator lookup_result, - const SpdyStringPiece key, + const quiche::QuicheStringPiece key, size_t* spdy_header_block_value_size); SpdyHeaderBlock* block_; SpdyHeaderBlock::MapType::iterator lookup_result_; - SpdyStringPiece key_; + quiche::QuicheStringPiece key_; size_t* spdy_header_block_value_size_; bool valid_; }; // Allows either lookup or mutation of the value associated with a key. - SPDY_MUST_USE_RESULT ValueProxy operator[](const SpdyStringPiece key); + SPDY_MUST_USE_RESULT ValueProxy + operator[](const quiche::QuicheStringPiece key); // Returns the estimate of dynamically allocated memory in bytes. size_t EstimateMemoryUsage() const; @@ -232,11 +239,12 @@ private: friend class test::SpdyHeaderBlockPeer; - void AppendHeader(const SpdyStringPiece key, const SpdyStringPiece value); - SpdyStringPiece WriteKey(const SpdyStringPiece key); + void AppendHeader(const quiche::QuicheStringPiece key, + const quiche::QuicheStringPiece value); + quiche::QuicheStringPiece WriteKey(const quiche::QuicheStringPiece key); size_t bytes_allocated() const; - // SpdyStringPieces held by |map_| point to memory owned by |storage_|. + // QuicheStringPieces held by |map_| point to memory owned by |storage_|. MapType map_; SpdyHeaderStorage storage_;
diff --git a/spdy/core/spdy_header_block_test.cc b/spdy/core/spdy_header_block_test.cc index 7695aad..aad264c 100644 --- a/spdy/core/spdy_header_block_test.cc +++ b/spdy/core/spdy_header_block_test.cc
@@ -17,11 +17,14 @@ class ValueProxyPeer { public: - static SpdyStringPiece key(SpdyHeaderBlock::ValueProxy* p) { return p->key_; } + static quiche::QuicheStringPiece key(SpdyHeaderBlock::ValueProxy* p) { + return p->key_; + } }; -std::pair<SpdyStringPiece, SpdyStringPiece> Pair(SpdyStringPiece k, - SpdyStringPiece v) { +std::pair<quiche::QuicheStringPiece, quiche::QuicheStringPiece> Pair( + quiche::QuicheStringPiece k, + quiche::QuicheStringPiece v) { return std::make_pair(k, v); } @@ -39,19 +42,20 @@ TEST(SpdyHeaderBlockTest, KeyMemoryReclaimedOnLookup) { SpdyHeaderBlock block; - SpdyStringPiece copied_key1; + quiche::QuicheStringPiece copied_key1; { auto proxy1 = block["some key name"]; copied_key1 = ValueProxyPeer::key(&proxy1); } - SpdyStringPiece copied_key2; + quiche::QuicheStringPiece copied_key2; { auto proxy2 = block["some other key name"]; copied_key2 = ValueProxyPeer::key(&proxy2); } // Because proxy1 was never used to modify the block, the memory used for the // key could be reclaimed and used for the second call to operator[]. - // Therefore, we expect the pointers of the two SpdyStringPieces to be equal. + // Therefore, we expect the pointers of the two QuicheStringPieces to be + // equal. EXPECT_EQ(copied_key1.data(), copied_key2.data()); { @@ -189,25 +193,25 @@ EXPECT_EQ("singleton", block["h4"]); } -TEST(SpdyHeaderBlockTest, CompareValueToSpdyStringPiece) { +TEST(SpdyHeaderBlockTest, CompareValueToStringPiece) { SpdyHeaderBlock block; block["foo"] = "foo"; block.AppendValueOrAddHeader("foo", "bar"); const auto& val = block["foo"]; const char expected[] = "foo\0bar"; - EXPECT_TRUE(SpdyStringPiece(expected, 7) == val); - EXPECT_TRUE(val == SpdyStringPiece(expected, 7)); - EXPECT_FALSE(SpdyStringPiece(expected, 3) == val); - EXPECT_FALSE(val == SpdyStringPiece(expected, 3)); + EXPECT_TRUE(quiche::QuicheStringPiece(expected, 7) == val); + EXPECT_TRUE(val == quiche::QuicheStringPiece(expected, 7)); + EXPECT_FALSE(quiche::QuicheStringPiece(expected, 3) == val); + EXPECT_FALSE(val == quiche::QuicheStringPiece(expected, 3)); const char not_expected[] = "foo\0barextra"; - EXPECT_FALSE(SpdyStringPiece(not_expected, 12) == val); - EXPECT_FALSE(val == SpdyStringPiece(not_expected, 12)); + EXPECT_FALSE(quiche::QuicheStringPiece(not_expected, 12) == val); + EXPECT_FALSE(val == quiche::QuicheStringPiece(not_expected, 12)); const auto& val2 = block["foo2"]; - EXPECT_FALSE(SpdyStringPiece(expected, 7) == val2); - EXPECT_FALSE(val2 == SpdyStringPiece(expected, 7)); - EXPECT_FALSE(SpdyStringPiece("") == val2); - EXPECT_FALSE(val2 == SpdyStringPiece("")); + EXPECT_FALSE(quiche::QuicheStringPiece(expected, 7) == val2); + EXPECT_FALSE(val2 == quiche::QuicheStringPiece(expected, 7)); + EXPECT_FALSE(quiche::QuicheStringPiece("") == val2); + EXPECT_FALSE(val2 == quiche::QuicheStringPiece("")); } // This test demonstrates that the SpdyHeaderBlock data structure does not place
diff --git a/spdy/core/spdy_header_storage.cc b/spdy/core/spdy_header_storage.cc index e84b3be..76ba378 100644 --- a/spdy/core/spdy_header_storage.cc +++ b/spdy/core/spdy_header_storage.cc
@@ -12,19 +12,20 @@ SpdyHeaderStorage::SpdyHeaderStorage() : arena_(kDefaultStorageBlockSize) {} -SpdyStringPiece SpdyHeaderStorage::Write(const SpdyStringPiece s) { - return SpdyStringPiece(arena_.Memdup(s.data(), s.size()), s.size()); +quiche::QuicheStringPiece SpdyHeaderStorage::Write( + const quiche::QuicheStringPiece s) { + return quiche::QuicheStringPiece(arena_.Memdup(s.data(), s.size()), s.size()); } -void SpdyHeaderStorage::Rewind(const SpdyStringPiece s) { +void SpdyHeaderStorage::Rewind(const quiche::QuicheStringPiece s) { arena_.Free(const_cast<char*>(s.data()), s.size()); } -SpdyStringPiece SpdyHeaderStorage::WriteFragments( - const std::vector<SpdyStringPiece>& fragments, - SpdyStringPiece separator) { +quiche::QuicheStringPiece SpdyHeaderStorage::WriteFragments( + const std::vector<quiche::QuicheStringPiece>& fragments, + quiche::QuicheStringPiece separator) { if (fragments.empty()) { - return SpdyStringPiece(); + return quiche::QuicheStringPiece(); } size_t total_size = separator.size() * (fragments.size() - 1); for (const auto fragment : fragments) { @@ -33,12 +34,12 @@ char* dst = arena_.Alloc(total_size); size_t written = Join(dst, fragments, separator); DCHECK_EQ(written, total_size); - return SpdyStringPiece(dst, total_size); + return quiche::QuicheStringPiece(dst, total_size); } size_t Join(char* dst, - const std::vector<SpdyStringPiece>& fragments, - SpdyStringPiece separator) { + const std::vector<quiche::QuicheStringPiece>& fragments, + quiche::QuicheStringPiece separator) { if (fragments.empty()) { return 0; }
diff --git a/spdy/core/spdy_header_storage.h b/spdy/core/spdy_header_storage.h index fc559ec..af1775a 100644 --- a/spdy/core/spdy_header_storage.h +++ b/spdy/core/spdy_header_storage.h
@@ -1,15 +1,15 @@ #ifndef QUICHE_SPDY_CORE_SPDY_HEADER_STORAGE_H_ #define QUICHE_SPDY_CORE_SPDY_HEADER_STORAGE_H_ +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_simple_arena.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { -// This class provides a backing store for SpdyStringPieces. It previously used -// custom allocation logic, but now uses an UnsafeArena instead. It has the -// property that SpdyStringPieces that refer to data in SpdyHeaderStorage are +// This class provides a backing store for QuicheStringPieces. It previously +// used custom allocation logic, but now uses an UnsafeArena instead. It has the +// property that QuicheStringPieces that refer to data in SpdyHeaderStorage are // never invalidated until the SpdyHeaderStorage is deleted or Clear() is // called. // @@ -26,19 +26,20 @@ SpdyHeaderStorage(SpdyHeaderStorage&& other) = default; SpdyHeaderStorage& operator=(SpdyHeaderStorage&& other) = default; - SpdyStringPiece Write(SpdyStringPiece s); + quiche::QuicheStringPiece Write(quiche::QuicheStringPiece s); // If |s| points to the most recent allocation from arena_, the arena will // reclaim the memory. Otherwise, this method is a no-op. - void Rewind(SpdyStringPiece s); + void Rewind(quiche::QuicheStringPiece s); void Clear() { arena_.Reset(); } // Given a list of fragments and a separator, writes the fragments joined by - // the separator to a contiguous region of memory. Returns a SpdyStringPiece + // the separator to a contiguous region of memory. Returns a QuicheStringPiece // pointing to the region of memory. - SpdyStringPiece WriteFragments(const std::vector<SpdyStringPiece>& fragments, - SpdyStringPiece separator); + quiche::QuicheStringPiece WriteFragments( + const std::vector<quiche::QuicheStringPiece>& fragments, + quiche::QuicheStringPiece separator); size_t bytes_allocated() const { return arena_.status().bytes_allocated(); } @@ -50,9 +51,10 @@ // Writes |fragments| to |dst|, joined by |separator|. |dst| must be large // enough to hold the result. Returns the number of bytes written. -SPDY_EXPORT_PRIVATE size_t Join(char* dst, - const std::vector<SpdyStringPiece>& fragments, - SpdyStringPiece separator); +SPDY_EXPORT_PRIVATE size_t +Join(char* dst, + const std::vector<quiche::QuicheStringPiece>& fragments, + quiche::QuicheStringPiece separator); } // namespace spdy
diff --git a/spdy/core/spdy_header_storage_test.cc b/spdy/core/spdy_header_storage_test.cc index 6f82013..2abd762 100644 --- a/spdy/core/spdy_header_storage_test.cc +++ b/spdy/core/spdy_header_storage_test.cc
@@ -6,29 +6,29 @@ namespace test { TEST(JoinTest, JoinEmpty) { - std::vector<SpdyStringPiece> empty; - SpdyStringPiece separator = ", "; + std::vector<quiche::QuicheStringPiece> empty; + quiche::QuicheStringPiece separator = ", "; char buf[10] = ""; size_t written = Join(buf, empty, separator); EXPECT_EQ(0u, written); } TEST(JoinTest, JoinOne) { - std::vector<SpdyStringPiece> v = {"one"}; - SpdyStringPiece separator = ", "; + std::vector<quiche::QuicheStringPiece> v = {"one"}; + quiche::QuicheStringPiece separator = ", "; char buf[15]; size_t written = Join(buf, v, separator); EXPECT_EQ(3u, written); - EXPECT_EQ("one", SpdyStringPiece(buf, written)); + EXPECT_EQ("one", quiche::QuicheStringPiece(buf, written)); } TEST(JoinTest, JoinMultiple) { - std::vector<SpdyStringPiece> v = {"one", "two", "three"}; - SpdyStringPiece separator = ", "; + std::vector<quiche::QuicheStringPiece> v = {"one", "two", "three"}; + quiche::QuicheStringPiece separator = ", "; char buf[15]; size_t written = Join(buf, v, separator); EXPECT_EQ(15u, written); - EXPECT_EQ("one, two, three", SpdyStringPiece(buf, written)); + EXPECT_EQ("one, two, three", quiche::QuicheStringPiece(buf, written)); } } // namespace test
diff --git a/spdy/core/spdy_headers_handler_interface.h b/spdy/core/spdy_headers_handler_interface.h index ce6c1b6..cff4922 100644 --- a/spdy/core/spdy_headers_handler_interface.h +++ b/spdy/core/spdy_headers_handler_interface.h
@@ -7,8 +7,8 @@ #include <stddef.h> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { @@ -25,7 +25,8 @@ // A callback method which notifies on a header key value pair. Multiple // values for a given key will be emitted as multiple calls to OnHeader. - virtual void OnHeader(SpdyStringPiece key, SpdyStringPiece value) = 0; + virtual void OnHeader(quiche::QuicheStringPiece key, + quiche::QuicheStringPiece value) = 0; // A callback method which notifies when the parser finishes handling a // header block (i.e. the containing frame has the END_HEADERS flag set).
diff --git a/spdy/core/spdy_no_op_visitor.h b/spdy/core/spdy_no_op_visitor.h index 6e4a48a..a6f4438 100644 --- a/spdy/core/spdy_no_op_visitor.h +++ b/spdy/core/spdy_no_op_visitor.h
@@ -11,9 +11,9 @@ #include <cstdint> +#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_protocol.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { namespace test { @@ -61,7 +61,7 @@ bool /*end*/) override {} void OnContinuation(SpdyStreamId /*stream_id*/, bool /*end*/) override {} void OnAltSvc(SpdyStreamId /*stream_id*/, - SpdyStringPiece /*origin*/, + quiche::QuicheStringPiece /*origin*/, const SpdyAltSvcWireFormat::AlternativeServiceVector& /*altsvc_vector*/) override {} void OnPriority(SpdyStreamId /*stream_id*/, @@ -82,7 +82,8 @@ // SpdyHeadersHandlerInterface methods: void OnHeaderBlockStart() override {} - void OnHeader(SpdyStringPiece /*key*/, SpdyStringPiece /*value*/) override {} + void OnHeader(quiche::QuicheStringPiece /*key*/, + quiche::QuicheStringPiece /*value*/) override {} void OnHeaderBlockEnd(size_t /* uncompressed_header_bytes */, size_t /* compressed_header_bytes */) override {} };
diff --git a/spdy/core/spdy_pinnable_buffer_piece.h b/spdy/core/spdy_pinnable_buffer_piece.h index 3032ad7..469c0d3 100644 --- a/spdy/core/spdy_pinnable_buffer_piece.h +++ b/spdy/core/spdy_pinnable_buffer_piece.h
@@ -9,8 +9,8 @@ #include <memory> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { @@ -27,8 +27,8 @@ const char* buffer() const { return buffer_; } - explicit operator SpdyStringPiece() const { - return SpdyStringPiece(buffer_, length_); + explicit operator quiche::QuicheStringPiece() const { + return quiche::QuicheStringPiece(buffer_, length_); } // Allocates and copies the buffer to internal storage.
diff --git a/spdy/core/spdy_pinnable_buffer_piece_test.cc b/spdy/core/spdy_pinnable_buffer_piece_test.cc index 9c7f138..f625425 100644 --- a/spdy/core/spdy_pinnable_buffer_piece_test.cc +++ b/spdy/core/spdy_pinnable_buffer_piece_test.cc
@@ -31,14 +31,16 @@ EXPECT_TRUE(reader.ReadN(6, &piece)); // Piece points to underlying prefix storage. - EXPECT_EQ(SpdyStringPiece("foobar"), SpdyStringPiece(piece)); + EXPECT_EQ(quiche::QuicheStringPiece("foobar"), + quiche::QuicheStringPiece(piece)); EXPECT_FALSE(piece.IsPinned()); EXPECT_EQ(prefix_.data(), piece.buffer()); piece.Pin(); // Piece now points to allocated storage. - EXPECT_EQ(SpdyStringPiece("foobar"), SpdyStringPiece(piece)); + EXPECT_EQ(quiche::QuicheStringPiece("foobar"), + quiche::QuicheStringPiece(piece)); EXPECT_TRUE(piece.IsPinned()); EXPECT_NE(prefix_.data(), piece.buffer()); @@ -56,22 +58,24 @@ piece1.Pin(); - EXPECT_EQ(SpdyStringPiece("foob"), SpdyStringPiece(piece1)); + EXPECT_EQ(quiche::QuicheStringPiece("foob"), + quiche::QuicheStringPiece(piece1)); EXPECT_TRUE(piece1.IsPinned()); - EXPECT_EQ(SpdyStringPiece("ar"), SpdyStringPiece(piece2)); + EXPECT_EQ(quiche::QuicheStringPiece("ar"), quiche::QuicheStringPiece(piece2)); EXPECT_FALSE(piece2.IsPinned()); piece1.Swap(&piece2); - EXPECT_EQ(SpdyStringPiece("ar"), SpdyStringPiece(piece1)); + EXPECT_EQ(quiche::QuicheStringPiece("ar"), quiche::QuicheStringPiece(piece1)); EXPECT_FALSE(piece1.IsPinned()); - EXPECT_EQ(SpdyStringPiece("foob"), SpdyStringPiece(piece2)); + EXPECT_EQ(quiche::QuicheStringPiece("foob"), + quiche::QuicheStringPiece(piece2)); EXPECT_TRUE(piece2.IsPinned()); SpdyPinnableBufferPiece empty; piece2.Swap(&empty); - EXPECT_EQ(SpdyStringPiece(""), SpdyStringPiece(piece2)); + EXPECT_EQ(quiche::QuicheStringPiece(""), quiche::QuicheStringPiece(piece2)); EXPECT_FALSE(piece2.IsPinned()); }
diff --git a/spdy/core/spdy_prefixed_buffer_reader_test.cc b/spdy/core/spdy_prefixed_buffer_reader_test.cc index a0f9257..273e001 100644 --- a/spdy/core/spdy_prefixed_buffer_reader_test.cc +++ b/spdy/core/spdy_prefixed_buffer_reader_test.cc
@@ -6,7 +6,7 @@ #include <string> -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_test.h" namespace spdy { @@ -46,7 +46,8 @@ EXPECT_FALSE(reader.ReadN(10, &piece)); // Not enough buffer. EXPECT_TRUE(reader.ReadN(6, &piece)); EXPECT_FALSE(piece.IsPinned()); - EXPECT_EQ(SpdyStringPiece("foobar"), SpdyStringPiece(piece)); + EXPECT_EQ(quiche::QuicheStringPiece("foobar"), + quiche::QuicheStringPiece(piece)); EXPECT_EQ(0u, reader.Available()); } @@ -69,7 +70,8 @@ EXPECT_FALSE(reader.ReadN(10, &piece)); // Not enough buffer. EXPECT_TRUE(reader.ReadN(6, &piece)); EXPECT_FALSE(piece.IsPinned()); - EXPECT_EQ(SpdyStringPiece("foobar"), SpdyStringPiece(piece)); + EXPECT_EQ(quiche::QuicheStringPiece("foobar"), + quiche::QuicheStringPiece(piece)); EXPECT_EQ(0u, reader.Available()); } @@ -92,7 +94,8 @@ EXPECT_FALSE(reader.ReadN(10, &piece)); // Not enough buffer. EXPECT_TRUE(reader.ReadN(6, &piece)); EXPECT_TRUE(piece.IsPinned()); - EXPECT_EQ(SpdyStringPiece("foobar"), SpdyStringPiece(piece)); + EXPECT_EQ(quiche::QuicheStringPiece("foobar"), + quiche::QuicheStringPiece(piece)); EXPECT_EQ(0u, reader.Available()); } @@ -112,12 +115,12 @@ EXPECT_EQ(6u, reader.Available()); EXPECT_TRUE(reader.ReadN(3, &piece)); - EXPECT_EQ(SpdyStringPiece("fhi"), SpdyStringPiece(piece)); + EXPECT_EQ(quiche::QuicheStringPiece("fhi"), quiche::QuicheStringPiece(piece)); EXPECT_TRUE(piece.IsPinned()); EXPECT_EQ(3u, reader.Available()); EXPECT_TRUE(reader.ReadN(2, &piece)); - EXPECT_EQ(SpdyStringPiece("jk"), SpdyStringPiece(piece)); + EXPECT_EQ(quiche::QuicheStringPiece("jk"), quiche::QuicheStringPiece(piece)); EXPECT_FALSE(piece.IsPinned()); EXPECT_EQ(1u, reader.Available());
diff --git a/spdy/core/spdy_protocol.cc b/spdy/core/spdy_protocol.cc index 0ab6737..4a59d55 100644 --- a/spdy/core/spdy_protocol.cc +++ b/spdy/core/spdy_protocol.cc
@@ -280,7 +280,7 @@ SpdyFrameWithHeaderBlockIR::~SpdyFrameWithHeaderBlockIR() = default; -SpdyDataIR::SpdyDataIR(SpdyStreamId stream_id, SpdyStringPiece data) +SpdyDataIR::SpdyDataIR(SpdyStreamId stream_id, quiche::QuicheStringPiece data) : SpdyFrameWithFinIR(stream_id), data_(nullptr), data_len_(0), @@ -290,7 +290,7 @@ } SpdyDataIR::SpdyDataIR(SpdyStreamId stream_id, const char* data) - : SpdyDataIR(stream_id, SpdyStringPiece(data)) {} + : SpdyDataIR(stream_id, quiche::QuicheStringPiece(data)) {} SpdyDataIR::SpdyDataIR(SpdyStreamId stream_id, std::string data) : SpdyFrameWithFinIR(stream_id), @@ -376,7 +376,7 @@ SpdyGoAwayIR::SpdyGoAwayIR(SpdyStreamId last_good_stream_id, SpdyErrorCode error_code, - SpdyStringPiece description) + quiche::QuicheStringPiece description) : description_(description) { set_last_good_stream_id(last_good_stream_id); set_error_code(error_code); @@ -387,7 +387,7 @@ const char* description) : SpdyGoAwayIR(last_good_stream_id, error_code, - SpdyStringPiece(description)) {} + quiche::QuicheStringPiece(description)) {} SpdyGoAwayIR::SpdyGoAwayIR(SpdyStreamId last_good_stream_id, SpdyErrorCode error_code,
diff --git a/spdy/core/spdy_protocol.h b/spdy/core/spdy_protocol.h index cb6906c..5d96497 100644 --- a/spdy/core/spdy_protocol.h +++ b/spdy/core/spdy_protocol.h
@@ -19,13 +19,13 @@ #include <string> #include <utility> +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/core/spdy_alt_svc_wire_format.h" #include "net/third_party/quiche/src/spdy/core/spdy_bitmasks.h" #include "net/third_party/quiche/src/spdy/core/spdy_header_block.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_bug_tracker.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_export.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_logging.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { @@ -499,7 +499,8 @@ // Deep copy. header_block_ = std::move(header_block); } - void SetHeader(SpdyStringPiece name, SpdyStringPiece value) { + void SetHeader(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { header_block_[name] = value; } @@ -517,7 +518,7 @@ class SPDY_EXPORT_PRIVATE SpdyDataIR : public SpdyFrameWithFinIR { public: // Performs a deep copy on data. - SpdyDataIR(SpdyStreamId stream_id, SpdyStringPiece data); + SpdyDataIR(SpdyStreamId stream_id, quiche::QuicheStringPiece data); // Performs a deep copy on data. SpdyDataIR(SpdyStreamId stream_id, const char* data); @@ -548,14 +549,14 @@ } // Deep-copy of data (keep private copy). - void SetDataDeep(SpdyStringPiece data) { + void SetDataDeep(quiche::QuicheStringPiece data) { data_store_ = std::make_unique<std::string>(data.data(), data.size()); data_ = data_store_->data(); data_len_ = data.size(); } // Shallow-copy of data (do not keep private copy). - void SetDataShallow(SpdyStringPiece data) { + void SetDataShallow(quiche::QuicheStringPiece data) { data_store_.reset(); data_ = data.data(); data_len_ = data.size(); @@ -661,7 +662,7 @@ // this SpdyGoAwayIR. SpdyGoAwayIR(SpdyStreamId last_good_stream_id, SpdyErrorCode error_code, - SpdyStringPiece description); + quiche::QuicheStringPiece description); // References description, doesn't copy it, so description must outlast // this SpdyGoAwayIR. @@ -690,7 +691,7 @@ error_code_ = error_code; } - const SpdyStringPiece& description() const { return description_; } + const quiche::QuicheStringPiece& description() const { return description_; } void Visit(SpdyFrameVisitor* visitor) const override; @@ -702,7 +703,7 @@ SpdyStreamId last_good_stream_id_; SpdyErrorCode error_code_; const std::string description_store_; - const SpdyStringPiece description_; + const quiche::QuicheStringPiece description_; }; class SPDY_EXPORT_PRIVATE SpdyHeadersIR : public SpdyFrameWithHeaderBlockIR {
diff --git a/spdy/core/spdy_protocol_test.cc b/spdy/core/spdy_protocol_test.cc index 542d23d..af6df35 100644 --- a/spdy/core/spdy_protocol_test.cc +++ b/spdy/core/spdy_protocol_test.cc
@@ -226,8 +226,8 @@ TEST(SpdyDataIRTest, Construct) { // Confirm that it makes a string of zero length from a - // SpdyStringPiece(nullptr). - SpdyStringPiece s1; + // QuicheStringPiece(nullptr). + quiche::QuicheStringPiece s1; SpdyDataIR d1(/* stream_id = */ 1, s1); EXPECT_EQ(0u, d1.data_len()); EXPECT_NE(nullptr, d1.data()); @@ -235,8 +235,8 @@ // Confirms makes a copy of char array. const char s2[] = "something"; SpdyDataIR d2(/* stream_id = */ 2, s2); - EXPECT_EQ(SpdyStringPiece(d2.data(), d2.data_len()), s2); - EXPECT_NE(SpdyStringPiece(d1.data(), d1.data_len()), s2); + EXPECT_EQ(quiche::QuicheStringPiece(d2.data(), d2.data_len()), s2); + EXPECT_NE(quiche::QuicheStringPiece(d1.data(), d1.data_len()), s2); EXPECT_EQ((int)d1.data_len(), d1.flow_control_window_consumed()); // Confirm copies a const string. @@ -249,18 +249,20 @@ std::string bar = "bar"; SpdyDataIR d4(/* stream_id = */ 4, bar); EXPECT_EQ("bar", bar); - EXPECT_EQ("bar", SpdyStringPiece(d4.data(), d4.data_len())); + EXPECT_EQ("bar", quiche::QuicheStringPiece(d4.data(), d4.data_len())); // Confirm moves an rvalue reference. Note that the test string "baz" is too // short to trigger the move optimization, and instead a copy occurs. std::string baz = "the quick brown fox"; SpdyDataIR d5(/* stream_id = */ 5, std::move(baz)); EXPECT_EQ("", baz); - EXPECT_EQ(SpdyStringPiece(d5.data(), d5.data_len()), "the quick brown fox"); + EXPECT_EQ(quiche::QuicheStringPiece(d5.data(), d5.data_len()), + "the quick brown fox"); // Confirms makes a copy of string literal. SpdyDataIR d7(/* stream_id = */ 7, "something else"); - EXPECT_EQ(SpdyStringPiece(d7.data(), d7.data_len()), "something else"); + EXPECT_EQ(quiche::QuicheStringPiece(d7.data(), d7.data_len()), + "something else"); SpdyDataIR d8(/* stream_id = */ 8, "shawarma"); d8.set_padding_len(20);
diff --git a/spdy/core/spdy_protocol_test_utils.cc b/spdy/core/spdy_protocol_test_utils.cc index b8ffb4a..7390f50 100644 --- a/spdy/core/spdy_protocol_test_utils.cc +++ b/spdy/core/spdy_protocol_test_utils.cc
@@ -6,7 +6,7 @@ #include <cstdint> -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace spdy { namespace test { @@ -47,8 +47,8 @@ if (expected.data() == nullptr) { VERIFY_EQ(nullptr, actual.data()); } else { - VERIFY_EQ(SpdyStringPiece(expected.data(), expected.data_len()), - SpdyStringPiece(actual.data(), actual.data_len())); + VERIFY_EQ(quiche::QuicheStringPiece(expected.data(), expected.data_len()), + quiche::QuicheStringPiece(actual.data(), actual.data_len())); } VERIFY_SUCCESS(VerifySpdyFrameWithPaddingIREquals(expected, actual)); return ::testing::AssertionSuccess();
diff --git a/spdy/core/spdy_simple_arena_test.cc b/spdy/core/spdy_simple_arena_test.cc index 35c84f1..d20bdff 100644 --- a/spdy/core/spdy_simple_arena_test.cc +++ b/spdy/core/spdy_simple_arena_test.cc
@@ -7,7 +7,7 @@ #include <string> #include <vector> -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" +#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_test.h" namespace spdy { @@ -27,7 +27,7 @@ char* c = arena.Memdup(kTestString, length); EXPECT_NE(nullptr, c); EXPECT_NE(c, kTestString); - EXPECT_EQ(SpdyStringPiece(c, length), kTestString); + EXPECT_EQ(quiche::QuicheStringPiece(c, length), kTestString); } TEST(SpdySimpleArenaTest, MemdupLargeString) { @@ -36,7 +36,7 @@ char* c = arena.Memdup(kTestString, length); EXPECT_NE(nullptr, c); EXPECT_NE(c, kTestString); - EXPECT_EQ(SpdyStringPiece(c, length), kTestString); + EXPECT_EQ(quiche::QuicheStringPiece(c, length), kTestString); } TEST(SpdySimpleArenaTest, MultipleBlocks) { @@ -44,9 +44,9 @@ std::vector<std::string> strings = { "One decently long string.", "Another string.", "A third string that will surely go in a different block."}; - std::vector<SpdyStringPiece> copies; + std::vector<quiche::QuicheStringPiece> copies; for (const std::string& s : strings) { - SpdyStringPiece sp(arena.Memdup(s.data(), s.size()), s.size()); + quiche::QuicheStringPiece sp(arena.Memdup(s.data(), s.size()), s.size()); copies.push_back(sp); } EXPECT_EQ(strings.size(), copies.size()); @@ -63,7 +63,7 @@ c = arena.Memdup(kTestString, length); EXPECT_NE(nullptr, c); EXPECT_NE(c, kTestString); - EXPECT_EQ(SpdyStringPiece(c, length), kTestString); + EXPECT_EQ(quiche::QuicheStringPiece(c, length), kTestString); } TEST(SpdySimpleArenaTest, Free) { @@ -102,7 +102,7 @@ EXPECT_EQ(c1 + length, c2); EXPECT_EQ(c2 + 2 * length, c3); EXPECT_EQ(c3 + 3 * length, c4); - EXPECT_EQ(SpdyStringPiece(c4, length), kTestString); + EXPECT_EQ(quiche::QuicheStringPiece(c4, length), kTestString); } TEST(SpdySimpleArenaTest, Realloc) { @@ -113,28 +113,28 @@ char* c2 = arena.Realloc(c1, length, 2 * length); EXPECT_TRUE(c1); EXPECT_EQ(c1, c2); - EXPECT_EQ(SpdyStringPiece(c1, length), kTestString); + EXPECT_EQ(quiche::QuicheStringPiece(c1, length), kTestString); // Multiple reallocs. char* c3 = arena.Memdup(kTestString, length); EXPECT_EQ(c2 + 2 * length, c3); - EXPECT_EQ(SpdyStringPiece(c3, length), kTestString); + EXPECT_EQ(quiche::QuicheStringPiece(c3, length), kTestString); char* c4 = arena.Realloc(c3, length, 2 * length); EXPECT_EQ(c3, c4); - EXPECT_EQ(SpdyStringPiece(c4, length), kTestString); + EXPECT_EQ(quiche::QuicheStringPiece(c4, length), kTestString); char* c5 = arena.Realloc(c4, 2 * length, 3 * length); EXPECT_EQ(c4, c5); - EXPECT_EQ(SpdyStringPiece(c5, length), kTestString); + EXPECT_EQ(quiche::QuicheStringPiece(c5, length), kTestString); char* c6 = arena.Memdup(kTestString, length); EXPECT_EQ(c5 + 3 * length, c6); - EXPECT_EQ(SpdyStringPiece(c6, length), kTestString); + EXPECT_EQ(quiche::QuicheStringPiece(c6, length), kTestString); // Realloc that does not fit in the remainder of the first block. char* c7 = arena.Realloc(c6, length, kDefaultBlockSize); - EXPECT_EQ(SpdyStringPiece(c7, length), kTestString); + EXPECT_EQ(quiche::QuicheStringPiece(c7, length), kTestString); arena.Free(c7, kDefaultBlockSize); char* c8 = arena.Memdup(kTestString, length); EXPECT_NE(c6, c7); EXPECT_EQ(c7, c8); - EXPECT_EQ(SpdyStringPiece(c8, length), kTestString); + EXPECT_EQ(quiche::QuicheStringPiece(c8, length), kTestString); } } // namespace
diff --git a/spdy/core/spdy_test_utils.cc b/spdy/core/spdy_test_utils.cc index f248c86..860e2e5 100644 --- a/spdy/core/spdy_test_utils.cc +++ b/spdy/core/spdy_test_utils.cc
@@ -104,7 +104,8 @@ block_.clear(); } -void TestHeadersHandler::OnHeader(SpdyStringPiece name, SpdyStringPiece value) { +void TestHeadersHandler::OnHeader(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) { block_.AppendValueOrAddHeader(name, value); }
diff --git a/spdy/core/spdy_test_utils.h b/spdy/core/spdy_test_utils.h index ff08a50..b3c3aa5 100644 --- a/spdy/core/spdy_test_utils.h +++ b/spdy/core/spdy_test_utils.h
@@ -9,15 +9,15 @@ #include <cstdint> #include <string> +#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" #include "net/third_party/quiche/src/spdy/core/spdy_protocol.h" #include "net/third_party/quiche/src/spdy/platform/api/spdy_bug_tracker.h" -#include "net/third_party/quiche/src/spdy/platform/api/spdy_string_piece.h" namespace spdy { -inline bool operator==(SpdyStringPiece x, +inline bool operator==(quiche::QuicheStringPiece x, const SpdyHeaderBlock::ValueProxy& y) { return y.operator==(x); } @@ -49,7 +49,8 @@ void OnHeaderBlockStart() override; - void OnHeader(SpdyStringPiece name, SpdyStringPiece value) override; + void OnHeader(quiche::QuicheStringPiece name, + quiche::QuicheStringPiece value) override; void OnHeaderBlockEnd(size_t header_bytes_parsed, size_t compressed_header_bytes_parsed) override;