| 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/hash_tables.h" | 13 #include "base/hash_tables.h" |
| 14 #include "net/base/ip_endpoint.h" | 14 #include "net/base/ip_endpoint.h" |
| 15 #include "net/quic/blocked_list.h" | 15 #include "net/quic/blocked_list.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_packet_creator.h" | 18 #include "net/quic/quic_packet_creator.h" |
| 19 #include "net/quic/quic_protocol.h" | 19 #include "net/quic/quic_protocol.h" |
| 20 #include "net/quic/quic_spdy_compressor.h" | |
| 21 #include "net/quic/quic_spdy_decompressor.h" | |
| 22 #include "net/quic/reliable_quic_stream.h" | 20 #include "net/quic/reliable_quic_stream.h" |
| 23 | 21 |
| 24 namespace net { | 22 namespace net { |
| 25 | 23 |
| 26 class QuicCryptoStream; | 24 class QuicCryptoStream; |
| 27 class ReliableQuicStream; | 25 class ReliableQuicStream; |
| 28 class VisitorShim; | 26 class VisitorShim; |
| 29 | 27 |
| 30 namespace test { | 28 namespace test { |
| 31 class QuicSessionPeer; | 29 class QuicSessionPeer; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 QuicGuid guid() const { return connection_->guid(); } | 113 QuicGuid guid() const { return connection_->guid(); } |
| 116 | 114 |
| 117 QuicPacketCreator::Options* options() { return connection()->options(); } | 115 QuicPacketCreator::Options* options() { return connection()->options(); } |
| 118 | 116 |
| 119 // Returns the number of currently open streams, including those which have | 117 // Returns the number of currently open streams, including those which have |
| 120 // been implicitly created. | 118 // been implicitly created. |
| 121 virtual size_t GetNumOpenStreams() const; | 119 virtual size_t GetNumOpenStreams() const; |
| 122 | 120 |
| 123 void MarkWriteBlocked(QuicStreamId id); | 121 void MarkWriteBlocked(QuicStreamId id); |
| 124 | 122 |
| 125 // Marks that |stream_id| is blocked waiting to decompress the | |
| 126 // headers identified by |decompression_id|. | |
| 127 void MarkDecompressionBlocked(QuicHeaderId decompression_id, | |
| 128 QuicStreamId stream_id); | |
| 129 | |
| 130 bool goaway_received() const { | 123 bool goaway_received() const { |
| 131 return goaway_received_; | 124 return goaway_received_; |
| 132 } | 125 } |
| 133 | 126 |
| 134 bool goaway_sent() const { | 127 bool goaway_sent() const { |
| 135 return goaway_sent_; | 128 return goaway_sent_; |
| 136 } | 129 } |
| 137 | 130 |
| 138 QuicSpdyDecompressor* decompressor() { return &decompressor_; } | |
| 139 QuicSpdyCompressor* compressor() { return &compressor_; } | |
| 140 | |
| 141 protected: | 131 protected: |
| 142 // Creates a new stream, owned by the caller, to handle a peer-initiated | 132 // Creates a new stream, owned by the caller, to handle a peer-initiated |
| 143 // stream. Returns NULL and does error handling if the stream can not be | 133 // stream. Returns NULL and does error handling if the stream can not be |
| 144 // created. | 134 // created. |
| 145 virtual ReliableQuicStream* CreateIncomingReliableStream(QuicStreamId id) = 0; | 135 virtual ReliableQuicStream* CreateIncomingReliableStream(QuicStreamId id) = 0; |
| 146 | 136 |
| 147 // Create a new stream, owned by the caller, to handle a locally-initiated | 137 // Create a new stream, owned by the caller, to handle a locally-initiated |
| 148 // stream. Returns NULL if max streams have already been opened. | 138 // stream. Returns NULL if max streams have already been opened. |
| 149 virtual ReliableQuicStream* CreateOutgoingReliableStream() = 0; | 139 virtual ReliableQuicStream* CreateOutgoingReliableStream() = 0; |
| 150 | 140 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 ReliableQuicStream* GetStream(const QuicStreamId stream_id); | 175 ReliableQuicStream* GetStream(const QuicStreamId stream_id); |
| 186 | 176 |
| 187 scoped_ptr<QuicConnection> connection_; | 177 scoped_ptr<QuicConnection> connection_; |
| 188 | 178 |
| 189 // A shim to stand between the connection and the session, to handle stream | 179 // A shim to stand between the connection and the session, to handle stream |
| 190 // deletions. | 180 // deletions. |
| 191 scoped_ptr<VisitorShim> visitor_shim_; | 181 scoped_ptr<VisitorShim> visitor_shim_; |
| 192 | 182 |
| 193 std::vector<ReliableQuicStream*> closed_streams_; | 183 std::vector<ReliableQuicStream*> closed_streams_; |
| 194 | 184 |
| 195 QuicSpdyDecompressor decompressor_; | |
| 196 QuicSpdyCompressor compressor_; | |
| 197 | |
| 198 // Returns the maximum number of streams this connection can open. | 185 // Returns the maximum number of streams this connection can open. |
| 199 const size_t max_open_streams_; | 186 const size_t max_open_streams_; |
| 200 | 187 |
| 201 // Map from StreamId to pointers to streams that are owned by the caller. | 188 // Map from StreamId to pointers to streams that are owned by the caller. |
| 202 ReliableStreamMap stream_map_; | 189 ReliableStreamMap stream_map_; |
| 203 QuicStreamId next_stream_id_; | 190 QuicStreamId next_stream_id_; |
| 204 bool is_server_; | 191 bool is_server_; |
| 205 | 192 |
| 206 // Set of stream ids that have been "implicitly created" by receipt | 193 // Set of stream ids that have been "implicitly created" by receipt |
| 207 // of a stream id larger than the next expected stream id. | 194 // of a stream id larger than the next expected stream id. |
| 208 base::hash_set<QuicStreamId> implicitly_created_streams_; | 195 base::hash_set<QuicStreamId> implicitly_created_streams_; |
| 209 | 196 |
| 210 // A list of streams which need to write more data. | 197 // A list of streams which need to write more data. |
| 211 BlockedList<QuicStreamId> write_blocked_streams_; | 198 BlockedList<QuicStreamId> write_blocked_streams_; |
| 212 | 199 |
| 213 // A map of headers waiting to be compressed, and the streams | |
| 214 // they are associated with. | |
| 215 map<uint32, QuicStreamId> decompression_blocked_streams_; | |
| 216 | |
| 217 QuicStreamId largest_peer_created_stream_id_; | 200 QuicStreamId largest_peer_created_stream_id_; |
| 218 | 201 |
| 219 // Whether a GoAway has been received. | 202 // Whether a GoAway has been received. |
| 220 bool goaway_received_; | 203 bool goaway_received_; |
| 221 // Whether a GoAway has been sent. | 204 // Whether a GoAway has been sent. |
| 222 bool goaway_sent_; | 205 bool goaway_sent_; |
| 223 | 206 |
| 224 DISALLOW_COPY_AND_ASSIGN(QuicSession); | 207 DISALLOW_COPY_AND_ASSIGN(QuicSession); |
| 225 }; | 208 }; |
| 226 | 209 |
| 227 } // namespace net | 210 } // namespace net |
| 228 | 211 |
| 229 #endif // NET_QUIC_QUIC_SESSION_H_ | 212 #endif // NET_QUIC_QUIC_SESSION_H_ |
| OLD | NEW |