Deprecate gfe2_reloadable_flag_quic_use_idle_network_detector.

PiperOrigin-RevId: 318854988
Change-Id: I01bbf3eb76ca1cb2800a2db4ae274e23381e69b0
diff --git a/quic/core/quic_connection.cc b/quic/core/quic_connection.cc
index 3544457..50a42f5 100644
--- a/quic/core/quic_connection.cc
+++ b/quic/core/quic_connection.cc
@@ -109,19 +109,6 @@
   QuicConnection* connection_;
 };
 
-class TimeoutAlarmDelegate : public QuicAlarm::Delegate {
- public:
-  explicit TimeoutAlarmDelegate(QuicConnection* connection)
-      : connection_(connection) {}
-  TimeoutAlarmDelegate(const TimeoutAlarmDelegate&) = delete;
-  TimeoutAlarmDelegate& operator=(const TimeoutAlarmDelegate&) = delete;
-
-  void OnAlarm() override { connection_->CheckForTimeout(); }
-
- private:
-  QuicConnection* connection_;
-};
-
 class PingAlarmDelegate : public QuicAlarm::Delegate {
  public:
   explicit PingAlarmDelegate(QuicConnection* connection)
@@ -265,9 +252,6 @@
       send_alarm_(
           alarm_factory_->CreateAlarm(arena_.New<SendAlarmDelegate>(this),
                                       &arena_)),
-      timeout_alarm_(
-          alarm_factory_->CreateAlarm(arena_.New<TimeoutAlarmDelegate>(this),
-                                      &arena_)),
       ping_alarm_(
           alarm_factory_->CreateAlarm(arena_.New<PingAlarmDelegate>(this),
                                       &arena_)),
@@ -280,11 +264,7 @@
       visitor_(nullptr),
       debug_visitor_(nullptr),
       packet_creator_(server_connection_id_, &framer_, random_generator_, this),
-      idle_network_timeout_(QuicTime::Delta::Infinite()),
-      handshake_timeout_(QuicTime::Delta::Infinite()),
-      time_of_first_packet_sent_after_receiving_(QuicTime::Zero()),
       time_of_last_received_packet_(clock_->ApproximateNow()),
-      time_of_last_decryptable_packet_(time_of_last_received_packet_),
       sent_packet_manager_(perspective,
                            clock_,
                            random_generator_,
@@ -1031,11 +1011,7 @@
     // Address is validated by successfully processing a HANDSHAKE packet.
     address_validated_ = true;
   }
-  if (use_idle_network_detector_) {
-    idle_network_detector_.OnPacketReceived(time_of_last_received_packet_);
-  } else {
-    time_of_last_decryptable_packet_ = time_of_last_received_packet_;
-  }
+  idle_network_detector_.OnPacketReceived(time_of_last_received_packet_);
 
   visitor_->OnPacketDecrypted(level);
 }
@@ -1110,7 +1086,7 @@
   // frames, since the processing may result in sending a bundled ack.
   uber_received_packet_manager_.RecordPacketReceived(
       last_decrypted_packet_level_, last_header_,
-      GetTimeOfLastReceivedPacket());
+      idle_network_detector_.time_of_last_received_packet());
   DCHECK(connected_);
   return true;
 }
@@ -1205,8 +1181,9 @@
     return false;
   }
   processing_ack_frame_ = true;
-  sent_packet_manager_.OnAckFrameStart(largest_acked, ack_delay_time,
-                                       GetTimeOfLastReceivedPacket());
+  sent_packet_manager_.OnAckFrameStart(
+      largest_acked, ack_delay_time,
+      idle_network_detector_.time_of_last_received_packet());
   return true;
 }
 
