| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 14 #include "net/quic/core/quic_protocol.h" | 14 #include "net/quic/core/quic_protocol.h" |
| 15 #include "net/quic/core/quic_stream_sequencer_buffer.h" | 15 #include "net/quic/core/quic_stream_sequencer_buffer.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 namespace test { | 19 namespace test { |
| 20 class QuicStreamSequencerPeer; | 20 class QuicStreamSequencerPeer; |
| 21 } // namespace test | 21 } // namespace test |
| 22 | 22 |
| 23 class QuicClock; | 23 class QuicClock; |
| 24 class QuicSession; | 24 class QuicSession; |
| 25 class ReliableQuicStream; | 25 class QuicStream; |
| 26 | 26 |
| 27 // Buffers frames until we have something which can be passed | 27 // Buffers frames until we have something which can be passed |
| 28 // up to the next layer. | 28 // up to the next layer. |
| 29 class NET_EXPORT_PRIVATE QuicStreamSequencer { | 29 class NET_EXPORT_PRIVATE QuicStreamSequencer { |
| 30 public: | 30 public: |
| 31 QuicStreamSequencer(ReliableQuicStream* quic_stream, const QuicClock* clock); | 31 QuicStreamSequencer(QuicStream* quic_stream, const QuicClock* clock); |
| 32 virtual ~QuicStreamSequencer(); | 32 virtual ~QuicStreamSequencer(); |
| 33 | 33 |
| 34 // If the frame is the next one we need in order to process in-order data, | 34 // If the frame is the next one we need in order to process in-order data, |
| 35 // ProcessData will be immediately called on the stream until all buffered | 35 // ProcessData will be immediately called on the stream until all buffered |
| 36 // data is processed or the stream fails to consume data. Any unconsumed | 36 // data is processed or the stream fails to consume data. Any unconsumed |
| 37 // data will be buffered. If the frame is not the next in line, it will be | 37 // data will be buffered. If the frame is not the next in line, it will be |
| 38 // buffered. | 38 // buffered. |
| 39 void OnStreamFrame(const QuicStreamFrame& frame); | 39 void OnStreamFrame(const QuicStreamFrame& frame); |
| 40 | 40 |
| 41 // Once data is buffered, it's up to the stream to read it when the stream | 41 // Once data is buffered, it's up to the stream to read it when the stream |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 void FlushBufferedFrames(); | 111 void FlushBufferedFrames(); |
| 112 | 112 |
| 113 // Wait until we've seen 'offset' bytes, and then terminate the stream. | 113 // Wait until we've seen 'offset' bytes, and then terminate the stream. |
| 114 void CloseStreamAtOffset(QuicStreamOffset offset); | 114 void CloseStreamAtOffset(QuicStreamOffset offset); |
| 115 | 115 |
| 116 // If we've received a FIN and have processed all remaining data, then inform | 116 // If we've received a FIN and have processed all remaining data, then inform |
| 117 // the stream of FIN, and clear buffers. | 117 // the stream of FIN, and clear buffers. |
| 118 bool MaybeCloseStream(); | 118 bool MaybeCloseStream(); |
| 119 | 119 |
| 120 // The stream which owns this sequencer. | 120 // The stream which owns this sequencer. |
| 121 ReliableQuicStream* stream_; | 121 QuicStream* stream_; |
| 122 | 122 |
| 123 // Stores received data in offset order. | 123 // Stores received data in offset order. |
| 124 QuicStreamSequencerBuffer buffered_frames_; | 124 QuicStreamSequencerBuffer buffered_frames_; |
| 125 | 125 |
| 126 // The offset, if any, we got a stream termination for. When this many bytes | 126 // The offset, if any, we got a stream termination for. When this many bytes |
| 127 // have been processed, the sequencer will be closed. | 127 // have been processed, the sequencer will be closed. |
| 128 QuicStreamOffset close_offset_; | 128 QuicStreamOffset close_offset_; |
| 129 | 129 |
| 130 // If true, the sequencer is blocked from passing data to the stream and will | 130 // If true, the sequencer is blocked from passing data to the stream and will |
| 131 // buffer all new incoming data until FlushBufferedFrames is called. | 131 // buffer all new incoming data until FlushBufferedFrames is called. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 142 | 142 |
| 143 // If true, all incoming data will be discarded. | 143 // If true, all incoming data will be discarded. |
| 144 bool ignore_read_data_; | 144 bool ignore_read_data_; |
| 145 | 145 |
| 146 DISALLOW_COPY_AND_ASSIGN(QuicStreamSequencer); | 146 DISALLOW_COPY_AND_ASSIGN(QuicStreamSequencer); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 } // namespace net | 149 } // namespace net |
| 150 | 150 |
| 151 #endif // NET_QUIC_QUIC_STREAM_SEQUENCER_H_ | 151 #endif // NET_QUIC_QUIC_STREAM_SEQUENCER_H_ |
| OLD | NEW |