Use non-signal APIs to IceTransportInternal signals

This CL doesn't remove visibility of the signals yet, since Chrome
has not been updated.

Bug: webrtc:42222066
Change-Id: I13cbbed1895e75d9295607f16dfd5ce3c1599b48
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/407380
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45533}
diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc
index eee1092..a2d0b9c 100644
--- a/p2p/base/p2p_transport_channel.cc
+++ b/p2p/base/p2p_transport_channel.cc
@@ -916,7 +916,7 @@
 
   port->SubscribePortDestroyed(
       [this](PortInterface* port) { OnPortDestroyed(port); });
-  port->SubscribeRoleConflict([this]() { NotifyRoleConflict(); });
+  port->SubscribeRoleConflict([this] { NotifyRoleConflictInternal(); });
 
   // Attempt to create a connection from this new port to all of the remote
   // candidates that we were given so far.
@@ -936,7 +936,7 @@
     const std::vector<Candidate>& candidates) {
   RTC_DCHECK_RUN_ON(network_thread_);
   for (size_t i = 0; i < candidates.size(); ++i) {
-    SignalCandidateGathered(this, candidates[i]);
+    NotifyCandidateGathered(this, candidates[i]);
   }
 }
 
@@ -1123,8 +1123,8 @@
   }
 }
 
-void P2PTransportChannel::NotifyRoleConflict() {
-  SignalRoleConflict(this);  // STUN ping will be sent when SetRole is called
+void P2PTransportChannel::NotifyRoleConflictInternal() {
+  NotifyRoleConflict(this);  // STUN ping will be sent when SetRole is called
                              // from Transport.
 }
 
@@ -1969,8 +1969,8 @@
     standardized_state_ = current_standardized_state;
     state_ = state;
     // Unconditionally signal change, no matter what changed.
-    // TODO: issues.webrtc.org/42234495 - rmeove nonstandard state_
-    SignalIceTransportStateChanged(this);
+    // TODO: issues.webrtc.org/42234495 - remove nonstandard state_
+    NotifyIceTransportStateChanged(this);
   }
 }
 
diff --git a/p2p/base/p2p_transport_channel.h b/p2p/base/p2p_transport_channel.h
index 7f087ba..29d59e5 100644
--- a/p2p/base/p2p_transport_channel.h
+++ b/p2p/base/p2p_transport_channel.h
@@ -364,7 +364,7 @@
   // When pruning a port, move it from `ports_` to `pruned_ports_`.
   // Returns true if the port is found and removed from `ports_`.
   bool PrunePort(PortInterface* port);
-  void NotifyRoleConflict();
+  void NotifyRoleConflictInternal();
 
   void OnConnectionStateChange(Connection* connection);
   void OnReadPacket(Connection* connection, const ReceivedIpPacket& packet);
diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc
index 541c26f..42beff4 100644
--- a/p2p/base/p2p_transport_channel_unittest.cc
+++ b/p2p/base/p2p_transport_channel_unittest.cc
@@ -490,8 +490,10 @@
                                                std::move(init));
     channel->SignalReadyToSend.connect(
         this, &P2PTransportChannelTestBase::OnReadyToSend);
-    channel->SignalCandidateGathered.connect(
-        this, &P2PTransportChannelTestBase::OnCandidateGathered);
+    channel->SubscribeCandidateGathered(
+        [this](IceTransportInternal* transport, const Candidate& candidate) {
+          OnCandidateGathered(transport, candidate);
+        });
     channel->SetCandidatesRemovedCallback(
         [this](IceTransportInternal* transport, const Candidates& candidates) {
           OnCandidatesRemoved(transport, candidates);
@@ -501,8 +503,8 @@
                   const ReceivedIpPacket& packet) {
           OnReadPacket(transport, packet);
         });
