Add QpackStreams into QuicSpdySession.
Currently our QuicStreamIdManager is still in a gQUIC style, which doesn't support creating static streams later in a session. Thus in this CL, all QPACK send streams are created right at QuicSpdySession initialization.
For the same reason, QPACK stream types are sent on the wire once handshake is confirmed. In the future we can delay it until we send data on those streams.
gfe-relnote: v99 only, not used in prod.
PiperOrigin-RevId: 263776677
Change-Id: If710bde79ea2698f68710d7ac36ca6b039556260
diff --git a/quic/tools/quic_simple_server_session_test.cc b/quic/tools/quic_simple_server_session_test.cc
index 10661ba..899db9c 100644
--- a/quic/tools/quic_simple_server_session_test.cc
+++ b/quic/tools/quic_simple_server_session_test.cc
@@ -496,7 +496,7 @@
QuicSimpleServerSessionPeer::CreateOutgoingUnidirectionalStream(
session_.get());
if (VersionHasStreamType(connection_->transport_version())) {
- EXPECT_EQ(GetNthServerInitiatedUnidirectionalId(i + 1),
+ EXPECT_EQ(GetNthServerInitiatedUnidirectionalId(i + 3),
created_stream->id());
} else {
EXPECT_EQ(GetNthServerInitiatedUnidirectionalId(i), created_stream->id());
@@ -533,7 +533,7 @@
"Data for nonexistent stream", _));
EXPECT_EQ(nullptr,
QuicSessionPeer::GetOrCreateStream(
- session_.get(), GetNthServerInitiatedUnidirectionalId(1)));
+ session_.get(), GetNthServerInitiatedUnidirectionalId(3)));
}
// In order to test the case where server push stream creation goes beyond
@@ -622,7 +622,7 @@
for (unsigned int i = 1; i <= num_resources; ++i) {
QuicStreamId stream_id;
if (VersionHasStreamType(connection_->transport_version())) {
- stream_id = GetNthServerInitiatedUnidirectionalId(i);
+ stream_id = GetNthServerInitiatedUnidirectionalId(i + 2);
} else {
stream_id = GetNthServerInitiatedUnidirectionalId(i - 1);
}
@@ -728,7 +728,7 @@
QuicStreamId next_out_going_stream_id;
if (VersionHasStreamType(connection_->transport_version())) {
next_out_going_stream_id =
- GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest + 1);
+ GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest + 3);
} else {
next_out_going_stream_id =
GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest);
@@ -773,11 +773,11 @@
// Version 99 also has unidirectional static streams, so we need to send
// MaxStreamFrame of the number of resources + number of static streams.
session_->OnMaxStreamsFrame(
- QuicMaxStreamsFrame(0, num_resources + 1, /*unidirectional=*/true));
+ QuicMaxStreamsFrame(0, num_resources + 3, /*unidirectional=*/true));
}
if (VersionHasStreamType(connection_->transport_version())) {
- session_->StreamDraining(GetNthServerInitiatedUnidirectionalId(1));
+ session_->StreamDraining(GetNthServerInitiatedUnidirectionalId(3));
} else {
session_->StreamDraining(GetNthServerInitiatedUnidirectionalId(0));
}
@@ -809,7 +809,7 @@
QuicStreamId stream_got_reset;
if (VersionHasStreamType(connection_->transport_version())) {
stream_got_reset =
- GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest + 2);
+ GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest + 4);
} else {
stream_got_reset =
GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest + 1);
@@ -829,7 +829,7 @@
QuicStreamId stream_not_reset;
if (VersionHasStreamType(connection_->transport_version())) {
stream_not_reset =
- GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest + 1);
+ GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest + 3);
} else {
stream_not_reset =
GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest);
@@ -869,10 +869,10 @@
// For pre-v-99, the node monitors its own stream usage and makes streams
// available as it closes/etc them.
session_->OnMaxStreamsFrame(
- QuicMaxStreamsFrame(0, num_resources + 1, /*unidirectional=*/true));
+ QuicMaxStreamsFrame(0, num_resources + 3, /*unidirectional=*/true));
}
- session_->StreamDraining(GetNthServerInitiatedUnidirectionalId(1));
- session_->StreamDraining(GetNthServerInitiatedUnidirectionalId(2));
+ session_->StreamDraining(GetNthServerInitiatedUnidirectionalId(3));
+ session_->StreamDraining(GetNthServerInitiatedUnidirectionalId(4));
}
// Tests that closing a open outgoing stream can trigger a promised resource in
@@ -893,14 +893,14 @@
QuicStreamId stream_to_open;
if (VersionHasStreamType(connection_->transport_version())) {
stream_to_open =
- GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest + 1);
+ GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest + 3);
} else {
stream_to_open = GetNthServerInitiatedUnidirectionalId(kMaxStreamsForTest);
}
// Resetting an open stream will close the stream and give space for extra
// stream to be opened.
- QuicStreamId stream_got_reset = GetNthServerInitiatedUnidirectionalId(1);
+ QuicStreamId stream_got_reset = GetNthServerInitiatedUnidirectionalId(3);
EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1);
EXPECT_CALL(*connection_, SendControlFrame(_));
if (!VersionHasIetfQuicFrames(transport_version())) {
@@ -944,7 +944,7 @@
// For pre-v-99, the node monitors its own stream usage and makes streams
// available as it closes/etc them.
session_->OnMaxStreamsFrame(
- QuicMaxStreamsFrame(0, num_resources + 1, /*unidirectional=*/true));
+ QuicMaxStreamsFrame(0, num_resources + 3, /*unidirectional=*/true));
}
visitor_->OnRstStream(rst);
// Create and inject a STOP_SENDING frame. In GOOGLE QUIC, receiving a
diff --git a/quic/tools/quic_simple_server_stream_test.cc b/quic/tools/quic_simple_server_stream_test.cc
index bf435b9..55ea842 100644
--- a/quic/tools/quic_simple_server_stream_test.cc
+++ b/quic/tools/quic_simple_server_stream_test.cc
@@ -417,7 +417,7 @@
// Create a new promised stream with even id().
auto promised_stream = new StrictMock<TestStream>(
GetNthServerInitiatedUnidirectionalStreamId(
- connection_->transport_version(), 1),
+ connection_->transport_version(), 3),
&session_, WRITE_UNIDIRECTIONAL, &memory_cache_backend_);
session_.ActivateStream(QuicWrapUnique(promised_stream));
@@ -553,7 +553,7 @@
// Create a stream with even stream id and test against this stream.
const QuicStreamId kServerInitiatedStreamId =
GetNthServerInitiatedUnidirectionalStreamId(
- connection_->transport_version(), 1);
+ connection_->transport_version(), 3);
// Create a server initiated stream and pass it to session_.
auto server_initiated_stream =
new StrictMock<TestStream>(kServerInitiatedStreamId, &session_,