@@ -1252,8 +1229,8 @@
   const bool one_rtt_packet_was_acked =
       sent_packet_manager_.one_rtt_packet_acked();
   const AckResult ack_result = sent_packet_manager_.OnAckFrameEnd(
-      GetTimeOfLastReceivedPacket(), last_header_.packet_number,
-      last_decrypted_packet_level_);
+      idle_network_detector_.time_of_last_received_packet(),
+      last_header_.packet_number, last_decrypted_packet_level_);
   if (ack_result != PACKETS_NEWLY_ACKED &&
       ack_result != NO_PACKETS_NEWLY_ACKED) {
     // Error occurred (e.g., this ACK tries to ack packets in wrong packet
@@ -1526,7 +1503,8 @@
   UpdatePacketContent(NOT_PADDED_PING);
 
   if (debug_visitor_ != nullptr) {
-    debug_visitor_->OnWindowUpdateFrame(frame, GetTimeOfLastReceivedPacket());
+    debug_visitor_->OnWindowUpdateFrame(
+        frame, idle_network_detector_.time_of_last_received_packet());
   }
   QUIC_DVLOG(1) << ENDPOINT << "WINDOW_UPDATE_FRAME received " << frame;
   MaybeUpdateAckTimeout();
@@ -1696,7 +1674,8 @@
   if (!should_last_packet_instigate_acks_) {
     uber_received_packet_manager_.MaybeUpdateAckTimeout(
         should_last_packet_instigate_acks_, last_decrypted_packet_level_,
-        last_header_.packet_number, GetTimeOfLastReceivedPacket(),
+        last_header_.packet_number,
+        idle_network_detector_.time_of_last_received_packet(),
         clock_->ApproximateNow(), sent_packet_manager_.GetRttStats());
   }
 
@@ -2765,18 +2744,7 @@
       blackhole_detector_.RestartDetection(GetPathDegradingDeadline(),
                                            GetNetworkBlackholeDeadline());
     }
-
-    if (use_idle_network_detector_) {
-      idle_network_detector_.OnPacketSent(packet_send_time);
-      QUIC_RELOADABLE_FLAG_COUNT_N(quic_use_idle_network_detector, 2, 6);
-    } else if (time_of_first_packet_sent_after_receiving_ <
-               GetTimeOfLastReceivedPacket()) {
-      // Update |time_of_first_packet_sent_after_receiving_| if this is the
-      // first packet sent after the last packet was received. If it were
-      // updated on every sent packet, then sending into a black hole might
-      // never timeout.
-      time_of_first_packet_sent_after_receiving_ = packet_send_time;
-    }
+    idle_network_detector_.OnPacketSent(packet_send_time);
   }
 
   MaybeSetMtuAlarm(packet_number);
@@ -3496,14 +3464,10 @@
   ping_alarm_->Cancel();
   retransmission_alarm_->Cancel();
   send_alarm_->Cancel();
-  timeout_alarm_->Cancel();
   mtu_discovery_alarm_->Cancel();
   process_undecryptable_packets_alarm_->Cancel();
   blackhole_detector_.StopDetection();
-  if (use_idle_network_detector_) {
-    QUIC_RELOADABLE_FLAG_COUNT_N(quic_use_idle_network_detector, 3, 6);
-    idle_network_detector_.StopDetection();
-  }
+  idle_network_detector_.StopDetection();
 }
 
 QuicByteCount QuicConnection::max_packet_length() const {
@@ -3532,85 +3496,7 @@
   } else if (idle_timeout > QuicTime::Delta::FromSeconds(1)) {
     idle_timeout = idle_timeout - QuicTime::Delta::FromSeconds(1);
   }