-    channel->SignalRoleConflict.connect(
-        this, &P2PTransportChannelTestBase::OnRoleConflict);
+    channel->SubscribeRoleConflict(
+        [this](IceTransportInternal* transport) { OnRoleConflict(transport); });
     channel->SignalNetworkRouteChanged.connect(
         this, &P2PTransportChannelTestBase::OnNetworkRouteChanged);
     channel->SignalSentPacket.connect(
@@ -3585,8 +3587,10 @@
         this, &P2PTransportChannelPingTest::OnNetworkRouteChanged);
     ch->SignalReadyToSend.connect(this,
                                   &P2PTransportChannelPingTest::OnReadyToSend);
-    ch->SignalIceTransportStateChanged.connect(
-        this, &P2PTransportChannelPingTest::OnChannelStateChanged);
+    ch->SubscribeIceTransportStateChanged(
+        [this](IceTransportInternal* transport) {
+          OnChannelStateChanged(transport);
+        });
     ch->SetCandidatePairChangeCallback(
         [this](const CandidatePairChangeEvent& event) {
           OnCandidatePairChanged(event);
diff --git a/p2p/base/regathering_controller.cc b/p2p/base/regathering_controller.cc
index bbebc60..8ca4029 100644
--- a/p2p/base/regathering_controller.cc
+++ b/p2p/base/regathering_controller.cc
@@ -27,8 +27,10 @@
   RTC_DCHECK(thread_);
   RTC_DCHECK_RUN_ON(thread_);
   RTC_DCHECK(ice_transport_);
-  ice_transport_->SignalIceTransportStateChanged.connect(
-      this, &BasicRegatheringController::OnIceTransportStateChanged);
+  ice_transport_->SubscribeIceTransportStateChanged(
+      [this](IceTransportInternal* transport) {
+        OnIceTransportStateChanged(transport);
+      });
   ice_transport->SignalWritableState.connect(
       this, &BasicRegatheringController::OnIceTransportWritableState);
   ice_transport->SignalReceivingState.connect(
diff --git a/p2p/dtls/dtls_ice_integrationtest.cc b/p2p/dtls/dtls_ice_integrationtest.cc
index b6b8d40..0cd9e9e 100644
--- a/p2p/dtls/dtls_ice_integrationtest.cc
+++ b/p2p/dtls/dtls_ice_integrationtest.cc
@@ -192,11 +192,17 @@
                                                    : ICEROLE_CONTROLLED);
       }
       if (client) {
-        ep.ice->SignalCandidateGathered.connect(
-            this, &DtlsIceIntegrationTest::CandidateC2S);
+        ep.ice->SubscribeCandidateGathered(
+            [this](IceTransportInternal* transport,
+                   const Candidate& candidate) {
+              CandidateC2S(transport, candidate);
+            });
       } else {
-        ep.ice->SignalCandidateGathered.connect(
-            this, &DtlsIceIntegrationTest::CandidateS2C);
+        ep.ice->SubscribeCandidateGathered(
+            [this](IceTransportInternal* transport,
+                   const Candidate& candidate) {
+              CandidateS2C(transport, candidate);
+            });
       }
 
       // Setup DTLS.
diff --git a/p2p/test/fake_ice_transport.h b/p2p/test/fake_ice_transport.h
index c236c9a..316668d 100644
--- a/p2p/test/fake_ice_transport.h
+++ b/p2p/test/fake_ice_transport.h
@@ -150,7 +150,7 @@
     RTC_DCHECK_RUN_ON(network_thread_);
     transport_state_ = state;
     legacy_transport_state_ = legacy_state;
-    SignalIceTransportStateChanged(this);
+    NotifyIceTransportStateChanged(this);
   }
 
   void SetConnectionCount(size_t connection_count) {
@@ -163,7 +163,7 @@
     // In this fake transport channel, `connection_count_` determines the
     // transport state.
     if (connection_count_ < old_connection_count) {
-      SignalIceTransportStateChanged(this);
+      NotifyIceTransportStateChanged(this);
     }
   }
 
diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc
index 82316b7..e7bcdb9 100644
--- a/pc/jsep_transport_controller.cc
+++ b/pc/jsep_transport_controller.cc
@@ -523,8 +523,11 @@
         RTC_DCHECK_RUN_ON(network_thread_);
         OnTransportGatheringState_n(transport);
       });
-  dtls->ice_transport()->SignalCandidateGathered.connect(
-      this, &JsepTransportController::OnTransportCandidateGathered_n);
+  dtls->ice_transport()->SubscribeCandidateGathered(
+      [this](IceTransportInternal* transport, const Candidate& candidate) {
+        RTC_DCHECK_RUN_ON(network_thread_);
+        OnTransportCandidateGathered_n(transport, candidate);
+      });
   dtls->ice_transport()->SetCandidateErrorCallback(
       [this](IceTransportInternal* transport,
              const IceCandidateErrorEvent& error) {
@@ -536,10 +539,16 @@
         RTC_DCHECK_RUN_ON(network_thread_);
         OnTransportCandidatesRemoved_n(transport, candidates);
       });
-  dtls->ice_transport()->SignalRoleConflict.connect(
-      this, &JsepTransportController::OnTransportRoleConflict_n);
-  dtls->ice_transport()->SignalIceTransportStateChanged.connect(
-      this, &JsepTransportController::OnTransportStateChanged_n);
+  dtls->ice_transport()->SubscribeRoleConflict(
+      [this](IceTransportInternal* transport) {
+        RTC_DCHECK_RUN_ON(network_thread_);
+        OnTransportRoleConflict_n(transport);
+      });
+  dtls->ice_transport()->SubscribeIceTransportStateChanged(
+      [this](IceTransportInternal* transport) {
+        RTC_DCHECK_RUN_ON(network_thread_);
+        OnTransportStateChanged_n(transport);
+      });
   dtls->ice_transport()->SetCandidatePairChangeCallback(
       [this](const CandidatePairChangeEvent& event) {
         RTC_DCHECK_RUN_ON(network_thread_);
diff --git a/pc/jsep_transport_controller_unittest.cc b/pc/jsep_transport_controller_unittest.cc
index 085a9af..a4c96242 100644
--- a/pc/jsep_transport_controller_unittest.cc
+++ b/pc/jsep_transport_controller_unittest.cc
@@ -306,9 +306,9 @@
         transport_controller_->GetDtlsTransport(kAudioMid1));
     auto fake_video_dtls = static_cast<FakeDtlsTransport*>(
         transport_controller_->GetDtlsTransport(kVideoMid1));
-    fake_audio_dtls->fake_ice_transport()->SignalCandidateGathered(
+    fake_audio_dtls->fake_ice_transport()->NotifyCandidateGathered(
         fake_audio_dtls->fake_ice_transport(), CreateCandidate());
-    fake_video_dtls->fake_ice_transport()->SignalCandidateGathered(
+    fake_video_dtls->fake_ice_transport()->NotifyCandidateGathered(
         fake_video_dtls->fake_ice_transport(), CreateCandidate());
     fake_audio_dtls->fake_ice_transport()->SetCandidatesGatheringComplete();
     fake_video_dtls->fake_ice_transport()->SetCandidatesGatheringComplete();
@@ -1118,7 +1118,7 @@
 
   auto fake_audio_dtls = static_cast<FakeDtlsTransport*>(
       transport_controller_->GetDtlsTransport(kAudioMid1));
-  fake_audio_dtls->fake_ice_transport()->SignalCandidateGathered(
+  fake_audio_dtls->fake_ice_transport()->NotifyCandidateGathered(
       fake_audio_dtls->fake_ice_transport(), CreateCandidate());
   EXPECT_THAT(
       WaitUntil([&] { return 1; }, ::testing::Eq(candidates_signal_count_),