In QuicSentPacketManager::OnPacketSent and QuicUnackedPacketMap::AddSentPacket, make it clear that which part of the serialized packet can be modified.
I plan to move the debug_visitor_->OnPacketSent in QuicConnection to be after QuicSentPacketManager::OnPacketSent, such that the recorded traces reflects the state after the packet is sent. This is a prerequisite for that.
PiperOrigin-RevId: 331256790
Change-Id: I731983563a27ca068fd797e775e4039e4dd26309
diff --git a/quic/core/quic_sent_packet_manager.cc b/quic/core/quic_sent_packet_manager.cc
index 268e3cc..91e119a 100644
--- a/quic/core/quic_sent_packet_manager.cc
+++ b/quic/core/quic_sent_packet_manager.cc
@@ -688,37 +688,37 @@
}
bool QuicSentPacketManager::OnPacketSent(
- SerializedPacket* serialized_packet,
+ SerializedPacket* mutable_packet,
QuicTime sent_time,
TransmissionType transmission_type,
HasRetransmittableData has_retransmittable_data,
bool measure_rtt) {
- QuicPacketNumber packet_number = serialized_packet->packet_number;
+ const SerializedPacket& packet = *mutable_packet;
+ QuicPacketNumber packet_number = packet.packet_number;
DCHECK_LE(FirstSendingPacketNumber(), packet_number);
DCHECK(!unacked_packets_.IsUnacked(packet_number));
- QUIC_BUG_IF(serialized_packet->encrypted_length == 0)
- << "Cannot send empty packets.";
+ QUIC_BUG_IF(packet.encrypted_length == 0) << "Cannot send empty packets.";
if (pending_timer_transmission_count_ > 0) {
--pending_timer_transmission_count_;
}
bool in_flight = has_retransmittable_data == HAS_RETRANSMITTABLE_DATA;
if (using_pacing_) {
- pacing_sender_.OnPacketSent(
- sent_time, unacked_packets_.bytes_in_flight(), packet_number,
- serialized_packet->encrypted_length, has_retransmittable_data);
+ pacing_sender_.OnPacketSent(sent_time, unacked_packets_.bytes_in_flight(),
+ packet_number, packet.encrypted_length,
+ has_retransmittable_data);
} else {
- send_algorithm_->OnPacketSent(
- sent_time, unacked_packets_.bytes_in_flight(), packet_number,
- serialized_packet->encrypted_length, has_retransmittable_data);
+ send_algorithm_->OnPacketSent(sent_time, unacked_packets_.bytes_in_flight(),
+ packet_number, packet.encrypted_length,
+ has_retransmittable_data);
}
- if (serialized_packet->encryption_level == ENCRYPTION_FORWARD_SECURE) {
+ if (packet.encryption_level == ENCRYPTION_FORWARD_SECURE) {
one_rtt_packet_sent_ = true;
}
- unacked_packets_.AddSentPacket(serialized_packet, transmission_type,
- sent_time, in_flight, measure_rtt);
+ unacked_packets_.AddSentPacket(mutable_packet, transmission_type, sent_time,
+ in_flight, measure_rtt);
// Reset the retransmission timer anytime a pending packet is sent.
return in_flight;
}
diff --git a/quic/core/quic_sent_packet_manager.h b/quic/core/quic_sent_packet_manager.h
index a5181ab..678ce04 100644
--- a/quic/core/quic_sent_packet_manager.h
+++ b/quic/core/quic_sent_packet_manager.h
@@ -189,7 +189,7 @@
// the number of bytes sent and if they were retransmitted and if this packet
// is used for rtt measuring. Returns true if the sender should reset the
// retransmission timer.
- bool OnPacketSent(SerializedPacket* serialized_packet,
+ bool OnPacketSent(SerializedPacket* mutable_packet,
QuicTime sent_time,
TransmissionType transmission_type,
HasRetransmittableData has_retransmittable_data,
diff --git a/quic/core/quic_unacked_packet_map.cc b/quic/core/quic_unacked_packet_map.cc
index 1632fe3..3d5579d 100644
--- a/quic/core/quic_unacked_packet_map.cc
+++ b/quic/core/quic_unacked_packet_map.cc
@@ -128,13 +128,14 @@
}
}
-void QuicUnackedPacketMap::AddSentPacket(SerializedPacket* packet,
+void QuicUnackedPacketMap::AddSentPacket(SerializedPacket* mutable_packet,
TransmissionType transmission_type,
QuicTime sent_time,
bool set_in_flight,
bool measure_rtt) {
- QuicPacketNumber packet_number = packet->packet_number;
- QuicPacketLength bytes_sent = packet->encrypted_length;
+ const SerializedPacket& packet = *mutable_packet;
+ QuicPacketNumber packet_number = packet.packet_number;
+ QuicPacketLength bytes_sent = packet.encrypted_length;
QUIC_BUG_IF(largest_sent_packet_.IsInitialized() &&
largest_sent_packet_ >= packet_number)
<< "largest_sent_packet_: " << largest_sent_packet_
@@ -145,12 +146,11 @@
unacked_packets_.back().state = NEVER_SENT;
}
- const bool has_crypto_handshake =
- packet->has_crypto_handshake == IS_HANDSHAKE;
- QuicTransmissionInfo info(packet->encryption_level, transmission_type,
+ const bool has_crypto_handshake = packet.has_crypto_handshake == IS_HANDSHAKE;
+ QuicTransmissionInfo info(packet.encryption_level, transmission_type,
sent_time, bytes_sent, has_crypto_handshake);
- info.largest_acked = packet->largest_acked;
- largest_sent_largest_acked_.UpdateMax(packet->largest_acked);
+ info.largest_acked = packet.largest_acked;
+ largest_sent_largest_acked_.UpdateMax(packet.largest_acked);
if (!measure_rtt) {
QUIC_BUG_IF(set_in_flight);
@@ -176,7 +176,7 @@
last_crypto_packet_sent_time_ = sent_time;
}
- packet->retransmittable_frames.swap(
+ mutable_packet->retransmittable_frames.swap(
unacked_packets_.back().retransmittable_frames);
}
diff --git a/quic/core/quic_unacked_packet_map.h b/quic/core/quic_unacked_packet_map.h
index 8365009..601daeb 100644
--- a/quic/core/quic_unacked_packet_map.h
+++ b/quic/core/quic_unacked_packet_map.h
@@ -30,13 +30,13 @@
QuicUnackedPacketMap& operator=(const QuicUnackedPacketMap&) = delete;
~QuicUnackedPacketMap();
- // Adds |serialized_packet| to the map and marks it as sent at |sent_time|.
+ // Adds |mutable_packet| to the map and marks it as sent at |sent_time|.
// Marks the packet as in flight if |set_in_flight| is true.
// Packets marked as in flight are expected to be marked as missing when they
// don't arrive, indicating the need for retransmission.
- // Any AckNotifierWrappers in |serialized_packet| are swapped from the
- // serialized packet into the QuicTransmissionInfo.
- void AddSentPacket(SerializedPacket* serialized_packet,
+ // Any retransmittible_frames in |mutable_packet| are swapped from
+ // |mutable_packet| into the QuicTransmissionInfo.
+ void AddSentPacket(SerializedPacket* mutable_packet,
TransmissionType transmission_type,
QuicTime sent_time,
bool set_in_flight,