Revise interface to inform send algorithm ECN is active.

Protected by FLAGS_quic_reloadable_flag_quic_send_ect1.

PiperOrigin-RevId: 587087493
diff --git a/quiche/quic/core/congestion_control/bbr2_sender.h b/quiche/quic/core/congestion_control/bbr2_sender.h
index a49cda1..a10d24b 100644
--- a/quiche/quic/core/congestion_control/bbr2_sender.h
+++ b/quiche/quic/core/congestion_control/bbr2_sender.h
@@ -95,8 +95,8 @@
 
   void PopulateConnectionStats(QuicConnectionStats* stats) const override;
 
-  bool SupportsECT0() const override { return false; }
-  bool SupportsECT1() const override { return false; }
+  bool EnableECT0() override { return false; }
+  bool EnableECT1() override { return false; }
   // End implementation of SendAlgorithmInterface.
 
   const Bbr2Params& Params() const { return params_; }
diff --git a/quiche/quic/core/congestion_control/bbr_sender.h b/quiche/quic/core/congestion_control/bbr_sender.h
index 61ad946..625394a 100644
--- a/quiche/quic/core/congestion_control/bbr_sender.h
+++ b/quiche/quic/core/congestion_control/bbr_sender.h
@@ -132,8 +132,8 @@
   std::string GetDebugState() const override;
   void OnApplicationLimited(QuicByteCount bytes_in_flight) override;
   void PopulateConnectionStats(QuicConnectionStats* stats) const override;
-  bool SupportsECT0() const override { return false; }
-  bool SupportsECT1() const override { return false; }
+  bool EnableECT0() override { return false; }
+  bool EnableECT1() override { return false; }
   // End implementation of SendAlgorithmInterface.
 
   // Gets the number of RTTs BBR remains in STARTUP phase.
diff --git a/quiche/quic/core/congestion_control/send_algorithm_interface.h b/quiche/quic/core/congestion_control/send_algorithm_interface.h
index ba471ba..95cd8f0 100644
--- a/quiche/quic/core/congestion_control/send_algorithm_interface.h
+++ b/quiche/quic/core/congestion_control/send_algorithm_interface.h
@@ -168,10 +168,12 @@
   // Called before connection close to collect stats.
   virtual void PopulateConnectionStats(QuicConnectionStats* stats) const = 0;
 
-  // Returns true if the algorithm will respond to Congestion Experienced (CE)
-  // indications in accordance with RFC3168 [ECT(0)] or RFC9331 [ECT(1)].
-  virtual bool SupportsECT0() const = 0;
-  virtual bool SupportsECT1() const = 0;
+  // Causes this send algorithm to respond to Congestion Experienced (CE)
+  // indications in accordance with RFC3168 [ECT(0)] or RFC9331 [ECT(1)] and
+  // returns true, if this mode is supported. Otherwise, returns false. Once an
+  // ECN mode is enabled, it is an error to call either of these methods.
+  virtual bool EnableECT0() = 0;
+  virtual bool EnableECT1() = 0;
 };
 
 }  // namespace quic
diff --git a/quiche/quic/core/congestion_control/tcp_cubic_sender_bytes.h b/quiche/quic/core/congestion_control/tcp_cubic_sender_bytes.h
index cc6aa4e..0a945db 100644
--- a/quiche/quic/core/congestion_control/tcp_cubic_sender_bytes.h
+++ b/quiche/quic/core/congestion_control/tcp_cubic_sender_bytes.h
@@ -74,8 +74,8 @@
   std::string GetDebugState() const override;
   void OnApplicationLimited(QuicByteCount bytes_in_flight) override;
   void PopulateConnectionStats(QuicConnectionStats* /*stats*/) const override {}
-  bool SupportsECT0() const override { return false; }
-  bool SupportsECT1() const override { return false; }
+  bool EnableECT0() override { return false; }
+  bool EnableECT1() override { return false; }
   // End implementation of SendAlgorithmInterface.
 
   QuicByteCount min_congestion_window() const { return min_congestion_window_; }
