| 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 // A QuicSession, which demuxes a single connection to individual streams. | 5 // A QuicSession, which demuxes a single connection to individual streams. |
| 6 | 6 |
| 7 #ifndef NET_QUIC_QUIC_SESSION_H_ | 7 #ifndef NET_QUIC_QUIC_SESSION_H_ |
| 8 #define NET_QUIC_QUIC_SESSION_H_ | 8 #define NET_QUIC_QUIC_SESSION_H_ |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 // Mark a stream as draining. | 222 // Mark a stream as draining. |
| 223 virtual void StreamDraining(QuicStreamId id); | 223 virtual void StreamDraining(QuicStreamId id); |
| 224 | 224 |
| 225 // Returns true if this stream should yield writes to another blocked stream. | 225 // Returns true if this stream should yield writes to another blocked stream. |
| 226 bool ShouldYield(QuicStreamId stream_id); | 226 bool ShouldYield(QuicStreamId stream_id); |
| 227 | 227 |
| 228 protected: | 228 protected: |
| 229 typedef std::unordered_map<QuicStreamId, ReliableQuicStream*> StreamMap; | 229 typedef std::unordered_map<QuicStreamId, ReliableQuicStream*> StreamMap; |
| 230 | 230 |
| 231 // Creates a new stream, owned by the caller, to handle a peer-initiated | 231 // Creates a new stream to handle a peer-initiated stream. |
| 232 // stream. Returns nullptr and does error handling if the stream can not be | 232 // Caller does not own the returned stream. |
| 233 // created. | 233 // Returns nullptr and does error handling if the stream can not be created. |
| 234 virtual ReliableQuicStream* CreateIncomingDynamicStream(QuicStreamId id) = 0; | 234 virtual ReliableQuicStream* CreateIncomingDynamicStream(QuicStreamId id) = 0; |
| 235 | 235 |
| 236 // Create a new stream, owned by the caller, to handle a locally-initiated | 236 // Create a new stream to handle a locally-initiated stream. |
| 237 // stream. Returns nullptr if max streams have already been opened. | 237 // Caller does not own the returned stream. |
| 238 // Returns nullptr if max streams have already been opened. |
| 238 virtual ReliableQuicStream* CreateOutgoingDynamicStream( | 239 virtual ReliableQuicStream* CreateOutgoingDynamicStream( |
| 239 SpdyPriority priority) = 0; | 240 SpdyPriority priority) = 0; |
| 240 | 241 |
| 241 // Return the reserved crypto stream. | 242 // Return the reserved crypto stream. |
| 242 virtual QuicCryptoStream* GetCryptoStream() = 0; | 243 virtual QuicCryptoStream* GetCryptoStream() = 0; |
| 243 | 244 |
| 244 // Adds |stream| to the dynamic stream map. | 245 // Adds |stream| to the dynamic stream map. |
| 245 // Takes ownership of |stream|. | 246 // Takes ownership of |stream|. |
| 246 virtual void ActivateStream(ReliableQuicStream* stream); | 247 virtual void ActivateStream(ReliableQuicStream* stream); |
| 247 | 248 |
| 248 // Returns the stream ID for a new outgoing stream, and increments the | 249 // Returns the stream ID for a new outgoing stream, and increments the |
| 249 // underlying counter. | 250 // underlying counter. |
| 250 QuicStreamId GetNextOutgoingStreamId(); | 251 QuicStreamId GetNextOutgoingStreamId(); |
| 251 | 252 |
| 252 // Returns existing stream with id = |stream_id|. If no such stream exists, | 253 // Returns existing stream with id = |stream_id|. If no such stream exists, |
| 253 // and |stream_id| is a peer-created id, then a new stream is created and | 254 // and |stream_id| is a peer-created id, then a new stream is created and |
| 254 // returned. However if |stream_id| is a locally-created id and no such stream | 255 // returned. However if |stream_id| is a locally-created id and no such stream |
| 255 // exists, the connection is closed. | 256 // exists, the connection is closed. |
| 257 // Caller does not own the returned stream. |
| 256 ReliableQuicStream* GetOrCreateDynamicStream(QuicStreamId stream_id); | 258 ReliableQuicStream* GetOrCreateDynamicStream(QuicStreamId stream_id); |
| 257 | 259 |
| 258 // Performs the work required to close |stream_id|. If |locally_reset| | 260 // Performs the work required to close |stream_id|. If |locally_reset| |
| 259 // then the stream has been reset by this endpoint, not by the peer. | 261 // then the stream has been reset by this endpoint, not by the peer. |
| 260 virtual void CloseStreamInner(QuicStreamId stream_id, bool locally_reset); | 262 virtual void CloseStreamInner(QuicStreamId stream_id, bool locally_reset); |
| 261 | 263 |
| 262 // When a stream is closed locally, it may not yet know how many bytes the | 264 // When a stream is closed locally, it may not yet know how many bytes the |
| 263 // peer sent on that stream. | 265 // peer sent on that stream. |
| 264 // When this data arrives (via stream frame w. FIN, or RST) this method | 266 // When this data arrives (via stream frame w. FIN, or RST) this method |
| 265 // is called, and correctly updates the connection level flow controller. | 267 // is called, and correctly updates the connection level flow controller. |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 // The stream id which was last popped in OnCanWrite, or 0, if not under the | 407 // The stream id which was last popped in OnCanWrite, or 0, if not under the |
| 406 // call stack of OnCanWrite. | 408 // call stack of OnCanWrite. |
| 407 QuicStreamId currently_writing_stream_id_; | 409 QuicStreamId currently_writing_stream_id_; |
| 408 | 410 |
| 409 DISALLOW_COPY_AND_ASSIGN(QuicSession); | 411 DISALLOW_COPY_AND_ASSIGN(QuicSession); |
| 410 }; | 412 }; |
| 411 | 413 |
| 412 } // namespace net | 414 } // namespace net |
| 413 | 415 |
| 414 #endif // NET_QUIC_QUIC_SESSION_H_ | 416 #endif // NET_QUIC_QUIC_SESSION_H_ |
| OLD | NEW |