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 QUIC streams. | 5 // The base class for client/server QUIC streams. |
6 | 6 |
7 // It does not contain the entire interface needed by an application to interact | 7 // It does not contain the entire interface needed by an application to interact |
8 // with a QUIC stream. Some parts of the interface must be obtained by | 8 // with a QUIC stream. Some parts of the interface must be obtained by |
9 // accessing the owning session object. A subclass of QuicStream | 9 // accessing the owning session object. A subclass of QuicStream |
10 // connects the object and the application that generates and consumes the data | 10 // connects the object and the application that generates and consumes the data |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 virtual void StopReading(); | 177 virtual void StopReading(); |
178 | 178 |
179 // Get peer IP of the lastest packet which connection is dealing/delt with. | 179 // Get peer IP of the lastest packet which connection is dealing/delt with. |
180 virtual const QuicSocketAddress& PeerAddressOfLatestPacket() const; | 180 virtual const QuicSocketAddress& PeerAddressOfLatestPacket() const; |
181 | 181 |
182 protected: | 182 protected: |
183 // Sends as much of 'data' to the connection as the connection will consume, | 183 // Sends as much of 'data' to the connection as the connection will consume, |
184 // and then buffers any remaining data in queued_data_. | 184 // and then buffers any remaining data in queued_data_. |
185 // If fin is true: if it is immediately passed on to the session, | 185 // If fin is true: if it is immediately passed on to the session, |
186 // write_side_closed() becomes true, otherwise fin_buffered_ becomes true. | 186 // write_side_closed() becomes true, otherwise fin_buffered_ becomes true. |
187 void WriteOrBufferData(base::StringPiece data, | 187 void WriteOrBufferData( |
188 bool fin, | 188 base::StringPiece data, |
189 QuicAckListenerInterface* ack_listener); | 189 bool fin, |
| 190 const scoped_refptr<QuicAckListenerInterface>& ack_listener); |
190 | 191 |
191 // Sends as many bytes in the first |count| buffers of |iov| to the connection | 192 // Sends as many bytes in the first |count| buffers of |iov| to the connection |
192 // as the connection will consume. | 193 // as the connection will consume. |
193 // If |ack_listener| is provided, then it will be notified once all | 194 // If |ack_listener| is provided, then it will be notified once all |
194 // the ACKs for this write have been received. | 195 // the ACKs for this write have been received. |
195 // Returns the number of bytes consumed by the connection. | 196 // Returns the number of bytes consumed by the connection. |
196 QuicConsumedData WritevData(const struct iovec* iov, | 197 QuicConsumedData WritevData( |
197 int iov_count, | 198 const struct iovec* iov, |
198 bool fin, | 199 int iov_count, |
199 QuicAckListenerInterface* ack_listener); | 200 bool fin, |
| 201 const scoped_refptr<QuicAckListenerInterface>& ack_listener); |
200 | 202 |
201 // Allows override of the session level writev, for the force HOL | 203 // Allows override of the session level writev, for the force HOL |
202 // blocking experiment. | 204 // blocking experiment. |
203 virtual QuicConsumedData WritevDataInner( | 205 virtual QuicConsumedData WritevDataInner( |
204 QuicIOVector iov, | 206 QuicIOVector iov, |
205 QuicStreamOffset offset, | 207 QuicStreamOffset offset, |
206 bool fin, | 208 bool fin, |
207 QuicAckListenerInterface* ack_notifier_delegate); | 209 const scoped_refptr<QuicAckListenerInterface>& ack_notifier_delegate); |
208 | 210 |
209 // Close the write side of the socket. Further writes will fail. | 211 // Close the write side of the socket. Further writes will fail. |
210 // Can be called by the subclass or internally. | 212 // Can be called by the subclass or internally. |
211 // Does not send a FIN. May cause the stream to be closed. | 213 // Does not send a FIN. May cause the stream to be closed. |
212 virtual void CloseWriteSide(); | 214 virtual void CloseWriteSide(); |
213 | 215 |
214 bool fin_buffered() const { return fin_buffered_; } | 216 bool fin_buffered() const { return fin_buffered_; } |
215 | 217 |
216 const QuicSession* session() const { return session_; } | 218 const QuicSession* session() const { return session_; } |
217 QuicSession* session() { return session_; } | 219 QuicSession* session() { return session_; } |
(...skipping 10 matching lines...) Expand all Loading... |
228 friend class QuicStreamUtils; | 230 friend class QuicStreamUtils; |
229 | 231 |
230 // Close the read side of the socket. May cause the stream to be closed. | 232 // Close the read side of the socket. May cause the stream to be closed. |
231 // Subclasses and consumers should use StopReading to terminate reading early. | 233 // Subclasses and consumers should use StopReading to terminate reading early. |
232 void CloseReadSide(); | 234 void CloseReadSide(); |
233 | 235 |
234 // Subclasses and consumers should use reading_stopped. | 236 // Subclasses and consumers should use reading_stopped. |
235 bool read_side_closed() const { return read_side_closed_; } | 237 bool read_side_closed() const { return read_side_closed_; } |
236 | 238 |
237 struct PendingData { | 239 struct PendingData { |
238 PendingData(std::string data_in, QuicAckListenerInterface* ack_listener_in); | 240 PendingData(std::string data_in, |
| 241 scoped_refptr<QuicAckListenerInterface> ack_listener_in); |
239 ~PendingData(); | 242 ~PendingData(); |
240 | 243 |
241 // Pending data to be written. | 244 // Pending data to be written. |
242 std::string data; | 245 std::string data; |
243 // Index of the first byte in data still to be written. | 246 // Index of the first byte in data still to be written. |
244 size_t offset; | 247 size_t offset; |
245 // AckListener that should be notified when the pending data is acked. | 248 // AckListener that should be notified when the pending data is acked. |
246 // Can be nullptr. | 249 // Can be nullptr. |
247 scoped_refptr<QuicAckListenerInterface> ack_listener; | 250 scoped_refptr<QuicAckListenerInterface> ack_listener; |
248 }; | 251 }; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 316 |
314 // For debugging only, used for busy loop check. | 317 // For debugging only, used for busy loop check. |
315 size_t busy_counter_; | 318 size_t busy_counter_; |
316 | 319 |
317 DISALLOW_COPY_AND_ASSIGN(QuicStream); | 320 DISALLOW_COPY_AND_ASSIGN(QuicStream); |
318 }; | 321 }; |
319 | 322 |
320 } // namespace net | 323 } // namespace net |
321 | 324 |
322 #endif // NET_QUIC_CORE_QUIC_STREAM_H_ | 325 #endif // NET_QUIC_CORE_QUIC_STREAM_H_ |
OLD | NEW |