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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 const char* data, | 563 const char* data, |
562 size_t len); | 564 size_t len); |
563 | 565 |
564 // Updates the maximum size of the header encoder compression table. | 566 // Updates the maximum size of the header encoder compression table. |
565 void UpdateHeaderEncoderTableSize(uint32_t value); | 567 void UpdateHeaderEncoderTableSize(uint32_t value); |
566 | 568 |
567 // Returns the maximum size of the header encoder compression table. | 569 // Returns the maximum size of the header encoder compression table. |
568 size_t header_encoder_table_size() const; | 570 size_t header_encoder_table_size() const; |
569 | 571 |
570 protected: | 572 protected: |
| 573 friend class BufferedSpdyFramer; |
571 friend class HttpNetworkLayer; // This is temporary for the server. | 574 friend class HttpNetworkLayer; // This is temporary for the server. |
572 friend class HttpNetworkTransactionTest; | 575 friend class HttpNetworkTransactionTest; |
573 friend class HttpProxyClientSocketPoolTest; | 576 friend class HttpProxyClientSocketPoolTest; |
574 friend class SpdyHttpStreamTest; | 577 friend class SpdyHttpStreamTest; |
575 friend class SpdyNetworkTransactionTest; | 578 friend class SpdyNetworkTransactionTest; |
576 friend class SpdyProxyClientSocketTest; | 579 friend class SpdyProxyClientSocketTest; |
577 friend class SpdySessionTest; | 580 friend class SpdySessionTest; |
578 friend class SpdyStreamTest; | 581 friend class SpdyStreamTest; |
579 friend class test::TestSpdyVisitor; | 582 friend class test::TestSpdyVisitor; |
580 friend class test::SpdyFramerPeer; | 583 friend class test::SpdyFramerPeer; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 // SPDY header compressors. | 763 // SPDY header compressors. |
761 std::unique_ptr<z_stream> header_compressor_; | 764 std::unique_ptr<z_stream> header_compressor_; |
762 std::unique_ptr<z_stream> header_decompressor_; | 765 std::unique_ptr<z_stream> header_decompressor_; |
763 | 766 |
764 std::unique_ptr<HpackEncoder> hpack_encoder_; | 767 std::unique_ptr<HpackEncoder> hpack_encoder_; |
765 std::unique_ptr<HpackDecoder> hpack_decoder_; | 768 std::unique_ptr<HpackDecoder> hpack_decoder_; |
766 | 769 |
767 SpdyFramerVisitorInterface* visitor_; | 770 SpdyFramerVisitorInterface* visitor_; |
768 SpdyFramerDebugVisitorInterface* debug_visitor_; | 771 SpdyFramerDebugVisitorInterface* debug_visitor_; |
769 | 772 |
| 773 std::unique_ptr<SpdyHeadersBlockParser> header_parser_; |
| 774 SpdyHeadersHandlerInterface* header_handler_; |
| 775 |
770 std::string display_protocol_; | 776 std::string display_protocol_; |
771 | 777 |
772 // The protocol version to be spoken/understood by this framer. | 778 // The protocol version to be spoken/understood by this framer. |
773 const SpdyMajorVersion protocol_version_; | 779 const SpdyMajorVersion protocol_version_; |
774 | 780 |
775 // The flags field of the frame currently being read. | 781 // The flags field of the frame currently being read. |
776 uint8_t current_frame_flags_; | 782 uint8_t current_frame_flags_; |
777 | 783 |
778 // Determines whether HPACK or gzip compression is used. | 784 // Determines whether HPACK or gzip compression is used. |
779 bool enable_compression_; | 785 bool enable_compression_; |
(...skipping 20 matching lines...) Expand all Loading... |
800 bool end_stream_when_done_; | 806 bool end_stream_when_done_; |
801 | 807 |
802 // If true, then ProcessInput returns after processing a full frame, | 808 // If true, then ProcessInput returns after processing a full frame, |
803 // rather than reading all available input. | 809 // rather than reading all available input. |
804 bool process_single_input_frame_ = false; | 810 bool process_single_input_frame_ = false; |
805 }; | 811 }; |
806 | 812 |
807 } // namespace net | 813 } // namespace net |
808 | 814 |
809 #endif // NET_SPDY_SPDY_FRAMER_H_ | 815 #endif // NET_SPDY_SPDY_FRAMER_H_ |
OLD | NEW |