diff --git a/quiche/quic/core/quic_connection.cc b/quiche/quic/core/quic_connection.cc
index 1e18807..9b061a4 100644
--- a/quiche/quic/core/quic_connection.cc
+++ b/quiche/quic/core/quic_connection.cc
@@ -7378,12 +7378,12 @@
       QUICHE_DCHECK(false);
       break;
     case ECN_ECT0:
-      if (!sent_packet_manager_.GetSendAlgorithm()->SupportsECT0()) {
+      if (!sent_packet_manager_.EnableECT0()) {
         return false;
       }
       break;
     case ECN_ECT1:
-      if (!sent_packet_manager_.GetSendAlgorithm()->SupportsECT1()) {
+      if (!sent_packet_manager_.EnableECT1()) {
         return false;
       }
       break;
diff --git a/quiche/quic/core/quic_connection_test.cc b/quiche/quic/core/quic_connection_test.cc
index 984a287..80c93d3 100644
--- a/quiche/quic/core/quic_connection_test.cc
+++ b/quiche/quic/core/quic_connection_test.cc
@@ -17256,9 +17256,9 @@
   SetQuicReloadableFlag(quic_send_ect1, true);
   for (QuicEcnCodepoint ecn : {ECN_NOT_ECT, ECN_ECT0, ECN_ECT1, ECN_CE}) {
     if (ecn == ECN_ECT0) {
-      EXPECT_CALL(*send_algorithm_, SupportsECT0()).WillOnce(Return(false));
+      EXPECT_CALL(*send_algorithm_, EnableECT0()).WillOnce(Return(false));
     } else if (ecn == ECN_ECT1) {
-      EXPECT_CALL(*send_algorithm_, SupportsECT1()).WillOnce(Return(false));
+      EXPECT_CALL(*send_algorithm_, EnableECT1()).WillOnce(Return(false));
     }
     if (ecn == ECN_NOT_ECT) {
       EXPECT_TRUE(connection_.set_ecn_codepoint(ecn));
@@ -17276,9 +17276,9 @@
   SetQuicReloadableFlag(quic_send_ect1, true);
   for (QuicEcnCodepoint ecn : {ECN_NOT_ECT, ECN_ECT0, ECN_ECT1, ECN_CE}) {
     if (ecn == ECN_ECT0) {
-      EXPECT_CALL(*send_algorithm_, SupportsECT0()).WillOnce(Return(true));
+      EXPECT_CALL(*send_algorithm_, EnableECT0()).WillOnce(Return(true));
     } else if (ecn == ECN_ECT1) {
-      EXPECT_CALL(*send_algorithm_, SupportsECT1()).WillOnce(Return(true));
+      EXPECT_CALL(*send_algorithm_, EnableECT1()).WillOnce(Return(true));
     }
     if (ecn == ECN_CE) {
       EXPECT_FALSE(connection_.set_ecn_codepoint(ecn));
@@ -17321,7 +17321,7 @@
 
 TEST_P(QuicConnectionTest, RtoDisablesEcnMarking) {
   SetQuicReloadableFlag(quic_send_ect1, true);
-  EXPECT_CALL(*send_algorithm_, SupportsECT1()).WillOnce(Return(true));
+  EXPECT_CALL(*send_algorithm_, EnableECT1()).WillOnce(Return(true));
   EXPECT_TRUE(connection_.set_ecn_codepoint(ECN_ECT1));
   QuicPacketCreatorPeer::SetPacketNumber(
       QuicConnectionPeer::GetPacketCreator(&connection_), 1);
@@ -17337,7 +17337,7 @@
 
 TEST_P(QuicConnectionTest, RtoDoesntDisableEcnMarkingIfEcnAcked) {
   SetQuicReloadableFlag(quic_send_ect1, true);
-  EXPECT_CALL(*send_algorithm_, SupportsECT1()).WillOnce(Return(true));
+  EXPECT_CALL(*send_algorithm_, EnableECT1()).WillOnce(Return(true));
   EXPECT_TRUE(connection_.set_ecn_codepoint(ECN_ECT1));
   QuicPacketCreatorPeer::SetPacketNumber(
       QuicConnectionPeer::GetPacketCreator(&connection_), 1);
@@ -17362,7 +17362,7 @@
 
 TEST_P(QuicConnectionTest, InvalidFeedbackCancelsEcn) {
   SetQuicReloadableFlag(quic_send_ect1, true);
-  EXPECT_CALL(*send_algorithm_, SupportsECT1()).WillOnce(Return(true));
+  EXPECT_CALL(*send_algorithm_, EnableECT1()).WillOnce(Return(true));
   EXPECT_TRUE(connection_.set_ecn_codepoint(ECN_ECT1));
   EXPECT_EQ(connection_.ecn_codepoint(), ECN_ECT1);
   if (!GetQuicReloadableFlag(quic_send_ect1)) {
@@ -17377,7 +17377,7 @@
 
 TEST_P(QuicConnectionTest, StateMatchesSentEcn) {
   SetQuicReloadableFlag(quic_send_ect1, true);
-  EXPECT_CALL(*send_algorithm_, SupportsECT1()).WillOnce(Return(true));
+  EXPECT_CALL(*send_algorithm_, EnableECT1()).WillOnce(Return(true));
   EXPECT_TRUE(connection_.set_ecn_codepoint(ECN_ECT1));
   SendPing();
   QuicSentPacketManager* sent_packet_manager =
@@ -17393,7 +17393,7 @@
     return;
   }
   SetQuicReloadableFlag(quic_send_ect1, true);
-  EXPECT_CALL(*send_algorithm_, SupportsECT1()).WillOnce(Return(true));
+  EXPECT_CALL(*send_algorithm_, EnableECT1()).WillOnce(Return(true));
   EXPECT_TRUE(connection_.set_ecn_codepoint(ECN_ECT1));
   // All these steps are necessary to send an INITIAL ping and save it to be
   // coalesced, instead of just calling SendPing() and sending it immediately.
@@ -17406,7 +17406,7 @@
       creator_, frames, buffer, sizeof(buffer));
   connection_.SendOrQueuePacket(std::move(packet1));
   creator_->set_encryption_level(ENCRYPTION_FORWARD_SECURE);
-  EXPECT_CALL(*send_algorithm_, SupportsECT0()).WillOnce(Return(true));
+  EXPECT_CALL(*send_algorithm_, EnableECT0()).WillOnce(Return(true));
   // If not for the line below, these packets would coalesce.
   EXPECT_TRUE(connection_.set_ecn_codepoint(ECN_ECT0));
   EXPECT_EQ(writer_->packets_write_attempts(), 0);
@@ -17417,12 +17417,12 @@
 
 TEST_P(QuicConnectionTest, BufferedPacketRetainsOldEcn) {
   SetQuicReloadableFlag(quic_send_ect1, true);
-  EXPECT_CALL(*send_algorithm_, SupportsECT1()).WillOnce(Return(true));
+  EXPECT_CALL(*send_algorithm_, EnableECT1()).WillOnce(Return(true));
   EXPECT_TRUE(connection_.set_ecn_codepoint(ECN_ECT1));
   writer_->SetWriteBlocked();
   EXPECT_CALL(visitor_, OnWriteBlocked()).Times(2);
   SendPing();
-  EXPECT_CALL(*send_algorithm_, SupportsECT0()).WillOnce(Return(true));
+  EXPECT_CALL(*send_algorithm_, EnableECT0()).WillOnce(Return(true));
   EXPECT_TRUE(connection_.set_ecn_codepoint(ECN_ECT0));
   writer_->SetWritable();
   connection_.OnCanWrite();
diff --git a/quiche/quic/core/quic_sent_packet_manager.h b/quiche/quic/core/quic_sent_packet_manager.h
index fe1aa0b..4d83546 100644
--- a/quiche/quic/core/quic_sent_packet_manager.h
+++ b/quiche/quic/core/quic_sent_packet_manager.h
@@ -398,6 +398,11 @@
     return send_algorithm_.get();
   }
 
+  // Wrapper for SendAlgorithmInterface functions, since these functions are
+  // not const.
+  bool EnableECT0() { return send_algorithm_->EnableECT0(); }
+  bool EnableECT1() { return send_algorithm_->EnableECT1(); }
+
   void SetSessionNotifier(SessionNotifierInterface* session_notifier) {
     unacked_packets_.SetSessionNotifier(session_notifier);
   }