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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // this behavior is not guaranteed for subclasses so callers should check the | 119 // this behavior is not guaranteed for subclasses so callers should check the |
120 // return value. | 120 // return value. |
121 virtual QuicConsumedData WriteData(base::StringPiece data, bool fin); | 121 virtual QuicConsumedData WriteData(base::StringPiece data, bool fin); |
122 | 122 |
123 // Close the read side of the socket. Further frames will not be accepted. | 123 // Close the read side of the socket. Further frames will not be accepted. |
124 virtual void CloseReadSide(); | 124 virtual void CloseReadSide(); |
125 | 125 |
126 // Close the write side of the socket. Further writes will fail. | 126 // Close the write side of the socket. Further writes will fail. |
127 void CloseWriteSide(); | 127 void CloseWriteSide(); |
128 | 128 |
| 129 bool fin_buffered() { return fin_buffered_; } |
| 130 |
129 QuicSession* session() { return session_; } | 131 QuicSession* session() { return session_; } |
130 | 132 |
131 // Sends as much of 'data' to the connection as the connection will consume, | 133 // Sends as much of 'data' to the connection as the connection will consume, |
132 // and then buffers any remaining data in queued_data_. | 134 // and then buffers any remaining data in queued_data_. |
133 // Returns (data.size(), true) as it always consumed all data: it returns for | 135 // Returns (data.size(), true) as it always consumed all data: it returns for |
134 // convenience to have the same return type as WriteDataInternal. | 136 // convenience to have the same return type as WriteDataInternal. |
135 QuicConsumedData WriteOrBuffer(base::StringPiece data, bool fin); | 137 QuicConsumedData WriteOrBuffer(base::StringPiece data, bool fin); |
136 | 138 |
137 // Sends as much of 'data' to the connection as the connection will consume. | 139 // Sends as much of 'data' to the connection as the connection will consume. |
138 // Returns the number of bytes consumed by the connection. | 140 // Returns the number of bytes consumed by the connection. |
139 QuicConsumedData WriteDataInternal(base::StringPiece data, bool fin); | 141 QuicConsumedData WriteDataInternal(base::StringPiece data, bool fin); |
140 | 142 |
141 private: | 143 private: |
142 friend class test::ReliableQuicStreamPeer; | 144 friend class test::ReliableQuicStreamPeer; |
143 friend class QuicStreamUtils; | 145 friend class QuicStreamUtils; |
144 | 146 |
145 std::list<string> queued_data_; | 147 std::list<string> queued_data_; |
146 | 148 |
147 QuicStreamSequencer sequencer_; | 149 QuicStreamSequencer sequencer_; |
148 QuicStreamId id_; | 150 QuicStreamId id_; |
149 QuicSession* session_; | 151 QuicSession* session_; |
150 // Optional visitor of this stream to be notified when the stream is closed. | 152 // Optional visitor of this stream to be notified when the stream is closed. |
151 Visitor* visitor_; | 153 Visitor* visitor_; |
152 // Bytes read and written refer to payload bytes only: they do not include | 154 // Bytes read and written refer to payload bytes only: they do not include |
153 // framing, encryption overhead etc. | 155 // framing, encryption overhead etc. |
154 uint64 stream_bytes_read_; | 156 uint64 stream_bytes_read_; |
155 uint64 stream_bytes_written_; | 157 uint64 stream_bytes_written_; |
156 // True if the headers have been completely decompresssed. | 158 // True if the headers have been completely decompresssed. |
157 bool headers_complete_; | 159 bool headers_decompressed_; |
158 // ID of the header block sent by the peer, once parsed. | 160 // ID of the header block sent by the peer, once parsed. |
159 QuicHeaderId headers_id_; | 161 QuicHeaderId headers_id_; |
160 // Buffer into which we write bytes from the headers_id_ | 162 // Buffer into which we write bytes from the headers_id_ |
161 // until it is fully parsed. | 163 // until it is fully parsed. |
162 string headers_id_buffer_; | 164 string headers_id_buffer_; |
163 // Contains a copy of the decompressed headers_ until they are consumed | 165 // Contains a copy of the decompressed headers_ until they are consumed |
164 // via ProcessData or Readv. | 166 // via ProcessData or Readv. |
165 string decompressed_headers_; | 167 string decompressed_headers_; |
166 | 168 |
167 // Stream error code received from a RstStreamFrame or error code sent by the | 169 // Stream error code received from a RstStreamFrame or error code sent by the |
168 // visitor or sequencer in the RstStreamFrame. | 170 // visitor or sequencer in the RstStreamFrame. |
169 QuicRstStreamErrorCode stream_error_; | 171 QuicRstStreamErrorCode stream_error_; |
170 // Connection error code due to which the stream was closed. |stream_error_| | 172 // Connection error code due to which the stream was closed. |stream_error_| |
171 // is set to |QUIC_STREAM_CONNECTION_ERROR| when this happens and consumers | 173 // is set to |QUIC_STREAM_CONNECTION_ERROR| when this happens and consumers |
172 // should check |connection_error_|. | 174 // should check |connection_error_|. |
173 QuicErrorCode connection_error_; | 175 QuicErrorCode connection_error_; |
174 | 176 |
175 // True if the read side is closed and further frames should be rejected. | 177 // True if the read side is closed and further frames should be rejected. |
176 bool read_side_closed_; | 178 bool read_side_closed_; |
177 // True if the write side is closed, and further writes should fail. | 179 // True if the write side is closed, and further writes should fail. |
178 bool write_side_closed_; | 180 bool write_side_closed_; |
179 | 181 |
180 bool fin_buffered_; | 182 bool fin_buffered_; |
181 bool fin_sent_; | 183 bool fin_sent_; |
182 }; | 184 }; |
183 | 185 |
184 } // namespace net | 186 } // namespace net |
185 | 187 |
186 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_ | 188 #endif // NET_QUIC_RELIABLE_QUIC_STREAM_H_ |
OLD | NEW |