• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 QUIC_EXPORT_PRIVATE QuicReceiveControlStream
20     : public QuicStream,
21       public HttpDecoder::Visitor {
22  public:
23   explicit QuicReceiveControlStream(PendingStream* pending,
24                                     QuicSpdySession* spdy_session);
25   QuicReceiveControlStream(const QuicReceiveControlStream&) = delete;
26   QuicReceiveControlStream& operator=(const QuicReceiveControlStream&) = delete;
27   ~QuicReceiveControlStream() override;
28 
29   // Overriding QuicStream::OnStreamReset to make sure control stream is never
30   // closed before connection.
31   void OnStreamReset(const QuicRstStreamFrame& frame) override;
32 
33   // Implementation of QuicStream.
34   void OnDataAvailable() override;
35 
36   // HttpDecoder::Visitor implementation.
37   void OnError(HttpDecoder* decoder) override;
38   bool OnMaxPushIdFrame() override;
39   bool OnGoAwayFrame(const GoAwayFrame& frame) override;
40   bool OnSettingsFrameStart(QuicByteCount header_length) override;
41   bool OnSettingsFrame(const SettingsFrame& frame) override;
42   bool OnDataFrameStart(QuicByteCount header_length,
43                         QuicByteCount payload_length) override;
44   bool OnDataFramePayload(absl::string_view payload) override;
45   bool OnDataFrameEnd() override;
46   bool OnHeadersFrameStart(QuicByteCount header_length,
47                            QuicByteCount payload_length) override;
48   bool OnHeadersFramePayload(absl::string_view payload) override;
49   bool OnHeadersFrameEnd() override;
50   bool OnPriorityUpdateFrameStart(QuicByteCount header_length) override;
51   bool OnPriorityUpdateFrame(const PriorityUpdateFrame& frame) override;
52   bool OnAcceptChFrameStart(QuicByteCount header_length) override;
53   bool OnAcceptChFrame(const AcceptChFrame& frame) override;
54   void OnWebTransportStreamFrameType(QuicByteCount header_length,
55                                      WebTransportSessionId session_id) override;
56   bool OnUnknownFrameStart(uint64_t frame_type, QuicByteCount header_length,
57                            QuicByteCount payload_length) override;
58   bool OnUnknownFramePayload(absl::string_view payload) override;
59   bool OnUnknownFrameEnd() override;
60 
spdy_session()61   QuicSpdySession* spdy_session() { return spdy_session_; }
62 
63  private:
64   // Called when a frame of allowed type is received.  Returns true if the frame
65   // is allowed in this position.  Returns false and resets the stream
66   // otherwise.
67   bool ValidateFrameType(HttpFrameType frame_type);
68 
69   // False until a SETTINGS frame is received.
70   bool settings_frame_received_;
71 
72   HttpDecoder decoder_;
73   QuicSpdySession* const spdy_session_;
74 };
75 
76 }  // namespace quic
77 
78 #endif  // QUICHE_QUIC_CORE_HTTP_QUIC_RECEIVE_CONTROL_STREAM_H_
79