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

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

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_framer_test.cc ('k') | net/spdy/spdy_headers_block_parser.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 #ifndef NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_ 5 #ifndef NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_
6 #define NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_ 6 #define NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 11 matching lines...) Expand all
22 // This class handles SPDY headers block bytes and parses out key-value pairs 22 // This class handles SPDY headers block bytes and parses out key-value pairs
23 // as they arrive. This class is not thread-safe, and assumes that all headers 23 // as they arrive. This class is not thread-safe, and assumes that all headers
24 // block bytes are processed in a single thread. 24 // block bytes are processed in a single thread.
25 class NET_EXPORT_PRIVATE SpdyHeadersBlockParser { 25 class NET_EXPORT_PRIVATE SpdyHeadersBlockParser {
26 public: 26 public:
27 // Bound on acceptable header name or value length. 27 // Bound on acceptable header name or value length.
28 static const size_t kMaximumFieldLength; // = 16 * 1024 28 static const size_t kMaximumFieldLength; // = 16 * 1024
29 29
30 // Constructor. The handler's OnHeader will be called for every key 30 // Constructor. The handler's OnHeader will be called for every key
31 // value pair that we parsed from the headers block. 31 // value pair that we parsed from the headers block.
32 SpdyHeadersBlockParser(SpdyMajorVersion spdy_version, 32 explicit SpdyHeadersBlockParser(SpdyHeadersHandlerInterface* handler);
33 SpdyHeadersHandlerInterface* handler);
34 33
35 virtual ~SpdyHeadersBlockParser(); 34 virtual ~SpdyHeadersBlockParser();
36 35
37 // Handles headers block data as it arrives. Returns false if an error has 36 // Handles headers block data as it arrives. Returns false if an error has
38 // been set, which can include the recoverable error NEED_MORE_DATA. Returns 37 // been set, which can include the recoverable error NEED_MORE_DATA. Returns
39 // true if the invocation completes the parse of the entire headers block, 38 // true if the invocation completes the parse of the entire headers block,
40 // in which case the parser is ready for a new headers block. 39 // in which case the parser is ready for a new headers block.
41 bool HandleControlFrameHeadersData(SpdyStreamId stream_id, 40 bool HandleControlFrameHeadersData(SpdyStreamId stream_id,
42 const char* headers_data, 41 const char* headers_data,
43 size_t len); 42 size_t len);
44 enum ParserError { 43 enum ParserError {
45 NO_PARSER_ERROR, 44 NO_PARSER_ERROR,
46 // Set when parsing failed due to insufficient data. 45 // Set when parsing failed due to insufficient data.
47 // This error is recoverable, by passing in new data. 46 // This error is recoverable, by passing in new data.
48 NEED_MORE_DATA, 47 NEED_MORE_DATA,
49 // Set when a complete block has been read, but unprocessed data remains. 48 // Set when a complete block has been read, but unprocessed data remains.
50 TOO_MUCH_DATA, 49 TOO_MUCH_DATA,
51 // Set when a block exceeds |MaxNumberOfHeadersForVersion| headers. 50 // Set when a block exceeds |MaxNumberOfHeadersForVersion| headers.
52 HEADER_BLOCK_TOO_LARGE, 51 HEADER_BLOCK_TOO_LARGE,
53 // Set when a header key or value exceeds |kMaximumFieldLength|. 52 // Set when a header key or value exceeds |kMaximumFieldLength|.
54 HEADER_FIELD_TOO_LARGE, 53 HEADER_FIELD_TOO_LARGE,
55 // Set when the parser is given an unexpected stream ID. 54 // Set when the parser is given an unexpected stream ID.
56 UNEXPECTED_STREAM_ID, 55 UNEXPECTED_STREAM_ID,
57 }; 56 };
58 ParserError get_error() const { return error_; } 57 ParserError get_error() const { return error_; }
59 58
60 SpdyMajorVersion spdy_version() const { return spdy_version_; }
61
62 // Returns the maximal number of headers in a SPDY headers block. 59 // Returns the maximal number of headers in a SPDY headers block.
63 static size_t MaxNumberOfHeaders(); 60 static size_t MaxNumberOfHeaders();
64 61
65 private: 62 private:
66 typedef SpdyPrefixedBufferReader Reader; 63 typedef SpdyPrefixedBufferReader Reader;
67 64
68 // Parses and sanity-checks header block length. 65 // Parses and sanity-checks header block length.
69 void ParseBlockLength(Reader* reader); 66 void ParseBlockLength(Reader* reader);
70 67
71 // Parses and sanity-checks header field length. 68 // Parses and sanity-checks header field length.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 SpdyPinnableBufferPiece headers_block_prefix_; 103 SpdyPinnableBufferPiece headers_block_prefix_;
107 104
108 // Holds the key of a partially processed header between calls to 105 // Holds the key of a partially processed header between calls to
109 // |HandleControlFrameHeadersData|. 106 // |HandleControlFrameHeadersData|.
110 SpdyPinnableBufferPiece key_; 107 SpdyPinnableBufferPiece key_;
111 108
112 // The current header block stream identifier. 109 // The current header block stream identifier.
113 SpdyStreamId stream_id_; 110 SpdyStreamId stream_id_;
114 111
115 ParserError error_; 112 ParserError error_;
116
117 const SpdyMajorVersion spdy_version_;
118 }; 113 };
119 114
120 } // namespace net 115 } // namespace net
121 116
122 #endif // NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_ 117 #endif // NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_framer_test.cc ('k') | net/spdy/spdy_headers_block_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698