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

Side by Side Diff: net/spdy/spdy_headers_block_parser.cc

Issue 2544813002: Remove enum SpdyMajorVersion. (Closed)
Patch Set: Merge comment changes from 140661724. Created 4 years 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/spdy_headers_block_parser.h ('k') | net/spdy/spdy_headers_block_parser_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/spdy_headers_block_parser.h" 5 #include "net/spdy/spdy_headers_block_parser.h"
6 6
7 #include "base/sys_byteorder.h" 7 #include "base/sys_byteorder.h"
8 #include "net/spdy/spdy_bug_tracker.h" 8 #include "net/spdy/spdy_bug_tracker.h"
9 #include "net/spdy/spdy_flags.h" 9 #include "net/spdy/spdy_flags.h"
10 10
11 namespace net { 11 namespace net {
12 namespace { 12 namespace {
13 13
14 // 0 is invalid according to both the SPDY 3.1 and HTTP/2 specifications. 14 // 0 is invalid according to both the SPDY 3.1 and HTTP/2 specifications.
15 const SpdyStreamId kInvalidStreamId = 0; 15 const SpdyStreamId kInvalidStreamId = 0;
16 16
17 } // anonymous namespace 17 } // anonymous namespace
18 18
19 namespace { 19 namespace {
20 const size_t kLengthFieldSize = sizeof(uint32_t); 20 const size_t kLengthFieldSize = sizeof(uint32_t);
21 } // anonymous namespace 21 } // anonymous namespace
22 22
23 const size_t SpdyHeadersBlockParser::kMaximumFieldLength = 16 * 1024; 23 const size_t SpdyHeadersBlockParser::kMaximumFieldLength = 16 * 1024;
24 24
25 SpdyHeadersBlockParser::SpdyHeadersBlockParser( 25 SpdyHeadersBlockParser::SpdyHeadersBlockParser(
26 SpdyMajorVersion spdy_version,
27 SpdyHeadersHandlerInterface* handler) 26 SpdyHeadersHandlerInterface* handler)
28 : state_(READING_HEADER_BLOCK_LEN), 27 : state_(READING_HEADER_BLOCK_LEN),
29 max_headers_in_block_(MaxNumberOfHeaders()), 28 max_headers_in_block_(MaxNumberOfHeaders()),
30 total_bytes_received_(0), 29 total_bytes_received_(0),
31 remaining_key_value_pairs_for_frame_(0), 30 remaining_key_value_pairs_for_frame_(0),
32 handler_(handler), 31 handler_(handler),
33 stream_id_(kInvalidStreamId), 32 stream_id_(kInvalidStreamId),
34 error_(NO_PARSER_ERROR), 33 error_(NO_PARSER_ERROR) {
35 spdy_version_(spdy_version) {
36 // The handler that we set must not be NULL. 34 // The handler that we set must not be NULL.
37 DCHECK(handler_ != NULL); 35 DCHECK(handler_ != NULL);
38 } 36 }
39 37
40 SpdyHeadersBlockParser::~SpdyHeadersBlockParser() {} 38 SpdyHeadersBlockParser::~SpdyHeadersBlockParser() {}
41 39
42 bool SpdyHeadersBlockParser::HandleControlFrameHeadersData( 40 bool SpdyHeadersBlockParser::HandleControlFrameHeadersData(
43 SpdyStreamId stream_id, 41 SpdyStreamId stream_id,
44 const char* headers_data, 42 const char* headers_data,
45 size_t headers_data_length) { 43 size_t headers_data_length) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 size_t SpdyHeadersBlockParser::MaxNumberOfHeaders() { 186 size_t SpdyHeadersBlockParser::MaxNumberOfHeaders() {
189 // Account for the length of the header block field. 187 // Account for the length of the header block field.
190 size_t max_bytes_for_headers = kMaximumFieldLength - kLengthFieldSize; 188 size_t max_bytes_for_headers = kMaximumFieldLength - kLengthFieldSize;
191 189
192 // A minimal size header is twice the length field size (and has a 190 // A minimal size header is twice the length field size (and has a
193 // zero-lengthed key and a zero-lengthed value). 191 // zero-lengthed key and a zero-lengthed value).
194 return max_bytes_for_headers / (2 * kLengthFieldSize); 192 return max_bytes_for_headers / (2 * kLengthFieldSize);
195 } 193 }
196 194
197 } // namespace net 195 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_headers_block_parser.h ('k') | net/spdy/spdy_headers_block_parser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698