Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Unified Diff: net/spdy/hpack/hpack_encoder.cc

Issue 2237113005: Adds a listener interface to HpackEncoder. Not used in production. Not protected. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/hpack/hpack_encoder.h ('k') | net/spdy/hpack/hpack_encoder_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/hpack/hpack_encoder.cc
diff --git a/net/spdy/hpack/hpack_encoder.cc b/net/spdy/hpack/hpack_encoder.cc
index d642c3f0d5537f43b4eb7a45480c1afd906b90f0..525a73766105cd4c5ce2eb911ddc4a288c06240a 100644
--- a/net/spdy/hpack/hpack_encoder.cc
+++ b/net/spdy/hpack/hpack_encoder.cc
@@ -56,6 +56,9 @@ class HpackEncoder::RepresentationIterator {
namespace {
+// The default header listener.
+void NoOpListener(StringPiece /*name*/, StringPiece /*value*/) {}
+
// The default HPACK indexing policy.
bool DefaultPolicy(StringPiece name, StringPiece /* value */) {
if (name.empty()) {
@@ -76,6 +79,7 @@ HpackEncoder::HpackEncoder(const HpackHuffmanTable& table)
: output_stream_(),
huffman_table_(table),
min_table_size_setting_received_(std::numeric_limits<size_t>::max()),
+ listener_(NoOpListener),
should_index_(DefaultPolicy),
allow_huffman_compression_(true),
should_emit_table_size_(false) {}
@@ -121,6 +125,7 @@ bool HpackEncoder::EncodeHeaderSetWithoutCompression(
allow_huffman_compression_ = false;
MaybeEmitTableSize();
for (const auto& header : header_set) {
+ listener_(header.first, header.second);
// Note that cookies are not crumbled in this case.
EmitNonIndexedLiteral(header);
}
@@ -146,6 +151,7 @@ void HpackEncoder::EncodeRepresentations(RepresentationIterator* iter,
MaybeEmitTableSize();
while (iter->HasNext()) {
const auto header = iter->Next();
+ listener_(header.first, header.second);
const HpackEntry* entry =
header_table_.GetByNameAndValue(header.first, header.second);
if (entry != nullptr) {
« no previous file with comments | « net/spdy/hpack/hpack_encoder.h ('k') | net/spdy/hpack/hpack_encoder_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698