1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef QUICHE_QUIC_CORE_HTTP_QUIC_RECEIVE_CONTROL_STREAM_H_ 6 #define QUICHE_QUIC_CORE_HTTP_QUIC_RECEIVE_CONTROL_STREAM_H_ 7 8 #include "quiche/quic/core/http/http_decoder.h" 9 #include "quiche/quic/core/quic_stream.h" 10 #include "quiche/quic/core/quic_types.h" 11 #include "quiche/quic/platform/api/quic_export.h" 12 13 namespace quic { 14 15 class QuicSpdySession; 16 17 // 3.2.1 Control Stream. 18 // The receive control stream is peer initiated and is read only. 19 class QUICHE_EXPORT QuicReceiveControlStream : public QuicStream, 20 public HttpDecoder::Visitor { 21 public: 22 explicit QuicReceiveControlStream(PendingStream* pending, 23 QuicSpdySession* spdy_session); 24 QuicReceiveControlStream(const QuicReceiveControlStream&) = delete; 25 QuicReceiveControlStream& operator=(const QuicReceiveControlStream&) = delete; 26 ~QuicReceiveControlStream() override; 27 28 // Overriding QuicStream::OnStreamReset to make sure control stream is never 29 // closed before connection. 30 void OnStreamReset(const QuicRstStreamFrame& frame) override; 31 32 // Implementation of QuicStream. 33 void OnDataAvailable() override; 34 35 // HttpDecoder::Visitor implementation. 36 void OnError(HttpDecoder* decoder) override; 37 bool OnMaxPushIdFrame() override; 38 bool OnGoAwayFrame(const GoAwayFrame& frame) override; 39 bool OnSettingsFrameStart(QuicByteCount header_length) override; 40 bool OnSettingsFrame(const SettingsFrame& frame) override; 41 bool OnDataFrameStart(QuicByteCount header_length, 42 QuicByteCount payload_length) override; 43 bool OnDataFramePayload(absl::string_view payload) override; 44 bool OnDataFrameEnd() override; 45 bool OnHeadersFrameStart(QuicByteCount header_length, 46 QuicByteCount payload_length) override; 47 bool OnHeadersFramePayload(absl::string_view payload) override; 48 bool OnHeadersFrameEnd() override; 49 bool OnPriorityUpdateFrameStart(QuicByteCount header_length) override; 50 bool OnPriorityUpdateFrame(const PriorityUpdateFrame& frame) override; 51 bool OnAcceptChFrameStart(QuicByteCount header_length) override; 52 bool OnAcceptChFrame(const AcceptChFrame& frame) override; 53 void OnWebTransportStreamFrameType(QuicByteCount header_length, 54 WebTransportSessionId session_id) override; 55 bool OnMetadataFrameStart(QuicByteCount header_length, 56 QuicByteCount payload_length) override; 57 bool OnMetadataFramePayload(absl::string_view payload) override; 58 bool OnMetadataFrameEnd() override; 59 bool OnUnknownFrameStart(uint64_t frame_type, QuicByteCount header_length, 60 QuicByteCount payload_length) override; 61 bool OnUnknownFramePayload(absl::string_view payload) override; 62 bool OnUnknownFrameEnd() override; 63 spdy_session()64 QuicSpdySession* spdy_session() { return spdy_session_; } 65 66 private: 67 // Called when a frame of allowed type is received. Returns true if the frame 68 // is allowed in this position. Returns false and resets the stream 69 // otherwise. 70 bool ValidateFrameType(HttpFrameType frame_type); 71 72 // False until a SETTINGS frame is received. 73 bool settings_frame_received_; 74 75 HttpDecoder decoder_; 76 QuicSpdySession* const spdy_session_; 77 }; 78 79 } // namespace quic 80 81 #endif // QUICHE_QUIC_CORE_HTTP_QUIC_RECEIVE_CONTROL_STREAM_H_ 82