Remove SpdyStringPiece; use QuicheStringPiece instead.
gfe-relnote: n/a, no functional change.
PiperOrigin-RevId: 288029999
Change-Id: If83322cadaac9647f246fa8ef18f5ce870995aa3
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_;