| OLD | NEW |
| 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 "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // the block. | 24 // the block. |
| 25 virtual void OnHeaderBlock(SpdyStreamId stream_id, | 25 virtual void OnHeaderBlock(SpdyStreamId stream_id, |
| 26 uint32_t num_of_headers) = 0; | 26 uint32_t num_of_headers) = 0; |
| 27 | 27 |
| 28 // A callback method which notifies on a SPDY header key value pair. | 28 // A callback method which notifies on a SPDY header key value pair. |
| 29 virtual void OnHeader(SpdyStreamId stream_id, | 29 virtual void OnHeader(SpdyStreamId stream_id, |
| 30 base::StringPiece key, | 30 base::StringPiece key, |
| 31 base::StringPiece value) = 0; | 31 base::StringPiece value) = 0; |
| 32 | 32 |
| 33 // A callback method which notifies when the parser finishes handling a SPDY | 33 // A callback method which notifies when the parser finishes handling a SPDY |
| 34 // headers block. | 34 // headers block. Also notifies on the total number of bytes in this block. |
| 35 virtual void OnHeaderBlockEnd(SpdyStreamId stream_id) = 0; | 35 virtual void OnHeaderBlockEnd(SpdyStreamId stream_id, |
| 36 size_t header_bytes_parsed) = 0; |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 namespace test { | 39 namespace test { |
| 39 | 40 |
| 40 class SpdyHeadersBlockParserPeer; | 41 class SpdyHeadersBlockParserPeer; |
| 41 | 42 |
| 42 } // namespace test | 43 } // namespace test |
| 43 | 44 |
| 44 // This class handles SPDY headers block bytes and parses out key-value pairs | 45 // This class handles SPDY headers block bytes and parses out key-value pairs |
| 45 // as they arrive. This class is not thread-safe, and assumes that all headers | 46 // as they arrive. This class is not thread-safe, and assumes that all headers |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 FINISHED_HEADER | 110 FINISHED_HEADER |
| 110 }; | 111 }; |
| 111 ParserState state_; | 112 ParserState state_; |
| 112 | 113 |
| 113 // Size in bytes of a length field in the spdy header. | 114 // Size in bytes of a length field in the spdy header. |
| 114 const size_t length_field_size_; | 115 const size_t length_field_size_; |
| 115 | 116 |
| 116 // The maximal number of headers in a SPDY headers block. | 117 // The maximal number of headers in a SPDY headers block. |
| 117 const size_t max_headers_in_block_; | 118 const size_t max_headers_in_block_; |
| 118 | 119 |
| 120 // A running total of the bytes parsed since the last call to Reset(). |
| 121 size_t total_bytes_received_; |
| 122 |
| 119 // Number of key-value pairs until we complete handling the current | 123 // Number of key-value pairs until we complete handling the current |
| 120 // headers block. | 124 // headers block. |
| 121 uint32_t remaining_key_value_pairs_for_frame_; | 125 uint32_t remaining_key_value_pairs_for_frame_; |
| 122 | 126 |
| 123 // The length of the next header field to be read (either key or value). | 127 // The length of the next header field to be read (either key or value). |
| 124 uint32_t next_field_length_; | 128 uint32_t next_field_length_; |
| 125 | 129 |
| 126 // Handles key-value pairs as we parse them. | 130 // Handles key-value pairs as we parse them. |
| 127 SpdyHeadersHandlerInterface* handler_; | 131 SpdyHeadersHandlerInterface* handler_; |
| 128 | 132 |
| 129 // Holds unprocessed buffer remainders between calls to | 133 // Holds unprocessed buffer remainders between calls to |
| 130 // |HandleControlFrameHeadersData|. | 134 // |HandleControlFrameHeadersData|. |
| 131 SpdyPinnableBufferPiece headers_block_prefix_; | 135 SpdyPinnableBufferPiece headers_block_prefix_; |
| 132 | 136 |
| 133 // Holds the key of a partially processed header between calls to | 137 // Holds the key of a partially processed header between calls to |
| 134 // |HandleControlFrameHeadersData|. | 138 // |HandleControlFrameHeadersData|. |
| 135 SpdyPinnableBufferPiece key_; | 139 SpdyPinnableBufferPiece key_; |
| 136 | 140 |
| 137 // The current header block stream identifier. | 141 // The current header block stream identifier. |
| 138 SpdyStreamId stream_id_; | 142 SpdyStreamId stream_id_; |
| 139 | 143 |
| 140 ParserError error_; | 144 ParserError error_; |
| 141 }; | 145 }; |
| 142 | 146 |
| 143 } // namespace net | 147 } // namespace net |
| 144 | 148 |
| 145 #endif // NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_ | 149 #endif // NET_SPDY_SPDY_HEADERS_BLOCK_PARSER_H_ |
| OLD | NEW |