Add QuicStreamsBlockedFrame and QuicMaxStreamsFrame classes
There are two main parts to this work
1) connecting up the new frames, replacing the old ones, to move data around the
system. This also entails a lot of editorial changes (just changing names, comments,
and so on, without notable logic chanages -- eg, "OnMaxStreamIdFrame" becomes
"OnMaxStreamsFrame".
2) the second, and more complex, task is revising the stream id manager to work entirely
with stream counts rather than stream-ids. For example, the logic to check whether a
new stream can be created checks if the current-stream-count is less than the limit
or not, rather than if the next stream id to hand out is above the limit or not.
For all intents and purposes, this completely rewrote the stream ID manager.
Another big change resulting from keeping track solely of stream counts is that the
stream ID manager doesn't care whether it is doing unidirectional or bidirectional
streams, nor does it care whether stream ids are client- or server- initiated.
gfe-relnote: N/A, all changes are for V99/IETF QUIC code only.
LOG_STORAGE_INCREASE(GB/week): 0
TMPLOG_STORAGE_INCREASE(GB): 0
This change neither adds nor deletes data stored. It adds two new codepoints to the QUIC FrameType enum. These new enums reflect two new frames defined in IETF QUIC, which replace two now-deprecated frames (and their associated type codepoints). This is a name change/type codepoint extension; data is neither added nor deleted.
PiperOrigin-RevId: 244661277
Change-Id: I07cdb79db6bd15e1d5ece97b3aa2d67e94ccf00b
diff --git a/quic/core/quic_session_test.cc b/quic/core/quic_session_test.cc
index a517d47..63235ba 100644
--- a/quic/core/quic_session_test.cc
+++ b/quic/core/quic_session_test.cc
@@ -393,6 +393,24 @@
QuicUtils::StreamIdDelta(connection_->transport_version()) * n;
}
+ QuicStreamId StreamCountToId(QuicStreamCount stream_count,
+ Perspective perspective,
+ bool bidirectional) {
+ // Calculate and build up stream ID rather than use
+ // GetFirst... because tests that rely on this method
+ // needs to do the stream count where #1 is 0/1/2/3, and not
+ // take into account that stream 0 is special.
+ QuicStreamId id =
+ ((stream_count - 1) * QuicUtils::StreamIdDelta(QUIC_VERSION_99));
+ if (!bidirectional) {
+ id |= 0x2;
+ }
+ if (perspective == Perspective::IS_SERVER) {
+ id |= 0x1;
+ }
+ return id;
+ }
+
MockQuicConnectionHelper helper_;
MockAlarmFactory alarm_factory_;
NiceMock<MockQuicSessionVisitor> session_visitor_;
@@ -1514,8 +1532,10 @@
}
if (transport_version() == QUIC_VERSION_99) {
- EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_STREAM_ID,
- "Stream id 24 above 20", _));
+ EXPECT_CALL(
+ *connection_,
+ CloseConnection(QUIC_INVALID_STREAM_ID,
+ "Stream id 24 would exceed stream count limit 6", _));
} else {
EXPECT_CALL(*connection_, SendControlFrame(_)).Times(1);
EXPECT_CALL(*connection_,
@@ -1601,7 +1621,7 @@
// it) does not count against the open quota (because it is closed from the
// protocol point of view).
if (transport_version() == QUIC_VERSION_99) {
- // On v99, we will expect to see a MAX_STREAM_ID go out when there are not
+ // On v99, we will expect to see a MAX_STREAMS go out when there are not
// enough streams to create the next one.
EXPECT_CALL(*connection_, SendControlFrame(_)).Times(1);
} else {
@@ -2179,19 +2199,24 @@
// Applicable only to V99
return;
}
- QuicStreamId bidirectional_stream_id =
+ QuicStreamId bidirectional_stream_id = StreamCountToId(
QuicSessionPeer::v99_streamid_manager(&session_)
- ->advertised_max_allowed_incoming_bidirectional_stream_id() -
- kV99StreamIdIncrement;
+ ->advertised_max_allowed_incoming_bidirectional_streams() -
+ 1,
+ Perspective::IS_CLIENT,
+ /*bidirectional=*/true);
+
QuicStreamFrame bidirectional_stream_frame(bidirectional_stream_id, false, 0,
"Random String");
EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0);
session_.OnStreamFrame(bidirectional_stream_frame);
- QuicStreamId unidirectional_stream_id =
+ QuicStreamId unidirectional_stream_id = StreamCountToId(
QuicSessionPeer::v99_streamid_manager(&session_)
- ->advertised_max_allowed_incoming_unidirectional_stream_id() -
- kV99StreamIdIncrement;
+ ->advertised_max_allowed_incoming_unidirectional_streams() -
+ 1,
+ Perspective::IS_CLIENT,
+ /*bidirectional=*/false);
QuicStreamFrame unidirectional_stream_frame(unidirectional_stream_id, false,
0, "Random String");
EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0);
@@ -2204,17 +2229,19 @@
// Applicable only to V99
return;
}
- QuicStreamId bidirectional_stream_id =
+ QuicStreamId bidirectional_stream_id = StreamCountToId(
QuicSessionPeer::v99_streamid_manager(&session_)
- ->advertised_max_allowed_incoming_bidirectional_stream_id();
+ ->advertised_max_allowed_incoming_bidirectional_streams(),
+ Perspective::IS_CLIENT, /*bidirectional=*/true);
QuicStreamFrame bidirectional_stream_frame(bidirectional_stream_id, false, 0,
"Random String");
EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0);
session_.OnStreamFrame(bidirectional_stream_frame);
- QuicStreamId unidirectional_stream_id =
+ QuicStreamId unidirectional_stream_id = StreamCountToId(
QuicSessionPeer::v99_streamid_manager(&session_)
- ->advertised_max_allowed_incoming_unidirectional_stream_id();
+ ->advertised_max_allowed_incoming_unidirectional_streams(),
+ Perspective::IS_CLIENT, /*bidirectional=*/false);
QuicStreamFrame unidirectional_stream_frame(unidirectional_stream_id, false,
0, "Random String");
EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0);
@@ -2227,24 +2254,30 @@
// Applicable only to V99
return;
}
- QuicStreamId bidirectional_stream_id =
+ QuicStreamId bidirectional_stream_id = StreamCountToId(
QuicSessionPeer::v99_streamid_manager(&session_)
- ->advertised_max_allowed_incoming_bidirectional_stream_id() +
- kV99StreamIdIncrement;
+ ->advertised_max_allowed_incoming_bidirectional_streams() +
+ 1,
+ Perspective::IS_CLIENT, /*bidirectional=*/true);
QuicStreamFrame bidirectional_stream_frame(bidirectional_stream_id, false, 0,
"Random String");
- EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_STREAM_ID,
- "Stream id 404 above 400", _));
+ EXPECT_CALL(
+ *connection_,
+ CloseConnection(QUIC_INVALID_STREAM_ID,
+ "Stream id 404 would exceed stream count limit 101", _));
session_.OnStreamFrame(bidirectional_stream_frame);
- QuicStreamId unidirectional_stream_id =
+ QuicStreamId unidirectional_stream_id = StreamCountToId(
QuicSessionPeer::v99_streamid_manager(&session_)
- ->advertised_max_allowed_incoming_unidirectional_stream_id() +
- kV99StreamIdIncrement;
+ ->advertised_max_allowed_incoming_unidirectional_streams() +
+ 1,
+ Perspective::IS_CLIENT, /*bidirectional=*/false);
QuicStreamFrame unidirectional_stream_frame(unidirectional_stream_id, false,
0, "Random String");
- EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_STREAM_ID,
- "Stream id 402 above 398", _));
+ EXPECT_CALL(
+ *connection_,
+ CloseConnection(QUIC_INVALID_STREAM_ID,
+ "Stream id 402 would exceed stream count limit 100", _));
session_.OnStreamFrame(unidirectional_stream_frame);
}