blob: 8a6313bc0c2ac00d9099992adc8a9d4d4d8f1441 [file] [log] [blame]
wubf975eac2019-08-19 19:41:01 -07001// 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 "net/third_party/quiche/src/quic/core/quic_session.h"
9#include "net/third_party/quiche/src/quic/core/quic_stream.h"
10#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
dmcardled70b99e2019-12-12 09:52:39 -080011#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
wubf975eac2019-08-19 19:41:01 -070012
13namespace quic {
14
15class 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).
20class QUIC_EXPORT_PRIVATE QboneWriteOnlyStream : public QuicStream {
21 public:
22 QboneWriteOnlyStream(QuicStreamId id, QuicSession* session);
23
bncc3843272020-02-27 04:58:51 -080024 // QuicStream implementation. QBONE writers are ephemeral and don't
wubf975eac2019-08-19 19:41:01 -070025 // read any data.
26 void OnDataAvailable() override {}
27
28 // Write a network packet over the quic stream.
dmcardled70b99e2019-12-12 09:52:39 -080029 void WritePacketToQuicStream(quiche::QuicheStringPiece packet);
wubf975eac2019-08-19 19:41:01 -070030};
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).
37class QUIC_EXPORT_PRIVATE QboneReadOnlyStream : public QuicStream {
38 public:
39 QboneReadOnlyStream(QuicStreamId id, QboneSessionBase* session);
40
QUICHE team5a393012020-03-31 12:14:24 -070041 ~QboneReadOnlyStream() override = default;
wubf975eac2019-08-19 19:41:01 -070042
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:
QUICHE teamb80d7c32020-02-23 23:44:20 -080050 std::string buffer_;
wubf975eac2019-08-19 19:41:01 -070051 QboneSessionBase* session_;
52};
53
54} // namespace quic
55
56#endif // QUICHE_QUIC_QBONE_QBONE_STREAM_H_