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> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // the server and thus the encryption key has been updated. Therefore the | 43 // the server and thus the encryption key has been updated. Therefore the |
44 // connection should resend any packets that were sent under | 44 // connection should resend any packets that were sent under |
45 // ENCRYPTION_INITIAL. (Client only.) | 45 // ENCRYPTION_INITIAL. (Client only.) |
46 ENCRYPTION_REESTABLISHED, | 46 ENCRYPTION_REESTABLISHED, |
47 // HANDSHAKE_CONFIRMED, in a client, indicates the the server has accepted | 47 // HANDSHAKE_CONFIRMED, in a client, indicates the the server has accepted |
48 // our handshake. In a server it indicates that a full, valid client hello | 48 // our handshake. In a server it indicates that a full, valid client hello |
49 // has been received. (Client and server.) | 49 // has been received. (Client and server.) |
50 HANDSHAKE_CONFIRMED, | 50 HANDSHAKE_CONFIRMED, |
51 }; | 51 }; |
52 | 52 |
53 QuicSession(QuicConnection* connection, bool is_server); | 53 QuicSession(QuicConnection* connection, |
| 54 const QuicConfig& config, |
| 55 bool is_server); |
54 | 56 |
55 virtual ~QuicSession(); | 57 virtual ~QuicSession(); |
56 | 58 |
57 // QuicConnectionVisitorInterface methods: | 59 // QuicConnectionVisitorInterface methods: |
58 virtual bool OnPacket(const IPEndPoint& self_address, | 60 virtual bool OnPacket(const IPEndPoint& self_address, |
59 const IPEndPoint& peer_address, | 61 const IPEndPoint& peer_address, |
60 const QuicPacketHeader& header, | 62 const QuicPacketHeader& header, |
61 const std::vector<QuicStreamFrame>& frame) OVERRIDE; | 63 const std::vector<QuicStreamFrame>& frame) OVERRIDE; |
62 virtual void OnRstStream(const QuicRstStreamFrame& frame) OVERRIDE; | 64 virtual void OnRstStream(const QuicRstStreamFrame& frame) OVERRIDE; |
63 virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE; | 65 virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // Called by the QuicCryptoStream when the handshake enters a new state. | 97 // Called by the QuicCryptoStream when the handshake enters a new state. |
96 // | 98 // |
97 // Clients will call this function in the order: | 99 // Clients will call this function in the order: |
98 // ENCRYPTION_FIRST_ESTABLISHED | 100 // ENCRYPTION_FIRST_ESTABLISHED |
99 // zero or more ENCRYPTION_REESTABLISHED | 101 // zero or more ENCRYPTION_REESTABLISHED |
100 // HANDSHAKE_CONFIRMED | 102 // HANDSHAKE_CONFIRMED |
101 // | 103 // |
102 // Servers will simply call it once with HANDSHAKE_CONFIRMED. | 104 // Servers will simply call it once with HANDSHAKE_CONFIRMED. |
103 virtual void OnCryptoHandshakeEvent(CryptoHandshakeEvent event); | 105 virtual void OnCryptoHandshakeEvent(CryptoHandshakeEvent event); |
104 | 106 |
| 107 virtual QuicConfig* config(); |
| 108 |
105 // Returns true if the stream existed previously and has been closed. | 109 // Returns true if the stream existed previously and has been closed. |
106 // Returns false if the stream is still active or if the stream has | 110 // Returns false if the stream is still active or if the stream has |
107 // not yet been created. | 111 // not yet been created. |
108 bool IsClosedStream(QuicStreamId id); | 112 bool IsClosedStream(QuicStreamId id); |
109 | 113 |
110 QuicConnection* connection() { return connection_.get(); } | 114 QuicConnection* connection() { return connection_.get(); } |
111 size_t num_active_requests() const { return stream_map_.size(); } | 115 size_t num_active_requests() const { return stream_map_.size(); } |
112 const IPEndPoint& peer_address() const { | 116 const IPEndPoint& peer_address() const { |
113 return connection_->peer_address(); | 117 return connection_->peer_address(); |
114 } | 118 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return &stream_map_; | 173 return &stream_map_; |
170 } | 174 } |
171 std::vector<ReliableQuicStream*>* closed_streams() { | 175 std::vector<ReliableQuicStream*>* closed_streams() { |
172 return &closed_streams_; | 176 return &closed_streams_; |
173 } | 177 } |
174 | 178 |
175 size_t get_max_open_streams() const { | 179 size_t get_max_open_streams() const { |
176 return max_open_streams_; | 180 return max_open_streams_; |
177 } | 181 } |
178 | 182 |
| 183 void set_max_open_streams(size_t max_open_streams) { |
| 184 max_open_streams_ = max_open_streams; |
| 185 } |
| 186 |
179 private: | 187 private: |
180 friend class test::QuicSessionPeer; | 188 friend class test::QuicSessionPeer; |
181 friend class VisitorShim; | 189 friend class VisitorShim; |
182 | 190 |
183 typedef base::hash_map<QuicStreamId, ReliableQuicStream*> ReliableStreamMap; | 191 typedef base::hash_map<QuicStreamId, ReliableQuicStream*> ReliableStreamMap; |
184 | 192 |
185 ReliableQuicStream* GetStream(const QuicStreamId stream_id); | 193 ReliableQuicStream* GetStream(const QuicStreamId stream_id); |
186 | 194 |
187 scoped_ptr<QuicConnection> connection_; | 195 scoped_ptr<QuicConnection> connection_; |
188 | 196 |
189 // A shim to stand between the connection and the session, to handle stream | 197 // A shim to stand between the connection and the session, to handle stream |
190 // deletions. | 198 // deletions. |
191 scoped_ptr<VisitorShim> visitor_shim_; | 199 scoped_ptr<VisitorShim> visitor_shim_; |
192 | 200 |
193 std::vector<ReliableQuicStream*> closed_streams_; | 201 std::vector<ReliableQuicStream*> closed_streams_; |
194 | 202 |
195 QuicSpdyDecompressor decompressor_; | 203 QuicSpdyDecompressor decompressor_; |
196 QuicSpdyCompressor compressor_; | 204 QuicSpdyCompressor compressor_; |
197 | 205 |
| 206 QuicConfig config_; |
| 207 |
198 // Returns the maximum number of streams this connection can open. | 208 // Returns the maximum number of streams this connection can open. |
199 const size_t max_open_streams_; | 209 size_t max_open_streams_; |
200 | 210 |
201 // Map from StreamId to pointers to streams that are owned by the caller. | 211 // Map from StreamId to pointers to streams that are owned by the caller. |
202 ReliableStreamMap stream_map_; | 212 ReliableStreamMap stream_map_; |
203 QuicStreamId next_stream_id_; | 213 QuicStreamId next_stream_id_; |
204 bool is_server_; | 214 bool is_server_; |
205 | 215 |
206 // Set of stream ids that have been "implicitly created" by receipt | 216 // Set of stream ids that have been "implicitly created" by receipt |
207 // of a stream id larger than the next expected stream id. | 217 // of a stream id larger than the next expected stream id. |
208 base::hash_set<QuicStreamId> implicitly_created_streams_; | 218 base::hash_set<QuicStreamId> implicitly_created_streams_; |
209 | 219 |
(...skipping 10 matching lines...) Expand all Loading... |
220 bool goaway_received_; | 230 bool goaway_received_; |
221 // Whether a GoAway has been sent. | 231 // Whether a GoAway has been sent. |
222 bool goaway_sent_; | 232 bool goaway_sent_; |
223 | 233 |
224 DISALLOW_COPY_AND_ASSIGN(QuicSession); | 234 DISALLOW_COPY_AND_ASSIGN(QuicSession); |
225 }; | 235 }; |
226 | 236 |
227 } // namespace net | 237 } // namespace net |
228 | 238 |
229 #endif // NET_QUIC_QUIC_SESSION_H_ | 239 #endif // NET_QUIC_QUIC_SESSION_H_ |
OLD | NEW |