Automated g4 rollback of changelist 539970480. *** Reason for rollback *** This is causing Tests/QuicSpdyClientSessionTest.ZeroRttRejectReducesSessionFlowControlTooMuch/* to fail in Chromium. Rolling back to unblock merge. *** Original change description *** Remove MockClock from PacketSavingConnection, and use the MockClock in MockQuicConnectionHelper instead. *** PiperOrigin-RevId: 540881082
diff --git a/quiche/quic/test_tools/quic_test_utils.cc b/quiche/quic/test_tools/quic_test_utils.cc index ecc08ac..e04f0ca 100644 --- a/quiche/quic/test_tools/quic_test_utils.cc +++ b/quiche/quic/test_tools/quic_test_utils.cc
@@ -455,9 +455,9 @@ MockQuicConnectionHelper::~MockQuicConnectionHelper() {} -const MockClock* MockQuicConnectionHelper::GetClock() const { return &clock_; } +const QuicClock* MockQuicConnectionHelper::GetClock() const { return &clock_; } -MockClock* MockQuicConnectionHelper::GetClock() { return &clock_; } +QuicClock* MockQuicConnectionHelper::GetClock() { return &clock_; } QuicRandom* MockQuicConnectionHelper::GetRandomGenerator() { return &random_generator_; @@ -551,18 +551,16 @@ return false; } -PacketSavingConnection::PacketSavingConnection(MockQuicConnectionHelper* helper, - QuicAlarmFactory* alarm_factory, - Perspective perspective) - : MockQuicConnection(helper, alarm_factory, perspective), - mock_helper_(helper) {} +PacketSavingConnection::PacketSavingConnection( + QuicConnectionHelperInterface* helper, QuicAlarmFactory* alarm_factory, + Perspective perspective) + : MockQuicConnection(helper, alarm_factory, perspective) {} PacketSavingConnection::PacketSavingConnection( - MockQuicConnectionHelper* helper, QuicAlarmFactory* alarm_factory, + QuicConnectionHelperInterface* helper, QuicAlarmFactory* alarm_factory, Perspective perspective, const ParsedQuicVersionVector& supported_versions) : MockQuicConnection(helper, alarm_factory, perspective, - supported_versions), - mock_helper_(helper) {} + supported_versions) {} PacketSavingConnection::~PacketSavingConnection() {} @@ -574,13 +572,12 @@ void PacketSavingConnection::SendOrQueuePacket(SerializedPacket packet) { encrypted_packets_.push_back(std::make_unique<QuicEncryptedPacket>( CopyBuffer(packet), packet.encrypted_length, true)); - MockClock& clock = *mock_helper_->GetClock(); - clock.AdvanceTime(QuicTime::Delta::FromMilliseconds(10)); + clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(10)); // Transfer ownership of the packet to the SentPacketManager and the // ack notifier to the AckNotifierManager. OnPacketSent(packet.encryption_level, packet.transmission_type); QuicConnectionPeer::GetSentPacketManager(this)->OnPacketSent( - &packet, clock.ApproximateNow(), NOT_RETRANSMISSION, + &packet, clock_.ApproximateNow(), NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, true, ECN_NOT_ECT); } @@ -1135,7 +1132,7 @@ void CreateClientSessionForTest( QuicServerId server_id, QuicTime::Delta connection_start_time, const ParsedQuicVersionVector& supported_versions, - MockQuicConnectionHelper* helper, QuicAlarmFactory* alarm_factory, + QuicConnectionHelperInterface* helper, QuicAlarmFactory* alarm_factory, QuicCryptoClientConfig* crypto_client_config, PacketSavingConnection** client_connection, TestQuicSpdyClientSession** client_session) { @@ -1158,7 +1155,7 @@ void CreateServerSessionForTest( QuicServerId /*server_id*/, QuicTime::Delta connection_start_time, ParsedQuicVersionVector supported_versions, - MockQuicConnectionHelper* helper, QuicAlarmFactory* alarm_factory, + QuicConnectionHelperInterface* helper, QuicAlarmFactory* alarm_factory, QuicCryptoServerConfig* server_crypto_config, QuicCompressedCertsCache* compressed_certs_cache, PacketSavingConnection** server_connection,
diff --git a/quiche/quic/test_tools/quic_test_utils.h b/quiche/quic/test_tools/quic_test_utils.h index 4a054f3..ab1ec88 100644 --- a/quiche/quic/test_tools/quic_test_utils.h +++ b/quiche/quic/test_tools/quic_test_utils.h
@@ -516,8 +516,8 @@ MockQuicConnectionHelper(const MockQuicConnectionHelper&) = delete; MockQuicConnectionHelper& operator=(const MockQuicConnectionHelper&) = delete; ~MockQuicConnectionHelper() override; - const MockClock* GetClock() const override; - MockClock* GetClock(); + const QuicClock* GetClock() const override; + QuicClock* GetClock(); QuicRandom* GetRandomGenerator() override; quiche::QuicheBufferAllocator* GetStreamSendBufferAllocator() override; void AdvanceTime(QuicTime::Delta delta); @@ -737,11 +737,11 @@ class PacketSavingConnection : public MockQuicConnection { public: - PacketSavingConnection(MockQuicConnectionHelper* helper, + PacketSavingConnection(QuicConnectionHelperInterface* helper, QuicAlarmFactory* alarm_factory, Perspective perspective); - PacketSavingConnection(MockQuicConnectionHelper* helper, + PacketSavingConnection(QuicConnectionHelperInterface* helper, QuicAlarmFactory* alarm_factory, Perspective perspective, const ParsedQuicVersionVector& supported_versions); @@ -761,7 +761,7 @@ // Number of packets in encrypted_packets that has been delivered to the peer // connection. size_t number_of_packets_delivered_ = 0; - MockQuicConnectionHelper* mock_helper_ = nullptr; + MockClock clock_; }; class MockQuicSession : public QuicSession { @@ -1540,7 +1540,7 @@ void CreateClientSessionForTest( QuicServerId server_id, QuicTime::Delta connection_start_time, const ParsedQuicVersionVector& supported_versions, - MockQuicConnectionHelper* helper, QuicAlarmFactory* alarm_factory, + QuicConnectionHelperInterface* helper, QuicAlarmFactory* alarm_factory, QuicCryptoClientConfig* crypto_client_config, PacketSavingConnection** client_connection, TestQuicSpdyClientSession** client_session); @@ -1563,7 +1563,7 @@ void CreateServerSessionForTest( QuicServerId server_id, QuicTime::Delta connection_start_time, ParsedQuicVersionVector supported_versions, - MockQuicConnectionHelper* helper, QuicAlarmFactory* alarm_factory, + QuicConnectionHelperInterface* helper, QuicAlarmFactory* alarm_factory, QuicCryptoServerConfig* server_crypto_config, QuicCompressedCertsCache* compressed_certs_cache, PacketSavingConnection** server_connection,