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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 const SpdyNameValueBlock& name_value_block) const; | 702 const SpdyNameValueBlock& name_value_block) const; |
703 | 703 |
704 // Compresses automatically according to enable_compression_. | 704 // Compresses automatically according to enable_compression_. |
705 void SerializeNameValueBlock( | 705 void SerializeNameValueBlock( |
706 SpdyFrameBuilder* builder, | 706 SpdyFrameBuilder* builder, |
707 const SpdyFrameWithNameValueBlockIR& frame); | 707 const SpdyFrameWithNameValueBlockIR& frame); |
708 | 708 |
709 // Set the error code and moves the framer into the error state. | 709 // Set the error code and moves the framer into the error state. |
710 void set_error(SpdyError error); | 710 void set_error(SpdyError error); |
711 | 711 |
712 // The maximum size of the control frames that we support. | |
713 // This limit is arbitrary. We can enforce it here or at the application | |
714 // layer. We chose the framing layer, but this can be changed (or removed) | |
715 // if necessary later down the line. | |
716 size_t GetControlFrameBufferMaxSize() const { | |
717 // The theoretical maximum for SPDY3 and earlier is (2^24 - 1) + | |
718 // 8, since the length field does not count the size of the | |
719 // header. | |
720 if (spdy_version_ == SPDY2) { | |
721 return 64 * 1024; | |
722 } | |
723 if (spdy_version_ == SPDY3) { | |
724 return 16 * 1024 * 1024; | |
725 } | |
726 // Absolute maximum size of HTTP2 frame payload (section 4.2 "Frame size"). | |
727 return (1<<14) - 1; | |
728 } | |
729 | |
730 // TODO(jgraettinger): For h2-13 interop testing coverage, | |
731 // fragment at smaller payload boundaries. | |
732 size_t GetHeaderFragmentMaxSize() const { | |
733 return GetControlFrameBufferMaxSize() >> 4; // 1023 bytes. | |
734 } | |
735 | |
736 // The size of the control frame buffer. | 712 // The size of the control frame buffer. |
737 // Since this is only used for control frame headers, the maximum control | 713 // Since this is only used for control frame headers, the maximum control |
738 // frame header size (SYN_STREAM) is sufficient; all remaining control | 714 // frame header size (SYN_STREAM) is sufficient; all remaining control |
739 // frame data is streamed to the visitor. | 715 // frame data is streamed to the visitor. |
740 static const size_t kControlFrameBufferSize; | 716 static const size_t kControlFrameBufferSize; |
741 | 717 |
| 718 // The maximum size of the control frames that we support. |
| 719 // This limit is arbitrary. We can enforce it here or at the application |
| 720 // layer. We chose the framing layer, but this can be changed (or removed) |
| 721 // if necessary later down the line. |
| 722 static const size_t kMaxControlFrameSize; |
| 723 |
742 SpdyState state_; | 724 SpdyState state_; |
743 SpdyState previous_state_; | 725 SpdyState previous_state_; |
744 SpdyError error_code_; | 726 SpdyError error_code_; |
745 | 727 |
746 // Note that for DATA frame, remaining_data_length_ is sum of lengths of | 728 // Note that for DATA frame, remaining_data_length_ is sum of lengths of |
747 // frame header, padding length field (optional), data payload (optional) and | 729 // frame header, padding length field (optional), data payload (optional) and |
748 // padding payload (optional). | 730 // padding payload (optional). |
749 size_t remaining_data_length_; | 731 size_t remaining_data_length_; |
750 | 732 |
751 // The length (in bytes) of the padding payload to be processed. | 733 // The length (in bytes) of the padding payload to be processed. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 // If a HEADERS frame is followed by a CONTINUATION frame, the FIN/END_STREAM | 801 // If a HEADERS frame is followed by a CONTINUATION frame, the FIN/END_STREAM |
820 // flag is still carried in the HEADERS frame. If it's set, flip this so that | 802 // flag is still carried in the HEADERS frame. If it's set, flip this so that |
821 // we know to terminate the stream when the entire header block has been | 803 // we know to terminate the stream when the entire header block has been |
822 // processed. | 804 // processed. |
823 bool end_stream_when_done_; | 805 bool end_stream_when_done_; |
824 }; | 806 }; |
825 | 807 |
826 } // namespace net | 808 } // namespace net |
827 | 809 |
828 #endif // NET_SPDY_SPDY_FRAMER_H_ | 810 #endif // NET_SPDY_SPDY_FRAMER_H_ |
OLD | NEW |