| 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 <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 public: | 329 public: |
| 330 // SPDY states. | 330 // SPDY states. |
| 331 // TODO(mbelshe): Can we move these into the implementation | 331 // TODO(mbelshe): Can we move these into the implementation |
| 332 // and avoid exposing through the header. (Needed for test) | 332 // and avoid exposing through the header. (Needed for test) |
| 333 enum SpdyState { | 333 enum SpdyState { |
| 334 SPDY_ERROR, | 334 SPDY_ERROR, |
| 335 SPDY_RESET, | 335 SPDY_RESET, |
| 336 SPDY_AUTO_RESET, | 336 SPDY_AUTO_RESET, |
| 337 SPDY_READING_COMMON_HEADER, | 337 SPDY_READING_COMMON_HEADER, |
| 338 SPDY_CONTROL_FRAME_PAYLOAD, | 338 SPDY_CONTROL_FRAME_PAYLOAD, |
| 339 SPDY_READ_PADDING_LENGTH, | 339 SPDY_READ_DATA_FRAME_PADDING_LENGTH, |
| 340 SPDY_CONSUME_PADDING, | 340 SPDY_CONSUME_PADDING, |
| 341 SPDY_IGNORE_REMAINING_PAYLOAD, | 341 SPDY_IGNORE_REMAINING_PAYLOAD, |
| 342 SPDY_FORWARD_STREAM_FRAME, | 342 SPDY_FORWARD_STREAM_FRAME, |
| 343 SPDY_CONTROL_FRAME_BEFORE_HEADER_BLOCK, | 343 SPDY_CONTROL_FRAME_BEFORE_HEADER_BLOCK, |
| 344 SPDY_CONTROL_FRAME_HEADER_BLOCK, | 344 SPDY_CONTROL_FRAME_HEADER_BLOCK, |
| 345 SPDY_GOAWAY_FRAME_PAYLOAD, | 345 SPDY_GOAWAY_FRAME_PAYLOAD, |
| 346 SPDY_RST_STREAM_FRAME_PAYLOAD, | 346 SPDY_RST_STREAM_FRAME_PAYLOAD, |
| 347 SPDY_SETTINGS_FRAME_PAYLOAD, | 347 SPDY_SETTINGS_FRAME_PAYLOAD, |
| 348 SPDY_ALTSVC_FRAME_PAYLOAD, | 348 SPDY_ALTSVC_FRAME_PAYLOAD, |
| 349 }; | 349 }; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameSizesAreValidated); | 594 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameSizesAreValidated); |
| 595 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HeaderCompression); | 595 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HeaderCompression); |
| 596 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, DecompressUncompressedFrame); | 596 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, DecompressUncompressedFrame); |
| 597 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ExpandBuffer_HeapSmash); | 597 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ExpandBuffer_HeapSmash); |
| 598 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HugeHeaderBlock); | 598 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, HugeHeaderBlock); |
| 599 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, UnclosedStreamDataCompressors); | 599 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, UnclosedStreamDataCompressors); |
| 600 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, | 600 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
| 601 UnclosedStreamDataCompressorsOneByteAtATime); | 601 UnclosedStreamDataCompressorsOneByteAtATime); |
| 602 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, | 602 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
| 603 UncompressLargerThanFrameBufferInitialSize); | 603 UncompressLargerThanFrameBufferInitialSize); |
| 604 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
| 605 CreatePushPromiseThenContinuationUncompressed); |
| 604 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ReadLargeSettingsFrame); | 606 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ReadLargeSettingsFrame); |
| 605 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, | 607 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
| 606 ReadLargeSettingsFrameInSmallChunks); | 608 ReadLargeSettingsFrameInSmallChunks); |
| 607 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameAtMaxSizeLimit); | 609 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameAtMaxSizeLimit); |
| 608 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameTooLarge); | 610 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, ControlFrameTooLarge); |
| 609 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, | 611 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
| 610 TooLargeHeadersFrameUsesContinuation); | 612 TooLargeHeadersFrameUsesContinuation); |
| 611 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, | 613 FRIEND_TEST_ALL_PREFIXES(SpdyFramerTest, |
| 612 TooLargePushPromiseFrameUsesContinuation); | 614 TooLargePushPromiseFrameUsesContinuation); |
| 613 friend class net::HttpNetworkLayer; // This is temporary for the server. | 615 friend class net::HttpNetworkLayer; // This is temporary for the server. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 627 // consumed from the data. | 629 // consumed from the data. |
| 628 size_t ProcessCommonHeader(const char* data, size_t len); | 630 size_t ProcessCommonHeader(const char* data, size_t len); |
| 629 size_t ProcessControlFramePayload(const char* data, size_t len); | 631 size_t ProcessControlFramePayload(const char* data, size_t len); |
| 630 size_t ProcessControlFrameBeforeHeaderBlock(const char* data, size_t len); | 632 size_t ProcessControlFrameBeforeHeaderBlock(const char* data, size_t len); |
| 631 // HPACK data is re-encoded as SPDY3 and re-entrantly delivered through | 633 // HPACK data is re-encoded as SPDY3 and re-entrantly delivered through |
| 632 // |ProcessControlFrameHeaderBlock()|. |is_hpack_header_block| controls | 634 // |ProcessControlFrameHeaderBlock()|. |is_hpack_header_block| controls |
| 633 // whether data is treated as HPACK- vs SPDY3-encoded. | 635 // whether data is treated as HPACK- vs SPDY3-encoded. |
| 634 size_t ProcessControlFrameHeaderBlock(const char* data, | 636 size_t ProcessControlFrameHeaderBlock(const char* data, |
| 635 size_t len, | 637 size_t len, |
| 636 bool is_hpack_header_block); | 638 bool is_hpack_header_block); |
| 637 size_t ProcessFramePaddingLength(const char* data, size_t len); | 639 size_t ProcessDataFramePaddingLength(const char* data, size_t len); |
| 638 size_t ProcessFramePadding(const char* data, size_t len); | 640 size_t ProcessFramePadding(const char* data, size_t len); |
| 639 size_t ProcessDataFramePayload(const char* data, size_t len); | 641 size_t ProcessDataFramePayload(const char* data, size_t len); |
| 640 size_t ProcessGoAwayFramePayload(const char* data, size_t len); | 642 size_t ProcessGoAwayFramePayload(const char* data, size_t len); |
| 641 size_t ProcessRstStreamFramePayload(const char* data, size_t len); | 643 size_t ProcessRstStreamFramePayload(const char* data, size_t len); |
| 642 size_t ProcessSettingsFramePayload(const char* data, size_t len); | 644 size_t ProcessSettingsFramePayload(const char* data, size_t len); |
| 643 size_t ProcessAltSvcFramePayload(const char* data, size_t len); | 645 size_t ProcessAltSvcFramePayload(const char* data, size_t len); |
| 644 size_t ProcessIgnoredControlFramePayload(/*const char* data,*/ size_t len); | 646 size_t ProcessIgnoredControlFramePayload(/*const char* data,*/ size_t len); |
| 645 | 647 |
| 646 // TODO(jgraettinger): To be removed with migration to | 648 // TODO(jgraettinger): To be removed with migration to |
| 647 // SpdyHeadersHandlerInterface. | 649 // SpdyHeadersHandlerInterface. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 665 | 667 |
| 666 // Get (and lazily initialize) the HPACK state. | 668 // Get (and lazily initialize) the HPACK state. |
| 667 HpackEncoder* GetHpackEncoder(); | 669 HpackEncoder* GetHpackEncoder(); |
| 668 HpackDecoder* GetHpackDecoder(); | 670 HpackDecoder* GetHpackDecoder(); |
| 669 | 671 |
| 670 size_t GetNumberRequiredContinuationFrames(size_t size); | 672 size_t GetNumberRequiredContinuationFrames(size_t size); |
| 671 | 673 |
| 672 void WritePayloadWithContinuation(SpdyFrameBuilder* builder, | 674 void WritePayloadWithContinuation(SpdyFrameBuilder* builder, |
| 673 const std::string& hpack_encoding, | 675 const std::string& hpack_encoding, |
| 674 SpdyStreamId stream_id, | 676 SpdyStreamId stream_id, |
| 675 SpdyFrameType type); | 677 SpdyFrameType type, |
| 678 int padding_payload_len); |
| 676 | 679 |
| 677 private: | 680 private: |
| 678 // Deliver the given control frame's uncompressed headers block to the | 681 // Deliver the given control frame's uncompressed headers block to the |
| 679 // visitor in chunks. Returns true if the visitor has accepted all of the | 682 // visitor in chunks. Returns true if the visitor has accepted all of the |
| 680 // chunks. | 683 // chunks. |
| 681 bool IncrementallyDeliverControlFrameHeaderData(SpdyStreamId stream_id, | 684 bool IncrementallyDeliverControlFrameHeaderData(SpdyStreamId stream_id, |
| 682 const char* data, | 685 const char* data, |
| 683 size_t len); | 686 size_t len); |
| 684 | 687 |
| 685 // Utility to copy the given data block to the current frame buffer, up | 688 // Utility to copy the given data block to the current frame buffer, up |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 // If a HEADERS frame is followed by a CONTINUATION frame, the FIN/END_STREAM | 819 // If a HEADERS frame is followed by a CONTINUATION frame, the FIN/END_STREAM |
| 817 // flag is still carried in the HEADERS frame. If it's set, flip this so that | 820 // flag is still carried in the HEADERS frame. If it's set, flip this so that |
| 818 // we know to terminate the stream when the entire header block has been | 821 // we know to terminate the stream when the entire header block has been |
| 819 // processed. | 822 // processed. |
| 820 bool end_stream_when_done_; | 823 bool end_stream_when_done_; |
| 821 }; | 824 }; |
| 822 | 825 |
| 823 } // namespace net | 826 } // namespace net |
| 824 | 827 |
| 825 #endif // NET_SPDY_SPDY_FRAMER_H_ | 828 #endif // NET_SPDY_SPDY_FRAMER_H_ |
| OLD | NEW |