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

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

Issue 2438163002: Remove SpdyFramerVisitorInterface::OnControlFrameHeaderData(). (Closed)
Patch Set: rebase Created 4 years, 2 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 | « net/spdy/spdy_deframer_visitor.cc ('k') | net/spdy/spdy_framer.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_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
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 // SpdyFramerVisitorInterface is a set of callbacks for the SpdyFramer. 79 // SpdyFramerVisitorInterface is a set of callbacks for the SpdyFramer.
80 // Implement this interface to receive event callbacks as frames are 80 // Implement this interface to receive event callbacks as frames are
81 // decoded from the framer. 81 // decoded from the framer.
82 // 82 //
83 // Control frames that contain SPDY header blocks (SYN_STREAM, SYN_REPLY, 83 // Control frames that contain SPDY header blocks (SYN_STREAM, SYN_REPLY,
84 // HEADER, and PUSH_PROMISE) are processed in fashion that allows the 84 // HEADER, and PUSH_PROMISE) are processed in fashion that allows the
85 // decompressed header block to be delivered in chunks to the visitor. 85 // decompressed header block to be delivered in chunks to the visitor.
86 // The following steps are followed: 86 // The following steps are followed:
87 // 1. OnSynStream, OnSynReply, OnHeaders, or OnPushPromise is called. 87 // 1. OnSynStream, OnSynReply, OnHeaders, or OnPushPromise is called.
88 // 2. Repeated: OnControlFrameHeaderData is called with chunks of the
89 // decompressed header block. In each call the len parameter is greater
90 // than zero.
91 // 3. OnControlFrameHeaderData is called with len set to zero, indicating
92 // that the full header block has been delivered for the control frame.
93 // During step 2 the visitor may return false, indicating that the chunk of
94 // header data could not be handled by the visitor (typically this indicates
95 // resource exhaustion). If this occurs the framer will discontinue
96 // delivering chunks to the visitor, set a SPDY_CONTROL_PAYLOAD_TOO_LARGE
97 // error, and clean up appropriately. Note that this will cause the header
98 // decompressor to lose synchronization with the sender's header compressor,
99 // making the SPDY session unusable for future work. The visitor's OnError
100 // function should deal with this condition by closing the SPDY connection.
101 class NET_EXPORT_PRIVATE SpdyFramerVisitorInterface { 88 class NET_EXPORT_PRIVATE SpdyFramerVisitorInterface {
102 public: 89 public:
103 virtual ~SpdyFramerVisitorInterface() {} 90 virtual ~SpdyFramerVisitorInterface() {}
104 91
105 // Called if an error is detected in the SpdySerializedFrame protocol. 92 // Called if an error is detected in the SpdySerializedFrame protocol.
106 virtual void OnError(SpdyFramer* framer) = 0; 93 virtual void OnError(SpdyFramer* framer) = 0;
107 94
108 // Called when the common header for a frame is received. Validating the 95 // Called when the common header for a frame is received. Validating the
109 // common header occurs in later processing. 96 // common header occurs in later processing.
110 virtual void OnCommonHeader(SpdyStreamId stream_id, 97 virtual void OnCommonHeader(SpdyStreamId stream_id,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // and be returned for all header frames comprising a logical header block 130 // and be returned for all header frames comprising a logical header block
144 // (i.e. until OnHeaderFrameEnd() is called with end_headers == true). 131 // (i.e. until OnHeaderFrameEnd() is called with end_headers == true).
145 virtual SpdyHeadersHandlerInterface* OnHeaderFrameStart( 132 virtual SpdyHeadersHandlerInterface* OnHeaderFrameStart(
146 SpdyStreamId stream_id) = 0; 133 SpdyStreamId stream_id) = 0;
147 134
148 // Called after processing the payload of a frame containing header data. 135 // Called after processing the payload of a frame containing header data.
149 // |end_headers| is true if there will not be any subsequent CONTINUATION 136 // |end_headers| is true if there will not be any subsequent CONTINUATION
150 // frames. 137 // frames.
151 virtual void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) = 0; 138 virtual void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) = 0;
152 139
153 // Called when a chunk of header data is available. This is called
154 // after OnSynStream, OnSynReply, OnHeaders(), or OnPushPromise.
155 // |stream_id| The stream receiving the header data.
156 // |header_data| A buffer containing the header data chunk received.
157 // |len| The length of the header data buffer. A length of zero indicates
158 // that the header data block has been completely sent.
159 // When this function returns true the visitor indicates that it accepted
160 // all of the data. Returning false indicates that that an unrecoverable
161 // error has occurred, such as bad header data or resource exhaustion.
162 virtual bool OnControlFrameHeaderData(SpdyStreamId stream_id,
163 const char* header_data,
164 size_t len) = 0;
165
166 // Called when a SYN_STREAM frame is received. 140 // Called when a SYN_STREAM frame is received.
167 // Note that header block data is not included. See 141 // Note that header block data is not included. See OnHeaderFrameStart().
168 // OnControlFrameHeaderData().
169 virtual void OnSynStream(SpdyStreamId stream_id, 142 virtual void OnSynStream(SpdyStreamId stream_id,
170 SpdyStreamId associated_stream_id, 143 SpdyStreamId associated_stream_id,
171 SpdyPriority priority, 144 SpdyPriority priority,
172 bool fin, 145 bool fin,
173 bool unidirectional) = 0; 146 bool unidirectional) = 0;
174 147
175 // Called when a SYN_REPLY frame is received. 148 // Called when a SYN_REPLY frame is received.
176 // Note that header block data is not included. See 149 // Note that header block data is not included. See OnHeaderFrameStart().
177 // OnControlFrameHeaderData().
178 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) = 0; 150 virtual void OnSynReply(SpdyStreamId stream_id, bool fin) = 0;
179 151
180 // Called when a RST_STREAM frame has been parsed. 152 // Called when a RST_STREAM frame has been parsed.
181 virtual void OnRstStream(SpdyStreamId stream_id, 153 virtual void OnRstStream(SpdyStreamId stream_id,
182 SpdyRstStreamStatus status) = 0; 154 SpdyRstStreamStatus status) = 0;
183 155
184 // Called when a SETTINGS frame is received. 156 // Called when a SETTINGS frame is received.
185 // |clear_persisted| True if the respective flag is set on the SETTINGS frame. 157 // |clear_persisted| True if the respective flag is set on the SETTINGS frame.
186 virtual void OnSettings(bool clear_persisted) {} 158 virtual void OnSettings(bool clear_persisted) {}
187 159
188 // Called when a complete setting within a SETTINGS frame has been parsed and 160 // Called when a complete setting within a SETTINGS frame has been parsed and
189 // validated. 161 // validated.
190 virtual void OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) = 0; 162 virtual void OnSetting(SpdySettingsIds id, uint8_t flags, uint32_t value) = 0;
191 163
192 // Called when a SETTINGS frame is received with the ACK flag set. 164 // Called when a SETTINGS frame is received with the ACK flag set.
193 virtual void OnSettingsAck() {} 165 virtual void OnSettingsAck() {}
194 166
195 // Called before and after parsing SETTINGS id and value tuples. 167 // Called before and after parsing SETTINGS id and value tuples.
196 virtual void OnSettingsEnd() = 0; 168 virtual void OnSettingsEnd() = 0;
197 169
198 // Called when a PING frame has been parsed. 170 // Called when a PING frame has been parsed.
199 virtual void OnPing(SpdyPingId unique_id, bool is_ack) = 0; 171 virtual void OnPing(SpdyPingId unique_id, bool is_ack) = 0;
200 172
201 // Called when a GOAWAY frame has been parsed. 173 // Called when a GOAWAY frame has been parsed.
202 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, 174 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id,
203 SpdyGoAwayStatus status) = 0; 175 SpdyGoAwayStatus status) = 0;
204 176
205 // Called when a HEADERS frame is received. 177 // Called when a HEADERS frame is received.
206 // Note that header block data is not included. See 178 // Note that header block data is not included. See OnHeaderFrameStart().
207 // OnControlFrameHeaderData().
208 // |stream_id| The stream receiving the header. 179 // |stream_id| The stream receiving the header.
209 // |has_priority| Whether or not the headers frame included a priority value, 180 // |has_priority| Whether or not the headers frame included a priority value,
210 // and, if protocol version == HTTP2, stream dependency info. 181 // and, if protocol version == HTTP2, stream dependency info.
211 // |weight| If |has_priority| is true, then weight (in the range [1, 256]) 182 // |weight| If |has_priority| is true, then weight (in the range [1, 256])
212 // for the receiving stream, otherwise 0. 183 // for the receiving stream, otherwise 0.
213 // |parent_stream_id| If |has_priority| is true and protocol 184 // |parent_stream_id| If |has_priority| is true and protocol
214 // version == HTTP2, the parent stream of the receiving stream, else 0. 185 // version == HTTP2, the parent stream of the receiving stream, else 0.
215 // |exclusive| If |has_priority| is true and protocol 186 // |exclusive| If |has_priority| is true and protocol
216 // version == HTTP2, the exclusivity of dependence on the parent stream, 187 // version == HTTP2, the exclusivity of dependence on the parent stream,
217 // else false. 188 // else false.
(...skipping 28 matching lines...) Expand all
246 // that the opaque data has been completely sent. 217 // that the opaque data has been completely sent.
247 // When this function returns true the visitor indicates that it accepted 218 // When this function returns true the visitor indicates that it accepted
248 // all of the data. Returning false indicates that that an error has 219 // all of the data. Returning false indicates that that an error has
249 // occurred while processing the data. Default implementation returns true. 220 // occurred while processing the data. Default implementation returns true.
250 virtual bool OnRstStreamFrameData(const char* rst_stream_data, size_t len); 221 virtual bool OnRstStreamFrameData(const char* rst_stream_data, size_t len);
251 222
252 // Called when a BLOCKED frame has been parsed. 223 // Called when a BLOCKED frame has been parsed.
253 virtual void OnBlocked(SpdyStreamId stream_id) {} 224 virtual void OnBlocked(SpdyStreamId stream_id) {}
254 225
255 // Called when a PUSH_PROMISE frame is received. 226 // Called when a PUSH_PROMISE frame is received.
256 // Note that header block data is not included. See 227 // Note that header block data is not included. See OnHeaderFrameStart().
257 // OnControlFrameHeaderData().
258 virtual void OnPushPromise(SpdyStreamId stream_id, 228 virtual void OnPushPromise(SpdyStreamId stream_id,
259 SpdyStreamId promised_stream_id, 229 SpdyStreamId promised_stream_id,
260 bool end) = 0; 230 bool end) = 0;
261 231
262 // Called when a CONTINUATION frame is received. 232 // Called when a CONTINUATION frame is received.
263 // Note that header block data is not included. See 233 // Note that header block data is not included. See OnHeaderFrameStart().
264 // OnControlFrameHeaderData().
265 virtual void OnContinuation(SpdyStreamId stream_id, bool end) = 0; 234 virtual void OnContinuation(SpdyStreamId stream_id, bool end) = 0;
266 235
267 // Called when an ALTSVC frame has been parsed. 236 // Called when an ALTSVC frame has been parsed.
268 virtual void OnAltSvc( 237 virtual void OnAltSvc(
269 SpdyStreamId stream_id, 238 SpdyStreamId stream_id,
270 base::StringPiece origin, 239 base::StringPiece origin,
271 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) {} 240 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) {}
272 241
273 // Called when a PRIORITY frame is received. 242 // Called when a PRIORITY frame is received.
274 // |stream_id| The stream to update the priority of. 243 // |stream_id| The stream to update the priority of.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 }; 332 };
364 333
365 // Typedef for a function used to create SpdyFramerDecoderAdapter's. 334 // Typedef for a function used to create SpdyFramerDecoderAdapter's.
366 // Defined in support of evaluating an alternate HTTP/2 decoder. 335 // Defined in support of evaluating an alternate HTTP/2 decoder.
367 typedef std::unique_ptr<SpdyFramerDecoderAdapter> (*DecoderAdapterFactoryFn)( 336 typedef std::unique_ptr<SpdyFramerDecoderAdapter> (*DecoderAdapterFactoryFn)(
368 SpdyFramer* outer); 337 SpdyFramer* outer);
369 338
370 // Constant for invalid (or unknown) stream IDs. 339 // Constant for invalid (or unknown) stream IDs.
371 static const SpdyStreamId kInvalidStream; 340 static const SpdyStreamId kInvalidStream;
372 341
373 // The maximum size of header data chunks delivered to the framer visitor 342 // The maximum size of header data decompressed/delivered at once to the
374 // through OnControlFrameHeaderData. (It is exposed here for unit test 343 // header block parser. (Exposed here for unit test purposes.)
375 // purposes.)
376 static const size_t kHeaderDataChunkMaxSize; 344 static const size_t kHeaderDataChunkMaxSize;
377 345
378 void SerializeHeaderBlockWithoutCompression( 346 void SerializeHeaderBlockWithoutCompression(
379 SpdyFrameBuilder* builder, 347 SpdyFrameBuilder* builder,
380 const SpdyHeaderBlock& header_block) const; 348 const SpdyHeaderBlock& header_block) const;
381 349
382 // Retrieve serialized length of SpdyHeaderBlock. 350 // Retrieve serialized length of SpdyHeaderBlock.
383 // TODO(hkhalil): Remove, or move to quic code. 351 // TODO(hkhalil): Remove, or move to quic code.
384 static size_t GetSerializedLength( 352 static size_t GetSerializedLength(
385 const SpdyMajorVersion spdy_version, 353 const SpdyMajorVersion spdy_version,
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 // frame_type_field : the unparsed frame type octet(s) 676 // frame_type_field : the unparsed frame type octet(s)
709 // payload_length_field: the stated length in octets of the frame payload 677 // payload_length_field: the stated length in octets of the frame payload
710 // 678 //
711 // For valid frames, returns the correct SpdyFrameType. 679 // For valid frames, returns the correct SpdyFrameType.
712 // Otherwise returns a best guess at invalid frame type, 680 // Otherwise returns a best guess at invalid frame type,
713 // after setting the appropriate SpdyError. 681 // after setting the appropriate SpdyError.
714 SpdyFrameType ValidateFrameHeader(bool is_control_frame, 682 SpdyFrameType ValidateFrameHeader(bool is_control_frame,
715 int frame_type_field, 683 int frame_type_field,
716 size_t payload_length_field); 684 size_t payload_length_field);
717 685
718 // TODO(jgraettinger): To be removed with migration to
719 // SpdyHeadersHandlerInterface. Serializes the last-processed
720 // header block of |hpack_decoder_| as a SPDY3 format block, and
721 // delivers it to the visitor via reentrant call to
722 // ProcessControlFrameHeaderBlock(). |compressed_len| is used for
723 // logging compression percentage.
724 void DeliverHpackBlockAsSpdy3Block(size_t compressed_len);
725
726 // Helpers for above internal breakouts from ProcessInput. 686 // Helpers for above internal breakouts from ProcessInput.
727 void ProcessControlFrameHeader(int control_frame_type_field); 687 void ProcessControlFrameHeader(int control_frame_type_field);
728 // Always passed exactly 1 setting's worth of data. 688 // Always passed exactly 1 setting's worth of data.
729 bool ProcessSetting(const char* data); 689 bool ProcessSetting(const char* data);
730 690
731 // Retrieve serialized length of SpdyHeaderBlock. If compression is enabled, a 691 // Retrieve serialized length of SpdyHeaderBlock. If compression is enabled, a
732 // maximum estimate is returned. 692 // maximum estimate is returned.
733 size_t GetSerializedLength(const SpdyHeaderBlock& headers); 693 size_t GetSerializedLength(const SpdyHeaderBlock& headers);
734 694
735 // Get (and lazily initialize) the ZLib state. 695 // Get (and lazily initialize) the ZLib state.
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 bool end_stream_when_done_; 860 bool end_stream_when_done_;
901 861
902 // If true, then ProcessInput returns after processing a full frame, 862 // If true, then ProcessInput returns after processing a full frame,
903 // rather than reading all available input. 863 // rather than reading all available input.
904 bool process_single_input_frame_ = false; 864 bool process_single_input_frame_ = false;
905 }; 865 };
906 866
907 } // namespace net 867 } // namespace net
908 868
909 #endif // NET_SPDY_SPDY_FRAMER_H_ 869 #endif // NET_SPDY_SPDY_FRAMER_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_deframer_visitor.cc ('k') | net/spdy/spdy_framer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698