| 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 <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
| 15 #include "net/base/linked_hash_map.h" | 15 #include "net/base/linked_hash_map.h" |
| 16 #include "net/quic/quic_connection.h" | 16 #include "net/quic/quic_connection.h" |
| 17 #include "net/quic/quic_crypto_stream.h" | 17 #include "net/quic/quic_crypto_stream.h" |
| 18 #include "net/quic/quic_data_stream.h" | 18 #include "net/quic/quic_data_stream.h" |
| 19 #include "net/quic/quic_headers_stream.h" | 19 #include "net/quic/quic_headers_stream.h" |
| 20 #include "net/quic/quic_packet_creator.h" | 20 #include "net/quic/quic_packet_creator.h" |
| 21 #include "net/quic/quic_protocol.h" | 21 #include "net/quic/quic_protocol.h" |
| 22 #include "net/quic/quic_spdy_compressor.h" | 22 #include "net/quic/quic_spdy_compressor.h" |
| 23 #include "net/quic/quic_spdy_decompressor.h" | 23 #include "net/quic/quic_spdy_decompressor.h" |
| 24 #include "net/quic/quic_write_blocked_list.h" |
| 24 #include "net/quic/reliable_quic_stream.h" | 25 #include "net/quic/reliable_quic_stream.h" |
| 25 #include "net/spdy/write_blocked_list.h" | |
| 26 | 26 |
| 27 namespace net { | 27 namespace net { |
| 28 | 28 |
| 29 class QuicCryptoStream; | 29 class QuicCryptoStream; |
| 30 class ReliableQuicStream; | 30 class ReliableQuicStream; |
| 31 class SSLInfo; | 31 class SSLInfo; |
| 32 class VisitorShim; | 32 class VisitorShim; |
| 33 | 33 |
| 34 namespace test { | 34 namespace test { |
| 35 class QuicSessionPeer; | 35 class QuicSessionPeer; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 58 const QuicConfig& config); | 58 const QuicConfig& config); |
| 59 | 59 |
| 60 virtual ~QuicSession(); | 60 virtual ~QuicSession(); |
| 61 | 61 |
| 62 // QuicConnectionVisitorInterface methods: | 62 // QuicConnectionVisitorInterface methods: |
| 63 virtual bool OnStreamFrames( | 63 virtual bool OnStreamFrames( |
| 64 const std::vector<QuicStreamFrame>& frames) OVERRIDE; | 64 const std::vector<QuicStreamFrame>& frames) OVERRIDE; |
| 65 virtual void OnRstStream(const QuicRstStreamFrame& frame) OVERRIDE; | 65 virtual void OnRstStream(const QuicRstStreamFrame& frame) OVERRIDE; |
| 66 virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE; | 66 virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE; |
| 67 virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE; | 67 virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE; |
| 68 virtual void OnWriteBlocked() OVERRIDE {} |
| 68 virtual void OnSuccessfulVersionNegotiation( | 69 virtual void OnSuccessfulVersionNegotiation( |
| 69 const QuicVersion& version) OVERRIDE {} | 70 const QuicVersion& version) OVERRIDE {} |
| 70 virtual void OnConfigNegotiated() OVERRIDE; | 71 virtual void OnConfigNegotiated() OVERRIDE; |
| 71 // Not needed for HTTP. | |
| 72 virtual bool OnCanWrite() OVERRIDE; | 72 virtual bool OnCanWrite() OVERRIDE; |
| 73 virtual bool HasPendingHandshake() const OVERRIDE; | 73 virtual bool HasPendingHandshake() const OVERRIDE; |
| 74 | 74 |
| 75 // Called by the headers stream when headers have been received for a stream. | 75 // Called by the headers stream when headers have been received for a stream. |
| 76 virtual void OnStreamHeaders(QuicStreamId stream_id, | 76 virtual void OnStreamHeaders(QuicStreamId stream_id, |
| 77 base::StringPiece headers_data); | 77 base::StringPiece headers_data); |
| 78 // Called by the headers stream when headers with a priority have been | 78 // Called by the headers stream when headers with a priority have been |
| 79 // received for this stream. This method will only be called for server | 79 // received for this stream. This method will only be called for server |
| 80 // streams. | 80 // streams. |
| 81 virtual void OnStreamHeadersPriority(QuicStreamId stream_id, | 81 virtual void OnStreamHeadersPriority(QuicStreamId stream_id, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 QuicPacketCreator::Options* options() { return connection()->options(); } | 164 QuicPacketCreator::Options* options() { return connection()->options(); } |
| 165 | 165 |
| 166 // Returns the number of currently open streams, including those which have | 166 // Returns the number of currently open streams, including those which have |
| 167 // been implicitly created. | 167 // been implicitly created. |
| 168 virtual size_t GetNumOpenStreams() const; | 168 virtual size_t GetNumOpenStreams() const; |
| 169 | 169 |
| 170 void MarkWriteBlocked(QuicStreamId id, QuicPriority priority); | 170 void MarkWriteBlocked(QuicStreamId id, QuicPriority priority); |
| 171 | 171 |
| 172 // Returns true if the session has data to be sent, either queued in the | 172 // Returns true if the session has data to be sent, either queued in the |
| 173 // connection, or in a write-blocked stream. | 173 // connection, or in a write-blocked stream. |
| 174 bool HasQueuedData() const; | 174 bool HasDataToWrite() const; |
| 175 | 175 |
| 176 // Marks that |stream_id| is blocked waiting to decompress the | 176 // Marks that |stream_id| is blocked waiting to decompress the |
| 177 // headers identified by |decompression_id|. | 177 // headers identified by |decompression_id|. |
| 178 void MarkDecompressionBlocked(QuicHeaderId decompression_id, | 178 void MarkDecompressionBlocked(QuicHeaderId decompression_id, |
| 179 QuicStreamId stream_id); | 179 QuicStreamId stream_id); |
| 180 | 180 |
| 181 bool goaway_received() const { | 181 bool goaway_received() const { |
| 182 return goaway_received_; | 182 return goaway_received_; |
| 183 } | 183 } |
| 184 | 184 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 296 |
| 297 // Map from StreamId to pointers to streams that are owned by the caller. | 297 // Map from StreamId to pointers to streams that are owned by the caller. |
| 298 DataStreamMap stream_map_; | 298 DataStreamMap stream_map_; |
| 299 QuicStreamId next_stream_id_; | 299 QuicStreamId next_stream_id_; |
| 300 | 300 |
| 301 // Set of stream ids that have been "implicitly created" by receipt | 301 // Set of stream ids that have been "implicitly created" by receipt |
| 302 // of a stream id larger than the next expected stream id. | 302 // of a stream id larger than the next expected stream id. |
| 303 base::hash_set<QuicStreamId> implicitly_created_streams_; | 303 base::hash_set<QuicStreamId> implicitly_created_streams_; |
| 304 | 304 |
| 305 // A list of streams which need to write more data. | 305 // A list of streams which need to write more data. |
| 306 WriteBlockedList<QuicStreamId> write_blocked_streams_; | 306 QuicWriteBlockedList write_blocked_streams_; |
| 307 | 307 |
| 308 // A map of headers waiting to be compressed, and the streams | 308 // A map of headers waiting to be compressed, and the streams |
| 309 // they are associated with. | 309 // they are associated with. |
| 310 map<uint32, QuicStreamId> decompression_blocked_streams_; | 310 map<uint32, QuicStreamId> decompression_blocked_streams_; |
| 311 | 311 |
| 312 QuicStreamId largest_peer_created_stream_id_; | 312 QuicStreamId largest_peer_created_stream_id_; |
| 313 | 313 |
| 314 // The latched error with which the connection was closed. | 314 // The latched error with which the connection was closed. |
| 315 QuicErrorCode error_; | 315 QuicErrorCode error_; |
| 316 | 316 |
| 317 // Whether a GoAway has been received. | 317 // Whether a GoAway has been received. |
| 318 bool goaway_received_; | 318 bool goaway_received_; |
| 319 // Whether a GoAway has been sent. | 319 // Whether a GoAway has been sent. |
| 320 bool goaway_sent_; | 320 bool goaway_sent_; |
| 321 | 321 |
| 322 // Indicate if there is pending data for the crypto stream. | 322 // Indicate if there is pending data for the crypto stream. |
| 323 bool has_pending_handshake_; | 323 bool has_pending_handshake_; |
| 324 | 324 |
| 325 DISALLOW_COPY_AND_ASSIGN(QuicSession); | 325 DISALLOW_COPY_AND_ASSIGN(QuicSession); |
| 326 }; | 326 }; |
| 327 | 327 |
| 328 } // namespace net | 328 } // namespace net |
| 329 | 329 |
| 330 #endif // NET_QUIC_QUIC_SESSION_H_ | 330 #endif // NET_QUIC_QUIC_SESSION_H_ |
| OLD | NEW |