Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(729)

Side by Side Diff: net/quic/quic_session.h

Issue 288313003: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: implemented rch's comments Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_write_blocked_list.h" 22 #include "net/quic/quic_write_blocked_list.h"
23 #include "net/quic/reliable_quic_stream.h" 23 #include "net/quic/reliable_quic_stream.h"
24 24
25 namespace net { 25 namespace net {
26 26
27 class QuicCryptoStream; 27 class QuicCryptoStream;
28 class QuicFlowController;
28 class ReliableQuicStream; 29 class ReliableQuicStream;
29 class SSLInfo; 30 class SSLInfo;
30 class VisitorShim; 31 class VisitorShim;
31 32
32 namespace test { 33 namespace test {
33 class QuicSessionPeer; 34 class QuicSessionPeer;
34 } // namespace test 35 } // namespace test
35 36
36 class NET_EXPORT_PRIVATE QuicSession : public QuicConnectionVisitorInterface { 37 class NET_EXPORT_PRIVATE QuicSession : public QuicConnectionVisitorInterface {
37 public: 38 public:
38 // CryptoHandshakeEvent enumerates the events generated by a QuicCryptoStream. 39 // CryptoHandshakeEvent enumerates the events generated by a QuicCryptoStream.
39 enum CryptoHandshakeEvent { 40 enum CryptoHandshakeEvent {
40 // ENCRYPTION_FIRST_ESTABLISHED indicates that a full client hello has been 41 // ENCRYPTION_FIRST_ESTABLISHED indicates that a full client hello has been
41 // sent by a client and that subsequent packets will be encrypted. (Client 42 // sent by a client and that subsequent packets will be encrypted. (Client
42 // only.) 43 // only.)
43 ENCRYPTION_FIRST_ESTABLISHED, 44 ENCRYPTION_FIRST_ESTABLISHED,
44 // ENCRYPTION_REESTABLISHED indicates that a client hello was rejected by 45 // ENCRYPTION_REESTABLISHED indicates that a client hello was rejected by
45 // 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
46 // connection should resend any packets that were sent under 47 // connection should resend any packets that were sent under
47 // ENCRYPTION_INITIAL. (Client only.) 48 // ENCRYPTION_INITIAL. (Client only.)
48 ENCRYPTION_REESTABLISHED, 49 ENCRYPTION_REESTABLISHED,
49 // HANDSHAKE_CONFIRMED, in a client, indicates the the server has accepted 50 // HANDSHAKE_CONFIRMED, in a client, indicates the the server has accepted
50 // 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
51 // has been received. (Client and server.) 52 // has been received. (Client and server.)
52 HANDSHAKE_CONFIRMED, 53 HANDSHAKE_CONFIRMED,
53 }; 54 };
54 55
55 QuicSession(QuicConnection* connection, 56 QuicSession(QuicConnection* connection,
57 uint32 max_flow_control_receive_window_bytes,
56 const QuicConfig& config); 58 const QuicConfig& config);
57 59
58 virtual ~QuicSession(); 60 virtual ~QuicSession();
59 61
60 // QuicConnectionVisitorInterface methods: 62 // QuicConnectionVisitorInterface methods:
61 virtual void OnStreamFrames( 63 virtual void OnStreamFrames(
62 const std::vector<QuicStreamFrame>& frames) OVERRIDE; 64 const std::vector<QuicStreamFrame>& frames) OVERRIDE;
63 virtual void OnRstStream(const QuicRstStreamFrame& frame) OVERRIDE; 65 virtual void OnRstStream(const QuicRstStreamFrame& frame) OVERRIDE;
64 virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE; 66 virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE;
65 virtual void OnWindowUpdateFrames( 67 virtual void OnWindowUpdateFrames(
66 const std::vector<QuicWindowUpdateFrame>& frames) OVERRIDE; 68 const std::vector<QuicWindowUpdateFrame>& frames) OVERRIDE;
67 virtual void OnBlockedFrames( 69 virtual void OnBlockedFrames(
68 const std::vector<QuicBlockedFrame>& frames) OVERRIDE; 70 const std::vector<QuicBlockedFrame>& frames) OVERRIDE;
69 virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE; 71 virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE;
70 virtual void OnWriteBlocked() OVERRIDE {} 72 virtual void OnWriteBlocked() OVERRIDE {}
71 virtual void OnSuccessfulVersionNegotiation( 73 virtual void OnSuccessfulVersionNegotiation(
72 const QuicVersion& version) OVERRIDE {} 74 const QuicVersion& version) OVERRIDE;
73 virtual void OnCanWrite() OVERRIDE; 75 virtual void OnCanWrite() OVERRIDE;
74 virtual bool HasPendingWrites() const OVERRIDE; 76 virtual bool WillingAndAbleToWrite() const OVERRIDE;
75 virtual bool HasPendingHandshake() const OVERRIDE; 77 virtual bool HasPendingHandshake() const OVERRIDE;
76 virtual bool HasOpenDataStreams() const OVERRIDE; 78 virtual bool HasOpenDataStreams() const OVERRIDE;
77 79
78 // Called by the headers stream when headers have been received for a stream. 80 // Called by the headers stream when headers have been received for a stream.
79 virtual void OnStreamHeaders(QuicStreamId stream_id, 81 virtual void OnStreamHeaders(QuicStreamId stream_id,
80 base::StringPiece headers_data); 82 base::StringPiece headers_data);
81 // Called by the headers stream when headers with a priority have been 83 // Called by the headers stream when headers with a priority have been
82 // received for this stream. This method will only be called for server 84 // received for this stream. This method will only be called for server
83 // streams. 85 // streams.
84 virtual void OnStreamHeadersPriority(QuicStreamId stream_id, 86 virtual void OnStreamHeadersPriority(QuicStreamId stream_id,
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return goaway_sent_; 196 return goaway_sent_;
195 } 197 }
196 198
197 // Gets the SSL connection information. 199 // Gets the SSL connection information.
198 virtual bool GetSSLInfo(SSLInfo* ssl_info) const; 200 virtual bool GetSSLInfo(SSLInfo* ssl_info) const;
199 201
200 QuicErrorCode error() const { return error_; } 202 QuicErrorCode error() const { return error_; }
201 203
202 bool is_server() const { return connection_->is_server(); } 204 bool is_server() const { return connection_->is_server(); }
203 205
206 uint32 max_flow_control_receive_window_bytes() {
207 return max_flow_control_receive_window_bytes_;
208 }
209
210 QuicFlowController* flow_controller() { return flow_controller_.get(); }
211
204 protected: 212 protected:
205 typedef base::hash_map<QuicStreamId, QuicDataStream*> DataStreamMap; 213 typedef base::hash_map<QuicStreamId, QuicDataStream*> DataStreamMap;
206 214
207 // Creates a new stream, owned by the caller, to handle a peer-initiated 215 // Creates a new stream, owned by the caller, to handle a peer-initiated
208 // stream. Returns NULL and does error handling if the stream can not be 216 // stream. Returns NULL and does error handling if the stream can not be
209 // created. 217 // created.
210 virtual QuicDataStream* CreateIncomingDataStream(QuicStreamId id) = 0; 218 virtual QuicDataStream* CreateIncomingDataStream(QuicStreamId id) = 0;
211 219
212 // Create a new stream, owned by the caller, to handle a locally-initiated 220 // Create a new stream, owned by the caller, to handle a locally-initiated
213 // stream. Returns NULL if max streams have already been opened. 221 // stream. Returns NULL if max streams have already been opened.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 QuicErrorCode error_; 296 QuicErrorCode error_;
289 297
290 // Whether a GoAway has been received. 298 // Whether a GoAway has been received.
291 bool goaway_received_; 299 bool goaway_received_;
292 // Whether a GoAway has been sent. 300 // Whether a GoAway has been sent.
293 bool goaway_sent_; 301 bool goaway_sent_;
294 302
295 // Indicate if there is pending data for the crypto stream. 303 // Indicate if there is pending data for the crypto stream.
296 bool has_pending_handshake_; 304 bool has_pending_handshake_;
297 305
306 // Used for session level flow control.
307 scoped_ptr<QuicFlowController> flow_controller_;
308
309 // Initial flow control receive window size for new streams.
310 uint32 max_flow_control_receive_window_bytes_;
311
298 DISALLOW_COPY_AND_ASSIGN(QuicSession); 312 DISALLOW_COPY_AND_ASSIGN(QuicSession);
299 }; 313 };
300 314
301 } // namespace net 315 } // namespace net
302 316
303 #endif // NET_QUIC_QUIC_SESSION_H_ 317 #endif // NET_QUIC_QUIC_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698