Rename QuicConnection member variable most_recent_alternative_path_ to alternative_path.

The variable doesn't necessary hold the most recent one with the upcoming IETF connection migration change.

PiperOrigin-RevId: 355900963
Change-Id: Ibf183ed2ec3fe01be1aff35f395b593ed27b75fb
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 07834a8..e63b953 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -371,7 +371,7 @@
           encrypted_control_frames_ &&
           GetQuicReloadableFlag(quic_use_encryption_level_context)),
       path_validator_(alarm_factory_, &arena_, this, random_generator_),
-      most_recent_alternative_path_(QuicSocketAddress(), QuicSocketAddress()),
+      alternative_path_(QuicSocketAddress(), QuicSocketAddress()),
       most_recent_frame_type_(NUM_FRAME_TYPES) {
   QUIC_BUG_IF(!start_peer_migration_earlier_ && send_path_response_);
 
@@ -1098,9 +1098,9 @@
     // probing, restart the path degrading and blackhole detection.
     OnForwardProgressMade();
   }
-  if (IsMostRecentAlternativePath(self_address_, effective_peer_address_)) {
+  if (IsAlternativePath(self_address_, effective_peer_address_)) {
     // Reset alternative path state even if it is still under validation.
-    most_recent_alternative_path_.Clear();
+    alternative_path_.Clear();
   }
   // TODO(b/159074035): notify SentPacketManger with RTT sample from probing and
   // reset cwnd if this is a successful network migration.
@@ -2070,10 +2070,9 @@
     if (!IsDefaultPath(last_packet_destination_address_,
                        last_packet_source_address_)) {
       // This packet is received on a probing path. Do not close connection.
-      if (IsMostRecentAlternativePath(
-              last_packet_destination_address_,
-              GetEffectivePeerAddressFromCurrentPacket())) {
-        QUIC_BUG_IF(most_recent_alternative_path_.validated)
+      if (IsAlternativePath(last_packet_destination_address_,
+                            GetEffectivePeerAddressFromCurrentPacket())) {
+        QUIC_BUG_IF(alternative_path_.validated)
             << "STATELESS_RESET received on alternate path after it's "
                "validated.";
         path_validator_.CancelPathValidation();
@@ -4861,15 +4860,15 @@
     }
     QUIC_CODE_COUNT_N(quic_count_bytes_on_alternative_path_seperately, 3, 5);
     if (type == PATH_CHALLENGE_FRAME &&
-        !IsMostRecentAlternativePath(last_packet_destination_address_,
-                                     current_effective_peer_address)) {
-      // Only override most recent alternative path state upon a PATH_CHALLENGE.
+        !IsAlternativePath(last_packet_destination_address_,
+                           current_effective_peer_address)) {
+      // Only override the alternative path state upon a PATH_CHALLENGE.
       QUIC_DVLOG(1)
           << "The peer is probing a new path with effective peer address "
           << current_effective_peer_address << ",  self address "
           << last_packet_destination_address_;
-      most_recent_alternative_path_ = AlternativePathState(
-          last_packet_destination_address_, current_effective_peer_address);
+      alternative_path_ = AlternativePathState(last_packet_destination_address_,
+                                               current_effective_peer_address);
     }
     MaybeUpdateBytesReceivedFromAlternativeAddress(last_size_);
     return !update_packet_content_returns_connected_ || connected_;
@@ -5674,7 +5673,7 @@
       packet_creator_.SerializePathChallengeConnectivityProbingPacket(
           data_buffer);
   QUICHE_DCHECK_EQ(IsRetransmittable(*probing_packet), NO_RETRANSMITTABLE_DATA);
-  QUICHE_DCHECK_EQ(self_address, most_recent_alternative_path_.self_address);
+  QUICHE_DCHECK_EQ(self_address, alternative_path_.self_address);
   WritePacketUsingWriter(std::move(probing_packet), writer, self_address,
                          peer_address, /*measure_rtt=*/false);
   return true;
@@ -5696,7 +5695,7 @@
   QUICHE_DCHECK(use_path_validator_);
   if (perspective_ == Perspective::IS_CLIENT &&
       !IsDefaultPath(context->self_address(), context->peer_address())) {
-    most_recent_alternative_path_ =
+    alternative_path_ =
         AlternativePathState(context->self_address(), context->peer_address());
   }
   if (path_validator_.HasPendingPathValidation()) {
@@ -5813,40 +5812,36 @@
     return;
   }
   QUICHE_DCHECK(!IsDefaultPath(self_address_, peer_address));
-  if (!IsMostRecentAlternativePath(self_address_, peer_address)) {
+  if (!IsAlternativePath(self_address_, peer_address)) {
     QUIC_DLOG(INFO) << "Wrote to uninteresting peer address: " << peer_address
                     << " default direct_peer_address_ " << direct_peer_address_
                     << " alternative path peer address "
-                    << most_recent_alternative_path_.peer_address;
+                    << alternative_path_.peer_address;
     return;
   }
-  if (most_recent_alternative_path_.validated) {
+  if (alternative_path_.validated) {
     return;
   }
-  if (most_recent_alternative_path_.bytes_sent_before_address_validation >=
+  if (alternative_path_.bytes_sent_before_address_validation >=
       anti_amplification_factor_ *
-          most_recent_alternative_path_
-              .bytes_received_before_address_validation) {
+          alternative_path_.bytes_received_before_address_validation) {
     QUIC_LOG_FIRST_N(WARNING, 100)
         << "Server sent more data than allowed to unverified alternative "
            "peer address "
         << peer_address << " bytes sent "
-        << most_recent_alternative_path_.bytes_sent_before_address_validation
+        << alternative_path_.bytes_sent_before_address_validation
         << ", bytes received "
-        << most_recent_alternative_path_
-               .bytes_received_before_address_validation;
+        << alternative_path_.bytes_received_before_address_validation;
   }
-  most_recent_alternative_path_.bytes_sent_before_address_validation +=
-      sent_packet_size;
+  alternative_path_.bytes_sent_before_address_validation += sent_packet_size;
 }
 
 void QuicConnection::MaybeUpdateBytesReceivedFromAlternativeAddress(
     QuicByteCount received_packet_size) {
   if (!version().SupportsAntiAmplificationLimit() ||
       perspective_ != Perspective::IS_SERVER ||
-      !IsMostRecentAlternativePath(
-          last_packet_destination_address_,
-          GetEffectivePeerAddressFromCurrentPacket()) ||
+      !IsAlternativePath(last_packet_destination_address_,
+                         GetEffectivePeerAddressFromCurrentPacket()) ||
       current_incoming_packet_received_bytes_counted_) {
     return;
   }
@@ -5854,8 +5849,8 @@
   // recent alternative path.
   QUICHE_DCHECK(!IsDefaultPath(last_packet_destination_address_,
                                GetEffectivePeerAddressFromCurrentPacket()));
-  if (!most_recent_alternative_path_.validated) {
-    most_recent_alternative_path_.bytes_received_before_address_validation +=
+  if (!alternative_path_.validated) {
+    alternative_path_.bytes_received_before_address_validation +=
         received_packet_size;
   }
   current_incoming_packet_received_bytes_counted_ = true;
@@ -5867,11 +5862,11 @@
   return direct_peer_address_ == peer_address && self_address_ == self_address;
 }
 
-bool QuicConnection::IsMostRecentAlternativePath(
+bool QuicConnection::IsAlternativePath(
     const QuicSocketAddress& self_address,
     const QuicSocketAddress& peer_address) const {
-  return most_recent_alternative_path_.peer_address == peer_address &&
-         most_recent_alternative_path_.self_address == self_address;
+  return alternative_path_.peer_address == peer_address &&
+         alternative_path_.self_address == self_address;
 }
 
 void QuicConnection::AlternativePathState::Clear() {
diff --git a/quic/core/quic_connection.h b/quic/core/quic_connection.h
index 5746d75..318e88c 100644
--- a/quic/core/quic_connection.h
+++ b/quic/core/quic_connection.h
@@ -1604,8 +1604,8 @@
                               const QuicSocketAddress& peer_address,
                               bool measure_rtt);
 
-  // Increment bytes sent/received on the most recent alternative path if the
-  // current packet is sent/received on that path.
+  // Increment bytes sent/received on the alternative path if the current packet
+  // is sent/received on that path.
   void MaybeUpdateBytesSentToAlternativeAddress(
       const QuicSocketAddress& peer_address,
       QuicByteCount sent_packet_size);
@@ -1618,9 +1618,9 @@
                      const QuicSocketAddress& peer_address) const;
 
   // Return true if the given self address and peer address is the same as the
-  // self address and peer address of the most recent alternative path.
-  bool IsMostRecentAlternativePath(const QuicSocketAddress& self_address,
-                                   const QuicSocketAddress& peer_address) const;
+  // self address and peer address of the alternative path.
+  bool IsAlternativePath(const QuicSocketAddress& self_address,
+                         const QuicSocketAddress& peer_address) const;
 
   QuicFramer framer_;
 
@@ -2036,12 +2036,13 @@
 
   QuicPathValidator path_validator_;
 
-  // The most recent alternative path probed by an endpoint or its peer.
-  // It keeps track of the state of the probed path till it becomes the default
-  // path of the connection or replaced by a newer path under probing. The
-  // client starts to track it when it starts to validate the path. The server
-  // starts to track it when it receives a PATH_CHALLENGE in non-default path.
-  AlternativePathState most_recent_alternative_path_;
+  // Stores information of a path which maybe used as default path in the
+  // future. On the client side, it gets created when the client starts
+  // validating a new path and gets cleared once it becomes the default path or
+  // the path validation fails or replaced by a newer path of interest. On the
+  // server side, alternative_path gets created when server receives
+  // PATH_CHALLENGE on non-default path.
+  AlternativePathState alternative_path_;
 
   // This field is used to debug b/177312785.
   QuicFrameType most_recent_frame_type_;
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index 9b6943d..30d9144 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -1944,11 +1944,10 @@
       connection_.use_path_validator() &&
       GetQuicReloadableFlag(quic_count_bytes_on_alternative_path_seperately)) {
     QuicByteCount bytes_sent =
-        QuicConnectionPeer::BytesSentOnMostRecentAlternativePath(&connection_);
+        QuicConnectionPeer::BytesSentOnAlternativePath(&connection_);
     EXPECT_LT(0u, bytes_sent);
     EXPECT_EQ(received->length(),
-              QuicConnectionPeer::BytesReceivedOnMostRecentAlternativePath(
-                  &connection_));
+              QuicConnectionPeer::BytesReceivedOnAlternativePath(&connection_));
 
     // Receiving one more probing packet should update the bytes count.
     probing_packet = ConstructProbingPacket();
@@ -1960,12 +1959,10 @@
 
     EXPECT_EQ(num_probing_received + 2,
               connection_.GetStats().num_connectivity_probing_received);
-    EXPECT_EQ(
-        2 * bytes_sent,
-        QuicConnectionPeer::BytesSentOnMostRecentAlternativePath(&connection_));
+    EXPECT_EQ(2 * bytes_sent,
+              QuicConnectionPeer::BytesSentOnAlternativePath(&connection_));
     EXPECT_EQ(2 * received->length(),
-              QuicConnectionPeer::BytesReceivedOnMostRecentAlternativePath(
-                  &connection_));
+              QuicConnectionPeer::BytesReceivedOnAlternativePath(&connection_));
 
     EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
         .Times(AtLeast(1u))
@@ -1978,9 +1975,8 @@
             connection_.self_address(), kNewPeerAddress, writer_.get()),
         std::make_unique<TestValidationResultDelegate>(
             connection_.self_address(), kNewPeerAddress, &success));
-    EXPECT_EQ(
-        3 * bytes_sent,
-        QuicConnectionPeer::BytesSentOnMostRecentAlternativePath(&connection_));
+    EXPECT_EQ(3 * bytes_sent,
+              QuicConnectionPeer::BytesSentOnAlternativePath(&connection_));
 
     QuicFrames frames;
     frames.push_back(QuicFrame(new QuicPathResponseFrame(
@@ -1989,8 +1985,7 @@
                                      kNewPeerAddress,
                                      ENCRYPTION_FORWARD_SECURE);
     EXPECT_LT(2 * received->length(),
-              QuicConnectionPeer::BytesReceivedOnMostRecentAlternativePath(
-                  &connection_));
+              QuicConnectionPeer::BytesReceivedOnAlternativePath(&connection_));
   }
 
   // Process another packet with the old peer address on server side will not
@@ -12971,14 +12966,14 @@
       std::make_unique<TestValidationResultDelegate>(
           kNewSelfAddress, connection_.peer_address(), &success));
   EXPECT_TRUE(connection_.HasPendingPathValidation());
-  EXPECT_TRUE(QuicConnectionPeer::IsMostRecentAlternativePath(
+  EXPECT_TRUE(QuicConnectionPeer::IsAlternativePath(
       &connection_, kNewSelfAddress, connection_.peer_address()));
 
   connection_.MigratePath(kNewSelfAddress, connection_.peer_address(),
                           &new_writer, /*owns_writer=*/false);
   EXPECT_EQ(kNewSelfAddress, connection_.self_address());
   EXPECT_TRUE(connection_.HasPendingPathValidation());
-  EXPECT_FALSE(QuicConnectionPeer::IsMostRecentAlternativePath(
+  EXPECT_FALSE(QuicConnectionPeer::IsAlternativePath(
       &connection_, kNewSelfAddress, connection_.peer_address()));
 }
 
diff --git a/quic/test_tools/quic_connection_peer.cc b/quic/test_tools/quic_connection_peer.cc
index 7fee644..a3dc946 100644
--- a/quic/test_tools/quic_connection_peer.cc
+++ b/quic/test_tools/quic_connection_peer.cc
@@ -415,25 +415,23 @@
 }
 
 //  static
-QuicByteCount QuicConnectionPeer::BytesSentOnMostRecentAlternativePath(
+QuicByteCount QuicConnectionPeer::BytesSentOnAlternativePath(
     QuicConnection* connection) {
-  return connection->most_recent_alternative_path_
-      .bytes_sent_before_address_validation;
+  return connection->alternative_path_.bytes_sent_before_address_validation;
 }
 
 //  static
-QuicByteCount QuicConnectionPeer::BytesReceivedOnMostRecentAlternativePath(
+QuicByteCount QuicConnectionPeer::BytesReceivedOnAlternativePath(
     QuicConnection* connection) {
-  return connection->most_recent_alternative_path_
-      .bytes_received_before_address_validation;
+  return connection->alternative_path_.bytes_received_before_address_validation;
 }
 
 // static
-bool QuicConnectionPeer::IsMostRecentAlternativePath(
+bool QuicConnectionPeer::IsAlternativePath(
     QuicConnection* connection,
     const QuicSocketAddress& self_address,
     const QuicSocketAddress& peer_address) {
-  return connection->IsMostRecentAlternativePath(self_address, peer_address);
+  return connection->IsAlternativePath(self_address, peer_address);
 }
 
 }  // namespace test
diff --git a/quic/test_tools/quic_connection_peer.h b/quic/test_tools/quic_connection_peer.h
index ce72e6e..a47873e 100644
--- a/quic/test_tools/quic_connection_peer.h
+++ b/quic/test_tools/quic_connection_peer.h
@@ -172,16 +172,14 @@
 
   static QuicPathValidator* path_validator(QuicConnection* connection);
 
-  static QuicByteCount BytesSentOnMostRecentAlternativePath(
+  static QuicByteCount BytesSentOnAlternativePath(QuicConnection* connection);
+
+  static QuicByteCount BytesReceivedOnAlternativePath(
       QuicConnection* connection);
 
-  static QuicByteCount BytesReceivedOnMostRecentAlternativePath(
-      QuicConnection* connection);
-
-  static bool IsMostRecentAlternativePath(
-      QuicConnection* connection,
-      const QuicSocketAddress& self_address,
-      const QuicSocketAddress& peer_address);
+  static bool IsAlternativePath(QuicConnection* connection,
+                                const QuicSocketAddress& self_address,
+                                const QuicSocketAddress& peer_address);
 };
 
 }  // namespace test