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_SEND_CONTROL_STREAM_H_ 6 #define QUICHE_QUIC_CORE_HTTP_QUIC_SEND_CONTROL_STREAM_H_ 7 8 #include "quiche/quic/core/http/http_encoder.h" 9 #include "quiche/quic/core/quic_stream.h" 10 #include "quiche/quic/core/quic_stream_priority.h" 11 #include "quiche/quic/core/quic_types.h" 12 #include "quiche/quic/platform/api/quic_export.h" 13 #include "quiche/quic/platform/api/quic_logging.h" 14 #include "quiche/common/platform/api/quiche_logging.h" 15 16 namespace quic { 17 18 class QuicSpdySession; 19 20 // 6.2.1 Control Stream. 21 // The send control stream is self initiated and is write only. 22 class QUICHE_EXPORT QuicSendControlStream : public QuicStream { 23 public: 24 // |session| can't be nullptr, and the ownership is not passed. The stream can 25 // only be accessed through the session. 26 QuicSendControlStream(QuicStreamId id, QuicSpdySession* session, 27 const SettingsFrame& settings); 28 QuicSendControlStream(const QuicSendControlStream&) = delete; 29 QuicSendControlStream& operator=(const QuicSendControlStream&) = delete; 30 ~QuicSendControlStream() override = default; 31 32 // Overriding QuicStream::OnStopSending() to make sure control stream is never 33 // closed before connection. 34 void OnStreamReset(const QuicRstStreamFrame& frame) override; 35 bool OnStopSending(QuicResetStreamError code) override; 36 37 // Send SETTINGS frame if it hasn't been sent yet. Settings frame must be the 38 // first frame sent on this stream. 39 void MaybeSendSettingsFrame(); 40 41 // Send a PRIORITY_UPDATE frame on this stream, and a SETTINGS frame 42 // beforehand if one has not been already sent. 43 void WritePriorityUpdate(QuicStreamId stream_id, HttpStreamPriority priority); 44 45 // Send a GOAWAY frame on this stream, and a SETTINGS frame beforehand if one 46 // has not been already sent. 47 void SendGoAway(QuicStreamId id); 48 49 // The send control stream is write unidirectional, so this method should 50 // never be called. OnDataAvailable()51 void OnDataAvailable() override { QUICHE_NOTREACHED(); } 52 53 private: 54 // Track if a settings frame is already sent. 55 bool settings_sent_; 56 57 // SETTINGS values to send. 58 const SettingsFrame settings_; 59 60 QuicSpdySession* const spdy_session_; 61 }; 62 63 } // namespace quic 64 65 #endif // QUICHE_QUIC_CORE_HTTP_QUIC_SEND_CONTROL_STREAM_H_ 66