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 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "net/quic/quic_frame_list.h" | 12 #include "net/quic/quic_frame_list.h" |
13 #include "net/quic/quic_protocol.h" | 13 #include "net/quic/quic_protocol.h" |
14 | 14 |
15 namespace net { | 15 namespace net { |
16 | 16 |
17 namespace test { | 17 namespace test { |
18 class QuicStreamSequencerPeer; | 18 class QuicStreamSequencerPeer; |
19 } // namespace test | 19 } // namespace test |
20 | 20 |
| 21 class QuicClock; |
21 class QuicSession; | 22 class QuicSession; |
22 class ReliableQuicStream; | 23 class ReliableQuicStream; |
23 | 24 |
24 // Buffers frames until we have something which can be passed | 25 // Buffers frames until we have something which can be passed |
25 // up to the next layer. | 26 // up to the next layer. |
26 class NET_EXPORT_PRIVATE QuicStreamSequencer { | 27 class NET_EXPORT_PRIVATE QuicStreamSequencer { |
27 public: | 28 public: |
28 explicit QuicStreamSequencer(ReliableQuicStream* quic_stream); | 29 QuicStreamSequencer(ReliableQuicStream* quic_stream, const QuicClock* clock); |
29 virtual ~QuicStreamSequencer(); | 30 virtual ~QuicStreamSequencer(); |
30 | 31 |
31 // If the frame is the next one we need in order to process in-order data, | 32 // If the frame is the next one we need in order to process in-order data, |
32 // ProcessData will be immediately called on the stream until all buffered | 33 // ProcessData will be immediately called on the stream until all buffered |
33 // data is processed or the stream fails to consume data. Any unconsumed | 34 // data is processed or the stream fails to consume data. Any unconsumed |
34 // data will be buffered. If the frame is not the next in line, it will be | 35 // data will be buffered. If the frame is not the next in line, it will be |
35 // buffered. | 36 // buffered. |
36 void OnStreamFrame(const QuicStreamFrame& frame); | 37 void OnStreamFrame(const QuicStreamFrame& frame); |
37 | 38 |
38 // Once data is buffered, it's up to the stream to read it when the stream | 39 // Once data is buffered, it's up to the stream to read it when the stream |
39 // can handle more data. The following three functions make that possible. | 40 // can handle more data. The following three functions make that possible. |
40 | 41 |
41 // Fills in up to iov_len iovecs with the next readable regions. Returns the | 42 // Fills in up to iov_len iovecs with the next readable regions. Returns the |
42 // number of iovs used. Non-destructive of the underlying data. | 43 // number of iovs used. Non-destructive of the underlying data. |
43 int GetReadableRegions(iovec* iov, size_t iov_len) const; | 44 int GetReadableRegions(iovec* iov, size_t iov_len) const; |
44 | 45 |
| 46 // Fills in one iovec with the next readable region. |timestamp| is |
| 47 // data arrived at the sequencer, and is used for measuring head of |
| 48 // line blocking (HOL). Returns false if there is no readable |
| 49 // region available. |
| 50 bool GetReadableRegion(iovec* iov, QuicTime* timestamp) const; |
| 51 |
45 // Copies the data into the iov_len buffers provided. Returns the number of | 52 // Copies the data into the iov_len buffers provided. Returns the number of |
46 // bytes read. Any buffered data no longer in use will be released. | 53 // bytes read. Any buffered data no longer in use will be released. |
47 // TODO(rch): remove this method and instead implement it as a helper method | 54 // TODO(rch): remove this method and instead implement it as a helper method |
48 // based on GetReadableRegions and MarkConsumed. | 55 // based on GetReadableRegions and MarkConsumed. |
49 int Readv(const struct iovec* iov, size_t iov_len); | 56 int Readv(const struct iovec* iov, size_t iov_len); |
50 | 57 |
51 // Consumes |num_bytes| data. Used in conjunction with |GetReadableRegions| | 58 // Consumes |num_bytes| data. Used in conjunction with |GetReadableRegions| |
52 // to do zero-copy reads. | 59 // to do zero-copy reads. |
53 void MarkConsumed(size_t num_bytes); | 60 void MarkConsumed(size_t num_bytes); |
54 | 61 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // Count of the number of frames received. | 121 // Count of the number of frames received. |
115 int num_frames_received_; | 122 int num_frames_received_; |
116 | 123 |
117 // Count of the number of duplicate frames received. | 124 // Count of the number of duplicate frames received. |
118 int num_duplicate_frames_received_; | 125 int num_duplicate_frames_received_; |
119 | 126 |
120 // Count of the number of frames received before all previous frames were | 127 // Count of the number of frames received before all previous frames were |
121 // received. | 128 // received. |
122 int num_early_frames_received_; | 129 int num_early_frames_received_; |
123 | 130 |
| 131 // Not owned. |
| 132 const QuicClock* clock_; |
| 133 |
124 DISALLOW_COPY_AND_ASSIGN(QuicStreamSequencer); | 134 DISALLOW_COPY_AND_ASSIGN(QuicStreamSequencer); |
125 }; | 135 }; |
126 | 136 |
127 } // namespace net | 137 } // namespace net |
128 | 138 |
129 #endif // NET_QUIC_QUIC_STREAM_SEQUENCER_H_ | 139 #endif // NET_QUIC_QUIC_STREAM_SEQUENCER_H_ |
OLD | NEW |