| 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> |
| 11 | 11 |
| 12 #include <map> | 12 #include <map> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <unordered_map> |
| 15 #include <unordered_set> |
| 14 #include <vector> | 16 #include <vector> |
| 15 | 17 |
| 16 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 17 #include "base/containers/hash_tables.h" | 19 #include "base/containers/hash_tables.h" |
| 18 #include "base/macros.h" | 20 #include "base/macros.h" |
| 19 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/strings/string_piece.h" | 22 #include "base/strings/string_piece.h" |
| 21 #include "net/base/ip_endpoint.h" | 23 #include "net/base/ip_endpoint.h" |
| 22 #include "net/quic/quic_connection.h" | 24 #include "net/quic/quic_connection.h" |
| 23 #include "net/quic/quic_crypto_stream.h" | 25 #include "net/quic/quic_crypto_stream.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 // Mark a stream as draining. | 220 // Mark a stream as draining. |
| 219 virtual void StreamDraining(QuicStreamId id); | 221 virtual void StreamDraining(QuicStreamId id); |
| 220 | 222 |
| 221 // Close the connection, if it is not already closed. | 223 // Close the connection, if it is not already closed. |
| 222 void CloseConnectionWithDetails(QuicErrorCode error, const char* details); | 224 void CloseConnectionWithDetails(QuicErrorCode error, const char* details); |
| 223 | 225 |
| 224 // Returns true if this stream should yield writes to another blocked stream. | 226 // Returns true if this stream should yield writes to another blocked stream. |
| 225 bool ShouldYield(QuicStreamId stream_id); | 227 bool ShouldYield(QuicStreamId stream_id); |
| 226 | 228 |
| 227 protected: | 229 protected: |
| 228 typedef base::hash_map<QuicStreamId, ReliableQuicStream*> StreamMap; | 230 typedef std::unordered_map<QuicStreamId, ReliableQuicStream*> StreamMap; |
| 229 | 231 |
| 230 // Creates a new stream, owned by the caller, to handle a peer-initiated | 232 // Creates a new stream, owned by the caller, to handle a peer-initiated |
| 231 // stream. Returns nullptr and does error handling if the stream can not be | 233 // stream. Returns nullptr and does error handling if the stream can not be |
| 232 // created. | 234 // created. |
| 233 virtual ReliableQuicStream* CreateIncomingDynamicStream(QuicStreamId id) = 0; | 235 virtual ReliableQuicStream* CreateIncomingDynamicStream(QuicStreamId id) = 0; |
| 234 | 236 |
| 235 // Create a new stream, owned by the caller, to handle a locally-initiated | 237 // Create a new stream, owned by the caller, to handle a locally-initiated |
| 236 // stream. Returns nullptr if max streams have already been opened. | 238 // stream. Returns nullptr if max streams have already been opened. |
| 237 virtual ReliableQuicStream* CreateOutgoingDynamicStream( | 239 virtual ReliableQuicStream* CreateOutgoingDynamicStream( |
| 238 SpdyPriority priority) = 0; | 240 SpdyPriority priority) = 0; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 StreamMap static_stream_map_; | 368 StreamMap static_stream_map_; |
| 367 | 369 |
| 368 // Map from StreamId to pointers to streams. Owns the streams. | 370 // Map from StreamId to pointers to streams. Owns the streams. |
| 369 StreamMap dynamic_stream_map_; | 371 StreamMap dynamic_stream_map_; |
| 370 | 372 |
| 371 // The ID to use for the next outgoing stream. | 373 // The ID to use for the next outgoing stream. |
| 372 QuicStreamId next_outgoing_stream_id_; | 374 QuicStreamId next_outgoing_stream_id_; |
| 373 | 375 |
| 374 // Set of stream ids that are less than the largest stream id that has been | 376 // Set of stream ids that are less than the largest stream id that has been |
| 375 // received, but are nonetheless available to be created. | 377 // received, but are nonetheless available to be created. |
| 376 base::hash_set<QuicStreamId> available_streams_; | 378 std::unordered_set<QuicStreamId> available_streams_; |
| 377 | 379 |
| 378 // Set of stream ids that are "draining" -- a FIN has been sent and received, | 380 // Set of stream ids that are "draining" -- a FIN has been sent and received, |
| 379 // but the stream object still exists because not all the received data has | 381 // but the stream object still exists because not all the received data has |
| 380 // been consumed. | 382 // been consumed. |
| 381 base::hash_set<QuicStreamId> draining_streams_; | 383 std::unordered_set<QuicStreamId> draining_streams_; |
| 382 | 384 |
| 383 // A list of streams which need to write more data. | 385 // A list of streams which need to write more data. |
| 384 QuicWriteBlockedList write_blocked_streams_; | 386 QuicWriteBlockedList write_blocked_streams_; |
| 385 | 387 |
| 386 QuicStreamId largest_peer_created_stream_id_; | 388 QuicStreamId largest_peer_created_stream_id_; |
| 387 | 389 |
| 388 // A counter for peer initiated streams which are in the dynamic_stream_map_. | 390 // A counter for peer initiated streams which are in the dynamic_stream_map_. |
| 389 size_t num_dynamic_incoming_streams_; | 391 size_t num_dynamic_incoming_streams_; |
| 390 | 392 |
| 391 // A counter for peer initiated streams which are in the draining_streams_. | 393 // A counter for peer initiated streams which are in the draining_streams_. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 404 // The stream id which was last popped in OnCanWrite, or 0, if not under the | 406 // The stream id which was last popped in OnCanWrite, or 0, if not under the |
| 405 // call stack of OnCanWrite. | 407 // call stack of OnCanWrite. |
| 406 QuicStreamId currently_writing_stream_id_; | 408 QuicStreamId currently_writing_stream_id_; |
| 407 | 409 |
| 408 DISALLOW_COPY_AND_ASSIGN(QuicSession); | 410 DISALLOW_COPY_AND_ASSIGN(QuicSession); |
| 409 }; | 411 }; |
| 410 | 412 |
| 411 } // namespace net | 413 } // namespace net |
| 412 | 414 |
| 413 #endif // NET_QUIC_QUIC_SESSION_H_ | 415 #endif // NET_QUIC_QUIC_SESSION_H_ |
| OLD | NEW |