Let quic::serializedpacket to own the frames and optionally the encrypted_buffer. no behavior change.
This change removes quic::ClearSerializedPacket() and quic::OwningSerializedPacketPointer. Their functionality have be moved to the destructor of quic::SerializedPacket. To simplify ownership, I changed quic::SerializedPacket to move-only and changed many functions in QuicPacketCreator and QuicConnection to take a SerializedPacket object instead of a pointer.
The optional ownership of encrypted_buffer is expressed using the newly added SerializedPacket.release_encrypted_buffer function. Currently only connectivity probing packets are setting it. In the next flag-protected change, I'll use it to free writer-allocated buffers.
PiperOrigin-RevId: 311381784
Change-Id: Icea678c488c4f2af1397ce82ecdf715b3d9f5407
diff --git a/quic/test_tools/quic_test_utils.cc b/quic/test_tools/quic_test_utils.cc
index 00a57e7..7d88ccd 100644
--- a/quic/test_tools/quic_test_utils.cc
+++ b/quic/test_tools/quic_test_utils.cc
@@ -560,14 +560,14 @@
PacketSavingConnection::~PacketSavingConnection() {}
-void PacketSavingConnection::SendOrQueuePacket(SerializedPacket* packet) {
+void PacketSavingConnection::SendOrQueuePacket(SerializedPacket packet) {
encrypted_packets_.push_back(std::make_unique<QuicEncryptedPacket>(
- CopyBuffer(*packet), packet->encrypted_length, true));
+ CopyBuffer(packet), packet.encrypted_length, true));
clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(10));
// Transfer ownership of the packet to the SentPacketManager and the
// ack notifier to the AckNotifierManager.
QuicConnectionPeer::GetSentPacketManager(this)->OnPacketSent(
- packet, clock_.ApproximateNow(), NOT_RETRANSMISSION,
+ &packet, clock_.ApproximateNow(), NOT_RETRANSMISSION,
HAS_RETRANSMITTABLE_DATA);
}