| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_QUIC_STREAM_SEQUENCER_H_ | 5 #ifndef NET_QUIC_QUIC_STREAM_SEQUENCER_H_ |
| 6 #define NET_QUIC_QUIC_STREAM_SEQUENCER_H_ | 6 #define NET_QUIC_QUIC_STREAM_SEQUENCER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 // If the frame is the next one we need in order to process in-order data, | 43 // If the frame is the next one we need in order to process in-order data, |
| 44 // ProcessData will be immediately called on the stream until all buffered | 44 // ProcessData will be immediately called on the stream until all buffered |
| 45 // data is processed or the stream fails to consume data. Any unconsumed | 45 // data is processed or the stream fails to consume data. Any unconsumed |
| 46 // data will be buffered. | 46 // data will be buffered. |
| 47 // | 47 // |
| 48 // If the frame is not the next in line, it will either be buffered, and | 48 // If the frame is not the next in line, it will either be buffered, and |
| 49 // this will return true, or it will be rejected and this will return false. | 49 // this will return true, or it will be rejected and this will return false. |
| 50 bool OnStreamFrame(const QuicStreamFrame& frame); | 50 bool OnStreamFrame(const QuicStreamFrame& frame); |
| 51 | 51 |
| 52 // Wait until we've seen 'offset' bytes, and then terminate the stream. | |
| 53 void CloseStreamAtOffset(QuicStreamOffset offset); | |
| 54 | |
| 55 // Once data is buffered, it's up to the stream to read it when the stream | 52 // Once data is buffered, it's up to the stream to read it when the stream |
| 56 // can handle more data. The following three functions make that possible. | 53 // can handle more data. The following three functions make that possible. |
| 57 | 54 |
| 58 // Fills in up to iov_len iovecs with the next readable regions. Returns the | 55 // Fills in up to iov_len iovecs with the next readable regions. Returns the |
| 59 // number of iovs used. Non-destructive of the underlying data. | 56 // number of iovs used. Non-destructive of the underlying data. |
| 60 int GetReadableRegions(iovec* iov, size_t iov_len); | 57 int GetReadableRegions(iovec* iov, size_t iov_len); |
| 61 | 58 |
| 62 // Copies the data into the iov_len buffers provided. Returns the number of | 59 // Copies the data into the iov_len buffers provided. Returns the number of |
| 63 // bytes read. Any buffered data no longer in use will be released. | 60 // bytes read. Any buffered data no longer in use will be released. |
| 64 int Readv(const struct iovec* iov, size_t iov_len); | 61 int Readv(const struct iovec* iov, size_t iov_len); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 79 // Calls |ProcessRawData| on |stream_| for each buffered frame that may | 76 // Calls |ProcessRawData| on |stream_| for each buffered frame that may |
| 80 // be processed. | 77 // be processed. |
| 81 void FlushBufferedFrames(); | 78 void FlushBufferedFrames(); |
| 82 | 79 |
| 83 private: | 80 private: |
| 84 friend class test::QuicStreamSequencerPeer; | 81 friend class test::QuicStreamSequencerPeer; |
| 85 | 82 |
| 86 // TODO(alyssar) use something better than strings. | 83 // TODO(alyssar) use something better than strings. |
| 87 typedef map<QuicStreamOffset, string> FrameMap; | 84 typedef map<QuicStreamOffset, string> FrameMap; |
| 88 | 85 |
| 86 // Wait until we've seen 'offset' bytes, and then terminate the stream. |
| 87 void CloseStreamAtOffset(QuicStreamOffset offset); |
| 88 |
| 89 bool MaybeCloseStream(); | 89 bool MaybeCloseStream(); |
| 90 | 90 |
| 91 ReliableQuicStream* stream_; // The stream which owns this sequencer. | 91 ReliableQuicStream* stream_; // The stream which owns this sequencer. |
| 92 QuicStreamOffset num_bytes_consumed_; // The last data consumed by the stream | 92 QuicStreamOffset num_bytes_consumed_; // The last data consumed by the stream |
| 93 FrameMap frames_; // sequence number -> frame | 93 FrameMap frames_; // sequence number -> frame |
| 94 size_t max_frame_memory_; // the maximum memory the sequencer can buffer. | 94 size_t max_frame_memory_; // the maximum memory the sequencer can buffer. |
| 95 // The offset, if any, we got a stream termination for. When this many bytes | 95 // The offset, if any, we got a stream termination for. When this many bytes |
| 96 // have been processed, the stream will be half closed. | 96 // have been processed, the stream will be half closed. |
| 97 QuicStreamOffset close_offset_; | 97 QuicStreamOffset close_offset_; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 } // namespace net | 100 } // namespace net |
| 101 | 101 |
| 102 #endif // NET_QUIC_QUIC_STREAM_SEQUENCER_H_ | 102 #endif // NET_QUIC_QUIC_STREAM_SEQUENCER_H_ |
| OLD | NEW |