| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // 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. |
| 105 // Returns true if the highest offset did increase. | 105 // Returns true if the highest offset did increase. |
| 106 bool MaybeIncreaseHighestReceivedOffset(uint64 new_offset); | 106 bool MaybeIncreaseHighestReceivedOffset(uint64 new_offset); |
| 107 // Called when bytese are sent to the peer. | 107 // Called when bytese are sent to the peer. |
| 108 void AddBytesSent(uint64 bytes); | 108 void AddBytesSent(uint64 bytes); |
| 109 // 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. |
| 110 // 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 |
| 111 // WINDOW_UPDATE frame. | 111 // WINDOW_UPDATE frame. |
| 112 void AddBytesConsumed(uint64 bytes); | 112 void AddBytesConsumed(uint64 bytes); |
| 113 | 113 |
| 114 // Updates the flow controller's send window offset and calls OnCanWrite if |
| 115 // it was blocked before. |
| 116 void UpdateSendWindowOffset(uint64 new_offset); |
| 117 |
| 114 // Returns true if the stream is flow control blocked, by the stream flow | 118 // Returns true if the stream is flow control blocked, by the stream flow |
| 115 // control window or the connection flow control window. | 119 // control window or the connection flow control window. |
| 116 bool IsFlowControlBlocked(); | 120 bool IsFlowControlBlocked(); |
| 117 | 121 |
| 118 // Returns true if we have received either a RST or a FIN - either of which | 122 // Returns true if we have received either a RST or a FIN - either of which |
| 119 // gives a definitive number of bytes which the peer has sent. If this is not | 123 // gives a definitive number of bytes which the peer has sent. If this is not |
| 120 // true on stream termination the session must keep track of the stream's byte | 124 // true on stream termination the session must keep track of the stream's byte |
| 121 // offset until a definitive final value arrives. | 125 // offset until a definitive final value arrives. |
| 122 bool HasFinalReceivedByteOffset() const { | 126 bool HasFinalReceivedByteOffset() const { |
| 123 return fin_received_ || rst_received_; | 127 return fin_received_ || rst_received_; |
| 124 } | 128 } |
| 125 | 129 |
| 130 // Returns true if the stream has queued data waiting to write. |
| 131 bool HasBufferedData() const; |
| 132 |
| 126 protected: | 133 protected: |
| 127 // Sends as much of 'data' to the connection as the connection will consume, | 134 // Sends as much of 'data' to the connection as the connection will consume, |
| 128 // and then buffers any remaining data in queued_data_. | 135 // and then buffers any remaining data in queued_data_. |
| 129 void WriteOrBufferData( | 136 void WriteOrBufferData( |
| 130 base::StringPiece data, | 137 base::StringPiece data, |
| 131 bool fin, | 138 bool fin, |
| 132 QuicAckNotifier::DelegateInterface* ack_notifier_delegate); | 139 QuicAckNotifier::DelegateInterface* ack_notifier_delegate); |
| 133 | 140 |
| 134 // Sends as many bytes in the first |count| buffers of |iov| to the connection | 141 // Sends as many bytes in the first |count| buffers of |iov| to the connection |
| 135 // as the connection will consume. | 142 // as the connection will consume. |
| 136 // If |ack_notifier_delegate| is provided, then it will be notified once all | 143 // If |ack_notifier_delegate| is provided, then it will be notified once all |
| 137 // the ACKs for this write have been received. | 144 // the ACKs for this write have been received. |
| 138 // Returns the number of bytes consumed by the connection. | 145 // Returns the number of bytes consumed by the connection. |
| 139 QuicConsumedData WritevData( | 146 QuicConsumedData WritevData( |
| 140 const struct iovec* iov, | 147 const struct iovec* iov, |
| 141 int iov_count, | 148 int iov_count, |
| 142 bool fin, | 149 bool fin, |
| 143 QuicAckNotifier::DelegateInterface* ack_notifier_delegate); | 150 QuicAckNotifier::DelegateInterface* ack_notifier_delegate); |
| 144 | 151 |
| 145 // Helper method that returns FecProtection to use for writes to the session. | 152 // Helper method that returns FecProtection to use for writes to the session. |
| 146 FecProtection GetFecProtection(); | 153 FecProtection GetFecProtection(); |
| 147 | 154 |
| 148 // Close the read side of the socket. Further frames will not be accepted. | 155 // Close the read side of the socket. Further frames will not be accepted. |
| 149 virtual void CloseReadSide(); | 156 virtual void CloseReadSide(); |
| 150 | 157 |
| 151 // Close the write side of the socket. Further writes will fail. | 158 // Close the write side of the socket. Further writes will fail. |
| 152 void CloseWriteSide(); | 159 void CloseWriteSide(); |
| 153 | 160 |
| 154 bool HasBufferedData() const; | |
| 155 | |
| 156 bool fin_buffered() const { return fin_buffered_; } | 161 bool fin_buffered() const { return fin_buffered_; } |
| 157 | 162 |
| 158 const QuicSession* session() const { return session_; } | 163 const QuicSession* session() const { return session_; } |
| 159 QuicSession* session() { return session_; } | 164 QuicSession* session() { return session_; } |
| 160 | 165 |
| 161 const QuicStreamSequencer* sequencer() const { return &sequencer_; } | 166 const QuicStreamSequencer* sequencer() const { return &sequencer_; } |
| 162 QuicStreamSequencer* sequencer() { return &sequencer_; } | 167 QuicStreamSequencer* sequencer() { return &sequencer_; } |
| 163 | 168 |
| 164 // TODO(rjshade): Remove this method when removing QUIC_VERSION_19. | 169 // TODO(rjshade): Remove this method when removing QUIC_VERSION_19. |
| 165 void DisableFlowControl() { | 170 void DisableFlowControl() { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 // connection level flow control limits (but are stream level flow control | 248 // connection level flow control limits (but are stream level flow control |
| 244 // limited). | 249 // limited). |
| 245 bool stream_contributes_to_connection_flow_control_; | 250 bool stream_contributes_to_connection_flow_control_; |
| 246 | 251 |
| 247 DISALLOW_COPY_AND_ASSIGN(ReliableQuicStream); | 252 DISALLOW_COPY_AND_ASSIGN(ReliableQuicStream); |
| 248 }; | 253 }; |
| 249 | 254 |
| 250 } // namespace net | 255 } // namespace net |
| 251 | 256 |
| 252 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_ | 257 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_ |
| OLD | NEW |