In QUIC, remove num_padding_bytes from SerializedPacket and TransmissionInfo.

(n/a) remove unused variables.

PiperOrigin-RevId: 318153506
Change-Id: I8ef247da549280754eb76b1249ec65757f4c36f8
diff --git a/quic/core/quic_packet_creator.cc b/quic/core/quic_packet_creator.cc
index c1f8982..07be112 100644
--- a/quic/core/quic_packet_creator.cc
+++ b/quic/core/quic_packet_creator.cc
@@ -495,7 +495,6 @@
   packet_.has_ack = false;
   packet_.has_stop_waiting = false;
   packet_.has_crypto_handshake = NOT_HANDSHAKE;
-  packet_.num_padding_bytes = 0;
   packet_.transmission_type = NOT_RETRANSMISSION;
   packet_.encrypted_buffer = nullptr;
   packet_.encrypted_length = 0;
@@ -785,7 +784,6 @@
     QUIC_BUG << "Failed to serialize " << QuicFramesToString(queued_frames_)
              << " at encryption_level: " << packet_.encryption_level
              << ", needs_full_padding_: " << needs_full_padding_
-             << ", packet_.num_padding_bytes: " << packet_.num_padding_bytes
              << ", pending_padding_bytes_: " << pending_padding_bytes_
              << ", latched_hard_max_packet_length_: "
              << latched_hard_max_packet_length_
