wub | f975eac | 2019-08-19 19:41:01 -0700 | [diff] [blame] | 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 "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" |
dmcardle | d70b99e | 2019-12-12 09:52:39 -0800 | [diff] [blame] | 11 | #include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" |
wub | f975eac | 2019-08-19 19:41:01 -0700 | [diff] [blame] | 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 | |
bnc | c384327 | 2020-02-27 04:58:51 -0800 | [diff] [blame] | 24 | // QuicStream implementation. QBONE writers are ephemeral and don't |
wub | f975eac | 2019-08-19 19:41:01 -0700 | [diff] [blame] | 25 | // read any data. |
| 26 | void OnDataAvailable() override {} |
| 27 | |
| 28 | // Write a network packet over the quic stream. |
dmcardle | d70b99e | 2019-12-12 09:52:39 -0800 | [diff] [blame] | 29 | void WritePacketToQuicStream(quiche::QuicheStringPiece packet); |
wub | f975eac | 2019-08-19 19:41:01 -0700 | [diff] [blame] | 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 | |
QUICHE team | 5a39301 | 2020-03-31 12:14:24 -0700 | [diff] [blame^] | 41 | ~QboneReadOnlyStream() override = default; |
wub | f975eac | 2019-08-19 19:41:01 -0700 | [diff] [blame] | 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: |
QUICHE team | b80d7c3 | 2020-02-23 23:44:20 -0800 | [diff] [blame] | 50 | std::string buffer_; |
wub | f975eac | 2019-08-19 19:41:01 -0700 | [diff] [blame] | 51 | QboneSessionBase* session_; |
| 52 | }; |
| 53 | |
| 54 | } // namespace quic |
| 55 | |
| 56 | #endif // QUICHE_QUIC_QBONE_QBONE_STREAM_H_ |