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

Side by Side Diff: net/spdy/hpack/hpack_decoder.cc

Issue 1568423002: Implement better HPACK Huffman code decoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not use binary literals. Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « net/spdy/hpack/hpack_decoder.h ('k') | net/spdy/hpack/hpack_decoder_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/hpack/hpack_decoder.h" 5 #include "net/spdy/hpack/hpack_decoder.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "net/spdy/hpack/hpack_constants.h" 10 #include "net/spdy/hpack/hpack_constants.h"
11 #include "net/spdy/hpack/hpack_output_stream.h" 11 #include "net/spdy/hpack/hpack_output_stream.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 using base::StringPiece; 15 using base::StringPiece;
16 using std::string; 16 using std::string;
17 17
18 namespace { 18 namespace {
19 19
20 const char kCookieKey[] = "cookie"; 20 const char kCookieKey[] = "cookie";
21 21
22 } // namespace 22 } // namespace
23 23
24 HpackDecoder::HpackDecoder(const HpackHuffmanTable& table) 24 HpackDecoder::HpackDecoder()
25 : max_string_literal_size_(kDefaultMaxStringLiteralSize), 25 : max_string_literal_size_(kDefaultMaxStringLiteralSize),
26 huffman_table_(table),
27 handler_(nullptr), 26 handler_(nullptr),
28 regular_header_seen_(false), 27 regular_header_seen_(false),
29 header_block_started_(false) {} 28 header_block_started_(false) {}
30 29
31 HpackDecoder::~HpackDecoder() {} 30 HpackDecoder::~HpackDecoder() {}
32 31
33 bool HpackDecoder::HandleControlFrameHeadersData(const char* headers_data, 32 bool HpackDecoder::HandleControlFrameHeadersData(const char* headers_data,
34 size_t headers_data_length) { 33 size_t headers_data_length) {
35 decoded_block_.clear(); 34 decoded_block_.clear();
36 if (!header_block_started_) { 35 if (!header_block_started_) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 *next_name = key_buffer_; 201 *next_name = key_buffer_;
203 } 202 }
204 return true; 203 return true;
205 } 204 }
206 205
207 bool HpackDecoder::DecodeNextStringLiteral(HpackInputStream* input_stream, 206 bool HpackDecoder::DecodeNextStringLiteral(HpackInputStream* input_stream,
208 bool is_key, 207 bool is_key,
209 StringPiece* output) { 208 StringPiece* output) {
210 if (input_stream->MatchPrefixAndConsume(kStringLiteralHuffmanEncoded)) { 209 if (input_stream->MatchPrefixAndConsume(kStringLiteralHuffmanEncoded)) {
211 string* buffer = is_key ? &key_buffer_ : &value_buffer_; 210 string* buffer = is_key ? &key_buffer_ : &value_buffer_;
212 bool result = input_stream->DecodeNextHuffmanString(huffman_table_, buffer); 211 bool result = input_stream->DecodeNextHuffmanString(buffer);
213 *output = StringPiece(*buffer); 212 *output = StringPiece(*buffer);
214 return result; 213 return result;
215 } 214 }
216 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) { 215 if (input_stream->MatchPrefixAndConsume(kStringLiteralIdentityEncoded)) {
217 return input_stream->DecodeNextIdentityString(output); 216 return input_stream->DecodeNextIdentityString(output);
218 } 217 }
219 return false; 218 return false;
220 } 219 }
221 220
222 } // namespace net 221 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_decoder.h ('k') | net/spdy/hpack/hpack_decoder_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698