[sigslot] - Remove sigslot form NetworkMonitorInterface.

Bug: webrtc:11943
Change-Id: Iddedb2840e437dfbffcb0d6cbf71a09b0030fbab
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226869
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34573}
diff --git a/rtc_base/network.cc b/rtc_base/network.cc
index f4a349b..a22d8ff 100644
--- a/rtc_base/network.cc
+++ b/rtc_base/network.cc
@@ -863,8 +863,8 @@
     if (!network_monitor_) {
       return;
     }
-    network_monitor_->SignalNetworksChanged.connect(
-        this, &BasicNetworkManager::OnNetworksChanged);
+    network_monitor_->SetNetworksChangedCallback(
+        [this]() { OnNetworksChanged(); });
   }
 
   if (network_monitor_->SupportsBindSocketToNetwork()) {
diff --git a/rtc_base/network_monitor.h b/rtc_base/network_monitor.h
index dddc2f6..1e150fe 100644
--- a/rtc_base/network_monitor.h
+++ b/rtc_base/network_monitor.h
@@ -11,8 +11,10 @@
 #ifndef RTC_BASE_NETWORK_MONITOR_H_
 #define RTC_BASE_NETWORK_MONITOR_H_
 
+#include <functional>
+#include <utility>
+
 #include "rtc_base/network_constants.h"
-#include "rtc_base/third_party/sigslot/sigslot.h"
 
 namespace rtc {
 
@@ -73,8 +75,6 @@
   NetworkMonitorInterface();
   virtual ~NetworkMonitorInterface();
 
-  sigslot::signal0<> SignalNetworksChanged;
-
   virtual void Start() = 0;
   virtual void Stop() = 0;
 
@@ -110,6 +110,20 @@
   virtual bool IsAdapterAvailable(const std::string& interface_name) {
     return true;
   }
+
+  void SetNetworksChangedCallback(std::function<void()> callback) {
+    networks_changed_callback_ = std::move(callback);
+  }
+
+ protected:
+  void InvokeNetworksChangedCallback() {
+    if (networks_changed_callback_) {
+      networks_changed_callback_();
+    }
+  }
+
+ private:
+  std::function<void()> networks_changed_callback_;
 };
 
 }  // namespace rtc
diff --git a/rtc_base/network_unittest.cc b/rtc_base/network_unittest.cc
index 7585663..01e18af 100644
--- a/rtc_base/network_unittest.cc
+++ b/rtc_base/network_unittest.cc
@@ -100,6 +100,10 @@
 
   void set_adapters(std::vector<std::string> adapters) { adapters_ = adapters; }
 
+  void InovkeNetworksChangedCallbackForTesting() {
+    InvokeNetworksChangedCallback();
+  }
+
  private:
   bool started_ = false;
   std::vector<std::string> adapters_;
@@ -1128,7 +1132,7 @@
   ClearNetworks(manager);
   // Network manager is started, so the callback is called when the network
   // monitor fires the network-change event.
-  network_monitor->SignalNetworksChanged();
+  network_monitor->InovkeNetworksChangedCallbackForTesting();
   EXPECT_TRUE_WAIT(callback_called_, 1000);
 
   // Network manager is stopped.
diff --git a/sdk/android/src/jni/android_network_monitor.cc b/sdk/android/src/jni/android_network_monitor.cc
index 088ca47..08b77fe 100644
--- a/sdk/android/src/jni/android_network_monitor.cc
+++ b/sdk/android/src/jni/android_network_monitor.cc
@@ -267,8 +267,8 @@
   started_ = false;
   find_network_handle_without_ipv6_temporary_part_ = false;
 
-  // Cancel any pending tasks. We should not call SignalNetworksChanged when the
-  // monitor is stopped.
+  // Cancel any pending tasks. We should not call
+  // `InvokeNetworksChangedCallback()` when the monitor is stopped.
   safety_flag_->SetNotAlive();
 
   JNIEnv* env = AttachCurrentThreadIfNeeded();
@@ -411,7 +411,7 @@
   for (const rtc::IPAddress& address : network_info.ip_addresses) {
     network_handle_by_address_[address] = network_info.handle;
   }
-  SignalNetworksChanged();
+  InvokeNetworksChangedCallback();
 }
 
 absl::optional<NetworkHandle>
@@ -479,7 +479,7 @@
                    << rtc::NetworkPreferenceToString(preference);
   auto adapter_type = AdapterTypeFromNetworkType(type, surface_cellular_types_);
   network_preference_by_adapter_type_[adapter_type] = preference;
-  SignalNetworksChanged();
+  InvokeNetworksChangedCallback();
 }
 
 void AndroidNetworkMonitor::SetNetworkInfos(
@@ -586,7 +586,7 @@
   network_thread_->PostTask(ToQueuedTask(safety_flag_, [this] {
     RTC_LOG(LS_INFO)
         << "Android network monitor detected connection type change.";
-    SignalNetworksChanged();
+    InvokeNetworksChangedCallback();
   }));
 }
 
diff --git a/sdk/objc/native/src/objc_network_monitor.mm b/sdk/objc/native/src/objc_network_monitor.mm
index e85bb8b..2fc84df 100644
--- a/sdk/objc/native/src/objc_network_monitor.mm
+++ b/sdk/objc/native/src/objc_network_monitor.mm
@@ -87,7 +87,7 @@
   thread_->PostTask(ToQueuedTask(safety_flag_, [this, adapter_type_by_name] {
     RTC_DCHECK_RUN_ON(thread_);
     adapter_type_by_name_ = adapter_type_by_name;
-    SignalNetworksChanged();
+    InvokeNetworksChangedCallback();
   }));
 }