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/quic_connection.h" | 15 #include "net/quic/quic_connection.h" |
16 #include "net/quic/quic_crypto_stream.h" | 16 #include "net/quic/quic_crypto_stream.h" |
17 #include "net/quic/quic_packet_creator.h" | 17 #include "net/quic/quic_packet_creator.h" |
18 #include "net/quic/quic_protocol.h" | 18 #include "net/quic/quic_protocol.h" |
19 #include "net/quic/reliable_quic_stream.h" | 19 #include "net/quic/reliable_quic_stream.h" |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 | 22 |
23 class QuicCryptoStream; | 23 class QuicCryptoStream; |
24 class ReliableQuicStream; | 24 class ReliableQuicStream; |
| 25 class VisitorShim; |
25 | 26 |
26 namespace test { | 27 namespace test { |
27 class QuicSessionPeer; | 28 class QuicSessionPeer; |
28 } // namespace test | 29 } // namespace test |
29 | 30 |
30 class NET_EXPORT_PRIVATE QuicSession : public QuicConnectionVisitorInterface { | 31 class NET_EXPORT_PRIVATE QuicSession : public QuicConnectionVisitorInterface { |
31 public: | 32 public: |
32 QuicSession(QuicConnection* connection, bool is_server); | 33 QuicSession(QuicConnection* connection, bool is_server); |
33 | 34 |
34 virtual ~QuicSession(); | 35 virtual ~QuicSession(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 QuicStreamId GetNextStreamId(); | 105 QuicStreamId GetNextStreamId(); |
105 | 106 |
106 ReliableQuicStream* GetIncomingReliableStream(QuicStreamId stream_id); | 107 ReliableQuicStream* GetIncomingReliableStream(QuicStreamId stream_id); |
107 | 108 |
108 size_t get_max_open_streams() const { | 109 size_t get_max_open_streams() const { |
109 return max_open_streams_; | 110 return max_open_streams_; |
110 } | 111 } |
111 | 112 |
112 private: | 113 private: |
113 friend class test::QuicSessionPeer; | 114 friend class test::QuicSessionPeer; |
| 115 friend class VisitorShim; |
114 | 116 |
115 typedef base::hash_map<QuicStreamId, ReliableQuicStream*> ReliableStreamMap; | 117 typedef base::hash_map<QuicStreamId, ReliableQuicStream*> ReliableStreamMap; |
116 | 118 |
117 ReliableQuicStream* GetStream(const QuicStreamId stream_id); | 119 ReliableQuicStream* GetStream(const QuicStreamId stream_id); |
118 | 120 |
| 121 // This is called after every call other than OnConnectionClose from the |
| 122 // QuicConnectionVisitor to allow post-processing once the work has been done. |
| 123 // In this case, it deletes streams given that it's safe to do so (no other |
| 124 // opterations are being done on the streams at this time) |
| 125 void PostProcessAfterData(); |
| 126 |
119 scoped_ptr<QuicConnection> connection_; | 127 scoped_ptr<QuicConnection> connection_; |
120 | 128 |
| 129 // A shim to stand between the connection and the session, to handle stream |
| 130 // deletions. |
| 131 scoped_ptr<VisitorShim> visitor_shim_; |
| 132 |
| 133 std::vector<ReliableQuicStream*> closed_streams_; |
| 134 |
121 // Returns the maximum number of streams this connection can open. | 135 // Returns the maximum number of streams this connection can open. |
122 const size_t max_open_streams_; | 136 const size_t max_open_streams_; |
123 | 137 |
124 // Map from StreamId to pointers to streams that are owned by the caller. | 138 // Map from StreamId to pointers to streams that are owned by the caller. |
125 ReliableStreamMap stream_map_; | 139 ReliableStreamMap stream_map_; |
126 QuicStreamId next_stream_id_; | 140 QuicStreamId next_stream_id_; |
127 bool is_server_; | 141 bool is_server_; |
128 | 142 |
129 // Set of stream ids that have been "implicitly created" by receipt | 143 // Set of stream ids that have been "implicitly created" by receipt |
130 // of a stream id larger than the next expected stream id. | 144 // of a stream id larger than the next expected stream id. |
131 base::hash_set<QuicStreamId> implicitly_created_streams_; | 145 base::hash_set<QuicStreamId> implicitly_created_streams_; |
132 | 146 |
133 // A list of streams which need to write more data. | 147 // A list of streams which need to write more data. |
134 std::list<QuicStreamId> write_blocked_streams_; | 148 std::list<QuicStreamId> write_blocked_streams_; |
135 | 149 |
136 QuicStreamId largest_peer_created_stream_id_; | 150 QuicStreamId largest_peer_created_stream_id_; |
137 }; | 151 }; |
138 | 152 |
139 } // namespace net | 153 } // namespace net |
140 | 154 |
141 #endif // NET_QUIC_QUIC_SESSION_H_ | 155 #endif // NET_QUIC_QUIC_SESSION_H_ |
OLD | NEW |