xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/qbone/qbone_stream.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright (c) 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_QBONE_QBONE_STREAM_H_
6 #define QUICHE_QUIC_QBONE_QBONE_STREAM_H_
7 
8 #include "absl/strings/string_view.h"
9 #include "quiche/quic/core/quic_session.h"
10 #include "quiche/quic/core/quic_stream.h"
11 #include "quiche/quic/platform/api/quic_export.h"
12 
13 namespace quic {
14 
15 class QboneSessionBase;
16 
17 // QboneWriteOnlyStream is responsible for sending data for a single
18 // packet to the other side.
19 // Note that the stream will be created HalfClosed (reads will be closed).
20 class QUIC_EXPORT_PRIVATE QboneWriteOnlyStream : public QuicStream {
21  public:
22   QboneWriteOnlyStream(QuicStreamId id, QuicSession* session);
23 
24   // QuicStream implementation. QBONE writers are ephemeral and don't
25   // read any data.
OnDataAvailable()26   void OnDataAvailable() override {}
27 
28   // Write a network packet over the quic stream.
29   void WritePacketToQuicStream(absl::string_view packet);
30 };
31 
32 // QboneReadOnlyStream will be used if we find an incoming stream that
33 // isn't fully contained. It will buffer the data when available and
34 // attempt to parse it as a packet to send to the network when a FIN
35 // is found.
36 // Note that the stream will be created HalfClosed (writes will be closed).
37 class QUIC_EXPORT_PRIVATE QboneReadOnlyStream : public QuicStream {
38  public:
39   QboneReadOnlyStream(QuicStreamId id, QboneSessionBase* session);
40 
41   ~QboneReadOnlyStream() override = default;
42 
43   // QuicStream overrides.
44   // OnDataAvailable is called when there is data in the quic stream buffer.
45   // This will copy the buffer locally and attempt to parse it to write out
46   // packets to the network.
47   void OnDataAvailable() override;
48 
49  private:
50   std::string buffer_;
51   QboneSessionBase* session_;
52 };
53 
54 }  // namespace quic
55 
56 #endif  // QUICHE_QUIC_QBONE_QBONE_STREAM_H_
57