blob: 6a86e4d839fd1068c60c8e154c37b39f862e3f61 [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
24 // QuicStream implementation. Qbone writers are ephemeral and don't
25 // 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
41 ~QboneReadOnlyStream() override;
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 string buffer_;
51 QboneSessionBase* session_;
52};
53
54} // namespace quic
55
56#endif // QUICHE_QUIC_QBONE_QBONE_STREAM_H_