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

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

Issue 100173005: Break out the basic reliable QUIC stream functionality from the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_reliable_client_stream_test.cc ('k') | net/quic/quic_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_packet_creator.h" 19 #include "net/quic/quic_packet_creator.h"
19 #include "net/quic/quic_protocol.h" 20 #include "net/quic/quic_protocol.h"
20 #include "net/quic/quic_spdy_compressor.h" 21 #include "net/quic/quic_spdy_compressor.h"
21 #include "net/quic/quic_spdy_decompressor.h" 22 #include "net/quic/quic_spdy_decompressor.h"
22 #include "net/quic/reliable_quic_stream.h" 23 #include "net/quic/reliable_quic_stream.h"
23 #include "net/spdy/write_blocked_list.h" 24 #include "net/spdy/write_blocked_list.h"
24 25
25 namespace net { 26 namespace net {
26 27
27 class QuicCryptoStream; 28 class QuicCryptoStream;
(...skipping 30 matching lines...) Expand all
58 59
59 virtual ~QuicSession(); 60 virtual ~QuicSession();
60 61
61 // QuicConnectionVisitorInterface methods: 62 // QuicConnectionVisitorInterface methods:
62 virtual bool OnStreamFrames( 63 virtual bool OnStreamFrames(
63 const std::vector<QuicStreamFrame>& frames) OVERRIDE; 64 const std::vector<QuicStreamFrame>& frames) OVERRIDE;
64 virtual void OnRstStream(const QuicRstStreamFrame& frame) OVERRIDE; 65 virtual void OnRstStream(const QuicRstStreamFrame& frame) OVERRIDE;
65 virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE; 66 virtual void OnGoAway(const QuicGoAwayFrame& frame) OVERRIDE;
66 virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE; 67 virtual void OnConnectionClosed(QuicErrorCode error, bool from_peer) OVERRIDE;
67 virtual void OnSuccessfulVersionNegotiation( 68 virtual void OnSuccessfulVersionNegotiation(
68 const QuicVersion& version) OVERRIDE{} 69 const QuicVersion& version) OVERRIDE {}
69 virtual void OnConfigNegotiated() OVERRIDE; 70 virtual void OnConfigNegotiated() OVERRIDE;
70 // Not needed for HTTP. 71 // Not needed for HTTP.
71 virtual bool OnCanWrite() OVERRIDE; 72 virtual bool OnCanWrite() OVERRIDE;
72 virtual bool HasPendingHandshake() const OVERRIDE; 73 virtual bool HasPendingHandshake() const OVERRIDE;
73 74
74 // Called by streams when they want to write data to the peer. 75 // Called by streams when they want to write data to the peer.
75 // Returns a pair with the number of bytes consumed from data, and a boolean 76 // Returns a pair with the number of bytes consumed from data, and a boolean
76 // indicating if the fin bit was consumed. This does not indicate the data 77 // indicating if the fin bit was consumed. This does not indicate the data
77 // has been sent on the wire: it may have been turned into a packet and queued 78 // has been sent on the wire: it may have been turned into a packet and queued
78 // if the socket was unexpectedly blocked. 79 // if the socket was unexpectedly blocked.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 QuicSpdyCompressor* compressor() { return &compressor_; } 169 QuicSpdyCompressor* compressor() { return &compressor_; }
169 170
170 // Gets the SSL connection information. 171 // Gets the SSL connection information.
171 virtual bool GetSSLInfo(SSLInfo* ssl_info); 172 virtual bool GetSSLInfo(SSLInfo* ssl_info);
172 173
173 QuicErrorCode error() const { return error_; } 174 QuicErrorCode error() const { return error_; }
174 175
175 bool is_server() const { return is_server_; } 176 bool is_server() const { return is_server_; }
176 177
177 protected: 178 protected:
179 typedef base::hash_map<QuicStreamId, QuicDataStream*> DataStreamMap;
180
178 // Creates a new stream, owned by the caller, to handle a peer-initiated 181 // Creates a new stream, owned by the caller, to handle a peer-initiated
179 // stream. Returns NULL and does error handling if the stream can not be 182 // stream. Returns NULL and does error handling if the stream can not be
180 // created. 183 // created.
181 virtual ReliableQuicStream* CreateIncomingReliableStream(QuicStreamId id) = 0; 184 virtual QuicDataStream* CreateIncomingDataStream(QuicStreamId id) = 0;
182 185
183 // Create a new stream, owned by the caller, to handle a locally-initiated 186 // Create a new stream, owned by the caller, to handle a locally-initiated
184 // stream. Returns NULL if max streams have already been opened. 187 // stream. Returns NULL if max streams have already been opened.
185 virtual ReliableQuicStream* CreateOutgoingReliableStream() = 0; 188 virtual QuicDataStream* CreateOutgoingDataStream() = 0;
186 189
187 // Return the reserved crypto stream. 190 // Return the reserved crypto stream.
188 virtual QuicCryptoStream* GetCryptoStream() = 0; 191 virtual QuicCryptoStream* GetCryptoStream() = 0;
189 192
190 // Adds 'stream' to the active stream map. 193 // Adds 'stream' to the active stream map.
191 virtual void ActivateStream(ReliableQuicStream* stream); 194 virtual void ActivateStream(QuicDataStream* stream);
192 195
193 // Returns the stream id for a new stream. 196 // Returns the stream id for a new stream.
194 QuicStreamId GetNextStreamId(); 197 QuicStreamId GetNextStreamId();
195 198
196 ReliableQuicStream* GetIncomingReliableStream(QuicStreamId stream_id); 199 QuicDataStream* GetIncomingReliableStream(QuicStreamId stream_id);
200
201 QuicDataStream* GetDataStream(const QuicStreamId stream_id);
197 202
198 ReliableQuicStream* GetStream(const QuicStreamId stream_id); 203 ReliableQuicStream* GetStream(const QuicStreamId stream_id);
199 204
200 // This is called after every call other than OnConnectionClose from the 205 // This is called after every call other than OnConnectionClose from the
201 // QuicConnectionVisitor to allow post-processing once the work has been done. 206 // QuicConnectionVisitor to allow post-processing once the work has been done.
202 // In this case, it deletes streams given that it's safe to do so (no other 207 // In this case, it deletes streams given that it's safe to do so (no other
203 // operations are being done on the streams at this time) 208 // operations are being done on the streams at this time)
204 virtual void PostProcessAfterData(); 209 virtual void PostProcessAfterData();
205 210
206 base::hash_map<QuicStreamId, ReliableQuicStream*>* streams() { 211 base::hash_map<QuicStreamId, QuicDataStream*>* streams() {
207 return &stream_map_; 212 return &stream_map_;
208 } 213 }
209 214
210 const base::hash_map<QuicStreamId, ReliableQuicStream*>* streams() const { 215 const base::hash_map<QuicStreamId, QuicDataStream*>* streams() const {
211 return &stream_map_; 216 return &stream_map_;
212 } 217 }
213 218
214 std::vector<ReliableQuicStream*>* closed_streams() { 219 std::vector<QuicDataStream*>* closed_streams() { return &closed_streams_; }
215 return &closed_streams_;
216 }
217 220
218 size_t get_max_open_streams() const { 221 size_t get_max_open_streams() const {
219 return max_open_streams_; 222 return max_open_streams_;
220 } 223 }
221 224
222 private: 225 private:
223 friend class test::QuicSessionPeer; 226 friend class test::QuicSessionPeer;
224 friend class VisitorShim; 227 friend class VisitorShim;
225 228
226 typedef base::hash_map<QuicStreamId, ReliableQuicStream*> ReliableStreamMap;
227
228 // Performs the work required to close |stream_id|. If |locally_reset| 229 // Performs the work required to close |stream_id|. If |locally_reset|
229 // then the stream has been reset by this endpoint, not by the peer. This 230 // then the stream has been reset by this endpoint, not by the peer. This
230 // means the stream may become a zombie stream which needs to stay 231 // means the stream may become a zombie stream which needs to stay
231 // around until headers have been decompressed. 232 // around until headers have been decompressed.
232 void CloseStreamInner(QuicStreamId stream_id, bool locally_reset); 233 void CloseStreamInner(QuicStreamId stream_id, bool locally_reset);
233 234
234 // Adds |stream_id| to the zobmie stream map, closing the oldest 235 // Adds |stream_id| to the zobmie stream map, closing the oldest
235 // zombie stream if the set is full. 236 // zombie stream if the set is full.
236 void AddZombieStream(QuicStreamId stream_id); 237 void AddZombieStream(QuicStreamId stream_id);
237 238
(...skipping 15 matching lines...) Expand all
253 // Streams which have been locally reset before decompressing headers 254 // Streams which have been locally reset before decompressing headers
254 // from the peer. These streams need to stay open long enough to 255 // from the peer. These streams need to stay open long enough to
255 // process any headers from the peer. 256 // process any headers from the peer.
256 // Ideally this would be a linked_hash_set as the boolean is unused. 257 // Ideally this would be a linked_hash_set as the boolean is unused.
257 linked_hash_map<QuicStreamId, bool> zombie_streams_; 258 linked_hash_map<QuicStreamId, bool> zombie_streams_;
258 259
259 // A shim to stand between the connection and the session, to handle stream 260 // A shim to stand between the connection and the session, to handle stream
260 // deletions. 261 // deletions.
261 scoped_ptr<VisitorShim> visitor_shim_; 262 scoped_ptr<VisitorShim> visitor_shim_;
262 263
263 std::vector<ReliableQuicStream*> closed_streams_; 264 std::vector<QuicDataStream*> closed_streams_;
264 265
265 QuicSpdyDecompressor decompressor_; 266 QuicSpdyDecompressor decompressor_;
266 QuicSpdyCompressor compressor_; 267 QuicSpdyCompressor compressor_;
267 268
268 QuicConfig config_; 269 QuicConfig config_;
269 270
270 // Returns the maximum number of streams this connection can open. 271 // Returns the maximum number of streams this connection can open.
271 size_t max_open_streams_; 272 size_t max_open_streams_;
272 273
273 // Map from StreamId to pointers to streams that are owned by the caller. 274 // Map from StreamId to pointers to streams that are owned by the caller.
274 ReliableStreamMap stream_map_; 275 DataStreamMap stream_map_;
275 QuicStreamId next_stream_id_; 276 QuicStreamId next_stream_id_;
276 bool is_server_; 277 bool is_server_;
277 278
278 // Set of stream ids that have been "implicitly created" by receipt 279 // Set of stream ids that have been "implicitly created" by receipt
279 // of a stream id larger than the next expected stream id. 280 // of a stream id larger than the next expected stream id.
280 base::hash_set<QuicStreamId> implicitly_created_streams_; 281 base::hash_set<QuicStreamId> implicitly_created_streams_;
281 282
282 // A list of streams which need to write more data. 283 // A list of streams which need to write more data.
283 WriteBlockedList<QuicStreamId> write_blocked_streams_; 284 WriteBlockedList<QuicStreamId> write_blocked_streams_;
284 285
(...skipping 13 matching lines...) Expand all
298 299
299 // Indicate if there is pending data for the crypto stream. 300 // Indicate if there is pending data for the crypto stream.
300 bool has_pending_handshake_; 301 bool has_pending_handshake_;
301 302
302 DISALLOW_COPY_AND_ASSIGN(QuicSession); 303 DISALLOW_COPY_AND_ASSIGN(QuicSession);
303 }; 304 };
304 305
305 } // namespace net 306 } // namespace net
306 307
307 #endif // NET_QUIC_QUIC_SESSION_H_ 308 #endif // NET_QUIC_QUIC_SESSION_H_
OLDNEW
« no previous file with comments | « net/quic/quic_reliable_client_stream_test.cc ('k') | net/quic/quic_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698