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 // The base class for client/server reliable streams. | 5 // The base class for client/server reliable streams. |
6 | 6 |
7 #ifndef NET_QUIC_RELIABLE_QUIC_STREAM_H_ | 7 #ifndef NET_QUIC_RELIABLE_QUIC_STREAM_H_ |
8 #define NET_QUIC_RELIABLE_QUIC_STREAM_H_ | 8 #define NET_QUIC_RELIABLE_QUIC_STREAM_H_ |
9 | 9 |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 QuicRstStreamErrorCode stream_error() const { return stream_error_; } | 79 QuicRstStreamErrorCode stream_error() const { return stream_error_; } |
80 QuicErrorCode connection_error() const { return connection_error_; } | 80 QuicErrorCode connection_error() const { return connection_error_; } |
81 | 81 |
82 bool read_side_closed() const { return read_side_closed_; } | 82 bool read_side_closed() const { return read_side_closed_; } |
83 bool write_side_closed() const { return write_side_closed_; } | 83 bool write_side_closed() const { return write_side_closed_; } |
84 | 84 |
85 uint64 stream_bytes_read() const { return stream_bytes_read_; } | 85 uint64 stream_bytes_read() const { return stream_bytes_read_; } |
86 uint64 stream_bytes_written() const { return stream_bytes_written_; } | 86 uint64 stream_bytes_written() const { return stream_bytes_written_; } |
87 | 87 |
88 QuicVersion version() const; | |
89 | |
90 void set_fin_sent(bool fin_sent) { fin_sent_ = fin_sent; } | 88 void set_fin_sent(bool fin_sent) { fin_sent_ = fin_sent; } |
91 void set_rst_sent(bool rst_sent) { rst_sent_ = rst_sent; } | 89 void set_rst_sent(bool rst_sent) { rst_sent_ = rst_sent; } |
92 | 90 |
93 void set_fec_policy(FecPolicy fec_policy) { fec_policy_ = fec_policy; } | 91 void set_fec_policy(FecPolicy fec_policy) { fec_policy_ = fec_policy; } |
94 FecPolicy fec_policy() const { return fec_policy_; } | 92 FecPolicy fec_policy() const { return fec_policy_; } |
95 | 93 |
96 // Adjust our flow control windows according to new offset in |frame|. | 94 // Adjust our flow control windows according to new offset in |frame|. |
97 virtual void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame); | 95 virtual void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame); |
98 | 96 |
| 97 // Used in Chrome. |
99 int num_frames_received() const; | 98 int num_frames_received() const; |
100 int num_early_frames_received() const; | 99 int num_early_frames_received() const; |
101 int num_duplicate_frames_received() const; | 100 int num_duplicate_frames_received() const; |
102 | 101 |
103 QuicFlowController* flow_controller() { return &flow_controller_; } | 102 QuicFlowController* flow_controller() { return &flow_controller_; } |
104 | 103 |
105 // Called when we see a frame which could increase the highest offset. | 104 // Called when we see a frame which could increase the highest offset. |
106 // Returns true if the highest offset did increase. | 105 // Returns true if the highest offset did increase. |
107 bool MaybeIncreaseHighestReceivedOffset(QuicStreamOffset new_offset); | 106 bool MaybeIncreaseHighestReceivedOffset(QuicStreamOffset new_offset); |
108 // Called when bytese are sent to the peer. | 107 // Called when bytese are sent to the peer. |
109 void AddBytesSent(QuicByteCount bytes); | 108 void AddBytesSent(QuicByteCount bytes); |
110 // Called by the stream sequencer as bytes are consumed from the buffer. | 109 // Called by the stream sequencer as bytes are consumed from the buffer. |
111 // If our receive window has dropped below the threshold, then send a | 110 // If our receive window has dropped below the threshold, then send a |
112 // WINDOW_UPDATE frame. | 111 // WINDOW_UPDATE frame. |
113 void AddBytesConsumed(QuicByteCount bytes); | 112 void AddBytesConsumed(QuicByteCount bytes); |
114 | 113 |
115 // Updates the flow controller's send window offset and calls OnCanWrite if | 114 // Updates the flow controller's send window offset and calls OnCanWrite if |
116 // it was blocked before. | 115 // it was blocked before. |
117 void UpdateSendWindowOffset(QuicStreamOffset new_offset); | 116 void UpdateSendWindowOffset(QuicStreamOffset new_offset); |
118 | 117 |
119 // Returns true if the stream is flow control blocked, by the stream flow | |
120 // control window or the connection flow control window. | |
121 bool IsFlowControlBlocked(); | |
122 | |
123 // Returns true if we have received either a RST or a FIN - either of which | 118 // Returns true if we have received either a RST or a FIN - either of which |
124 // gives a definitive number of bytes which the peer has sent. If this is not | 119 // gives a definitive number of bytes which the peer has sent. If this is not |
125 // true on stream termination the session must keep track of the stream's byte | 120 // true on stream termination the session must keep track of the stream's byte |
126 // offset until a definitive final value arrives. | 121 // offset until a definitive final value arrives. |
127 bool HasFinalReceivedByteOffset() const { | 122 bool HasFinalReceivedByteOffset() const { |
128 return fin_received_ || rst_received_; | 123 return fin_received_ || rst_received_; |
129 } | 124 } |
130 | 125 |
131 // Returns true if the stream has queued data waiting to write. | 126 // Returns true if the stream has queued data waiting to write. |
132 bool HasBufferedData() const; | 127 bool HasBufferedData() const; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 // connection level flow control limits (but are stream level flow control | 239 // connection level flow control limits (but are stream level flow control |
245 // limited). | 240 // limited). |
246 bool stream_contributes_to_connection_flow_control_; | 241 bool stream_contributes_to_connection_flow_control_; |
247 | 242 |
248 DISALLOW_COPY_AND_ASSIGN(ReliableQuicStream); | 243 DISALLOW_COPY_AND_ASSIGN(ReliableQuicStream); |
249 }; | 244 }; |
250 | 245 |
251 } // namespace net | 246 } // namespace net |
252 | 247 |
253 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_ | 248 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_ |
OLD | NEW |