Add has_ack to QuicTransmissionInfo. Currently, only used for logging purpose, not protected. Add GetLastPacketContent to return a bitfield indicating the retransmittable frames in the last packet. PiperOrigin-RevId: 326496264 Change-Id: I181c101907a85b1070c42fae32a61e3034e111d5
diff --git a/quic/core/quic_unacked_packet_map.cc b/quic/core/quic_unacked_packet_map.cc index a18663f..e6328a7 100644 --- a/quic/core/quic_unacked_packet_map.cc +++ b/quic/core/quic_unacked_packet_map.cc
@@ -529,4 +529,21 @@ supports_multiple_packet_number_spaces_ = true; } +uint32_t QuicUnackedPacketMap::GetLastPacketContent() const { + if (empty()) { + // Use max uint32_t to distinguish with packets with no retransmittable + // frames nor acks. + return std::numeric_limits<uint32_t>::max(); + } + uint32_t content = 0; + const QuicTransmissionInfo& last_packet = unacked_packets_.back(); + for (const auto& frame : last_packet.retransmittable_frames) { + content |= (1 << frame.type); + } + if (last_packet.largest_acked.IsInitialized()) { + content |= (1 << ACK_FRAME); + } + return content; +} + } // namespace quic
diff --git a/quic/core/quic_unacked_packet_map.h b/quic/core/quic_unacked_packet_map.h index 43e9008..61b2ea8 100644 --- a/quic/core/quic_unacked_packet_map.h +++ b/quic/core/quic_unacked_packet_map.h
@@ -228,6 +228,12 @@ void EnableMultiplePacketNumberSpacesSupport(); + // Returns a bitfield of retransmittable frames of last packet in + // unacked_packets_. For example, if the packet contains STREAM_FRAME, content + // & (1 << STREAM_FRAME) would be set. Returns max uint32_t if + // unacked_packets_ is empty. + uint32_t GetLastPacketContent() const; + Perspective perspective() const { return perspective_; } bool supports_multiple_packet_number_spaces() const {
diff --git a/quic/core/quic_unacked_packet_map_test.cc b/quic/core/quic_unacked_packet_map_test.cc index 30482a3..330cc11 100644 --- a/quic/core/quic_unacked_packet_map_test.cc +++ b/quic/core/quic_unacked_packet_map_test.cc
@@ -634,6 +634,8 @@ EXPECT_EQ(QuicPacketNumber(4), unacked_packets_.GetLargestSentRetransmittableOfPacketNumberSpace( APPLICATION_DATA)); + EXPECT_TRUE(unacked_packets_.GetLastPacketContent() & (1 << STREAM_FRAME)); + EXPECT_FALSE(unacked_packets_.GetLastPacketContent() & (1 << ACK_FRAME)); } } // namespace