blob: e85336f9152f41ed0f69531f458e4549f9c38483 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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
10namespace quic {
QUICHE teama6ef0a62019-03-07 20:34:33 -050011
12UberQuicStreamIdManager::UberQuicStreamIdManager(
rchd40f9032019-09-23 07:27:04 -070013 Perspective perspective,
14 ParsedQuicVersion version,
15 QuicStreamIdManager::DelegateInterface* delegate,
fkastenholzd3a1de92019-05-15 07:00:07 -070016 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)
rchd40f9032019-09-23 07:27:04 -070020 : bidirectional_stream_id_manager_(delegate,
fkastenholz3c4eabf2019-04-22 07:49:59 -070021 /*unidirectional=*/false,
rchd40f9032019-09-23 07:27:04 -070022 perspective,
23 version.transport_version,
fkastenholzd3a1de92019-05-15 07:00:07 -070024 max_open_outgoing_bidirectional_streams,
25 max_open_incoming_bidirectional_streams),
26 unidirectional_stream_id_manager_(
rchd40f9032019-09-23 07:27:04 -070027 delegate,
fkastenholzd3a1de92019-05-15 07:00:07 -070028 /*unidirectional=*/true,
rchd40f9032019-09-23 07:27:04 -070029 perspective,
30 version.transport_version,
fkastenholzd3a1de92019-05-15 07:00:07 -070031 max_open_outgoing_unidirectional_streams,
32 max_open_incoming_unidirectional_streams) {}
QUICHE teama6ef0a62019-03-07 20:34:33 -050033
fkastenholzd3a1de92019-05-15 07:00:07 -070034void UberQuicStreamIdManager::SetMaxOpenOutgoingBidirectionalStreams(
renjietang52e13382019-12-16 15:58:04 -080035 QuicStreamCount max_open_streams) {
fkastenholz3c4eabf2019-04-22 07:49:59 -070036 bidirectional_stream_id_manager_.SetMaxOpenOutgoingStreams(max_open_streams);
fkastenholzd3a1de92019-05-15 07:00:07 -070037}
38void UberQuicStreamIdManager::SetMaxOpenOutgoingUnidirectionalStreams(
renjietang52e13382019-12-16 15:58:04 -080039 QuicStreamCount max_open_streams) {
fkastenholz3c4eabf2019-04-22 07:49:59 -070040 unidirectional_stream_id_manager_.SetMaxOpenOutgoingStreams(max_open_streams);
41}
fkastenholzd3a1de92019-05-15 07:00:07 -070042void UberQuicStreamIdManager::SetMaxOpenIncomingBidirectionalStreams(
renjietang52e13382019-12-16 15:58:04 -080043 QuicStreamCount max_open_streams) {
fkastenholz3c4eabf2019-04-22 07:49:59 -070044 bidirectional_stream_id_manager_.SetMaxOpenIncomingStreams(max_open_streams);
fkastenholzd3a1de92019-05-15 07:00:07 -070045}
46void UberQuicStreamIdManager::SetMaxOpenIncomingUnidirectionalStreams(
renjietang52e13382019-12-16 15:58:04 -080047 QuicStreamCount max_open_streams) {
fkastenholz3c4eabf2019-04-22 07:49:59 -070048 unidirectional_stream_id_manager_.SetMaxOpenIncomingStreams(max_open_streams);
QUICHE teama6ef0a62019-03-07 20:34:33 -050049}
50
fayang769172b2020-03-19 14:27:39 -070051bool UberQuicStreamIdManager::CanOpenNextOutgoingBidirectionalStream() const {
QUICHE teama6ef0a62019-03-07 20:34:33 -050052 return bidirectional_stream_id_manager_.CanOpenNextOutgoingStream();
53}
54
fayang769172b2020-03-19 14:27:39 -070055bool UberQuicStreamIdManager::CanOpenNextOutgoingUnidirectionalStream() const {
QUICHE teama6ef0a62019-03-07 20:34:33 -050056 return unidirectional_stream_id_manager_.CanOpenNextOutgoingStream();
57}
58
59QuicStreamId UberQuicStreamIdManager::GetNextOutgoingBidirectionalStreamId() {
60 return bidirectional_stream_id_manager_.GetNextOutgoingStreamId();
61}
62
63QuicStreamId UberQuicStreamIdManager::GetNextOutgoingUnidirectionalStreamId() {
64 return unidirectional_stream_id_manager_.GetNextOutgoingStreamId();
65}
66
67bool 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
76void 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
fkastenholz3c4eabf2019-04-22 07:49:59 -070084bool UberQuicStreamIdManager::OnMaxStreamsFrame(
85 const QuicMaxStreamsFrame& frame) {
86 if (frame.unidirectional) {
87 return unidirectional_stream_id_manager_.OnMaxStreamsFrame(frame);
QUICHE teama6ef0a62019-03-07 20:34:33 -050088 }
fkastenholz3c4eabf2019-04-22 07:49:59 -070089 return bidirectional_stream_id_manager_.OnMaxStreamsFrame(frame);
QUICHE teama6ef0a62019-03-07 20:34:33 -050090}
91
fkastenholz3c4eabf2019-04-22 07:49:59 -070092bool UberQuicStreamIdManager::OnStreamsBlockedFrame(
93 const QuicStreamsBlockedFrame& frame) {
94 if (frame.unidirectional) {
95 return unidirectional_stream_id_manager_.OnStreamsBlockedFrame(frame);
QUICHE teama6ef0a62019-03-07 20:34:33 -050096 }
fkastenholz3c4eabf2019-04-22 07:49:59 -070097 return bidirectional_stream_id_manager_.OnStreamsBlockedFrame(frame);
QUICHE teama6ef0a62019-03-07 20:34:33 -050098}
99
100bool 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
107bool 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
renjietang52e13382019-12-16 15:58:04 -0800114QuicStreamCount
115UberQuicStreamIdManager::GetMaxAllowdIncomingBidirectionalStreams() const {
fkastenholz3c4eabf2019-04-22 07:49:59 -0700116 return bidirectional_stream_id_manager_.incoming_initial_max_open_streams();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500117}
118
renjietang52e13382019-12-16 15:58:04 -0800119QuicStreamCount
120UberQuicStreamIdManager::GetMaxAllowdIncomingUnidirectionalStreams() const {
fkastenholz3c4eabf2019-04-22 07:49:59 -0700121 return unidirectional_stream_id_manager_.incoming_initial_max_open_streams();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500122}
123
renjietang686ce582019-10-17 14:28:16 -0700124QuicStreamId 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 teama6ef0a62019-03-07 20:34:33 -0500132QuicStreamId UberQuicStreamIdManager::next_outgoing_bidirectional_stream_id()
133 const {
134 return bidirectional_stream_id_manager_.next_outgoing_stream_id();
135}
136
137QuicStreamId UberQuicStreamIdManager::next_outgoing_unidirectional_stream_id()
138 const {
139 return unidirectional_stream_id_manager_.next_outgoing_stream_id();
140}
141
renjietang52e13382019-12-16 15:58:04 -0800142QuicStreamCount UberQuicStreamIdManager::max_outgoing_bidirectional_streams()
143 const {
fkastenholz3c4eabf2019-04-22 07:49:59 -0700144 return bidirectional_stream_id_manager_.outgoing_max_streams();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500145}
146
renjietang52e13382019-12-16 15:58:04 -0800147QuicStreamCount UberQuicStreamIdManager::max_outgoing_unidirectional_streams()
148 const {
fkastenholz3c4eabf2019-04-22 07:49:59 -0700149 return unidirectional_stream_id_manager_.outgoing_max_streams();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500150}
151
ianswettd1414532019-09-18 20:12:59 -0700152QuicStreamCount UberQuicStreamIdManager::max_incoming_bidirectional_streams()
QUICHE teama6ef0a62019-03-07 20:34:33 -0500153 const {
fkastenholz3c4eabf2019-04-22 07:49:59 -0700154 return bidirectional_stream_id_manager_.incoming_actual_max_streams();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500155}
156
ianswettd1414532019-09-18 20:12:59 -0700157QuicStreamCount UberQuicStreamIdManager::max_incoming_unidirectional_streams()
QUICHE teama6ef0a62019-03-07 20:34:33 -0500158 const {
fkastenholz3c4eabf2019-04-22 07:49:59 -0700159 return unidirectional_stream_id_manager_.incoming_actual_max_streams();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500160}
161
fkastenholz3c4eabf2019-04-22 07:49:59 -0700162QuicStreamCount
ianswettd1414532019-09-18 20:12:59 -0700163UberQuicStreamIdManager::advertised_max_incoming_bidirectional_streams() const {
fkastenholz3c4eabf2019-04-22 07:49:59 -0700164 return bidirectional_stream_id_manager_.incoming_advertised_max_streams();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500165}
166
ianswettd1414532019-09-18 20:12:59 -0700167QuicStreamCount
168UberQuicStreamIdManager::advertised_max_incoming_unidirectional_streams()
169 const {
fkastenholz3c4eabf2019-04-22 07:49:59 -0700170 return unidirectional_stream_id_manager_.incoming_advertised_max_streams();
QUICHE teama6ef0a62019-03-07 20:34:33 -0500171}
172
173} // namespace quic