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 | #include "net/third_party/quiche/src/quic/core/uber_quic_stream_id_manager.h" |
| 6 | |
| 7 | #include "net/third_party/quiche/src/quic/core/quic_session.h" |
| 8 | #include "net/third_party/quiche/src/quic/core/quic_utils.h" |
| 9 | |
| 10 | namespace quic { |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 11 | |
| 12 | UberQuicStreamIdManager::UberQuicStreamIdManager( |
rch | d40f903 | 2019-09-23 07:27:04 -0700 | [diff] [blame] | 13 | Perspective perspective, |
| 14 | ParsedQuicVersion version, |
| 15 | QuicStreamIdManager::DelegateInterface* delegate, |
fkastenholz | d3a1de9 | 2019-05-15 07:00:07 -0700 | [diff] [blame] | 16 | QuicStreamCount max_open_outgoing_bidirectional_streams, |
| 17 | QuicStreamCount max_open_outgoing_unidirectional_streams, |
| 18 | QuicStreamCount max_open_incoming_bidirectional_streams, |
| 19 | QuicStreamCount max_open_incoming_unidirectional_streams) |
rch | d40f903 | 2019-09-23 07:27:04 -0700 | [diff] [blame] | 20 | : bidirectional_stream_id_manager_(delegate, |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 21 | /*unidirectional=*/false, |
rch | d40f903 | 2019-09-23 07:27:04 -0700 | [diff] [blame] | 22 | perspective, |
| 23 | version.transport_version, |
fkastenholz | d3a1de9 | 2019-05-15 07:00:07 -0700 | [diff] [blame] | 24 | max_open_outgoing_bidirectional_streams, |
| 25 | max_open_incoming_bidirectional_streams), |
| 26 | unidirectional_stream_id_manager_( |
rch | d40f903 | 2019-09-23 07:27:04 -0700 | [diff] [blame] | 27 | delegate, |
fkastenholz | d3a1de9 | 2019-05-15 07:00:07 -0700 | [diff] [blame] | 28 | /*unidirectional=*/true, |
rch | d40f903 | 2019-09-23 07:27:04 -0700 | [diff] [blame] | 29 | perspective, |
| 30 | version.transport_version, |
fkastenholz | d3a1de9 | 2019-05-15 07:00:07 -0700 | [diff] [blame] | 31 | max_open_outgoing_unidirectional_streams, |
| 32 | max_open_incoming_unidirectional_streams) {} |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 33 | |
fkastenholz | d3a1de9 | 2019-05-15 07:00:07 -0700 | [diff] [blame] | 34 | void UberQuicStreamIdManager::SetMaxOpenOutgoingBidirectionalStreams( |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 35 | QuicStreamCount max_open_streams) { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 36 | bidirectional_stream_id_manager_.SetMaxOpenOutgoingStreams(max_open_streams); |
fkastenholz | d3a1de9 | 2019-05-15 07:00:07 -0700 | [diff] [blame] | 37 | } |
| 38 | void UberQuicStreamIdManager::SetMaxOpenOutgoingUnidirectionalStreams( |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 39 | QuicStreamCount max_open_streams) { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 40 | unidirectional_stream_id_manager_.SetMaxOpenOutgoingStreams(max_open_streams); |
| 41 | } |
fkastenholz | d3a1de9 | 2019-05-15 07:00:07 -0700 | [diff] [blame] | 42 | void UberQuicStreamIdManager::SetMaxOpenIncomingBidirectionalStreams( |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 43 | QuicStreamCount max_open_streams) { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 44 | bidirectional_stream_id_manager_.SetMaxOpenIncomingStreams(max_open_streams); |
fkastenholz | d3a1de9 | 2019-05-15 07:00:07 -0700 | [diff] [blame] | 45 | } |
| 46 | void UberQuicStreamIdManager::SetMaxOpenIncomingUnidirectionalStreams( |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 47 | QuicStreamCount max_open_streams) { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 48 | unidirectional_stream_id_manager_.SetMaxOpenIncomingStreams(max_open_streams); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 49 | } |
| 50 | |
fayang | 769172b | 2020-03-19 14:27:39 -0700 | [diff] [blame^] | 51 | bool UberQuicStreamIdManager::CanOpenNextOutgoingBidirectionalStream() const { |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 52 | return bidirectional_stream_id_manager_.CanOpenNextOutgoingStream(); |
| 53 | } |
| 54 | |
fayang | 769172b | 2020-03-19 14:27:39 -0700 | [diff] [blame^] | 55 | bool UberQuicStreamIdManager::CanOpenNextOutgoingUnidirectionalStream() const { |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 56 | return unidirectional_stream_id_manager_.CanOpenNextOutgoingStream(); |
| 57 | } |
| 58 | |
| 59 | QuicStreamId UberQuicStreamIdManager::GetNextOutgoingBidirectionalStreamId() { |
| 60 | return bidirectional_stream_id_manager_.GetNextOutgoingStreamId(); |
| 61 | } |
| 62 | |
| 63 | QuicStreamId UberQuicStreamIdManager::GetNextOutgoingUnidirectionalStreamId() { |
| 64 | return unidirectional_stream_id_manager_.GetNextOutgoingStreamId(); |
| 65 | } |
| 66 | |
| 67 | bool UberQuicStreamIdManager::MaybeIncreaseLargestPeerStreamId( |
| 68 | QuicStreamId id) { |
| 69 | if (QuicUtils::IsBidirectionalStreamId(id)) { |
| 70 | return bidirectional_stream_id_manager_.MaybeIncreaseLargestPeerStreamId( |
| 71 | id); |
| 72 | } |
| 73 | return unidirectional_stream_id_manager_.MaybeIncreaseLargestPeerStreamId(id); |
| 74 | } |
| 75 | |
| 76 | void UberQuicStreamIdManager::OnStreamClosed(QuicStreamId id) { |
| 77 | if (QuicUtils::IsBidirectionalStreamId(id)) { |
| 78 | bidirectional_stream_id_manager_.OnStreamClosed(id); |
| 79 | return; |
| 80 | } |
| 81 | unidirectional_stream_id_manager_.OnStreamClosed(id); |
| 82 | } |
| 83 | |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 84 | bool UberQuicStreamIdManager::OnMaxStreamsFrame( |
| 85 | const QuicMaxStreamsFrame& frame) { |
| 86 | if (frame.unidirectional) { |
| 87 | return unidirectional_stream_id_manager_.OnMaxStreamsFrame(frame); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 88 | } |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 89 | return bidirectional_stream_id_manager_.OnMaxStreamsFrame(frame); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 90 | } |
| 91 | |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 92 | bool UberQuicStreamIdManager::OnStreamsBlockedFrame( |
| 93 | const QuicStreamsBlockedFrame& frame) { |
| 94 | if (frame.unidirectional) { |
| 95 | return unidirectional_stream_id_manager_.OnStreamsBlockedFrame(frame); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 96 | } |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 97 | return bidirectional_stream_id_manager_.OnStreamsBlockedFrame(frame); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | bool UberQuicStreamIdManager::IsIncomingStream(QuicStreamId id) const { |
| 101 | if (QuicUtils::IsBidirectionalStreamId(id)) { |
| 102 | return bidirectional_stream_id_manager_.IsIncomingStream(id); |
| 103 | } |
| 104 | return unidirectional_stream_id_manager_.IsIncomingStream(id); |
| 105 | } |
| 106 | |
| 107 | bool UberQuicStreamIdManager::IsAvailableStream(QuicStreamId id) const { |
| 108 | if (QuicUtils::IsBidirectionalStreamId(id)) { |
| 109 | return bidirectional_stream_id_manager_.IsAvailableStream(id); |
| 110 | } |
| 111 | return unidirectional_stream_id_manager_.IsAvailableStream(id); |
| 112 | } |
| 113 | |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 114 | QuicStreamCount |
| 115 | UberQuicStreamIdManager::GetMaxAllowdIncomingBidirectionalStreams() const { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 116 | return bidirectional_stream_id_manager_.incoming_initial_max_open_streams(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 117 | } |
| 118 | |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 119 | QuicStreamCount |
| 120 | UberQuicStreamIdManager::GetMaxAllowdIncomingUnidirectionalStreams() const { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 121 | return unidirectional_stream_id_manager_.incoming_initial_max_open_streams(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 122 | } |
| 123 | |
renjietang | 686ce58 | 2019-10-17 14:28:16 -0700 | [diff] [blame] | 124 | QuicStreamId UberQuicStreamIdManager::GetLargestPeerCreatedStreamId( |
| 125 | bool unidirectional) const { |
| 126 | if (unidirectional) { |
| 127 | return unidirectional_stream_id_manager_.largest_peer_created_stream_id(); |
| 128 | } |
| 129 | return bidirectional_stream_id_manager_.largest_peer_created_stream_id(); |
| 130 | } |
| 131 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 132 | QuicStreamId UberQuicStreamIdManager::next_outgoing_bidirectional_stream_id() |
| 133 | const { |
| 134 | return bidirectional_stream_id_manager_.next_outgoing_stream_id(); |
| 135 | } |
| 136 | |
| 137 | QuicStreamId UberQuicStreamIdManager::next_outgoing_unidirectional_stream_id() |
| 138 | const { |
| 139 | return unidirectional_stream_id_manager_.next_outgoing_stream_id(); |
| 140 | } |
| 141 | |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 142 | QuicStreamCount UberQuicStreamIdManager::max_outgoing_bidirectional_streams() |
| 143 | const { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 144 | return bidirectional_stream_id_manager_.outgoing_max_streams(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 145 | } |
| 146 | |
renjietang | 52e1338 | 2019-12-16 15:58:04 -0800 | [diff] [blame] | 147 | QuicStreamCount UberQuicStreamIdManager::max_outgoing_unidirectional_streams() |
| 148 | const { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 149 | return unidirectional_stream_id_manager_.outgoing_max_streams(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 150 | } |
| 151 | |
ianswett | d141453 | 2019-09-18 20:12:59 -0700 | [diff] [blame] | 152 | QuicStreamCount UberQuicStreamIdManager::max_incoming_bidirectional_streams() |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 153 | const { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 154 | return bidirectional_stream_id_manager_.incoming_actual_max_streams(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 155 | } |
| 156 | |
ianswett | d141453 | 2019-09-18 20:12:59 -0700 | [diff] [blame] | 157 | QuicStreamCount UberQuicStreamIdManager::max_incoming_unidirectional_streams() |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 158 | const { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 159 | return unidirectional_stream_id_manager_.incoming_actual_max_streams(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 160 | } |
| 161 | |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 162 | QuicStreamCount |
ianswett | d141453 | 2019-09-18 20:12:59 -0700 | [diff] [blame] | 163 | UberQuicStreamIdManager::advertised_max_incoming_bidirectional_streams() const { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 164 | return bidirectional_stream_id_manager_.incoming_advertised_max_streams(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 165 | } |
| 166 | |
ianswett | d141453 | 2019-09-18 20:12:59 -0700 | [diff] [blame] | 167 | QuicStreamCount |
| 168 | UberQuicStreamIdManager::advertised_max_incoming_unidirectional_streams() |
| 169 | const { |
fkastenholz | 3c4eabf | 2019-04-22 07:49:59 -0700 | [diff] [blame] | 170 | return unidirectional_stream_id_manager_.incoming_advertised_max_streams(); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | } // namespace quic |