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_FRAME_BUILDER_H_ | 5 #ifndef NET_SPDY_SPDY_FRAME_BUILDER_H_ |
6 #define NET_SPDY_SPDY_FRAME_BUILDER_H_ | 6 #define NET_SPDY_SPDY_FRAME_BUILDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // capacity_. The given type must be a control frame type. | 52 // capacity_. The given type must be a control frame type. |
53 // Used only for SPDY versions <4. | 53 // Used only for SPDY versions <4. |
54 bool WriteControlFrameHeader(const SpdyFramer& framer, | 54 bool WriteControlFrameHeader(const SpdyFramer& framer, |
55 SpdyFrameType type, | 55 SpdyFrameType type, |
56 uint8 flags); | 56 uint8 flags); |
57 | 57 |
58 // Populates this frame with a SPDY data frame header using version-specific | 58 // Populates this frame with a SPDY data frame header using version-specific |
59 // information from the |framer| and length information from capacity_. | 59 // information from the |framer| and length information from capacity_. |
60 bool WriteDataFrameHeader(const SpdyFramer& framer, | 60 bool WriteDataFrameHeader(const SpdyFramer& framer, |
61 SpdyStreamId stream_id, | 61 SpdyStreamId stream_id, |
62 SpdyDataFlags flags); | 62 uint8 flags); |
63 | 63 |
64 // Populates this frame with a SPDY4/HTTP2 frame prefix using | 64 // Populates this frame with a SPDY4/HTTP2 frame prefix using |
65 // version-specific information from the |framer| and length information from | 65 // version-specific information from the |framer| and length information from |
66 // capacity_. The given type must be a control frame type. | 66 // capacity_. The given type must be a control frame type. |
67 // Used only for SPDY versions >=4. | 67 // Used only for SPDY versions >=4. |
68 bool WriteFramePrefix(const SpdyFramer& framer, | 68 bool WriteFramePrefix(const SpdyFramer& framer, |
69 SpdyFrameType type, | 69 SpdyFrameType type, |
70 uint8 flags, | 70 uint8 flags, |
71 SpdyStreamId stream_id); | 71 SpdyStreamId stream_id); |
72 | 72 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // with the correct version for the frame being written. | 110 // with the correct version for the frame being written. |
111 bool RewriteLength(const SpdyFramer& framer); | 111 bool RewriteLength(const SpdyFramer& framer); |
112 | 112 |
113 // Update (in-place) the length field in the frame being built to reflect the | 113 // Update (in-place) the length field in the frame being built to reflect the |
114 // given length. | 114 // given length. |
115 // The framer parameter is used to determine version-specific location and | 115 // The framer parameter is used to determine version-specific location and |
116 // size information of the length field to be written, and must be initialized | 116 // size information of the length field to be written, and must be initialized |
117 // with the correct version for the frame being written. | 117 // with the correct version for the frame being written. |
118 bool OverwriteLength(const SpdyFramer& framer, size_t length); | 118 bool OverwriteLength(const SpdyFramer& framer, size_t length); |
119 | 119 |
| 120 // Update (in-place) the flags field in the frame being built to reflect the |
| 121 // given flags value. |
| 122 // Used only for SPDY versions >=4. |
| 123 bool OverwriteFlags(const SpdyFramer& framer, uint8 flags); |
| 124 |
120 private: | 125 private: |
121 // Checks to make sure that there is an appropriate amount of space for a | 126 // Checks to make sure that there is an appropriate amount of space for a |
122 // write of given size, in bytes. | 127 // write of given size, in bytes. |
123 bool CanWrite(size_t length) const; | 128 bool CanWrite(size_t length) const; |
124 | 129 |
125 scoped_ptr<char[]> buffer_; | 130 scoped_ptr<char[]> buffer_; |
126 size_t capacity_; // Allocation size of payload, set by constructor. | 131 size_t capacity_; // Allocation size of payload, set by constructor. |
127 size_t length_; // Current length of the buffer. | 132 size_t length_; // Current length of the buffer. |
128 }; | 133 }; |
129 | 134 |
130 } // namespace net | 135 } // namespace net |
131 | 136 |
132 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ | 137 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ |
OLD | NEW |