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