blob: 09c6020cf49ab7df050505a60c6a1d27974be909 [file] [log] [blame]
renjietangd21094b2019-06-14 09:39:11 -07001// 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
bncd7d67632019-06-28 10:42:12 -07008#include <cstdint>
9
renjietangc2aa5cb2019-06-20 12:22:53 -070010#include "net/third_party/quiche/src/quic/core/qpack/qpack_stream_sender_delegate.h"
renjietangd21094b2019-06-14 09:39:11 -070011#include "net/third_party/quiche/src/quic/core/quic_stream.h"
12#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
bncd7d67632019-06-28 10:42:12 -070013#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h"
renjietangd21094b2019-06-14 09:39:11 -070014
15namespace quic {
16
renjietang89e73562019-07-22 11:24:22 -070017class QuicSession;
renjietangd21094b2019-06-14 09:39:11 -070018
19// QPACK 4.2.1 Encoder and Decoder Streams.
20// The QPACK send stream is self initiated and is write only.
renjietangc2aa5cb2019-06-20 12:22:53 -070021class QUIC_EXPORT_PRIVATE QpackSendStream : public QuicStream,
22 public QpackStreamSenderDelegate {
renjietangd21094b2019-06-14 09:39:11 -070023 public:
24 // |session| can't be nullptr, and the ownership is not passed. |session| owns
25 // this stream.
26 QpackSendStream(QuicStreamId id,
renjietang89e73562019-07-22 11:24:22 -070027 QuicSession* session,
renjietanga2736fc2019-07-18 11:07:23 -070028 uint64_t http3_stream_type);
renjietangd21094b2019-06-14 09:39:11 -070029 QpackSendStream(const QpackSendStream&) = delete;
30 QpackSendStream& operator=(const QpackSendStream&) = delete;
31 ~QpackSendStream() override = default;
32
33 // Overriding QuicStream::OnStreamReset to make sure QPACK stream is
34 // never closed before connection.
35 void OnStreamReset(const QuicRstStreamFrame& frame) override;
36
37 // The send QPACK stream is write unidirectional, so this method
38 // should never be called.
39 void OnDataAvailable() override { QUIC_NOTREACHED(); }
40
41 // Writes the instructions to peer. The stream type will be sent
42 // before the first instruction so that the peer can open an qpack stream.
renjietangc2aa5cb2019-06-20 12:22:53 -070043 void WriteStreamData(QuicStringPiece data) override;
renjietangd21094b2019-06-14 09:39:11 -070044
renjietang87cd7de2019-08-16 08:35:10 -070045 // TODO(b/112770235): Remove this method once QuicStreamIdManager supports
46 // creating HTTP/3 unidirectional streams dynamically.
renjietangc8c02a52019-08-22 10:38:37 -070047 void MaybeSendStreamType();
renjietang87cd7de2019-08-16 08:35:10 -070048
renjietangd21094b2019-06-14 09:39:11 -070049 private:
renjietanga2736fc2019-07-18 11:07:23 -070050 const uint64_t http3_stream_type_;
renjietangd21094b2019-06-14 09:39:11 -070051 bool stream_type_sent_;
52};
53
54} // namespace quic
55
56#endif // QUICHE_QUIC_CORE_QPACK_QPACK_SEND_STREAM_H_