OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_FRAMER_H_ | 5 #ifndef NET_SPDY_SPDY_FRAMER_H_ |
6 #define NET_SPDY_SPDY_FRAMER_H_ | 6 #define NET_SPDY_SPDY_FRAMER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <memory> | 12 #include <memory> |
13 #include <string> | 13 #include <string> |
14 #include <utility> | 14 #include <utility> |
15 | 15 |
16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
17 #include "base/sys_byteorder.h" | 17 #include "base/sys_byteorder.h" |
18 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
19 #include "net/spdy/hpack/hpack_decoder.h" | 19 #include "net/spdy/hpack/hpack_decoder.h" |
20 #include "net/spdy/hpack/hpack_encoder.h" | 20 #include "net/spdy/hpack/hpack_encoder.h" |
21 #include "net/spdy/spdy_alt_svc_wire_format.h" | 21 #include "net/spdy/spdy_alt_svc_wire_format.h" |
22 #include "net/spdy/spdy_header_block.h" | 22 #include "net/spdy/spdy_header_block.h" |
| 23 #include "net/spdy/spdy_headers_block_parser.h" |
23 #include "net/spdy/spdy_protocol.h" | 24 #include "net/spdy/spdy_protocol.h" |
24 | 25 |
25 typedef struct z_stream_s z_stream; // Forward declaration for zlib. | 26 typedef struct z_stream_s z_stream; // Forward declaration for zlib. |
26 | 27 |
27 namespace net { | 28 namespace net { |
28 | 29 |
29 class HttpProxyClientSocketPoolTest; | 30 class HttpProxyClientSocketPoolTest; |
30 class HttpNetworkLayer; | 31 class HttpNetworkLayer; |
31 class HttpNetworkTransactionTest; | 32 class HttpNetworkTransactionTest; |
32 class SpdyHttpStreamTest; | 33 class SpdyHttpStreamTest; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 virtual void OnStreamEnd(SpdyStreamId stream_id) = 0; | 121 virtual void OnStreamEnd(SpdyStreamId stream_id) = 0; |
121 | 122 |
122 // Called when padding is received (padding length field or padding octets). | 123 // Called when padding is received (padding length field or padding octets). |
123 // |stream_id| The stream receiving data. | 124 // |stream_id| The stream receiving data. |
124 // |len| The number of padding octets. | 125 // |len| The number of padding octets. |
125 virtual void OnStreamPadding(SpdyStreamId stream_id, size_t len) = 0; | 126 virtual void OnStreamPadding(SpdyStreamId stream_id, size_t len) = 0; |
126 | 127 |
127 // Called just before processing the payload of a frame containing header | 128 // Called just before processing the payload of a frame containing header |
128 // data. Should return an implementation of SpdyHeadersHandlerInterface that | 129 // data. Should return an implementation of SpdyHeadersHandlerInterface that |
129 // will receive headers for stream |stream_id|. The caller will not take | 130 // will receive headers for stream |stream_id|. The caller will not take |
130 // ownership of the headers handler. The same instance should be returned | 131 // ownership of the headers handler. The same instance should remain live |
131 // for all header frames comprising a logical header block (i.e. until | 132 // and be returned for all header frames comprising a logical header block |
132 // OnHeaderFrameEnd() is called with end_headers == true). | 133 // (i.e. until OnHeaderFrameEnd() is called with end_headers == true). |
133 virtual SpdyHeadersHandlerInterface* OnHeaderFrameStart( | 134 virtual SpdyHeadersHandlerInterface* OnHeaderFrameStart( |
134 SpdyStreamId stream_id) = 0; | 135 SpdyStreamId stream_id) = 0; |
135 | 136 |
136 // Called after processing the payload of a frame containing header data. | 137 // Called after processing the payload of a frame containing header data. |
137 // |end_headers| is true if there will not be any subsequent CONTINUATION | 138 // |end_headers| is true if there will not be any subsequent CONTINUATION |
138 // frames. | 139 // frames. |
139 virtual void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) = 0; | 140 virtual void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) = 0; |
140 | 141 |
141 // Called when a chunk of header data is available. This is called | 142 // Called when a chunk of header data is available. This is called |
142 // after OnSynStream, OnSynReply, OnHeaders(), or OnPushPromise. | 143 // after OnSynStream, OnSynReply, OnHeaders(), or OnPushPromise. |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 SPDY_ZLIB_INIT_FAILURE, // The Zlib library could not initialize. | 332 SPDY_ZLIB_INIT_FAILURE, // The Zlib library could not initialize. |
332 SPDY_UNSUPPORTED_VERSION, // Control frame has unsupported version. | 333 SPDY_UNSUPPORTED_VERSION, // Control frame has unsupported version. |
333 SPDY_DECOMPRESS_FAILURE, // There was an error decompressing. | 334 SPDY_DECOMPRESS_FAILURE, // There was an error decompressing. |
334 SPDY_COMPRESS_FAILURE, // There was an error compressing. | 335 SPDY_COMPRESS_FAILURE, // There was an error compressing. |
335 SPDY_GOAWAY_FRAME_CORRUPT, // GOAWAY frame could not be parsed. | 336 SPDY_GOAWAY_FRAME_CORRUPT, // GOAWAY frame could not be parsed. |
336 SPDY_RST_STREAM_FRAME_CORRUPT, // RST_STREAM frame could not be parsed. | 337 SPDY_RST_STREAM_FRAME_CORRUPT, // RST_STREAM frame could not be parsed. |
337 SPDY_INVALID_PADDING, // HEADERS or DATA frame padding invalid | 338 SPDY_INVALID_PADDING, // HEADERS or DATA frame padding invalid |
338 SPDY_INVALID_DATA_FRAME_FLAGS, // Data frame has invalid flags. | 339 SPDY_INVALID_DATA_FRAME_FLAGS, // Data frame has invalid flags. |
339 SPDY_INVALID_CONTROL_FRAME_FLAGS, // Control frame has invalid flags. | 340 SPDY_INVALID_CONTROL_FRAME_FLAGS, // Control frame has invalid flags. |
340 SPDY_UNEXPECTED_FRAME, // Frame received out of order. | 341 SPDY_UNEXPECTED_FRAME, // Frame received out of order. |
| 342 SPDY_INTERNAL_FRAMER_ERROR, // SpdyFramer was used incorrectly. |
341 SPDY_INVALID_CONTROL_FRAME_SIZE, // Control frame not sized to spec | 343 SPDY_INVALID_CONTROL_FRAME_SIZE, // Control frame not sized to spec |
342 | 344 |
343 LAST_ERROR, // Must be the last entry in the enum. | 345 LAST_ERROR, // Must be the last entry in the enum. |
344 }; | 346 }; |
345 | 347 |
346 // Constant for invalid (or unknown) stream IDs. | 348 // Constant for invalid (or unknown) stream IDs. |
347 static const SpdyStreamId kInvalidStream; | 349 static const SpdyStreamId kInvalidStream; |
348 | 350 |
349 // The maximum size of header data chunks delivered to the framer visitor | 351 // The maximum size of header data chunks delivered to the framer visitor |
350 // through OnControlFrameHeaderData. (It is exposed here for unit test | 352 // through OnControlFrameHeaderData. (It is exposed here for unit test |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 const char* data, | 569 const char* data, |
568 size_t len); | 570 size_t len); |
569 | 571 |
570 // Updates the maximum size of the header encoder compression table. | 572 // Updates the maximum size of the header encoder compression table. |
571 void UpdateHeaderEncoderTableSize(uint32_t value); | 573 void UpdateHeaderEncoderTableSize(uint32_t value); |
572 | 574 |
573 // Returns the maximum size of the header encoder compression table. | 575 // Returns the maximum size of the header encoder compression table. |
574 size_t header_encoder_table_size() const; | 576 size_t header_encoder_table_size() const; |
575 | 577 |
576 protected: | 578 protected: |
| 579 friend class BufferedSpdyFramer; |
577 friend class HttpNetworkLayer; // This is temporary for the server. | 580 friend class HttpNetworkLayer; // This is temporary for the server. |
578 friend class HttpNetworkTransactionTest; | 581 friend class HttpNetworkTransactionTest; |
579 friend class HttpProxyClientSocketPoolTest; | 582 friend class HttpProxyClientSocketPoolTest; |
580 friend class SpdyHttpStreamTest; | 583 friend class SpdyHttpStreamTest; |
581 friend class SpdyNetworkTransactionTest; | 584 friend class SpdyNetworkTransactionTest; |
582 friend class SpdyProxyClientSocketTest; | 585 friend class SpdyProxyClientSocketTest; |
583 friend class SpdySessionTest; | 586 friend class SpdySessionTest; |
584 friend class SpdyStreamTest; | 587 friend class SpdyStreamTest; |
585 friend class test::TestSpdyVisitor; | 588 friend class test::TestSpdyVisitor; |
586 friend class test::SpdyFramerPeer; | 589 friend class test::SpdyFramerPeer; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 // SPDY header compressors. | 769 // SPDY header compressors. |
767 std::unique_ptr<z_stream> header_compressor_; | 770 std::unique_ptr<z_stream> header_compressor_; |
768 std::unique_ptr<z_stream> header_decompressor_; | 771 std::unique_ptr<z_stream> header_decompressor_; |
769 | 772 |
770 std::unique_ptr<HpackEncoder> hpack_encoder_; | 773 std::unique_ptr<HpackEncoder> hpack_encoder_; |
771 std::unique_ptr<HpackDecoder> hpack_decoder_; | 774 std::unique_ptr<HpackDecoder> hpack_decoder_; |
772 | 775 |
773 SpdyFramerVisitorInterface* visitor_; | 776 SpdyFramerVisitorInterface* visitor_; |
774 SpdyFramerDebugVisitorInterface* debug_visitor_; | 777 SpdyFramerDebugVisitorInterface* debug_visitor_; |
775 | 778 |
| 779 std::unique_ptr<SpdyHeadersBlockParser> header_parser_; |
| 780 SpdyHeadersHandlerInterface* header_handler_; |
| 781 |
776 std::string display_protocol_; | 782 std::string display_protocol_; |
777 | 783 |
778 // The protocol version to be spoken/understood by this framer. | 784 // The protocol version to be spoken/understood by this framer. |
779 const SpdyMajorVersion protocol_version_; | 785 const SpdyMajorVersion protocol_version_; |
780 | 786 |
781 // The flags field of the frame currently being read. | 787 // The flags field of the frame currently being read. |
782 uint8_t current_frame_flags_; | 788 uint8_t current_frame_flags_; |
783 | 789 |
784 // Determines whether HPACK or gzip compression is used. | 790 // Determines whether HPACK or gzip compression is used. |
785 bool enable_compression_; | 791 bool enable_compression_; |
(...skipping 20 matching lines...) Expand all Loading... |
806 bool end_stream_when_done_; | 812 bool end_stream_when_done_; |
807 | 813 |
808 // If true, then ProcessInput returns after processing a full frame, | 814 // If true, then ProcessInput returns after processing a full frame, |
809 // rather than reading all available input. | 815 // rather than reading all available input. |
810 bool process_single_input_frame_ = false; | 816 bool process_single_input_frame_ = false; |
811 }; | 817 }; |
812 | 818 |
813 } // namespace net | 819 } // namespace net |
814 | 820 |
815 #endif // NET_SPDY_SPDY_FRAMER_H_ | 821 #endif // NET_SPDY_SPDY_FRAMER_H_ |
OLD | NEW |