-  if (use_idle_network_detector_) {
-    QUIC_RELOADABLE_FLAG_COUNT_N(quic_use_idle_network_detector, 4, 6);
-    idle_network_detector_.SetTimeouts(handshake_timeout, idle_timeout);
-    return;
-  }
-  handshake_timeout_ = handshake_timeout;
-  idle_network_timeout_ = idle_timeout;
-
-  SetTimeoutAlarm();
-}
-
-void QuicConnection::CheckForTimeout() {
-  DCHECK(!use_idle_network_detector_);
-  QuicTime now = clock_->ApproximateNow();
-  if (!handshake_timeout_.IsInfinite()) {
-    QuicTime::Delta connected_duration = now - stats_.connection_creation_time;
-    QUIC_DVLOG(1) << ENDPOINT
-                  << "connection time: " << connected_duration.ToMicroseconds()
-                  << " handshake timeout: "
-                  << handshake_timeout_.ToMicroseconds();
-    if (connected_duration >= handshake_timeout_) {
-      const std::string error_details = quiche::QuicheStrCat(
-          "Handshake timeout expired after ",
-          connected_duration.ToDebuggingValue(),
-          ". Timeout:", handshake_timeout_.ToDebuggingValue());
-      QUIC_DVLOG(1) << ENDPOINT << error_details;
-      CloseConnection(QUIC_HANDSHAKE_TIMEOUT, error_details,
-                      ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
-      return;
-    }
-  }
-
-  QuicTime time_of_last_packet =
-      std::max(GetTimeOfLastReceivedPacket(),
-               time_of_first_packet_sent_after_receiving_);
-
-  // |delta| can be < 0 as |now| is approximate time but |time_of_last_packet|
-  // is accurate time. However, this should not change the behavior of
-  // timeout handling.
-  QuicTime::Delta idle_duration = now - time_of_last_packet;
-  QUIC_DVLOG(1) << ENDPOINT << "last packet "
-                << time_of_last_packet.ToDebuggingValue()
-                << " now:" << now.ToDebuggingValue()
-                << " idle_duration:" << idle_duration.ToMicroseconds()
-                << " idle_network_timeout: "
-                << idle_network_timeout_.ToMicroseconds();
-  if (idle_duration >= idle_network_timeout_) {
-    const std::string error_details = quiche::QuicheStrCat(
-        "No recent network activity after ", idle_duration.ToDebuggingValue(),
-        ". Timeout:", idle_network_timeout_.ToDebuggingValue());
-    QUIC_DVLOG(1) << ENDPOINT << error_details;
-    if ((sent_packet_manager_.GetConsecutiveTlpCount() > 0 ||
-         sent_packet_manager_.GetConsecutiveRtoCount() > 0 ||
-         visitor_->ShouldKeepConnectionAlive())) {
-      CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, error_details,
-                      ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
-    } else {
-      CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, error_details,
-                      idle_timeout_connection_close_behavior_);
-    }
-    return;
-  }
-
-  SetTimeoutAlarm();
-}
-
-void QuicConnection::SetTimeoutAlarm() {
-  DCHECK(!use_idle_network_detector_);
-  QuicTime time_of_last_packet =
-      std::max(GetTimeOfLastReceivedPacket(),
-               time_of_first_packet_sent_after_receiving_);
-
-  QuicTime deadline = time_of_last_packet + idle_network_timeout_;
-  if (!handshake_timeout_.IsInfinite()) {
-    deadline = std::min(deadline,
-                        stats_.connection_creation_time + handshake_timeout_);
-  }
-
-  timeout_alarm_->Update(deadline, QuicTime::Delta::Zero());
+  idle_network_detector_.SetTimeouts(handshake_timeout, idle_timeout);
 }
 
 void QuicConnection::SetPingAlarm() {
@@ -4688,8 +4574,6 @@
 }
 
 void QuicConnection::OnHandshakeTimeout() {
-  QUIC_RELOADABLE_FLAG_COUNT_N(quic_use_idle_network_detector, 5, 6);
-  DCHECK(use_idle_network_detector_);
   const QuicTime::Delta duration =
       clock_->ApproximateNow() - stats_.connection_creation_time;
   std::string error_details = quiche::QuicheStrCat(
@@ -4706,8 +4590,6 @@
 }
 
 void QuicConnection::OnIdleNetworkDetected() {
-  QUIC_RELOADABLE_FLAG_COUNT_N(quic_use_idle_network_detector, 6, 6);
-  DCHECK(use_idle_network_detector_);
   const QuicTime::Delta duration =
       clock_->ApproximateNow() -
       idle_network_detector_.last_network_activity_time();
@@ -4735,7 +4617,8 @@
   should_last_packet_instigate_acks_ = true;
   uber_received_packet_manager_.MaybeUpdateAckTimeout(
       /*should_last_packet_instigate_acks=*/true, last_decrypted_packet_level_,
-      last_header_.packet_number, GetTimeOfLastReceivedPacket(),
+      last_header_.packet_number,
+      idle_network_detector_.time_of_last_received_packet(),
       clock_->ApproximateNow(), sent_packet_manager_.GetRttStats());
 }
 
@@ -4752,7 +4635,7 @@
     return false;
   }
   // No path degrading detection before handshake completes.
