QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // Copyright (c) 2018 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef QUICHE_QUIC_CORE_UBER_QUIC_STREAM_ID_MANAGER_H_ |
| 6 | #define QUICHE_QUIC_CORE_UBER_QUIC_STREAM_ID_MANAGER_H_ |
| 7 | |
| 8 | #include "net/third_party/quiche/src/quic/core/quic_stream_id_manager.h" |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 9 | #include "net/third_party/quiche/src/quic/core/quic_types.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 10 | |
| 11 | namespace quic { |
| 12 | |
| 13 | namespace test { |
| 14 | class QuicSessionPeer; |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 15 | class UberQuicStreamIdManagerPeer; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 16 | } // namespace test |
| 17 | |
| 18 | class QuicSession; |
| 19 | |
| 20 | // This class comprises two QuicStreamIdManagers, which manage bidirectional and |
| 21 | // unidirectional stream IDs, respectively. |
| 22 | class QUIC_EXPORT_PRIVATE UberQuicStreamIdManager { |
| 23 | public: |
fkastenholz | d3a1de9 | 2019-05-15 07:00:07 -0700 | [diff] [blame] | 24 | UberQuicStreamIdManager( |
rch | d40f903 | 2019-09-23 07:27:04 -0700 | [diff] [blame] | 25 | Perspective perspective, |
| 26 | ParsedQuicVersion version, |
| 27 | QuicStreamIdManager::DelegateInterface* delegate, |
fkastenholz | d3a1de9 | 2019-05-15 07:00:07 -0700 | [diff] [blame] | 28 | QuicStreamCount max_open_outgoing_bidirectional_streams, |
| 29 | QuicStreamCount max_open_outgoing_unidirectional_streams, |
| 30 | QuicStreamCount max_open_incoming_bidirectional_streams, |
| 31 | QuicStreamCount max_open_incoming_unidirectional_streams); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 32 | |
renjietang | 216dc01 | 2019-08-27 11:28:27 -0700 | [diff] [blame] | 33 | // Sets the limits to max_open_streams. |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 34 | void SetMaxOpenOutgoingBidirectionalStreams(QuicStreamCount max_open_streams); |
| 35 | void SetMaxOpenOutgoingUnidirectionalStreams( |
| 36 | QuicStreamCount max_open_streams); |
| 37 | void SetMaxOpenIncomingBidirectionalStreams(QuicStreamCount max_open_streams); |
| 38 | void SetMaxOpenIncomingUnidirectionalStreams( |
| 39 | QuicStreamCount max_open_streams); |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 40 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 41 | // Returns true if next outgoing bidirectional stream ID can be allocated. |
fayang | 769172b | 2020-03-19 14:27:39 -0700 | [diff] [blame^] | 42 | bool CanOpenNextOutgoingBidirectionalStream() const; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 43 | |
| 44 | // Returns true if next outgoing unidirectional stream ID can be allocated. |
fayang | 769172b | 2020-03-19 14:27:39 -0700 | [diff] [blame^] | 45 | bool CanOpenNextOutgoingUnidirectionalStream() const; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 46 | |
| 47 | // Returns the next outgoing bidirectional stream id. |
| 48 | QuicStreamId GetNextOutgoingBidirectionalStreamId(); |
| 49 | |
| 50 | // Returns the next outgoing unidirectional stream id. |
| 51 | QuicStreamId GetNextOutgoingUnidirectionalStreamId(); |
| 52 | |
fkastenholz | d3a1de9 | 2019-05-15 07:00:07 -0700 | [diff] [blame] | 53 | // Returns true if the incoming |id| is within the limit. |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 54 | bool MaybeIncreaseLargestPeerStreamId(QuicStreamId id); |
| 55 | |
| 56 | // Called when |id| is released. |
| 57 | void OnStreamClosed(QuicStreamId id); |
| 58 | |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 59 | // Called when a MAX_STREAMS frame is received. |
| 60 | bool OnMaxStreamsFrame(const QuicMaxStreamsFrame& frame); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 61 | |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 62 | // Called when a STREAMS_BLOCKED frame is received. |
| 63 | bool OnStreamsBlockedFrame(const QuicStreamsBlockedFrame& frame); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 64 | |
| 65 | // Return true if |id| is peer initiated. |
| 66 | bool IsIncomingStream(QuicStreamId id) const; |
| 67 | |
| 68 | // Returns true if |id| is still available. |
| 69 | bool IsAvailableStream(QuicStreamId id) const; |
| 70 | |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 71 | QuicStreamCount GetMaxAllowdIncomingBidirectionalStreams() const; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 72 | |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 73 | QuicStreamCount GetMaxAllowdIncomingUnidirectionalStreams() const; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 74 | |
renjietang | 686ce58 | 2019-10-17 14:28:16 -0700 | [diff] [blame] | 75 | QuicStreamId GetLargestPeerCreatedStreamId(bool unidirectional) const; |
| 76 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 77 | QuicStreamId next_outgoing_bidirectional_stream_id() const; |
| 78 | QuicStreamId next_outgoing_unidirectional_stream_id() const; |
| 79 | |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 80 | QuicStreamCount max_outgoing_bidirectional_streams() const; |
| 81 | QuicStreamCount max_outgoing_unidirectional_streams() const; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 82 | |
ianswett | d141453 | 2019-09-18 20:12:59 -0700 | [diff] [blame] | 83 | QuicStreamCount max_incoming_bidirectional_streams() const; |
| 84 | QuicStreamCount max_incoming_unidirectional_streams() const; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 85 | |
ianswett | d141453 | 2019-09-18 20:12:59 -0700 | [diff] [blame] | 86 | QuicStreamCount advertised_max_incoming_bidirectional_streams() const; |
| 87 | QuicStreamCount advertised_max_incoming_unidirectional_streams() const; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 88 | |
| 89 | private: |
| 90 | friend class test::QuicSessionPeer; |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 91 | friend class test::UberQuicStreamIdManagerPeer; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 92 | |
| 93 | // Manages stream IDs of bidirectional streams. |
| 94 | QuicStreamIdManager bidirectional_stream_id_manager_; |
| 95 | |
| 96 | // Manages stream IDs of unidirectional streams. |
| 97 | QuicStreamIdManager unidirectional_stream_id_manager_; |
| 98 | }; |
| 99 | |
| 100 | } // namespace quic |
| 101 | |
| 102 | #endif // QUICHE_QUIC_CORE_UBER_QUIC_STREAM_ID_MANAGER_H_ |