OLD | NEW |
(Empty) | |
| 1 #ifndef NET_QUIC_QUIC_STREAM_SEQUENCER_BUFFER_INTERFACE_H_ |
| 2 #define NET_QUIC_QUIC_STREAM_SEQUENCER_BUFFER_INTERFACE_H_ |
| 3 |
| 4 #include "net/quic/quic_frame_list.h" |
| 5 #include "net/quic/quic_protocol.h" |
| 6 |
| 7 using base::StringPiece; |
| 8 |
| 9 namespace net { |
| 10 |
| 11 // The QuicStreamSequencer uses an implementation of this interface to store |
| 12 // received data. |
| 13 class NET_EXPORT_PRIVATE QuicStreamSequencerBufferInterface { |
| 14 public: |
| 15 virtual ~QuicStreamSequencerBufferInterface() {} |
| 16 |
| 17 // Free the space used to buffer data. |
| 18 virtual void Clear() = 0; |
| 19 |
| 20 // Returns true if there is nothing to read in this buffer. |
| 21 virtual bool Empty() const = 0; |
| 22 |
| 23 // Called to buffer new data received for this stream. If the data was |
| 24 // successfully buffered, returns QUIC_NO_ERROR and stores the number of |
| 25 // bytes buffered in |bytes_buffered|. Returns an error otherwise. |
| 26 // |timestamp| is the time the data arrived. |
| 27 virtual QuicErrorCode OnStreamData(QuicStreamOffset offset, |
| 28 StringPiece data, |
| 29 QuicTime timestamp, |
| 30 size_t* bytes_buffered) = 0; |
| 31 |
| 32 // Reads from this buffer into given iovec array, up to number of iov_len |
| 33 // iovec objects and returns the number of bytes read. |
| 34 virtual size_t Readv(const struct iovec* iov, size_t iov_len) = 0; |
| 35 |
| 36 // Returns the readable region of valid data in iovec format. The readable |
| 37 // region is the buffer region where there is valid data not yet read by |
| 38 // client. |
| 39 // Returns the number of iovec entries in |iov| which were populated. |
| 40 // If the region is empty, one iovec entry with 0 length |
| 41 // is returned, and the function returns 0. If there are more readable |
| 42 // regions than iov_size, the function only processes the first |
| 43 // iov_size of them. |
| 44 virtual int GetReadableRegions(struct iovec* iov, int iov_len) const = 0; |
| 45 |
| 46 // Fills in one iovec with data which all arrived at the same time from the |
| 47 // next readable region. |
| 48 // Populates |timestamp| with the time that this data arrived. |
| 49 // Returns false if there is no readable region available. |
| 50 virtual bool GetReadableRegion(iovec* iov, QuicTime* timestamp) const = 0; |
| 51 |
| 52 // Called after GetReadableRegions() to free up |bytes_used| space if these |
| 53 // bytes are processed. |
| 54 // Pre-requisite: bytes_used <= available bytes to read. |
| 55 virtual bool MarkConsumed(size_t bytes_used) = 0; |
| 56 |
| 57 // Deletes and records as consumed any buffered data and clear the buffer. |
| 58 // (To be called only after sequencer's StopReading has been called.) |
| 59 virtual size_t FlushBufferedFrames() = 0; |
| 60 |
| 61 // Whether there are bytes can be read out. |
| 62 virtual bool HasBytesToRead() const = 0; |
| 63 |
| 64 // Count how many bytes have been consumed (read out of buffer). |
| 65 virtual QuicStreamOffset BytesConsumed() const = 0; |
| 66 |
| 67 // Count how many bytes are in buffer at this moment. |
| 68 virtual size_t BytesBuffered() const = 0; |
| 69 }; |
| 70 |
| 71 } // namespace net |
| 72 |
| 73 #endif // NET_QUIC_QUIC_STREAM_SEQUENCER_BUFFER_INTERFACE_H_ |
OLD | NEW |