Deprecate --gfe2_reloadable_flag_quic_add_cached_network_parameters_to_address_token2.

PiperOrigin-RevId: 438101444
diff --git a/quic/core/http/end_to_end_test.cc b/quic/core/http/end_to_end_test.cc
index 03c0943..ac10d0f 100644
--- a/quic/core/http/end_to_end_test.cc
+++ b/quic/core/http/end_to_end_test.cc
@@ -1661,30 +1661,26 @@
         static_cast<const QuicCryptoServerStreamBase*>(
             server_session->GetCryptoStream())
             ->PreviousCachedNetworkParams();
-    if (GetQuicReloadableFlag(
-            quic_add_cached_network_parameters_to_address_token2)) {
-      ASSERT_NE(server_received_network_params, nullptr);
-      // QuicSentPacketManager::SetInitialRtt clamps the initial_rtt to between
-      // [min_initial_rtt, max_initial_rtt].
-      const QuicTime::Delta min_initial_rtt =
-          server_connection->sent_packet_manager().use_lower_min_irtt()
-              ? QuicTime::Delta::FromMicroseconds(
-                    kMinTrustedInitialRoundTripTimeUs)
-              : QuicTime::Delta::FromMicroseconds(
-                    kMinUntrustedInitialRoundTripTimeUs);
-      const QuicTime::Delta max_initial_rtt =
-          QuicTime::Delta::FromMicroseconds(kMaxInitialRoundTripTimeUs);
-      const QuicTime::Delta expected_initial_rtt =
-          std::max(min_initial_rtt,
-                   std::min(max_initial_rtt,
-                            QuicTime::Delta::FromMilliseconds(
-                                server_received_network_params->min_rtt_ms())));
-      EXPECT_EQ(
-          server_connection->sent_packet_manager().GetRttStats()->initial_rtt(),
-          expected_initial_rtt);
-    } else {
-      EXPECT_EQ(server_received_network_params, nullptr);
-    }
+
+    ASSERT_NE(server_received_network_params, nullptr);
+    // QuicSentPacketManager::SetInitialRtt clamps the initial_rtt to between
+    // [min_initial_rtt, max_initial_rtt].
+    const QuicTime::Delta min_initial_rtt =
+        server_connection->sent_packet_manager().use_lower_min_irtt()
+            ? QuicTime::Delta::FromMicroseconds(
+                  kMinTrustedInitialRoundTripTimeUs)
+            : QuicTime::Delta::FromMicroseconds(
+                  kMinUntrustedInitialRoundTripTimeUs);
+    const QuicTime::Delta max_initial_rtt =
+        QuicTime::Delta::FromMicroseconds(kMaxInitialRoundTripTimeUs);
+    const QuicTime::Delta expected_initial_rtt =
+        std::max(min_initial_rtt,
+                 std::min(max_initial_rtt,
+                          QuicTime::Delta::FromMilliseconds(
+                              server_received_network_params->min_rtt_ms())));
+    EXPECT_EQ(
+        server_connection->sent_packet_manager().GetRttStats()->initial_rtt(),
+        expected_initial_rtt);
   } else {
     ADD_FAILURE() << "Missing server connection";
   }
@@ -1749,72 +1745,6 @@
   client_->Disconnect();
 }
 
