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