Simplify QuicUtils::GetMaxStreamCount() because it's never used in gQUIC.
gfe-relnote: not used in production. not protected.
PiperOrigin-RevId: 302031491
Change-Id: Ibd41f7fa0393b333e331429577cc475774c61ce3
diff --git a/quic/core/quic_framer.cc b/quic/core/quic_framer.cc
index 95589ca..725e947 100644
--- a/quic/core/quic_framer.cc
+++ b/quic/core/quic_framer.cc
@@ -5970,19 +5970,14 @@
set_detailed_error("Can not read STREAMS_BLOCKED stream count.");
return false;
}
- frame->unidirectional = (frame_type == IETF_STREAMS_BLOCKED_UNIDIRECTIONAL);
- if (frame->stream_count >
- QuicUtils::GetMaxStreamCount(
- (frame_type == IETF_STREAMS_BLOCKED_UNIDIRECTIONAL),
- ((perspective_ == Perspective::IS_CLIENT)
- ? Perspective::IS_SERVER
- : Perspective::IS_CLIENT))) {
+ if (frame->stream_count > QuicUtils::GetMaxStreamCount()) {
// If stream count is such that the resulting stream ID would exceed our
// implementation limit, generate an error.
set_detailed_error(
"STREAMS_BLOCKED stream count exceeds implementation limit.");
return false;
}
+ frame->unidirectional = (frame_type == IETF_STREAMS_BLOCKED_UNIDIRECTIONAL);
return true;
}
diff --git a/quic/core/quic_stream_id_manager.cc b/quic/core/quic_stream_id_manager.cc
index 2a64118..fc05be0 100644
--- a/quic/core/quic_stream_id_manager.cc
+++ b/quic/core/quic_stream_id_manager.cc
@@ -97,8 +97,7 @@
// This implementation only supports 32 bit Stream IDs, so limit max streams
// if it would exceed the max 32 bits can express.
outgoing_max_streams_ =
- std::min(max_open_streams,
- QuicUtils::GetMaxStreamCount(unidirectional_, perspective_));
+ std::min(max_open_streams, QuicUtils::GetMaxStreamCount());
// Inform the higher layers that the stream limit has increased and that
// new streams may be created.
@@ -109,17 +108,14 @@
void QuicStreamIdManager::SetMaxOpenIncomingStreams(
QuicStreamCount max_open_streams) {
- QuicStreamCount implementation_max =
- QuicUtils::GetMaxStreamCount(unidirectional_, perspective());
- QuicStreamCount new_max = std::min(implementation_max, max_open_streams);
- if (new_max < incoming_stream_count_) {
+ if (max_open_streams < incoming_stream_count_) {
delegate_->OnStreamIdManagerError(
QUIC_MAX_STREAMS_ERROR, "Stream limit less than existing stream count");
return;
}
- incoming_actual_max_streams_ = new_max;
- incoming_advertised_max_streams_ = new_max;
- incoming_initial_max_open_streams_ = new_max;
+ incoming_actual_max_streams_ = max_open_streams;
+ incoming_advertised_max_streams_ = max_open_streams;
+ incoming_initial_max_open_streams_ = max_open_streams;
CalculateIncomingMaxStreamsWindow();
}
@@ -146,8 +142,7 @@
// If the stream is inbound, we can increase the actual stream limit and maybe
// advertise the new limit to the peer. Have to check to make sure that we do
// not exceed the maximum.
- if (incoming_actual_max_streams_ ==
- QuicUtils::GetMaxStreamCount(unidirectional_, perspective())) {
+ if (incoming_actual_max_streams_ == QuicUtils::GetMaxStreamCount()) {
// Reached the maximum stream id value that the implementation
// supports. Nothing can be done here.
return;
diff --git a/quic/core/quic_stream_id_manager_test.cc b/quic/core/quic_stream_id_manager_test.cc
index e9a4948..17d76b2 100644
--- a/quic/core/quic_stream_id_manager_test.cc
+++ b/quic/core/quic_stream_id_manager_test.cc
@@ -135,8 +135,7 @@
}
TEST_P(QuicStreamIdManagerTest, CheckMaxStreamsBadValuesOverMaxFailsOutgoing) {
- QuicStreamCount implementation_max =
- QuicUtils::GetMaxStreamCount(IsUnidirectional(), perspective());
+ QuicStreamCount implementation_max = QuicUtils::GetMaxStreamCount();
// Ensure that the limit is less than the implementation maximum.
EXPECT_LT(stream_id_manager_.outgoing_max_streams(), implementation_max);
@@ -146,39 +145,6 @@
EXPECT_EQ(implementation_max, stream_id_manager_.outgoing_max_streams());
}
-// Now do the same for the incoming streams
-TEST_P(QuicStreamIdManagerTest, CheckMaxStreamsBadValuesIncoming) {
- QuicStreamCount implementation_max =
- QuicUtils::GetMaxStreamCount(IsUnidirectional(), perspective());
- stream_id_manager_.SetMaxOpenIncomingStreams(implementation_max - 1u);
- EXPECT_EQ(implementation_max - 1u,
- stream_id_manager_.incoming_initial_max_open_streams());
- EXPECT_EQ(implementation_max - 1u,
- stream_id_manager_.incoming_actual_max_streams());
- EXPECT_EQ((implementation_max - 1u) / 2u,
- stream_id_manager_.max_streams_window());
-
- stream_id_manager_.SetMaxOpenIncomingStreams(implementation_max);
- EXPECT_EQ(implementation_max,
- stream_id_manager_.incoming_initial_max_open_streams());
- EXPECT_EQ(implementation_max,
- stream_id_manager_.incoming_actual_max_streams());
- EXPECT_EQ(implementation_max / 2, stream_id_manager_.max_streams_window());
-
- // Reset to 1 so that we can detect the change.
- stream_id_manager_.SetMaxOpenIncomingStreams(1u);
- EXPECT_EQ(1u, stream_id_manager_.incoming_initial_max_open_streams());
- EXPECT_EQ(1u, stream_id_manager_.incoming_actual_max_streams());
- EXPECT_EQ(1u, stream_id_manager_.max_streams_window());
- // Now try to exceed the max, without wrapping.
- stream_id_manager_.SetMaxOpenIncomingStreams(implementation_max + 1);
- EXPECT_EQ(implementation_max,
- stream_id_manager_.incoming_initial_max_open_streams());
- EXPECT_EQ(implementation_max,
- stream_id_manager_.incoming_actual_max_streams());
- EXPECT_EQ(implementation_max / 2u, stream_id_manager_.max_streams_window());
-}
-
// Check the case of the stream count in a STREAMS_BLOCKED frame is less than
// the count most recently advertised in a MAX_STREAMS frame. This should cause
// a MAX_STREAMS frame with the most recently advertised count to be sent.
diff --git a/quic/core/quic_utils.cc b/quic/core/quic_utils.cc
index 8057a7d..60354f3 100644
--- a/quic/core/quic_utils.cc
+++ b/quic/core/quic_utils.cc
@@ -586,12 +586,7 @@
}
// static
-QuicStreamCount QuicUtils::GetMaxStreamCount(bool unidirectional,
- Perspective perspective) {
- // gQUIC uses one client initiated bidi stream for the crypto stream.
- if (!unidirectional && perspective == Perspective::IS_CLIENT) {
- return kMaxQuicStreamCount >> 2;
- }
+QuicStreamCount QuicUtils::GetMaxStreamCount() {
return (kMaxQuicStreamCount >> 2) + 1;
}
diff --git a/quic/core/quic_utils.h b/quic/core/quic_utils.h
index c143154..eec9a5f 100644
--- a/quic/core/quic_utils.h
+++ b/quic/core/quic_utils.h
@@ -219,8 +219,7 @@
// Get the maximum value for a V99/IETF QUIC stream count. If a count
// exceeds this value, it will result in a stream ID that exceeds the
// implementation limit on stream ID size.
- static QuicStreamCount GetMaxStreamCount(bool unidirectional,
- Perspective perspective);
+ static QuicStreamCount GetMaxStreamCount();
};
template <typename Mask>