@@ -1055,7 +1053,6 @@
     const QuicCoalescedPacket& coalesced,
     char* buffer,
     size_t buffer_len) {
-  QUIC_BUG_IF(packet_.num_padding_bytes != 0);
   if (HasPendingFrames()) {
     QUIC_BUG << "Try to serialize coalesced packet with pending frames";
     return 0;
@@ -1705,7 +1702,6 @@
 void QuicPacketCreator::MaybeAddPadding() {
   // The current packet should have no padding bytes because padding is only
   // added when this method is called just before the packet is serialized.
-  DCHECK_EQ(0, packet_.num_padding_bytes);
   if (BytesFree() == 0) {
     // Don't pad full packets.
     return;
@@ -1758,15 +1754,10 @@
   }
 
   int padding_bytes = -1;
-  if (needs_full_padding_) {
-    // Full padding does not consume pending padding bytes.
-    packet_.num_padding_bytes = -1;
-  } else {
-    packet_.num_padding_bytes =
-        std::min<int16_t>(pending_padding_bytes_, BytesFree());
-    pending_padding_bytes_ -= packet_.num_padding_bytes;
-    padding_bytes =
-        std::max<int16_t>(packet_.num_padding_bytes, extra_padding_bytes);
+  if (!needs_full_padding_) {
+    padding_bytes = std::min<int16_t>(pending_padding_bytes_, BytesFree());
+    pending_padding_bytes_ -= padding_bytes;
+    padding_bytes = std::max<int16_t>(padding_bytes, extra_padding_bytes);
   }
 
   bool success = AddFrame(QuicFrame(QuicPaddingFrame(padding_bytes)),
diff --git a/quic/core/quic_packets.cc b/quic/core/quic_packets.cc
index 69575b9..83b9773 100644
--- a/quic/core/quic_packets.cc
+++ b/quic/core/quic_packets.cc
@@ -456,7 +456,6 @@
     : encrypted_buffer(encrypted_buffer),
       encrypted_length(encrypted_length),
       has_crypto_handshake(NOT_HANDSHAKE),
-      num_padding_bytes(0),
       packet_number(packet_number),
       packet_number_length(packet_number_length),
       encryption_level(ENCRYPTION_INITIAL),
@@ -467,7 +466,6 @@
 
 SerializedPacket::SerializedPacket(SerializedPacket&& other)
     : has_crypto_handshake(other.has_crypto_handshake),
-      num_padding_bytes(other.num_padding_bytes),
       packet_number(other.packet_number),
       packet_number_length(other.packet_number_length),
       encryption_level(other.encryption_level),
@@ -515,7 +513,6 @@
       serialized.encrypted_buffer, serialized.encrypted_length,
       serialized.has_ack, serialized.has_stop_waiting);
   copy->has_crypto_handshake = serialized.has_crypto_handshake;
-  copy->num_padding_bytes = serialized.num_padding_bytes;
   copy->encryption_level = serialized.encryption_level;
   copy->transmission_type = serialized.transmission_type;
   copy->largest_acked = serialized.largest_acked;
diff --git a/quic/core/quic_packets.h b/quic/core/quic_packets.h
index 3e37a20..51105ad 100644
--- a/quic/core/quic_packets.h
+++ b/quic/core/quic_packets.h
@@ -390,10 +390,6 @@
   QuicFrames retransmittable_frames;
   QuicFrames nonretransmittable_frames;
   IsHandshake has_crypto_handshake;
-  // -1: full padding to the end of a max-sized packet
-  //  0: no padding
-  //  otherwise: only pad up to num_padding_bytes bytes
-  int16_t num_padding_bytes;
   QuicPacketNumber packet_number;
   QuicPacketNumberLength packet_number_length;
   EncryptionLevel encryption_level;
diff --git a/quic/core/quic_transmission_info.cc b/quic/core/quic_transmission_info.cc
index 163ba38..a27b769 100644
--- a/quic/core/quic_transmission_info.cc
+++ b/quic/core/quic_transmission_info.cc
@@ -13,24 +13,20 @@
       transmission_type(NOT_RETRANSMISSION),
       in_flight(false),
       state(OUTSTANDING),
-      has_crypto_handshake(false),
-      num_padding_bytes(0) {}
+      has_crypto_handshake(false) {}
 
-QuicTransmissionInfo::QuicTransmissionInfo(
-    EncryptionLevel level,
-    TransmissionType transmission_type,
-    QuicTime sent_time,
-    QuicPacketLength bytes_sent,
-    bool has_crypto_handshake,
-    int num_padding_bytes)
+QuicTransmissionInfo::QuicTransmissionInfo(EncryptionLevel level,
+                                           TransmissionType transmission_type,
+                                           QuicTime sent_time,
+                                           QuicPacketLength bytes_sent,
+                                           bool has_crypto_handshake)
     : encryption_level(level),
       bytes_sent(bytes_sent),
       sent_time(sent_time),
       transmission_type(transmission_type),
       in_flight(false),
       state(OUTSTANDING),
-      has_crypto_handshake(has_crypto_handshake),
-      num_padding_bytes(num_padding_bytes) {}
+      has_crypto_handshake(has_crypto_handshake) {}
 
 QuicTransmissionInfo::QuicTransmissionInfo(const QuicTransmissionInfo& other) =
     default;
diff --git a/quic/core/quic_transmission_info.h b/quic/core/quic_transmission_info.h
index a4fa762..b6c06a1 100644
--- a/quic/core/quic_transmission_info.h
+++ b/quic/core/quic_transmission_info.h
@@ -25,8 +25,7 @@
                        TransmissionType transmission_type,
                        QuicTime sent_time,
                        QuicPacketLength bytes_sent,
-                       bool has_crypto_handshake,
-                       int num_padding_bytes);
+                       bool has_crypto_handshake);
 
   QuicTransmissionInfo(const QuicTransmissionInfo& other);
 
@@ -44,8 +43,6 @@
   SentPacketState state;
   // True if the packet contains stream data from the crypto stream.
   bool has_crypto_handshake;
-  // Non-zero if the packet needs padding if it's retransmitted.
-  int16_t num_padding_bytes;
   // Stores the packet number of the next retransmission of this packet.
   // Zero if the packet has not been retransmitted.
   // TODO(fayang): rename this to first_sent_after_loss_ when deprecating
diff --git a/quic/core/quic_unacked_packet_map.cc b/quic/core/quic_unacked_packet_map.cc
index f06d074..38081ec 100644
--- a/quic/core/quic_unacked_packet_map.cc
+++ b/quic/core/quic_unacked_packet_map.cc
@@ -63,8 +63,7 @@
   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,
-                            packet->num_padding_bytes);
+                            sent_time, bytes_sent, has_crypto_handshake);
   info.largest_acked = packet->largest_acked;
   largest_sent_largest_acked_.UpdateMax(packet->largest_acked);