-  if (!GetHandshakeTimeout().IsInfinite()) {
+  if (!idle_network_detector_.handshake_timeout().IsInfinite()) {
     return false;
   }
   return perspective_ == Perspective::IS_CLIENT && !is_path_degrading_;
@@ -4779,27 +4662,11 @@
     return IsHandshakeComplete();
   }
 
-  if (!GetHandshakeTimeout().IsInfinite()) {
+  if (!idle_network_detector_.handshake_timeout().IsInfinite()) {
     return false;
   }
   return num_rtos_for_blackhole_detection_ > 0;
 }
 
-QuicTime::Delta QuicConnection::GetHandshakeTimeout() const {
-  if (use_idle_network_detector_) {
-    return idle_network_detector_.handshake_timeout();
-  }
-  return handshake_timeout_;
-}
-
-QuicTime QuicConnection::GetTimeOfLastReceivedPacket() const {
-  if (use_idle_network_detector_) {
-    return idle_network_detector_.time_of_last_received_packet();
-  }
-  DCHECK(time_of_last_decryptable_packet_ == time_of_last_received_packet_ ||
-         !last_packet_decrypted_);
-  return time_of_last_decryptable_packet_;
-}
-
 #undef ENDPOINT  // undef for jumbo builds
 }  // namespace quic
diff --git a/quic/core/quic_connection.h b/quic/core/quic_connection.h
index c0f722d..b3e44b3 100644
--- a/quic/core/quic_connection.h
+++ b/quic/core/quic_connection.h
@@ -687,10 +687,6 @@
   void SetNetworkTimeouts(QuicTime::Delta handshake_timeout,
                           QuicTime::Delta idle_timeout);
 
-  // If the connection has timed out, this will close the connection.
-  // Otherwise, it will reschedule the timeout alarm.
-  void CheckForTimeout();
-
   // Called when the ping alarm fires. Causes a ping frame to be sent only
   // if the retransmission alarm is not running.
   void OnPingTimeout();
@@ -1172,9 +1168,6 @@
   // sent if there are no outstanding packets.
   QuicPacketNumber GetLeastUnacked() const;
 
-  // Sets the timeout alarm to the appropriate value, if any.
-  void SetTimeoutAlarm();
-
   // Sets the ping alarm to the appropriate value, if any.
   void SetPingAlarm();
 
@@ -1314,10 +1307,6 @@
   // Returns true if network blackhole should be detected.
   bool ShouldDetectBlackhole() const;
 
-  // Remove these two when deprecating quic_use_idle_network_detector.
-  QuicTime::Delta GetHandshakeTimeout() const;
-  QuicTime GetTimeOfLastReceivedPacket() const;
-
   // Validate connection IDs used during the handshake. Closes the connection
   // on validation failure.
   bool ValidateConfigConnectionIds(const QuicConfig& config);
@@ -1488,11 +1477,6 @@
   // An alarm that is scheduled when the SentPacketManager requires a delay
   // before sending packets and fires when the packet may be sent.
   QuicArenaScopedPtr<QuicAlarm> send_alarm_;
