xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/core/qpack/qpack_send_stream.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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_QPACK_QPACK_SEND_STREAM_H_
6 #define QUICHE_QUIC_CORE_QPACK_QPACK_SEND_STREAM_H_
7 
8 #include <cstdint>
9 
10 #include "absl/strings/string_view.h"
11 #include "quiche/quic/core/qpack/qpack_stream_sender_delegate.h"
12 #include "quiche/quic/core/quic_stream.h"
13 #include "quiche/quic/platform/api/quic_export.h"
14 #include "quiche/common/platform/api/quiche_logging.h"
15 
16 namespace quic {
17 
18 class QuicSession;
19 
20 // QPACK 4.2.1 Encoder and Decoder Streams.
21 // The QPACK send stream is self initiated and is write only.
22 class QUICHE_EXPORT QpackSendStream : public QuicStream,
23                                       public QpackStreamSenderDelegate {
24  public:
25   // |session| can't be nullptr, and the ownership is not passed. |session| owns
26   // this stream.
27   QpackSendStream(QuicStreamId id, QuicSession* session,
28                   uint64_t http3_stream_type);
29   QpackSendStream(const QpackSendStream&) = delete;
30   QpackSendStream& operator=(const QpackSendStream&) = delete;
31   ~QpackSendStream() override = default;
32 
33   // Overriding QuicStream::OnStopSending() to make sure QPACK stream is never
34   // closed before connection.
35   void OnStreamReset(const QuicRstStreamFrame& frame) override;
36   bool OnStopSending(QuicResetStreamError code) override;
37 
38   // The send QPACK stream is write unidirectional, so this method
39   // should never be called.
OnDataAvailable()40   void OnDataAvailable() override { QUICHE_NOTREACHED(); }
41 
42   // Writes the instructions to peer. The stream type will be sent
43   // before the first instruction so that the peer can open an qpack stream.
44   void WriteStreamData(absl::string_view data) override;
45 
46   // Return the number of bytes buffered due to underlying stream being blocked.
47   uint64_t NumBytesBuffered() const override;
48 
49   // TODO(b/112770235): Remove this method once QuicStreamIdManager supports
50   // creating HTTP/3 unidirectional streams dynamically.
51   void MaybeSendStreamType();
52 
53  private:
54   const uint64_t http3_stream_type_;
55   bool stream_type_sent_;
56 };
57 
58 }  // namespace quic
59 
60 #endif  // QUICHE_QUIC_CORE_QPACK_QPACK_SEND_STREAM_H_
61