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

Unified Diff: net/spdy/hpack_decoder.cc

Issue 485833002: HTTP2 draft 14 support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ignore_result(). Created 6 years, 4 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_decoder.h ('k') | net/spdy/hpack_decoder_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/hpack_decoder.cc
diff --git a/net/spdy/hpack_decoder.cc b/net/spdy/hpack_decoder.cc
index abd579ad007049be6730eccd728e881109da6fa2..162b33e9240dc94746578ca4f5a423531bcb43b2 100644
--- a/net/spdy/hpack_decoder.cc
+++ b/net/spdy/hpack_decoder.cc
@@ -16,10 +16,6 @@ using std::string;
namespace {
-const uint8 kNoState = 0;
-// Set on entries added to the reference set during this decoding.
-const uint8 kReferencedThisEncoding = 1;
-
const char kCookieKey[] = "cookie";
} // namespace
@@ -56,21 +52,6 @@ bool HpackDecoder::HandleControlFrameHeadersComplete(SpdyStreamId id) {
}
headers_block_buffer_.clear();
- // Emit everything in the reference set that hasn't already been emitted.
- // Also clear entry state for the next decoded headers block.
- // TODO(jgraettinger): We may need to revisit the order in which headers
- // are emitted (b/14051713).
- for (HpackHeaderTable::OrderedEntrySet::const_iterator it =
- header_table_.reference_set().begin();
- it != header_table_.reference_set().end(); ++it) {
- HpackEntry* entry = *it;
-
- if (entry->state() == kNoState) {
- HandleHeaderRepresentation(entry->name(), entry->value());
- } else {
- entry->set_state(kNoState);
- }
- }
// Emit the Cookie header, if any crumbles were encountered.
if (!cookie_value_.empty()) {
decoded_block_[kCookieKey] = cookie_value_;
@@ -103,49 +84,42 @@ void HpackDecoder::HandleHeaderRepresentation(StringPiece name,
}
bool HpackDecoder::DecodeNextOpcode(HpackInputStream* input_stream) {
- // Implements 4.2: Indexed Header Field Representation.
+ // Implements 7.1: Indexed Header Field Representation.
if (input_stream->MatchPrefixAndConsume(kIndexedOpcode)) {
return DecodeNextIndexedHeader(input_stream);
}
- // Implements 4.3.1: Literal Header Field without Indexing.
- if (input_stream->MatchPrefixAndConsume(kLiteralNoIndexOpcode)) {
- return DecodeNextLiteralHeader(input_stream, false);
- }
- // Implements 4.3.2: Literal Header Field with Incremental Indexing.
+ // Implements 7.2.1: Literal Header Field with Incremental Indexing.
if (input_stream->MatchPrefixAndConsume(kLiteralIncrementalIndexOpcode)) {
return DecodeNextLiteralHeader(input_stream, true);
}
- // Implements 4.3.3: Literal Header Field never Indexed.
+ // Implements 7.2.2: Literal Header Field without Indexing.
+ if (input_stream->MatchPrefixAndConsume(kLiteralNoIndexOpcode)) {
+ return DecodeNextLiteralHeader(input_stream, false);
+ }
+ // Implements 7.2.3: Literal Header Field never Indexed.
// TODO(jgraettinger): Preserve the never-indexed bit.
if (input_stream->MatchPrefixAndConsume(kLiteralNeverIndexOpcode)) {
return DecodeNextLiteralHeader(input_stream, false);
}
- // Implements 4.4: Encoding context update.
- if (input_stream->MatchPrefixAndConsume(kEncodingContextOpcode)) {
- return DecodeNextContextUpdate(input_stream);
+ // Implements 7.3: Header Table Size Update.
+ if (input_stream->MatchPrefixAndConsume(kHeaderTableSizeUpdateOpcode)) {
+ return DecodeNextHeaderTableSizeUpdate(input_stream);
}
// Unrecognized opcode.
return false;
}
-bool HpackDecoder::DecodeNextContextUpdate(HpackInputStream* input_stream) {
- if (input_stream->MatchPrefixAndConsume(kEncodingContextEmptyReferenceSet)) {
- header_table_.ClearReferenceSet();
- return true;
+bool HpackDecoder::DecodeNextHeaderTableSizeUpdate(
+ HpackInputStream* input_stream) {
+ uint32 size = 0;
+ if (!input_stream->DecodeNextUint32(&size)) {
+ return false;
}
- if (input_stream->MatchPrefixAndConsume(kEncodingContextNewMaximumSize)) {
- uint32 size = 0;
- if (!input_stream->DecodeNextUint32(&size)) {
- return false;
- }
- if (size > header_table_.settings_size_bound()) {
- return false;
- }
- header_table_.SetMaxSize(size);
- return true;
+ if (size > header_table_.settings_size_bound()) {
+ return false;
}
- // Unrecognized encoding context update.
- return false;
+ header_table_.SetMaxSize(size);
+ return true;
}
bool HpackDecoder::DecodeNextIndexedHeader(HpackInputStream* input_stream) {
@@ -157,22 +131,7 @@ bool HpackDecoder::DecodeNextIndexedHeader(HpackInputStream* input_stream) {
if (entry == NULL)
return false;
- if (entry->IsStatic()) {
- HandleHeaderRepresentation(entry->name(), entry->value());
-
- HpackEntry* new_entry = header_table_.TryAddEntry(
- entry->name(), entry->value());
- if (new_entry) {
- header_table_.Toggle(new_entry);
- new_entry->set_state(kReferencedThisEncoding);
- }
- } else {
- entry->set_state(kNoState);
- if (header_table_.Toggle(entry)) {
- HandleHeaderRepresentation(entry->name(), entry->value());
- entry->set_state(kReferencedThisEncoding);
- }
- }
+ HandleHeaderRepresentation(entry->name(), entry->value());
return true;
}
@@ -191,11 +150,7 @@ bool HpackDecoder::DecodeNextLiteralHeader(HpackInputStream* input_stream,
if (!should_index)
return true;
- HpackEntry* new_entry = header_table_.TryAddEntry(name, value);
- if (new_entry) {
- header_table_.Toggle(new_entry);
- new_entry->set_state(kReferencedThisEncoding);
- }
+ ignore_result(header_table_.TryAddEntry(name, value));
return true;
}
« no previous file with comments | « net/spdy/hpack_decoder.h ('k') | net/spdy/hpack_decoder_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698