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

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

Issue 2862563003: Landing Recent QUIC changes until Sat Apr 29 00:22:04 2017 +0000 (Closed)
Patch Set: rebase and fix test bugs detected by swarm bot. Created 3 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
« no previous file with comments | « net/quic/core/quic_server_session_base_test.cc ('k') | net/quic/core/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_CORE_QUIC_SESSION_H_ 7 #ifndef NET_QUIC_CORE_QUIC_SESSION_H_
8 #define NET_QUIC_CORE_QUIC_SESSION_H_ 8 #define NET_QUIC_CORE_QUIC_SESSION_H_
9 9
10 #include <cstddef> 10 #include <cstddef>
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // then a new stream is created and returned. In all other cases, nullptr is 243 // then a new stream is created and returned. In all other cases, nullptr is
244 // returned. 244 // returned.
245 QuicStream* GetOrCreateStream(const QuicStreamId stream_id); 245 QuicStream* GetOrCreateStream(const QuicStreamId stream_id);
246 246
247 // Mark a stream as draining. 247 // Mark a stream as draining.
248 virtual void StreamDraining(QuicStreamId id); 248 virtual void StreamDraining(QuicStreamId id);
249 249
250 // Returns true if this stream should yield writes to another blocked stream. 250 // Returns true if this stream should yield writes to another blocked stream.
251 bool ShouldYield(QuicStreamId stream_id); 251 bool ShouldYield(QuicStreamId stream_id);
252 252
253 void set_respect_goaway(bool respect_goaway) {
254 respect_goaway_ = respect_goaway;
255 }
256
253 protected: 257 protected:
254 using StaticStreamMap = QuicSmallMap<QuicStreamId, QuicStream*, 2>; 258 using StaticStreamMap = QuicSmallMap<QuicStreamId, QuicStream*, 2>;
255 259
256 using DynamicStreamMap = 260 using DynamicStreamMap =
257 QuicSmallMap<QuicStreamId, std::unique_ptr<QuicStream>, 10>; 261 QuicSmallMap<QuicStreamId, std::unique_ptr<QuicStream>, 10>;
258 262
259 using ClosedStreams = std::vector<std::unique_ptr<QuicStream>>; 263 using ClosedStreams = std::vector<std::unique_ptr<QuicStream>>;
260 264
265 // TODO(ckrasic) - For all *DynamicStream2 below, rename after
266 // quic_reloadable_flag_quic_refactor_stream_creation is deprecated.
267
268 // Returns true if an incoming stream can be created.
269 virtual bool ShouldCreateIncomingDynamicStream2(QuicStreamId id);
270
271 // Returns true if an outgoing stream can be created.
272 virtual bool ShouldCreateOutgoingDynamicStream2();
273
261 // Creates a new stream to handle a peer-initiated stream. 274 // Creates a new stream to handle a peer-initiated stream.
262 // Caller does not own the returned stream. 275 // Caller does not own the returned stream.
263 // Returns nullptr and does error handling if the stream can not be created. 276 // Returns nullptr and does error handling if the stream can not be created.
277 virtual QuicStream* MaybeCreateIncomingDynamicStream(QuicStreamId id);
278
279 // Create a new stream to handle a locally-initiated stream.
280 // Caller does not own the returned stream.
281 // Returns nullptr if max streams have already been opened.
282 virtual QuicStream* MaybeCreateOutgoingDynamicStream(SpdyPriority priority);
283
284 // TODO(ckrasic) - For all Create*DynamicStream below, remove when
285 // quic_reloadable_flag_quic_refactor_stream_creation is deprecated.
286
287 // Creates a new stream to handle a peer-initiated stream.
288 // Caller does not own the returned stream.
289 // Returns nullptr and does error handling if the stream can not be created.
264 virtual QuicStream* CreateIncomingDynamicStream(QuicStreamId id) = 0; 290 virtual QuicStream* CreateIncomingDynamicStream(QuicStreamId id) = 0;
265 291
266 // Create a new stream to handle a locally-initiated stream. 292 // Create a new stream to handle a locally-initiated stream.
267 // Caller does not own the returned stream. 293 // Caller does not own the returned stream.
268 // Returns nullptr if max streams have already been opened. 294 // Returns nullptr if max streams have already been opened.
269 virtual QuicStream* CreateOutgoingDynamicStream(SpdyPriority priority) = 0; 295 virtual QuicStream* CreateOutgoingDynamicStream(SpdyPriority priority) = 0;
270 296
271 // Return the reserved crypto stream. 297 // Return the reserved crypto stream.
272 virtual QuicCryptoStream* GetMutableCryptoStream() = 0; 298 virtual QuicCryptoStream* GetMutableCryptoStream() = 0;
273 299
(...skipping 22 matching lines...) Expand all
296 // peer sent on that stream. 322 // peer sent on that stream.
297 // When this data arrives (via stream frame w. FIN, trailing headers, or RST) 323 // When this data arrives (via stream frame w. FIN, trailing headers, or RST)
298 // this method is called, and correctly updates the connection level flow 324 // this method is called, and correctly updates the connection level flow
299 // controller. 325 // controller.
300 virtual void OnFinalByteOffsetReceived(QuicStreamId id, 326 virtual void OnFinalByteOffsetReceived(QuicStreamId id,
301 QuicStreamOffset final_byte_offset); 327 QuicStreamOffset final_byte_offset);
302 328
303 // Return true if given stream is peer initiated. 329 // Return true if given stream is peer initiated.
304 bool IsIncomingStream(QuicStreamId id) const; 330 bool IsIncomingStream(QuicStreamId id) const;
305 331
332 // Unconditionally creates a stream. Subclasses should use this to
333 // provide streams appropriately subclassed from |QuicStream|,
334 // e.g. |QuicSpdySession::CreateStream()| creates a |QuicSpdyStream|.
335 virtual std::unique_ptr<QuicStream> CreateStream(QuicStreamId id) = 0;
336
337 // Creates a stream and activates it, owned by the session.
338 QuicStream* CreateAndActivateStream(QuicStreamId id);
339
306 StaticStreamMap& static_streams() { return static_stream_map_; } 340 StaticStreamMap& static_streams() { return static_stream_map_; }
307 const StaticStreamMap& static_streams() const { return static_stream_map_; } 341 const StaticStreamMap& static_streams() const { return static_stream_map_; }
308 342
309 DynamicStreamMap& dynamic_streams() { return dynamic_stream_map_; } 343 DynamicStreamMap& dynamic_streams() { return dynamic_stream_map_; }
310 const DynamicStreamMap& dynamic_streams() const { 344 const DynamicStreamMap& dynamic_streams() const {
311 return dynamic_stream_map_; 345 return dynamic_stream_map_;
312 } 346 }
313 347
314 ClosedStreams* closed_streams() { return &closed_streams_; } 348 ClosedStreams* closed_streams() { return &closed_streams_; }
315 349
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 bool MaybeIncreaseLargestPeerStreamId(const QuicStreamId stream_id); 386 bool MaybeIncreaseLargestPeerStreamId(const QuicStreamId stream_id);
353 387
354 void InsertLocallyClosedStreamsHighestOffset(const QuicStreamId id, 388 void InsertLocallyClosedStreamsHighestOffset(const QuicStreamId id,
355 QuicStreamOffset offset); 389 QuicStreamOffset offset);
356 // If stream is a locally closed stream, this RST will update FIN offset. 390 // If stream is a locally closed stream, this RST will update FIN offset.
357 // Otherwise stream is a preserved stream and the behavior of it depends on 391 // Otherwise stream is a preserved stream and the behavior of it depends on
358 // derived class's own implementation. 392 // derived class's own implementation.
359 virtual void HandleRstOnValidNonexistentStream( 393 virtual void HandleRstOnValidNonexistentStream(
360 const QuicRstStreamFrame& frame); 394 const QuicRstStreamFrame& frame);
361 395
396 bool respect_goaway() const { return respect_goaway_; }
397
362 private: 398 private:
363 friend class test::QuicSessionPeer; 399 friend class test::QuicSessionPeer;
364 400
365 // Called in OnConfigNegotiated when we receive a new stream level flow 401 // Called in OnConfigNegotiated when we receive a new stream level flow
366 // control window in a negotiated config. Closes the connection if invalid. 402 // control window in a negotiated config. Closes the connection if invalid.
367 void OnNewStreamFlowControlWindow(QuicStreamOffset new_window); 403 void OnNewStreamFlowControlWindow(QuicStreamOffset new_window);
368 404
369 // Called in OnConfigNegotiated when we receive a new connection level flow 405 // Called in OnConfigNegotiated when we receive a new connection level flow
370 // control window in a negotiated config. Closes the connection if invalid. 406 // control window in a negotiated config. Closes the connection if invalid.
371 void OnNewSessionFlowControlWindow(QuicStreamOffset new_window); 407 void OnNewSessionFlowControlWindow(QuicStreamOffset new_window);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // The latched error with which the connection was closed. 473 // The latched error with which the connection was closed.
438 QuicErrorCode error_; 474 QuicErrorCode error_;
439 475
440 // Used for connection-level flow control. 476 // Used for connection-level flow control.
441 QuicFlowController flow_controller_; 477 QuicFlowController flow_controller_;
442 478
443 // The stream id which was last popped in OnCanWrite, or 0, if not under the 479 // The stream id which was last popped in OnCanWrite, or 0, if not under the
444 // call stack of OnCanWrite. 480 // call stack of OnCanWrite.
445 QuicStreamId currently_writing_stream_id_; 481 QuicStreamId currently_writing_stream_id_;
446 482
483 // If this is set to false, the session will ignore peer GOAWAYs and
484 // allow the creation of outgoing streams regardless of the high
485 // chance they will fail.
486 bool respect_goaway_;
487
447 DISALLOW_COPY_AND_ASSIGN(QuicSession); 488 DISALLOW_COPY_AND_ASSIGN(QuicSession);
448 }; 489 };
449 490
450 } // namespace net 491 } // namespace net
451 492
452 #endif // NET_QUIC_CORE_QUIC_SESSION_H_ 493 #endif // NET_QUIC_CORE_QUIC_SESSION_H_
OLDNEW
« no previous file with comments | « net/quic/core/quic_server_session_base_test.cc ('k') | net/quic/core/quic_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698