Rename SpdyHeaderBlock to Http2HeaderBlock, with a using alias.
The goal is to rename SpdyHeaderBlock to Http2HeaderBlock, but performing that
rename globally in one CL would be rather large (cl/336384859). Instead, this
CL performs the rename just for the library and adds a using alias to allow the
global rename to be performed piecemeal. Thanks to ++birenroy@ for the idea!
As part of the alias addition, this CL also removes some forward declarations
of SpdyHeaderBlock in favor of #include-ing the corresponding header file. This
substitution is needed to prevent compilation errors like:
./third_party/quic/tools/quic_simple_server_backend.h:12:7: error: definition of type 'SpdyHeaderBlock' conflicts with type alias of the same name
class SpdyHeaderBlock;
^
./third_party/spdy/core/spdy_header_block.h:294:7: note: 'SpdyHeaderBlock' declared here
using SpdyHeaderBlock = Http2HeaderBlock;
PiperOrigin-RevId: 338091517
Change-Id: Ib1db825a7e7b6775f9da6b377fdd3321a6d204ce
diff --git a/spdy/core/spdy_header_block.h b/spdy/core/spdy_header_block.h
index 1faf34d..b069d20 100644
--- a/spdy/core/spdy_header_block.h
+++ b/spdy/core/spdy_header_block.h
@@ -41,12 +41,12 @@
// Under the hood, this data structure uses large, contiguous blocks of memory
// to store names and values. Lookups may be performed with absl::string_view
// keys, and values are returned as absl::string_views (via ValueProxy, below).
-// Value absl::string_views are valid as long as the SpdyHeaderBlock exists;
-// allocated memory is never freed until SpdyHeaderBlock's destruction.
+// Value absl::string_views are valid as long as the Http2HeaderBlock exists;
+// allocated memory is never freed until Http2HeaderBlock's destruction.
//
// This implementation does not make much of an effort to minimize wasted space.
-// It's expected that keys are rarely deleted from a SpdyHeaderBlock.
-class QUICHE_EXPORT_PRIVATE SpdyHeaderBlock {
+// It's expected that keys are rarely deleted from a Http2HeaderBlock.
+class QUICHE_EXPORT_PRIVATE Http2HeaderBlock {
private:
// Stores a list of value fragments that can be joined later with a
// key-dependent separator.
@@ -75,7 +75,7 @@
const std::pair<absl::string_view, absl::string_view>& as_pair() const;
// Size estimate including separators. Used when keys are erased from
- // SpdyHeaderBlock.
+ // Http2HeaderBlock.
size_t SizeEstimate() const { return size_; }
private:
@@ -158,17 +158,17 @@
};
typedef iterator const_iterator;
- SpdyHeaderBlock();
- SpdyHeaderBlock(const SpdyHeaderBlock& other) = delete;
- SpdyHeaderBlock(SpdyHeaderBlock&& other);
- ~SpdyHeaderBlock();
+ Http2HeaderBlock();
+ Http2HeaderBlock(const Http2HeaderBlock& other) = delete;
+ Http2HeaderBlock(Http2HeaderBlock&& other);
+ ~Http2HeaderBlock();
- SpdyHeaderBlock& operator=(const SpdyHeaderBlock& other) = delete;
- SpdyHeaderBlock& operator=(SpdyHeaderBlock&& other);
- SpdyHeaderBlock Clone() const;
+ Http2HeaderBlock& operator=(const Http2HeaderBlock& other) = delete;
+ Http2HeaderBlock& operator=(Http2HeaderBlock&& other);
+ Http2HeaderBlock Clone() const;
- bool operator==(const SpdyHeaderBlock& other) const;
- bool operator!=(const SpdyHeaderBlock& other) const;
+ bool operator==(const Http2HeaderBlock& other) const;
+ bool operator!=(const Http2HeaderBlock& other) const;
// Provides a human readable multi-line representation of the stored header
// keys and values.
@@ -202,8 +202,8 @@
void AppendValueOrAddHeader(const absl::string_view key,
const absl::string_view value);
- // This object provides automatic conversions that allow SpdyHeaderBlock to be
- // nearly a drop-in replacement for
+ // This object provides automatic conversions that allow Http2HeaderBlock to
+ // be nearly a drop-in replacement for
// SpdyLinkedHashMap<std::string, std::string>.
// It reads data from or writes data to a SpdyHeaderStorage.
class QUICHE_EXPORT_PRIVATE ValueProxy {
@@ -218,7 +218,7 @@
ValueProxy(const ValueProxy& other) = delete;
ValueProxy& operator=(const ValueProxy& other) = delete;
- // Assignment modifies the underlying SpdyHeaderBlock.
+ // Assignment modifies the underlying Http2HeaderBlock.
ValueProxy& operator=(absl::string_view value);
// Provides easy comparison against absl::string_view.
@@ -227,16 +227,16 @@
std::string as_string() const;
private:
- friend class SpdyHeaderBlock;
+ friend class Http2HeaderBlock;
friend class test::ValueProxyPeer;
- ValueProxy(SpdyHeaderBlock* block,
- SpdyHeaderBlock::MapType::iterator lookup_result,
+ ValueProxy(Http2HeaderBlock* block,
+ Http2HeaderBlock::MapType::iterator lookup_result,
const absl::string_view key,
size_t* spdy_header_block_value_size);
- SpdyHeaderBlock* block_;
- SpdyHeaderBlock::MapType::iterator lookup_result_;
+ Http2HeaderBlock* block_;
+ Http2HeaderBlock::MapType::iterator lookup_result_;
absl::string_view key_;
size_t* spdy_header_block_value_size_;
bool valid_;
@@ -290,6 +290,9 @@
size_t value_size_ = 0;
};
+// TODO(b/156770486): Remove this alias when the rename is complete.
+using SpdyHeaderBlock = Http2HeaderBlock;
+
} // namespace spdy
#endif // QUICHE_SPDY_CORE_SPDY_HEADER_BLOCK_H_