-  // An alarm that is scheduled when the connection can still write and there
-  // may be more data to send.
-  // An alarm that fires when the connection may have timed out.
-  // TODO(fayang): Remove this when deprecating quic_use_idle_network_detector.
-  QuicArenaScopedPtr<QuicAlarm> timeout_alarm_;
   // An alarm that fires when a ping should be sent.
   QuicArenaScopedPtr<QuicAlarm> ping_alarm_;
   // An alarm that fires when an MTU probe should be sent.
@@ -1506,33 +1490,13 @@
 
   QuicPacketCreator packet_creator_;
 
-  // TODO(fayang): Remove these two when deprecating
-  // quic_use_idle_network_detector.
-  // Network idle time before this connection is closed.
-  QuicTime::Delta idle_network_timeout_;
-  // The connection will wait this long for the handshake to complete.
-  QuicTime::Delta handshake_timeout_;
-
   // Statistics for this session.
   QuicConnectionStats stats_;
 
-  // Timestamps used for timeouts.
-  // The time of the first retransmittable packet that was sent after the most
-  // recently received packet.
-  // TODO(fayang): Remove time_of_first_packet_sent_after_receiving_ when
-  // deprecating quic_use_idle_network_detector.
-  QuicTime time_of_first_packet_sent_after_receiving_;
   // The time that a packet is received for this connection. Initialized to
   // connection creation time.
   // This does not indicate the packet was processed.
   QuicTime time_of_last_received_packet_;
-  // This gets set to time_of_last_received_packet_ when a packet gets
-  // decrypted. Please note, this is not necessarily the original receive time
-  // of this decrypt packet because connection can decryptable packet out of
-  // order.
-  // TODO(fayang): Remove time_of_last_decryptable_packet_ when
-  // deprecating quic_use_idle_network_detector.
-  QuicTime time_of_last_decryptable_packet_;
 
   // Sent packet manager which tracks the status of packets sent by this
   // connection and contains the send and receive algorithms to determine when
@@ -1706,9 +1670,6 @@
   // True if this connection supports handshake done frame.
   bool support_handshake_done_;
 
-  const bool use_idle_network_detector_ =
-      GetQuicReloadableFlag(quic_use_idle_network_detector);
-
   const bool update_ack_alarm_in_send_all_pending_acks_ =
       GetQuicReloadableFlag(quic_update_ack_alarm_in_send_all_pending_acks);
 
diff --git a/quic/core/quic_connection_test.cc b/quic/core/quic_connection_test.cc
index d8d3013..8b676fd 100644
--- a/quic/core/quic_connection_test.cc
+++ b/quic/core/quic_connection_test.cc
@@ -903,12 +903,8 @@
   }
 
   TestAlarmFactory::TestAlarm* GetTimeoutAlarm() {
-    if (GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-      return reinterpret_cast<TestAlarmFactory::TestAlarm*>(
-          QuicConnectionPeer::GetIdleNetworkDetectorAlarm(this));
-    }
     return reinterpret_cast<TestAlarmFactory::TestAlarm*>(
-        QuicConnectionPeer::GetTimeoutAlarm(this));
+        QuicConnectionPeer::GetIdleNetworkDetectorAlarm(this));
   }
 
   TestAlarmFactory::TestAlarm* GetMtuDiscoveryAlarm() {
@@ -4807,9 +4803,6 @@
   EXPECT_CALL(visitor_, OnConnectionClosed(_, _)).Times(0);
   QuicTime::Delta delay = initial_ddl - clock_.ApproximateNow();
   clock_.AdvanceTime(delay);
-  if (!GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    connection_.GetTimeoutAlarm()->Fire();
-  }
   // Verify the timeout alarm deadline is updated.
   EXPECT_TRUE(connection_.connected());
   EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
@@ -4898,10 +4891,6 @@
   EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _, _));
   ProcessAckPacket(&frame);
 
-  if (!GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    // Fire early to verify it wouldn't timeout yet.
-    connection_.GetTimeoutAlarm()->Fire();
-  }
   EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
   EXPECT_TRUE(connection_.connected());
 
