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/core/quic_connection.h b/quic/core/quic_connection.h
index 08f44ff..6586fb2 100644
--- a/quic/core/quic_connection.h
+++ b/quic/core/quic_connection.h
@@ -588,7 +588,7 @@
IsHandshake handshake) override;
const QuicFrames MaybeBundleAckOpportunistically() override;
char* GetPacketBuffer() override;
- void OnSerializedPacket(SerializedPacket* packet) override;
+ void OnSerializedPacket(SerializedPacket packet) override;
void OnUnrecoverableError(QuicErrorCode error,
const std::string& error_details) override;
@@ -971,7 +971,7 @@
// Send a packet to the peer, and takes ownership of the packet if the packet
// cannot be written immediately.
- virtual void SendOrQueuePacket(SerializedPacket* packet);
+ virtual void SendOrQueuePacket(SerializedPacket packet);
// Called after a packet is received from a new effective peer address and is
// decrypted. Starts validation of effective peer's address change. Calls