-TEST_P(EndToEndTest, AddressTokenRefreshedByServer) {
-  SetQuicReloadableFlag(quic_add_cached_network_parameters_to_address_token2,
-                        true);
-  ASSERT_TRUE(Initialize());
-  if (!version_.HasIetfQuicFrames()) {
-    return;
-  }
-
-  QuicCryptoClientConfig* client_crypto_config =
-      client_->client()->crypto_config();
-  QuicServerId server_id = client_->client()->server_id();
-
-  SendSynchronousFooRequestAndCheckResponse();
-  EXPECT_FALSE(GetClientSession()->EarlyDataAccepted());
-
-  client_->Disconnect();
-
-  QuicClientSessionCache* session_cache = static_cast<QuicClientSessionCache*>(
-      client_crypto_config->mutable_session_cache());
-  std::string old_address_token;
-  if (GetQuicReloadableFlag(quic_tls_use_token_in_session_cache)) {
-    old_address_token =
-        QuicClientSessionCachePeer::GetToken(session_cache, server_id);
-  } else {
-    old_address_token =
-        client_crypto_config->LookupOrCreate(server_id)->source_address_token();
-  }
-  ASSERT_TRUE(!old_address_token.empty());
-
-  SetQuicReloadableFlag(quic_add_cached_network_parameters_to_address_token2,
-                        false);
-
-  // The 0-RTT handshake should succeed.
-  client_->Connect();
-  EXPECT_TRUE(client_->client()->WaitForOneRttKeysAvailable());
-  ASSERT_TRUE(client_->client()->connected());
-  SendSynchronousFooRequestAndCheckResponse();
-
-  EXPECT_TRUE(GetClientSession()->EarlyDataAccepted());
-
-  server_thread_->Pause();
-  QuicSpdySession* server_session = GetServerSession();
-  QuicConnection* server_connection = GetServerConnection();
-  ASSERT_TRUE(server_session != nullptr && server_connection != nullptr);
-  // Verify address is validated via validating token received in INITIAL
-  // packet.
-  EXPECT_FALSE(
-      server_connection->GetStats().address_validated_via_decrypting_packet);
-  EXPECT_TRUE(server_connection->GetStats().address_validated_via_token);
-
-  server_thread_->Resume();
-
-  client_->Disconnect();
-
-  std::string new_address_token;
-  if (GetQuicReloadableFlag(quic_tls_use_token_in_session_cache)) {
-    new_address_token =
-        QuicClientSessionCachePeer::GetToken(session_cache, server_id);
-  } else {
-    new_address_token =
-        client_crypto_config->LookupOrCreate(server_id)->source_address_token();
-  }
-  ASSERT_TRUE(!new_address_token.empty());
-  ASSERT_NE(new_address_token, old_address_token);
-}
-
 // Verify that client does not reuse a source address token.
 TEST_P(EndToEndTest, AddressTokenNotReusedByClient) {
   ASSERT_TRUE(Initialize());
diff --git a/quic/core/http/quic_server_session_base.cc b/quic/core/http/quic_server_session_base.cc
index 5b1fe05..b96a693 100644
--- a/quic/core/http/quic_server_session_base.cc
+++ b/quic/core/http/quic_server_session_base.cc
@@ -62,8 +62,7 @@
   // Set the initial rtt from cached_network_params.min_rtt_ms, which comes from
   // a validated address token. This will override the initial rtt that may have
   // been set by the transport parameters.
-  if (add_cached_network_parameters_to_address_token() && version().UsesTls() &&
-      cached_network_params != nullptr) {
+  if (version().UsesTls() && cached_network_params != nullptr) {
     if (cached_network_params->serving_region() == serving_region_) {
       QUIC_CODE_COUNT(quic_server_received_network_params_at_same_region);
       if ((!use_lower_min_irtt || config()->HasReceivedConnectionOptions()) &&
@@ -102,8 +101,7 @@
   // resumption.
   if (cached_network_params != nullptr &&
       cached_network_params->serving_region() == serving_region_) {
-    if (!add_cached_network_parameters_to_address_token() ||
-        !version().UsesTls()) {
+    if (!version().UsesTls()) {
       // Log the received connection parameters, regardless of how they
       // get used for bandwidth resumption.
       connection()->OnReceiveConnectionState(*cached_network_params);
@@ -190,74 +188,28 @@
     return;
   }
 
-  if (add_cached_network_parameters_to_address_token()) {
-    if (version().UsesTls()) {
-      if (version().HasIetfQuicFrames() && MaybeSendAddressToken()) {
-        bandwidth_estimate_sent_to_client_ = new_bandwidth_estimate;
-      }
-    } else {
-      absl::optional<CachedNetworkParameters> cached_network_params =
-          GenerateCachedNetworkParameters();
-
-      if (cached_network_params.has_value()) {
-        bandwidth_estimate_sent_to_client_ = new_bandwidth_estimate;
-        QUIC_DVLOG(1) << "Server: sending new bandwidth estimate (KBytes/s): "
-                      << bandwidth_estimate_sent_to_client_.ToKBytesPerSecond();
-
-        QUICHE_DCHECK_EQ(
-            BandwidthToCachedParameterBytesPerSecond(
-                bandwidth_estimate_sent_to_client_),
-            cached_network_params->bandwidth_estimate_bytes_per_second());
-
-        crypto_stream_->SendServerConfigUpdate(&cached_network_params.value());
-
-        connection()->OnSendConnectionState(*cached_network_params);
-      }
+  if (version().UsesTls()) {
+    if (version().HasIetfQuicFrames() && MaybeSendAddressToken()) {
+      bandwidth_estimate_sent_to_client_ = new_bandwidth_estimate;
     }
   } else {
-    bandwidth_estimate_sent_to_client_ = new_bandwidth_estimate;
-    QUIC_DVLOG(1) << "Server: sending new bandwidth estimate (KBytes/s): "
-                  << bandwidth_estimate_sent_to_client_.ToKBytesPerSecond();
+    absl::optional<CachedNetworkParameters> cached_network_params =
+        GenerateCachedNetworkParameters();
 
-    // Include max bandwidth in the update.
-    QuicBandwidth max_bandwidth_estimate =
-        bandwidth_recorder->MaxBandwidthEstimate();
-    int32_t max_bandwidth_timestamp =
-        bandwidth_recorder->MaxBandwidthTimestamp();
+    if (cached_network_params.has_value()) {
+      bandwidth_estimate_sent_to_client_ = new_bandwidth_estimate;
+      QUIC_DVLOG(1) << "Server: sending new bandwidth estimate (KBytes/s): "
+                    << bandwidth_estimate_sent_to_client_.ToKBytesPerSecond();
 
-    // Fill the proto before passing it to the crypto stream to send.
-    const int32_t bw_estimate_bytes_per_second =
-        BandwidthToCachedParameterBytesPerSecond(
-            bandwidth_estimate_sent_to_client_);
-    const int32_t max_bw_estimate_bytes_per_second =
-        BandwidthToCachedParameterBytesPerSecond(max_bandwidth_estimate);
-    QUIC_BUG_IF(quic_bug_12513_1, max_bw_estimate_bytes_per_second < 0)
-        << max_bw_estimate_bytes_per_second;
-    QUIC_BUG_IF(quic_bug_10393_1, bw_estimate_bytes_per_second < 0)
-        << bw_estimate_bytes_per_second;
+      QUICHE_DCHECK_EQ(
+          BandwidthToCachedParameterBytesPerSecond(
+              bandwidth_estimate_sent_to_client_),
+          cached_network_params->bandwidth_estimate_bytes_per_second());
 
-    CachedNetworkParameters cached_network_params;
-    cached_network_params.set_bandwidth_estimate_bytes_per_second(
-        bw_estimate_bytes_per_second);
-    cached_network_params.set_max_bandwidth_estimate_bytes_per_second(
-        max_bw_estimate_bytes_per_second);
-    cached_network_params.set_max_bandwidth_timestamp_seconds(
-        max_bandwidth_timestamp);
-    cached_network_params.set_min_rtt_ms(
-        sent_packet_manager.GetRttStats()->min_rtt().ToMilliseconds());
-    cached_network_params.set_previous_connection_state(
-        bandwidth_recorder->EstimateRecordedDuringSlowStart()
-            ? CachedNetworkParameters::SLOW_START
-            : CachedNetworkParameters::CONGESTION_AVOIDANCE);
-    cached_network_params.set_timestamp(
-        connection()->clock()->WallNow().ToUNIXSeconds());
-    if (!serving_region_.empty()) {
-      cached_network_params.set_serving_region(serving_region_);
+      crypto_stream_->SendServerConfigUpdate(&cached_network_params.value());
+
+      connection()->OnSendConnectionState(*cached_network_params);
     }
-
-    crypto_stream_->SendServerConfigUpdate(&cached_network_params);
-
-    connection()->OnSendConnectionState(cached_network_params);
   }
 
   last_scup_time_ = now;
@@ -372,7 +324,6 @@
 
 absl::optional<CachedNetworkParameters>
 QuicServerSessionBase::GenerateCachedNetworkParameters() const {
-  QUICHE_DCHECK(add_cached_network_parameters_to_address_token());
   const QuicSentPacketManager& sent_packet_manager =
       connection()->sent_packet_manager();
   const QuicSustainedBandwidthRecorder* bandwidth_recorder =
diff --git a/quic/core/http/quic_server_session_base_test.cc b/quic/core/http/quic_server_session_base_test.cc
index 2d144d2..6121a81 100644
--- a/quic/core/http/quic_server_session_base_test.cc
+++ b/quic/core/http/quic_server_session_base_test.cc
@@ -642,11 +642,6 @@
     EXPECT_CALL(*quic_crypto_stream,
                 SendServerConfigUpdate(EqualsProto(expected_network_params)))
         .Times(1);
-  } else if (!GetQuicReloadableFlag(
-                 quic_add_cached_network_parameters_to_address_token2)) {
-    EXPECT_CALL(*tls_server_stream,
-                SendServerConfigUpdate(EqualsProto(expected_network_params)))
-        .Times(1);
   } else {
     EXPECT_CALL(*tls_server_stream,
                 GetAddressToken(EqualsProto(expected_network_params)))
diff --git a/quic/core/quic_flags_list.h b/quic/core/quic_flags_list.h
index 94eb8e0..6dc0d06 100644
--- a/quic/core/quic_flags_list.h
+++ b/quic/core/quic_flags_list.h
@@ -19,8 +19,6 @@
 QUIC_FLAG(FLAGS_quic_restart_flag_quic_testonly_default_true, true)
 // If bytes in flight has dipped below 1.25*MaxBW in the last round, do not exit PROBE_UP due to excess queue buildup.
 QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_bbr2_no_probe_up_exit_if_no_queue, true)
-// If true, 1) NEW_TOKENs sent from a IETF QUIC session will include the cached network parameters proto, 2) A min_rtt received from a validated token will be used to set the initial rtt, 3) Enable bandwidth resumption for IETF QUIC when connection options BWRE or BWMX exists.
-QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_add_cached_network_parameters_to_address_token2, true)
 // If true, 1) QUIC connections will use a lower minimum for trusted initial rtt, 2) When TRTT is received, QUIC server sessions will mark the initial rtt from CachedNetworkParameters as trusted.
 QUIC_FLAG(FLAGS_quic_reloadable_flag_quic_use_lower_min_for_trusted_irtt, true)
 // If true, QUIC connection will be closed if it fails to serialize a coalesced packet.
diff --git a/quic/core/quic_session.cc b/quic/core/quic_session.cc
index 90c84de..73de6fb 100644
--- a/quic/core/quic_session.cc
+++ b/quic/core/quic_session.cc
@@ -1669,10 +1669,9 @@
 bool QuicSession::MaybeSendAddressToken() {
   QUICHE_DCHECK(perspective_ == Perspective::IS_SERVER &&
                 connection()->version().HasIetfQuicFrames());
-  absl::optional<CachedNetworkParameters> cached_network_params;
-  if (add_cached_network_parameters_to_address_token()) {
-    cached_network_params = GenerateCachedNetworkParameters();
-  }
+  absl::optional<CachedNetworkParameters> cached_network_params =
+      GenerateCachedNetworkParameters();
+
   std::string address_token = GetCryptoStream()->GetAddressToken(
       cached_network_params.has_value() ? &cached_network_params.value()
                                         : nullptr);
@@ -1687,11 +1686,8 @@
   writer.WriteBytes(address_token.data(), address_token.length());
   control_frame_manager_.WriteOrBufferNewToken(
       absl::string_view(buffer.get(), buf_len));
-  if (add_cached_network_parameters_to_address_token() &&
-      cached_network_params.has_value()) {
+  if (cached_network_params.has_value()) {
     connection()->OnSendConnectionState(*cached_network_params);
-    QUIC_RELOADABLE_FLAG_COUNT_N(
-        quic_add_cached_network_parameters_to_address_token2, 1, 2);
   }
   return true;
 }
@@ -2658,14 +2654,12 @@
   }
   const bool valid = GetCryptoStream()->ValidateAddressToken(
       absl::string_view(token.data() + 1, token.length() - 1));
-  if (add_cached_network_parameters_to_address_token() && valid) {
+  if (valid) {
     const CachedNetworkParameters* cached_network_params =
         GetCryptoStream()->PreviousCachedNetworkParams();
     if (cached_network_params != nullptr &&
         cached_network_params->timestamp() > 0) {
       connection()->OnReceiveConnectionState(*cached_network_params);
-      QUIC_RELOADABLE_FLAG_COUNT_N(
-          quic_add_cached_network_parameters_to_address_token2, 2, 2);
     }
   }
   return valid;
diff --git a/quic/core/quic_session.h b/quic/core/quic_session.h
index b8f175e..9e58acc 100644
--- a/quic/core/quic_session.h
+++ b/quic/core/quic_session.h
@@ -624,11 +624,6 @@
   // Latched value of flag --quic_tls_server_support_client_cert.
   bool support_client_cert() const { return support_client_cert_; }
 
-  // Get latched flag value.
-  bool add_cached_network_parameters_to_address_token() const {
-    return add_cached_network_parameters_to_address_token_;
-  }
-
   // Try converting all pending streams to normal streams.
   void ProcessAllPendingStreams();
 
@@ -1013,10 +1008,6 @@
   // creation of new outgoing bidirectional streams.
   bool liveness_testing_in_progress_;
 
-  const bool add_cached_network_parameters_to_address_token_ =
-      GetQuicReloadableFlag(
-          quic_add_cached_network_parameters_to_address_token2);
-
   // Whether BoringSSL randomizes the order of TLS extensions.
   bool permutes_tls_extensions_ = true;
 
diff --git a/quic/core/tls_server_handshaker.cc b/quic/core/tls_server_handshaker.cc
index 6d2e7ce..f959a76 100644
--- a/quic/core/tls_server_handshaker.cc
+++ b/quic/core/tls_server_handshaker.cc
@@ -346,9 +346,7 @@
       crypto_config_->source_address_token_boxer(), empty_previous_tokens,
       connection->effective_peer_address().host(),
       connection->random_generator(), connection->clock()->WallNow(),
-      session()->add_cached_network_parameters_to_address_token()
-          ? cached_network_params
-          : nullptr);
+      cached_network_params);
 }
 
 bool TlsServerHandshaker::ValidateAddressToken(absl::string_view token) const {
@@ -363,18 +361,14 @@
   auto cached_network_params = std::make_unique<CachedNetworkParameters>();
   reason = crypto_config_->ValidateSourceAddressTokens(
       tokens, session()->connection()->effective_peer_address().host(),
-      session()->connection()->clock()->WallNow(),
-      session()->add_cached_network_parameters_to_address_token()
-          ? cached_network_params.get()
-          : nullptr);
+      session()->connection()->clock()->WallNow(), cached_network_params.get());
   if (reason != HANDSHAKE_OK) {
     QUIC_DLOG(WARNING) << "Failed to validate source address token: "
                        << CryptoUtils::HandshakeFailureReasonToString(reason);
     return false;
   }
-  if (session()->add_cached_network_parameters_to_address_token()) {
-    last_received_cached_network_params_ = std::move(cached_network_params);
-  }
+
+  last_received_cached_network_params_ = std::move(cached_network_params);
   return true;
 }