Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: net/spdy/spdy_frame_builder.h

Issue 2794063002: Add a SpdyFramer extension API implementation. (Closed)
Patch Set: Add BeginNewExtensionFrame. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/spdy/spdy_frame_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // GetWriteableBuffer() above. 47 // GetWriteableBuffer() above.
48 bool Seek(size_t length); 48 bool Seek(size_t length);
49 49
50 // Populates this frame with a HTTP2 frame prefix using length information 50 // Populates this frame with a HTTP2 frame prefix using length information
51 // from |capacity_|. The given type must be a control frame type. 51 // from |capacity_|. The given type must be a control frame type.
52 bool BeginNewFrame(const SpdyFramer& framer, 52 bool BeginNewFrame(const SpdyFramer& framer,
53 SpdyFrameType type, 53 SpdyFrameType type,
54 uint8_t flags, 54 uint8_t flags,
55 SpdyStreamId stream_id); 55 SpdyStreamId stream_id);
56 56
57 // Populates this frame with a HTTP2 frame prefix with length information. 57 // Populates this frame with a HTTP2 frame prefix with type and length
58 // The given type must be a control frame type. 58 // information. |type| must be a defined type.
Bence 2017/04/05 13:43:09 This is incorrect: "control frame" means defined f
59 bool BeginNewFrame(const SpdyFramer& framer, 59 bool BeginNewFrame(const SpdyFramer& framer,
60 SpdyFrameType type, 60 SpdyFrameType type,
61 uint8_t flags, 61 uint8_t flags,
62 SpdyStreamId stream_id, 62 SpdyStreamId stream_id,
63 size_t length); 63 size_t length);
64 64
65 // Populates this frame with a HTTP2 frame prefix with type and length
66 // information. |raw_frame_type| must not be a defined frame type.
67 bool BeginNewExtensionFrame(const SpdyFramer& framer,
68 uint8_t raw_frame_type,
69 uint8_t flags,
70 SpdyStreamId stream_id,
71 size_t length);
72
65 // Takes the buffer from the SpdyFrameBuilder. 73 // Takes the buffer from the SpdyFrameBuilder.
66 SpdySerializedFrame take() { 74 SpdySerializedFrame take() {
67 SPDY_BUG_IF(output_ != nullptr) << "ZeroCopyOutputBuffer is used to build " 75 SPDY_BUG_IF(output_ != nullptr) << "ZeroCopyOutputBuffer is used to build "
68 << "frames. take() shouldn't be called"; 76 << "frames. take() shouldn't be called";
69 SPDY_BUG_IF(kMaxFrameSizeLimit < length_) 77 SPDY_BUG_IF(kMaxFrameSizeLimit < length_)
70 << "Frame length " << length_ 78 << "Frame length " << length_
71 << " is longer than the maximum possible allowed length."; 79 << " is longer than the maximum possible allowed length.";
72 SpdySerializedFrame rv(buffer_.release(), length(), true); 80 SpdySerializedFrame rv(buffer_.release(), length(), true);
73 capacity_ = 0; 81 capacity_ = 0;
74 length_ = 0; 82 length_ = 0;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // The framer parameter is used to determine version-specific location and 116 // The framer parameter is used to determine version-specific location and
109 // size information of the length field to be written, and must be initialized 117 // size information of the length field to be written, and must be initialized
110 // with the correct version for the frame being written. 118 // with the correct version for the frame being written.
111 bool OverwriteLength(const SpdyFramer& framer, size_t length); 119 bool OverwriteLength(const SpdyFramer& framer, size_t length);
112 120
113 private: 121 private:
114 FRIEND_TEST_ALL_PREFIXES(SpdyFrameBuilderTest, GetWritableBuffer); 122 FRIEND_TEST_ALL_PREFIXES(SpdyFrameBuilderTest, GetWritableBuffer);
115 FRIEND_TEST_ALL_PREFIXES(SpdyFrameBuilderTest, GetWritableOutput); 123 FRIEND_TEST_ALL_PREFIXES(SpdyFrameBuilderTest, GetWritableOutput);
116 FRIEND_TEST_ALL_PREFIXES(SpdyFrameBuilderTest, GetWritableOutputNegative); 124 FRIEND_TEST_ALL_PREFIXES(SpdyFrameBuilderTest, GetWritableOutputNegative);
117 125
126 // Populates this frame with a HTTP2 frame prefix with type and length
127 // information.
128 bool BeginNewFrameInternal(const SpdyFramer& framer,
129 uint8_t raw_frame_type,
130 uint8_t flags,
131 SpdyStreamId stream_id,
132 size_t length);
133
118 // Returns a writeable buffer of given size in bytes, to be appended to the 134 // Returns a writeable buffer of given size in bytes, to be appended to the
119 // currently written frame. Does bounds checking on length but does not 135 // currently written frame. Does bounds checking on length but does not
120 // increment the underlying iterator. To do so, consumers should subsequently 136 // increment the underlying iterator. To do so, consumers should subsequently
121 // call Seek(). 137 // call Seek().
122 // In general, consumers should use Write*() calls instead of this. 138 // In general, consumers should use Write*() calls instead of this.
123 // Returns NULL on failure. 139 // Returns NULL on failure.
124 char* GetWritableBuffer(size_t length); 140 char* GetWritableBuffer(size_t length);
125 char* GetWritableOutput(size_t desired_length, size_t* actual_length); 141 char* GetWritableOutput(size_t desired_length, size_t* actual_length);
126 142
127 // Checks to make sure that there is an appropriate amount of space for a 143 // Checks to make sure that there is an appropriate amount of space for a
(...skipping 16 matching lines...) Expand all
144 const size_t kLengthFieldLength = 3; 160 const size_t kLengthFieldLength = 3;
145 char* start_of_current_frame_ = nullptr; 161 char* start_of_current_frame_ = nullptr;
146 size_t bytes_of_length_written_in_first_block_ = kLengthFieldLength; 162 size_t bytes_of_length_written_in_first_block_ = kLengthFieldLength;
147 // In case length of a new frame is cross blocks. 163 // In case length of a new frame is cross blocks.
148 char* start_of_current_frame_in_next_block_ = nullptr; 164 char* start_of_current_frame_in_next_block_ = nullptr;
149 }; 165 };
150 166
151 } // namespace net 167 } // namespace net
152 168
153 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_ 169 #endif // NET_SPDY_SPDY_FRAME_BUILDER_H_
OLDNEW
« no previous file with comments | « no previous file | net/spdy/spdy_frame_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698