| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // the server and thus the encryption key has been updated. Therefore the | 46 // the server and thus the encryption key has been updated. Therefore the |
| 47 // connection should resend any packets that were sent under | 47 // connection should resend any packets that were sent under |
| 48 // ENCRYPTION_INITIAL. (Client only.) | 48 // ENCRYPTION_INITIAL. (Client only.) |
| 49 ENCRYPTION_REESTABLISHED, | 49 ENCRYPTION_REESTABLISHED, |
| 50 // HANDSHAKE_CONFIRMED, in a client, indicates the the server has accepted | 50 // HANDSHAKE_CONFIRMED, in a client, indicates the the server has accepted |
| 51 // our handshake. In a server it indicates that a full, valid client hello | 51 // our handshake. In a server it indicates that a full, valid client hello |
| 52 // has been received. (Client and server.) | 52 // has been received. (Client and server.) |
| 53 HANDSHAKE_CONFIRMED, | 53 HANDSHAKE_CONFIRMED, |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 QuicSession(QuicConnection* connection, | 56 QuicSession(QuicConnection* connection, const QuicConfig& config); |
| 57 uint32 max_flow_control_receive_window_bytes, | |
| 58 const QuicConfig& config); | |
| 59 | 57 |
| 60 virtual ~QuicSession(); | 58 virtual ~QuicSession(); |
| 61 | 59 |
| 62 // QuicConnectionVisitorInterface methods: | 60 // QuicConnectionVisitorInterface methods: |
| 63 virtual void OnStreamFrames( | 61 virtual void OnStreamFrames( |
| 64 const std::vector<QuicStreamFrame>& frames) OVERRIDE; | 62 const std::vector<QuicStreamFrame>& frames) OVERRIDE; |
| 65 virtual void OnRstStream(const QuicRstStreamFrame& frame) OVERRIDE; | 63 virtual void OnRstStream(const QuicRstStreamFrame& frame) OVERRIDE; |
| 66 virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE; | 64 virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE; |
| 67 virtual void OnWindowUpdateFrames( | 65 virtual void OnWindowUpdateFrames( |
| 68 const std::vector<QuicWindowUpdateFrame>& frames) OVERRIDE; | 66 const std::vector<QuicWindowUpdateFrame>& frames) OVERRIDE; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 return goaway_sent_; | 196 return goaway_sent_; |
| 199 } | 197 } |
| 200 | 198 |
| 201 // Gets the SSL connection information. | 199 // Gets the SSL connection information. |
| 202 virtual bool GetSSLInfo(SSLInfo* ssl_info) const; | 200 virtual bool GetSSLInfo(SSLInfo* ssl_info) const; |
| 203 | 201 |
| 204 QuicErrorCode error() const { return error_; } | 202 QuicErrorCode error() const { return error_; } |
| 205 | 203 |
| 206 bool is_server() const { return connection_->is_server(); } | 204 bool is_server() const { return connection_->is_server(); } |
| 207 | 205 |
| 208 uint32 max_flow_control_receive_window_bytes() { | |
| 209 return max_flow_control_receive_window_bytes_; | |
| 210 } | |
| 211 | |
| 212 QuicFlowController* flow_controller() { return flow_controller_.get(); } | 206 QuicFlowController* flow_controller() { return flow_controller_.get(); } |
| 213 | 207 |
| 214 protected: | 208 protected: |
| 215 typedef base::hash_map<QuicStreamId, QuicDataStream*> DataStreamMap; | 209 typedef base::hash_map<QuicStreamId, QuicDataStream*> DataStreamMap; |
| 216 | 210 |
| 217 // Creates a new stream, owned by the caller, to handle a peer-initiated | 211 // Creates a new stream, owned by the caller, to handle a peer-initiated |
| 218 // stream. Returns NULL and does error handling if the stream can not be | 212 // stream. Returns NULL and does error handling if the stream can not be |
| 219 // created. | 213 // created. |
| 220 virtual QuicDataStream* CreateIncomingDataStream(QuicStreamId id) = 0; | 214 virtual QuicDataStream* CreateIncomingDataStream(QuicStreamId id) = 0; |
| 221 | 215 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // then the stream has been reset by this endpoint, not by the peer. | 260 // then the stream has been reset by this endpoint, not by the peer. |
| 267 void CloseStreamInner(QuicStreamId stream_id, bool locally_reset); | 261 void CloseStreamInner(QuicStreamId stream_id, bool locally_reset); |
| 268 | 262 |
| 269 // When a stream is closed locally, it may not yet know how many bytes the | 263 // When a stream is closed locally, it may not yet know how many bytes the |
| 270 // peer sent on that stream. | 264 // peer sent on that stream. |
| 271 // When this data arrives (via stream frame w. FIN, or RST) this method | 265 // When this data arrives (via stream frame w. FIN, or RST) this method |
| 272 // is called, and correctly updates the connection level flow controller. | 266 // is called, and correctly updates the connection level flow controller. |
| 273 void UpdateFlowControlOnFinalReceivedByteOffset( | 267 void UpdateFlowControlOnFinalReceivedByteOffset( |
| 274 QuicStreamId id, QuicStreamOffset final_byte_offset); | 268 QuicStreamId id, QuicStreamOffset final_byte_offset); |
| 275 | 269 |
| 270 // Called in OnConfigNegotiated when we receive a new stream level flow |
| 271 // control window in a negotiated config. Closes the connection if invalid. |
| 272 void OnNewStreamFlowControlWindow(uint32 new_window); |
| 273 |
| 274 // Called in OnConfigNegotiated when we receive a new session level flow |
| 275 // control window in a negotiated config. Closes the connection if invalid. |
| 276 void OnNewSessionFlowControlWindow(uint32 new_window); |
| 277 |
| 276 // Keep track of highest received byte offset of locally closed streams, while | 278 // Keep track of highest received byte offset of locally closed streams, while |
| 277 // waiting for a definitive final highest offset from the peer. | 279 // waiting for a definitive final highest offset from the peer. |
| 278 std::map<QuicStreamId, QuicStreamOffset> | 280 std::map<QuicStreamId, QuicStreamOffset> |
| 279 locally_closed_streams_highest_offset_; | 281 locally_closed_streams_highest_offset_; |
| 280 | 282 |
| 281 scoped_ptr<QuicConnection> connection_; | 283 scoped_ptr<QuicConnection> connection_; |
| 282 | 284 |
| 283 scoped_ptr<QuicHeadersStream> headers_stream_; | 285 scoped_ptr<QuicHeadersStream> headers_stream_; |
| 284 | 286 |
| 285 // A shim to stand between the connection and the session, to handle stream | 287 // A shim to stand between the connection and the session, to handle stream |
| (...skipping 27 matching lines...) Expand all Loading... |
| 313 bool goaway_received_; | 315 bool goaway_received_; |
| 314 // Whether a GoAway has been sent. | 316 // Whether a GoAway has been sent. |
| 315 bool goaway_sent_; | 317 bool goaway_sent_; |
| 316 | 318 |
| 317 // Indicate if there is pending data for the crypto stream. | 319 // Indicate if there is pending data for the crypto stream. |
| 318 bool has_pending_handshake_; | 320 bool has_pending_handshake_; |
| 319 | 321 |
| 320 // Used for session level flow control. | 322 // Used for session level flow control. |
| 321 scoped_ptr<QuicFlowController> flow_controller_; | 323 scoped_ptr<QuicFlowController> flow_controller_; |
| 322 | 324 |
| 323 // Initial flow control receive window size for new streams. | |
| 324 uint32 max_flow_control_receive_window_bytes_; | |
| 325 | |
| 326 DISALLOW_COPY_AND_ASSIGN(QuicSession); | 325 DISALLOW_COPY_AND_ASSIGN(QuicSession); |
| 327 }; | 326 }; |
| 328 | 327 |
| 329 } // namespace net | 328 } // namespace net |
| 330 | 329 |
| 331 #endif // NET_QUIC_QUIC_SESSION_H_ | 330 #endif // NET_QUIC_QUIC_SESSION_H_ |
| OLD | NEW |