Internal QUICHE change

PiperOrigin-RevId: 302548174
Change-Id: Id8d21524db16feccf218fd8a48821f283a7c66b8
diff --git a/quic/core/congestion_control/uber_loss_algorithm.cc b/quic/core/congestion_control/uber_loss_algorithm.cc
index abea529..08f0b6b 100644
--- a/quic/core/congestion_control/uber_loss_algorithm.cc
+++ b/quic/core/congestion_control/uber_loss_algorithm.cc
@@ -6,6 +6,8 @@
 
 #include <algorithm>
 
+#include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
+
 namespace quic {
 
 UberLossAlgorithm::UberLossAlgorithm() {
@@ -67,13 +69,33 @@
 }
 
 void UberLossAlgorithm::SetLossDetectionTuner(
-    std::unique_ptr<LossDetectionTunerInterface> /*tuner*/) {}
+    std::unique_ptr<LossDetectionTunerInterface> tuner) {
+  if (tuner_ != nullptr) {
+    QUIC_BUG << "LossDetectionTuner can only be set once when session begins.";
+    return;
+  }
+  tuner_ = std::move(tuner);
+}
+
+void UberLossAlgorithm::MaybeStartTuning() {
+  if (tuner_ == nullptr || tuner_started_) {
+    return;
+  }
+
+  tuner_started_ = tuner_->Start(&tuned_parameters_);
+}
 
 void UberLossAlgorithm::OnConfigNegotiated() {}
 
-void UberLossAlgorithm::OnMinRttAvailable() {}
+void UberLossAlgorithm::OnMinRttAvailable() {
+  MaybeStartTuning();
+}
 
-void UberLossAlgorithm::OnConnectionClosed() {}
+void UberLossAlgorithm::OnConnectionClosed() {
+  if (tuner_ != nullptr && tuner_started_) {
+    tuner_->Finish(tuned_parameters_);
+  }
+}
 
 void UberLossAlgorithm::SetReorderingShift(int reordering_shift) {
   for (int8_t i = INITIAL_DATA; i < NUM_PACKET_NUMBER_SPACES; ++i) {
diff --git a/quic/core/congestion_control/uber_loss_algorithm.h b/quic/core/congestion_control/uber_loss_algorithm.h
index b133f09..37b83c6 100644
--- a/quic/core/congestion_control/uber_loss_algorithm.h
+++ b/quic/core/congestion_control/uber_loss_algorithm.h
@@ -91,8 +91,15 @@
  private:
   friend class test::QuicSentPacketManagerPeer;
 
+  void MaybeStartTuning();
+
   // One loss algorithm per packet number space.
   GeneralLossAlgorithm general_loss_algorithms_[NUM_PACKET_NUMBER_SPACES];
+
+  // Used to tune reordering_shift and reordering_threshold.
+  std::unique_ptr<LossDetectionTunerInterface> tuner_;
+  LossDetectionParameters tuned_parameters_;
+  bool tuner_started_ = false;
 };
 
 }  // namespace quic