| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_QUIC_QUARTC_QUARTC_STREAM_INTERFACE_H_ | 5 #ifndef NET_QUIC_QUARTC_QUARTC_STREAM_INTERFACE_H_ |
| 6 #define NET_QUIC_QUARTC_QUARTC_STREAM_INTERFACE_H_ | 6 #define NET_QUIC_QUARTC_QUARTC_STREAM_INTERFACE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 | 12 |
| 13 // Sends and receives data with a particular QUIC stream ID, reliably and | 13 // Sends and receives data with a particular QUIC stream ID, reliably and |
| 14 // in-order. To send/receive data out of order, use separate streams. To | 14 // in-order. To send/receive data out of order, use separate streams. To |
| 15 // send/receive unreliably, close a stream after reliability is no longer | 15 // send/receive unreliably, close a stream after reliability is no longer |
| 16 // needed. | 16 // needed. |
| 17 class QuartcStreamInterface { | 17 class QUIC_EXPORT_PRIVATE QuartcStreamInterface { |
| 18 public: | 18 public: |
| 19 virtual ~QuartcStreamInterface() {} | 19 virtual ~QuartcStreamInterface() {} |
| 20 | 20 |
| 21 // The QUIC stream ID. | 21 // The QUIC stream ID. |
| 22 virtual uint32_t stream_id() = 0; | 22 virtual uint32_t stream_id() = 0; |
| 23 | 23 |
| 24 // The amount of data buffered by the QuicConnection. | 24 // The amount of data buffered by the QuicConnection. |
| 25 virtual uint64_t buffered_amount() = 0; | 25 virtual uint64_t buffered_amount() = 0; |
| 26 | 26 |
| 27 // Return true if the FIN has been sent. Used by the outgoing streams to | 27 // Return true if the FIN has been sent. Used by the outgoing streams to |
| 28 // determine if all the data has been sent | 28 // determine if all the data has been sent |
| 29 virtual bool fin_sent() = 0; | 29 virtual bool fin_sent() = 0; |
| 30 | 30 |
| 31 virtual int stream_error() = 0; |
| 32 |
| 33 virtual int connection_error() = 0; |
| 34 |
| 31 struct WriteParameters { | 35 struct WriteParameters { |
| 32 WriteParameters() : fin(false) {} | 36 WriteParameters() : fin(false) {} |
| 33 // |fin| is set to be true when there is no more data need to be send | 37 // |fin| is set to be true when there is no more data need to be send |
| 34 // through a particular stream. The receiving side will used it to determine | 38 // through a particular stream. The receiving side will used it to determine |
| 35 // if the sender finish sending data. | 39 // if the sender finish sending data. |
| 36 bool fin; | 40 bool fin; |
| 37 }; | 41 }; |
| 38 | 42 |
| 39 // Sends data reliably and in-order, buffering if necessary until Close() is | 43 // Sends data reliably and in-order, buffering if necessary until Close() is |
| 40 // called. | 44 // called. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 54 | 58 |
| 55 // Called when the stream receives the date. | 59 // Called when the stream receives the date. |
| 56 virtual void OnReceived(QuartcStreamInterface* stream, | 60 virtual void OnReceived(QuartcStreamInterface* stream, |
| 57 const char* data, | 61 const char* data, |
| 58 size_t size) = 0; | 62 size_t size) = 0; |
| 59 | 63 |
| 60 // Called when the stream is closed, either locally or by the remote | 64 // Called when the stream is closed, either locally or by the remote |
| 61 // endpoint. | 65 // endpoint. |
| 62 // TODO(zhihuang) Creates a map from the integer error_code to WebRTC native | 66 // TODO(zhihuang) Creates a map from the integer error_code to WebRTC native |
| 63 // error code. | 67 // error code. |
| 64 virtual void OnClose(QuartcStreamInterface* stream, int error_code) = 0; | 68 virtual void OnClose(QuartcStreamInterface* stream) = 0; |
| 65 | 69 |
| 66 // Called when buffered_amount() decreases. | 70 // Called when buffered_amount() decreases. |
| 67 virtual void OnBufferedAmountDecrease(QuartcStreamInterface* stream) = 0; | 71 virtual void OnBufferedAmountDecrease(QuartcStreamInterface* stream) = 0; |
| 68 }; | 72 }; |
| 69 | 73 |
| 70 // The |delegate| is not owned by QuartcStream. | 74 // The |delegate| is not owned by QuartcStream. |
| 71 virtual void SetDelegate(Delegate* delegate) = 0; | 75 virtual void SetDelegate(Delegate* delegate) = 0; |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 } // namespace net | 78 } // namespace net |
| 75 | 79 |
| 76 #endif // NET_QUIC_QUARTC_QUARTC_STREAM_INTERFACE_H_ | 80 #endif // NET_QUIC_QUARTC_QUARTC_STREAM_INTERFACE_H_ |
| OLD | NEW |