QuicConnection methods call CloseConnection rather than
TearDownLocalConnectionState
Some of the QuicConnection methods call TearDownLocalConnectionState
rather than CloseConnection. This changes then all to call CloseConnection,
specifying ConnectionCloseBehavior::SILENT_CLOSE.
Some tests modified to expect calls to CloseConnection (preventing test failure due to unexpected calls). Before this CL the connection closing happened via internal calls directly to TearDownLocalConnectionState; now these calls go through CloseConnection and trigger the expect.
This is done in preparation for landing another CL adding IETF QUIC Connection Close functionality.
QuicConnection::OnUnrecoverableError (which is an override of QuicPacketCreator::OnUnrecoverableError) called TearDownLocalConnectionState. It had to be modified to call CloseConnection. OnUnrecoverableError has a ConnectionCloseSource parameter, which CloseConnection does not take. Thus the parameter was removed from OnUnrecoverableError. This is OK since all of the calls to OnUnrecoverableError specified FROM_SELF as the source. CloseConnection uses FROM_SELF as the source (unless the error code is a stateless reject or public reset).
gfe-relnote: No flag protection as it is only moving existing functionality around.
PiperOrigin-RevId: 250341745
Change-Id: Iafe499eda682f3db678d0eddbf7e2e3e4367cebd
diff --git a/quic/test_tools/quic_test_utils.h b/quic/test_tools/quic_test_utils.h
index a889804..4f6a30a 100644
--- a/quic/test_tools/quic_test_utils.h
+++ b/quic/test_tools/quic_test_utils.h
@@ -1046,10 +1046,7 @@
MOCK_METHOD0(GetPacketBuffer, char*());
MOCK_METHOD1(OnSerializedPacket, void(SerializedPacket* packet));
- MOCK_METHOD3(OnUnrecoverableError,
- void(QuicErrorCode,
- const std::string&,
- ConnectionCloseSource source));
+ MOCK_METHOD2(OnUnrecoverableError, void(QuicErrorCode, const std::string&));
};
class MockSessionNotifier : public SessionNotifierInterface {
diff --git a/quic/test_tools/simple_session_notifier_test.cc b/quic/test_tools/simple_session_notifier_test.cc
index e5298eb..d2aad9f 100644
--- a/quic/test_tools/simple_session_notifier_test.cc
+++ b/quic/test_tools/simple_session_notifier_test.cc
@@ -241,6 +241,7 @@
EXPECT_CALL(connection_, SendCryptoData(ENCRYPTION_INITIAL, 1024, 0))
.WillOnce(Invoke(&connection_,
&MockQuicConnection::QuicConnection_SendCryptoData));
+ EXPECT_CALL(connection_, CloseConnection(QUIC_PACKET_WRITE_ERROR, _, _));
producer.SaveCryptoData(ENCRYPTION_INITIAL, 0, std::string(1024, 'a'));
producer.SaveCryptoData(ENCRYPTION_INITIAL, 500, std::string(524, 'a'));
notifier_.WriteCryptoData(ENCRYPTION_INITIAL, 1024, 0);