| 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 |
| 11 // of the stream. | 11 // of the stream. |
| 12 | 12 |
| 13 // The QuicStream object has a dependent QuicStreamSequencer object, | 13 // The QuicStream object has a dependent QuicStreamSequencer object, |
| 14 // which is given the stream frames as they arrive, and provides stream data in | 14 // which is given the stream frames as they arrive, and provides stream data in |
| 15 // order by invoking ProcessRawData(). | 15 // order by invoking ProcessRawData(). |
| 16 | 16 |
| 17 #ifndef NET_QUIC_CORE_QUIC_STREAM_H_ | 17 #ifndef NET_QUIC_CORE_QUIC_STREAM_H_ |
| 18 #define NET_QUIC_CORE_QUIC_STREAM_H_ | 18 #define NET_QUIC_CORE_QUIC_STREAM_H_ |
| 19 | 19 |
| 20 #include <stddef.h> | 20 #include <stddef.h> |
| 21 #include <stdint.h> | 21 #include <stdint.h> |
| 22 #include <sys/types.h> | 22 #include <sys/types.h> |
| 23 | 23 |
| 24 #include <list> | 24 #include <list> |
| 25 #include <string> | 25 #include <string> |
| 26 | 26 |
| 27 #include "base/macros.h" | 27 #include "base/macros.h" |
| 28 #include "base/memory/ref_counted.h" | |
| 29 #include "base/strings/string_piece.h" | 28 #include "base/strings/string_piece.h" |
| 30 #include "net/base/iovec.h" | 29 #include "net/base/iovec.h" |
| 31 #include "net/quic/core/quic_flow_controller.h" | 30 #include "net/quic/core/quic_flow_controller.h" |
| 32 #include "net/quic/core/quic_iovector.h" | 31 #include "net/quic/core/quic_iovector.h" |
| 33 #include "net/quic/core/quic_packets.h" | 32 #include "net/quic/core/quic_packets.h" |
| 34 #include "net/quic/core/quic_stream_sequencer.h" | 33 #include "net/quic/core/quic_stream_sequencer.h" |
| 35 #include "net/quic/core/quic_types.h" | 34 #include "net/quic/core/quic_types.h" |
| 36 #include "net/quic/platform/api/quic_export.h" | 35 #include "net/quic/platform/api/quic_export.h" |
| 36 #include "net/quic/platform/api/quic_reference_counted.h" |
| 37 | 37 |
| 38 namespace net { | 38 namespace net { |
| 39 | 39 |
| 40 namespace test { | 40 namespace test { |
| 41 class QuicStreamPeer; | 41 class QuicStreamPeer; |
| 42 } // namespace test | 42 } // namespace test |
| 43 | 43 |
| 44 class QuicSession; | 44 class QuicSession; |
| 45 | 45 |
| 46 class QUIC_EXPORT_PRIVATE QuicStream { | 46 class QUIC_EXPORT_PRIVATE QuicStream { |
| (...skipping 130 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 scoped_refptr<QuicAckListenerInterface> ack_listener); | 189 bool fin, |
| 190 QuicReferenceCountedPointer<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( | 197 QuicConsumedData WritevData( |
| 197 const struct iovec* iov, | 198 const struct iovec* iov, |
| 198 int iov_count, | 199 int iov_count, |
| 199 bool fin, | 200 bool fin, |
| 200 scoped_refptr<QuicAckListenerInterface> ack_listener); | 201 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener); |
| 201 | 202 |
| 202 // Allows override of the session level writev, for the force HOL | 203 // Allows override of the session level writev, for the force HOL |
| 203 // blocking experiment. | 204 // blocking experiment. |
| 204 virtual QuicConsumedData WritevDataInner( | 205 virtual QuicConsumedData WritevDataInner( |
| 205 QuicIOVector iov, | 206 QuicIOVector iov, |
| 206 QuicStreamOffset offset, | 207 QuicStreamOffset offset, |
| 207 bool fin, | 208 bool fin, |
| 208 scoped_refptr<QuicAckListenerInterface> ack_notifier_delegate); | 209 QuicReferenceCountedPointer<QuicAckListenerInterface> |
| 210 ack_notifier_delegate); |
| 209 | 211 |
| 210 // Close the write side of the socket. Further writes will fail. | 212 // Close the write side of the socket. Further writes will fail. |
| 211 // Can be called by the subclass or internally. | 213 // Can be called by the subclass or internally. |
| 212 // Does not send a FIN. May cause the stream to be closed. | 214 // Does not send a FIN. May cause the stream to be closed. |
| 213 virtual void CloseWriteSide(); | 215 virtual void CloseWriteSide(); |
| 214 | 216 |
| 215 bool fin_buffered() const { return fin_buffered_; } | 217 bool fin_buffered() const { return fin_buffered_; } |
| 216 | 218 |
| 217 const QuicSession* session() const { return session_; } | 219 const QuicSession* session() const { return session_; } |
| 218 QuicSession* session() { return session_; } | 220 QuicSession* session() { return session_; } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 229 friend class QuicStreamUtils; | 231 friend class QuicStreamUtils; |
| 230 | 232 |
| 231 // Close the read side of the socket. May cause the stream to be closed. | 233 // Close the read side of the socket. May cause the stream to be closed. |
| 232 // Subclasses and consumers should use StopReading to terminate reading early. | 234 // Subclasses and consumers should use StopReading to terminate reading early. |
| 233 void CloseReadSide(); | 235 void CloseReadSide(); |
| 234 | 236 |
| 235 // Subclasses and consumers should use reading_stopped. | 237 // Subclasses and consumers should use reading_stopped. |
| 236 bool read_side_closed() const { return read_side_closed_; } | 238 bool read_side_closed() const { return read_side_closed_; } |
| 237 | 239 |
| 238 struct PendingData { | 240 struct PendingData { |
| 239 PendingData(std::string data_in, | 241 PendingData( |
| 240 scoped_refptr<QuicAckListenerInterface> ack_listener_in); | 242 std::string data_in, |
| 243 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener_in); |
| 241 ~PendingData(); | 244 ~PendingData(); |
| 242 | 245 |
| 243 // Pending data to be written. | 246 // Pending data to be written. |
| 244 std::string data; | 247 std::string data; |
| 245 // Index of the first byte in data still to be written. | 248 // Index of the first byte in data still to be written. |
| 246 size_t offset; | 249 size_t offset; |
| 247 // AckListener that should be notified when the pending data is acked. | 250 // AckListener that should be notified when the pending data is acked. |
| 248 // Can be nullptr. | 251 // Can be nullptr. |
| 249 scoped_refptr<QuicAckListenerInterface> ack_listener; | 252 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener; |
| 250 }; | 253 }; |
| 251 | 254 |
| 252 // Calls MaybeSendBlocked on the stream's flow controller and the connection | 255 // Calls MaybeSendBlocked on the stream's flow controller and the connection |
| 253 // level flow controller. If the stream is flow control blocked by the | 256 // level flow controller. If the stream is flow control blocked by the |
| 254 // connection-level flow controller but not by the stream-level flow | 257 // connection-level flow controller but not by the stream-level flow |
| 255 // controller, marks this stream as connection-level write blocked. | 258 // controller, marks this stream as connection-level write blocked. |
| 256 void MaybeSendBlocked(); | 259 void MaybeSendBlocked(); |
| 257 | 260 |
| 258 std::list<PendingData> queued_data_; | 261 std::list<PendingData> queued_data_; |
| 259 // How many bytes are queued? | 262 // How many bytes are queued? |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 318 |
| 316 // For debugging only, used for busy loop check. | 319 // For debugging only, used for busy loop check. |
| 317 size_t busy_counter_; | 320 size_t busy_counter_; |
| 318 | 321 |
| 319 DISALLOW_COPY_AND_ASSIGN(QuicStream); | 322 DISALLOW_COPY_AND_ASSIGN(QuicStream); |
| 320 }; | 323 }; |
| 321 | 324 |
| 322 } // namespace net | 325 } // namespace net |
| 323 | 326 |
| 324 #endif // NET_QUIC_CORE_QUIC_STREAM_H_ | 327 #endif // NET_QUIC_CORE_QUIC_STREAM_H_ |
| OLD | NEW |