blob: a2d0b574441db3fb6cc75cd5c5a5996e7170c176 [file] [log] [blame]
mikescarlettcd0e4752016-02-08 17:35:47 -08001/*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_P2P_QUIC_RELIABLEQUICSTREAM_H_
12#define WEBRTC_P2P_QUIC_RELIABLEQUICSTREAM_H_
13
14#include "net/quic/reliable_quic_stream.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020015#include "webrtc/rtc_base/constructormagic.h"
16#include "webrtc/rtc_base/sigslot.h"
17#include "webrtc/rtc_base/stream.h"
mikescarlettcd0e4752016-02-08 17:35:47 -080018
19namespace cricket {
20
21// Streams created by QuicSession.
22class ReliableQuicStream : public net::ReliableQuicStream,
23 public sigslot::has_slots<> {
24 public:
25 ReliableQuicStream(net::QuicStreamId id, net::QuicSession* session);
26
27 ~ReliableQuicStream() override;
28
29 // ReliableQuicStream overrides.
30 void OnDataAvailable() override;
31 void OnClose() override;
mikescarlett18b67a52016-04-11 16:56:23 -070032 void OnCanWrite() override;
mikescarlettcd0e4752016-02-08 17:35:47 -080033
34 // Process decrypted data into encrypted QUIC packets, which get sent to the
35 // QuicPacketWriter. rtc::SR_BLOCK is returned if the operation blocks instead
36 // of writing, in which case the data is queued until OnCanWrite() is called.
mikescarlett18b67a52016-04-11 16:56:23 -070037 // If |fin| == true, then this stream closes after sending data.
38 rtc::StreamResult Write(const char* data, size_t len, bool fin = false);
39 // Removes this stream from the QuicSession's stream map.
40 void Close();
mikescarlettcd0e4752016-02-08 17:35:47 -080041
42 // Called when decrypted data is ready to be read.
43 sigslot::signal3<net::QuicStreamId, const char*, size_t> SignalDataReceived;
mikescarlett18b67a52016-04-11 16:56:23 -070044 // Called when the stream is closed.
45 sigslot::signal2<net::QuicStreamId, int> SignalClosed;
46 // Emits the number of queued bytes that were written by OnCanWrite(), after
47 // the stream was previously write blocked.
48 sigslot::signal2<net::QuicStreamId, uint64_t> SignalQueuedBytesWritten;
mikescarlettcd0e4752016-02-08 17:35:47 -080049
50 private:
51 RTC_DISALLOW_COPY_AND_ASSIGN(ReliableQuicStream);
52};
53
54} // namespace cricket
55
56#endif // WEBRTC_P2P_QUIC_RELIABLEQUICSTREAM_H_