@@ -5643,12 +5632,8 @@
   SendStreamDataToPeer(
       GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
       0, FIN, nullptr);
-  if (GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    EXPECT_EQ(default_timeout + five_ms,
-              connection_.GetTimeoutAlarm()->deadline());
-  } else {
-    EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
-  }
+  EXPECT_EQ(default_timeout + five_ms,
+            connection_.GetTimeoutAlarm()->deadline());
 
   // Now send more data. This will not move the timeout because
   // no data has been received since the previous write.
@@ -5656,20 +5641,13 @@
   SendStreamDataToPeer(
       GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
       3, FIN, nullptr);
-  if (GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    EXPECT_EQ(default_timeout + five_ms,
-              connection_.GetTimeoutAlarm()->deadline());
-  } else {
-    EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
-  }
+  EXPECT_EQ(default_timeout + five_ms,
+            connection_.GetTimeoutAlarm()->deadline());
 
   // The original alarm will fire.  We should not time out because we had a
   // network event at t=5ms.  The alarm will reregister.
   clock_.AdvanceTime(initial_idle_timeout - five_ms - five_ms);
   EXPECT_EQ(default_timeout, clock_.ApproximateNow());
-  if (!GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    connection_.GetTimeoutAlarm()->Fire();
-  }
   EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
   EXPECT_TRUE(connection_.connected());
   EXPECT_EQ(default_timeout + five_ms,
@@ -5717,12 +5695,8 @@
   SendStreamDataToPeer(
       GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
       0, FIN, nullptr);
-  if (GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    EXPECT_EQ(default_timeout + five_ms,
-              connection_.GetTimeoutAlarm()->deadline());
-  } else {
-    EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
-  }
+  EXPECT_EQ(default_timeout + five_ms,
+            connection_.GetTimeoutAlarm()->deadline());
 
   // Move forward 5 ms and receive a packet, which will move the timeout
   // forward 5 ms more (but will not reschedule the alarm).
@@ -5751,9 +5725,6 @@
   ASSERT_EQ(default_timeout.ToDebuggingValue(),
             clock_.Now().ToDebuggingValue());
   EXPECT_EQ(default_timeout, clock_.Now());
-  if (!GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    connection_.GetTimeoutAlarm()->Fire();
-  }
   EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
   EXPECT_TRUE(connection_.connected());
   ASSERT_EQ(final_timeout.ToDebuggingValue(),
@@ -5813,12 +5784,8 @@
   SendStreamDataToPeer(
       GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
       0, FIN, nullptr);
-  if (GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    EXPECT_EQ(default_timeout + five_ms,
-              connection_.GetTimeoutAlarm()->deadline());
-  } else {
-    EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
-  }
+  EXPECT_EQ(default_timeout + five_ms,
+            connection_.GetTimeoutAlarm()->deadline());
 
   // Now send more data. This will not move the timeout because
   // no data has been received since the previous write.
@@ -5826,20 +5793,13 @@
   SendStreamDataToPeer(
       GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
       3, FIN, nullptr);
-  if (GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    EXPECT_EQ(default_timeout + five_ms,
-              connection_.GetTimeoutAlarm()->deadline());
-  } else {
-    EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
-  }
+  EXPECT_EQ(default_timeout + five_ms,
+            connection_.GetTimeoutAlarm()->deadline());
 
   // The original alarm will fire.  We should not time out because we had a
   // network event at t=5ms.  The alarm will reregister.
   clock_.AdvanceTime(default_idle_timeout - five_ms - five_ms);
   EXPECT_EQ(default_timeout, clock_.ApproximateNow());
-  if (!GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    connection_.GetTimeoutAlarm()->Fire();
-  }
   EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
   EXPECT_TRUE(connection_.connected());
   EXPECT_EQ(default_timeout + five_ms,
@@ -5899,12 +5859,8 @@
   SendStreamDataToPeer(
       GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
       0, FIN, nullptr);
-  if (GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    EXPECT_EQ(default_timeout + five_ms,
-              connection_.GetTimeoutAlarm()->deadline());
-  } else {
-    EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
-  }
+  EXPECT_EQ(default_timeout + five_ms,
+            connection_.GetTimeoutAlarm()->deadline());
 
   // Retransmit the packet via tail loss probe.
   clock_.AdvanceTime(connection_.GetRetransmissionAlarm()->deadline() -
@@ -5965,12 +5921,8 @@
   SendStreamDataToPeer(
       GetNthClientInitiatedStreamId(1, connection_.transport_version()), "foo",
       0, FIN, nullptr);
-  if (GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    EXPECT_EQ(default_timeout + five_ms,
-              connection_.GetTimeoutAlarm()->deadline());
-  } else {
-    EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
-  }
+  EXPECT_EQ(default_timeout + five_ms,
+            connection_.GetTimeoutAlarm()->deadline());
 
   // Indicate streams are still open.
   EXPECT_CALL(visitor_, ShouldKeepConnectionAlive())
@@ -6020,9 +5972,6 @@
   // network event at t=5ms.  The alarm will reregister.
   clock_.AdvanceTime(initial_idle_timeout - five_ms);
   EXPECT_EQ(default_timeout, clock_.ApproximateNow());
-  if (!GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    connection_.GetTimeoutAlarm()->Fire();
-  }
   EXPECT_TRUE(connection_.connected());
   EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
   EXPECT_EQ(default_timeout + five_ms,
@@ -6078,9 +6027,6 @@
   // network event at t=5ms.  The alarm will reregister.
   clock_.AdvanceTime(initial_idle_timeout - five_ms);
   EXPECT_EQ(default_timeout, clock_.ApproximateNow());
-  if (!GetQuicReloadableFlag(quic_use_idle_network_detector)) {
-    connection_.GetTimeoutAlarm()->Fire();
-  }
   EXPECT_TRUE(connection_.connected());
   EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
   EXPECT_EQ(default_timeout + five_ms,
diff --git a/quic/test_tools/quic_connection_peer.cc b/quic/test_tools/quic_connection_peer.cc
index 54616b2..7192797 100644
--- a/quic/test_tools/quic_connection_peer.cc
+++ b/quic/test_tools/quic_connection_peer.cc
@@ -51,10 +51,7 @@
 // static
 QuicTime::Delta QuicConnectionPeer::GetNetworkTimeout(
     QuicConnection* connection) {
-  if (connection->use_idle_network_detector_) {
-    return connection->idle_network_detector_.idle_network_timeout_;
-  }
-  return connection->idle_network_timeout_;
+  return connection->idle_network_detector_.idle_network_timeout_;
 }
 
 // static
@@ -143,11 +140,6 @@
 }
 
 // static
-QuicAlarm* QuicConnectionPeer::GetTimeoutAlarm(QuicConnection* connection) {
-  return connection->timeout_alarm_.get();
-}
-
-// static
 QuicAlarm* QuicConnectionPeer::GetMtuDiscoveryAlarm(
     QuicConnection* connection) {
   return connection->mtu_discovery_alarm_.get();
diff --git a/quic/test_tools/quic_connection_peer.h b/quic/test_tools/quic_connection_peer.h
index a5b94ef..258d953 100644
--- a/quic/test_tools/quic_connection_peer.h
+++ b/quic/test_tools/quic_connection_peer.h
@@ -79,7 +79,6 @@
   static QuicAlarm* GetPingAlarm(QuicConnection* connection);
   static QuicAlarm* GetRetransmissionAlarm(QuicConnection* connection);
   static QuicAlarm* GetSendAlarm(QuicConnection* connection);
-  static QuicAlarm* GetTimeoutAlarm(QuicConnection* connection);
   static QuicAlarm* GetMtuDiscoveryAlarm(QuicConnection* connection);
   static QuicAlarm* GetProcessUndecryptablePacketsAlarm(
       QuicConnection* connection);