OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 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 NET_QUIC_QUARTC_QUARTC_STREAM_INTERFACE_H_ | |
6 #define NET_QUIC_QUARTC_QUARTC_STREAM_INTERFACE_H_ | |
skvlad-chromium
2016/10/28 21:51:42
Please add includes for system types:
#include <st
| |
7 | |
8 namespace net { | |
9 | |
10 // Sends and receives data with a particular QUIC stream ID, reliably and | |
11 // in-order. To send/receive data out of order, use separate streams. To | |
12 // send/receive unreliably, close a stream after reliability is no longer | |
13 // needed. | |
14 class NET_EXPORT_PRIVATE QuartcStreamInterface { | |
15 public: | |
16 virtual ~QuartcStreamInterface() {} | |
17 | |
18 // The QUIC stream ID. | |
19 virtual uint32_t stream_id() = 0; | |
20 | |
21 // The amount of data buffered by the QuicConnection. | |
22 virtual uint64_t buffered_amount() = 0; | |
23 | |
24 // Return true if the FIN has been sent. Used by the outgoing streams to | |
25 // determine if all the data has been sent | |
26 virtual bool fin_sent() = 0; | |
27 | |
28 struct WriteParameters { | |
29 // |fin| is set to be true when there is no more data need to be send | |
30 // through a particular stream. The receiving side will used it to determine | |
31 // if the sender finish sending data. | |
32 bool fin = false; | |
33 }; | |
34 | |
35 // Sends data reliably and in-order, buffering if necessary until Close() is | |
36 // called. | |
37 virtual void Write(const char* data, | |
38 size_t size, | |
39 const WriteParameters& param) = 0; | |
40 | |
41 // Once Close is called, no more data can be sent, all buffered data will be | |
42 // dropped and no data will be retransmitted. | |
43 virtual void Close() = 0; | |
44 | |
45 // Implemented by the user of the QuartcStreamInterface to receive incoming | |
46 // data and be notified of state changes. | |
47 class Delegate { | |
48 public: | |
49 virtual ~Delegate() {} | |
50 | |
51 // Called when the stream receives the date. | |
52 virtual void OnReceived(QuartcStreamInterface* stream, | |
53 const char* data, | |
54 size_t size) = 0; | |
55 | |
56 // Called when the stream is closed, either locally or by the remote | |
57 // endpoint. | |
58 // TODO(zhihuang) Creates a map from the integer error_code to WebRTC native | |
59 // error code. | |
60 virtual void OnClose(QuartcStreamInterface* stream, int error_code) = 0; | |
61 | |
62 // Called when buffered_amount() decreases. | |
63 virtual void OnBufferedAmountDecrease(QuartcStreamInterface* stream) = 0; | |
64 }; | |
65 | |
66 // The |delegate| is not owned by QuartcStream. | |
67 virtual void SetDelegate(Delegate* delegate) = 0; | |
68 }; | |
69 | |
70 } // namespace net | |
71 | |
72 #endif // NET_QUIC_QUARTC_QUARTC_STREAM_INTERFACE_H_ | |
OLD | NEW |