OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_QUIC_CORE_QUIC_STREAM_SEND_BUFFER_H_ |
| 6 #define NET_QUIC_CORE_QUIC_STREAM_SEND_BUFFER_H_ |
| 7 |
| 8 #include <deque> |
| 9 |
| 10 #include "net/quic/core/frames/quic_stream_frame.h" |
| 11 #include "net/quic/core/quic_iovector.h" |
| 12 |
| 13 namespace net { |
| 14 |
| 15 class QuicDataWriter; |
| 16 |
| 17 // QuicStreamDataSlice comprises information of a piece of stream data. |
| 18 struct QuicStreamDataSlice { |
| 19 QuicStreamDataSlice(UniqueStreamBuffer data, |
| 20 QuicStreamOffset offset, |
| 21 QuicByteCount data_length); |
| 22 QuicStreamDataSlice(const QuicStreamDataSlice& other) = delete; |
| 23 QuicStreamDataSlice(QuicStreamDataSlice&& other) = delete; |
| 24 ~QuicStreamDataSlice(); |
| 25 |
| 26 // Stream data of this data slice. |
| 27 UniqueStreamBuffer data; |
| 28 // Location of this data slice in the stream. |
| 29 QuicStreamOffset offset; |
| 30 // Length of this data slice in bytes. |
| 31 QuicByteCount data_length; |
| 32 // Length of payload which is waiting for acks. |
| 33 QuicByteCount data_length_waiting_for_acks; |
| 34 }; |
| 35 |
| 36 // QuicStreamSendBuffer contains a list of QuicStreamDataSlices. New data slices |
| 37 // are added to the tail of the list. Data slices are removed from the head of |
| 38 // the list when they get fully acked. Stream data can be retrieved and acked |
| 39 // across slice boundaries. |
| 40 class QUIC_EXPORT_PRIVATE QuicStreamSendBuffer { |
| 41 public: |
| 42 explicit QuicStreamSendBuffer(QuicBufferAllocator* allocator); |
| 43 QuicStreamSendBuffer(const QuicStreamSendBuffer& other) = delete; |
| 44 QuicStreamSendBuffer(QuicStreamSendBuffer&& other) = delete; |
| 45 ~QuicStreamSendBuffer(); |
| 46 |
| 47 // Save |data_length| of data starts at |iov_offset| in |iov| to send buffer. |
| 48 void SaveStreamData(QuicIOVector iov, |
| 49 size_t iov_offset, |
| 50 QuicStreamOffset offset, |
| 51 QuicByteCount data_length); |
| 52 |
| 53 // Write |data_length| of data starts at |offset|. |
| 54 bool WriteStreamData(QuicStreamOffset offset, |
| 55 QuicByteCount data_length, |
| 56 QuicDataWriter* writer); |
| 57 |
| 58 // Called when data [offset, offset + data_length) is acked or removed as |
| 59 // stream is canceled. Removes fully acked data slice from send buffer. |
| 60 void RemoveStreamFrame(QuicStreamOffset offset, QuicByteCount data_length); |
| 61 |
| 62 // Number of data slices in send buffer. |
| 63 size_t size() const; |
| 64 |
| 65 private: |
| 66 std::deque<QuicStreamDataSlice> send_buffer_; |
| 67 |
| 68 QuicBufferAllocator* allocator_; |
| 69 }; |
| 70 |
| 71 } // namespace net |
| 72 |
| 73 #endif // NET_QUIC_CORE_QUIC_STREAM_SEND_BUFFER_H_ |
OLD | NEW |