Implement network monitor for iOS.

Notably, this should detect whether an interface is "available" or not,
which should prevent the failure is with dual SIM card setups.

This is gated behind a field trial for now, to ensure this doesn't cause
any regressions due to false negatives (interfaces that are usable
but not listed as available by NWPathMonitor).

Bug: webrtc:10966
Change-Id: Ia3942c4c57b525d08d8b340e2325f3705cfd0304
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180923
Commit-Queue: Taylor <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Reviewed-by: Anders Carlsson <andersc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31977}
diff --git a/rtc_base/network_monitor.h b/rtc_base/network_monitor.h
index b57a200..1098219 100644
--- a/rtc_base/network_monitor.h
+++ b/rtc_base/network_monitor.h
@@ -77,15 +77,34 @@
 
   // Implementations should call this method on the base when networks change,
   // and the base will fire SignalNetworksChanged on the right thread.
+  // TODO(deadbeef): This is an implementation detail of NetworkMonitorBase,
+  // it doesn't belong here.
   virtual void OnNetworksChanged() = 0;
 
   virtual AdapterType GetAdapterType(const std::string& interface_name) = 0;
   virtual AdapterType GetVpnUnderlyingAdapterType(
       const std::string& interface_name) = 0;
+
   virtual NetworkPreference GetNetworkPreference(
       const std::string& interface_name) = 0;
+
+  // Is this interface available to use? WebRTC shouldn't attempt to use it if
+  // this returns false.
+  //
+  // It's possible for this status to change, in which case
+  // SignalNetworksChanged will be fired.
+  //
+  // These specific use case this was added for was a phone with two SIM cards,
+  // where attempting to use all interfaces returned from getifaddrs caused the
+  // connection to be dropped.
+  virtual bool IsAdapterAvailable(const std::string& interface_name) {
+    return true;
+  }
 };
 
+// TODO(deadbeef): This class has marginal value, all it does is post a task
+// to call SignalNetworksChanged on the worker thread. Should fold it into
+// AndroidNetworkMonitor.
 class NetworkMonitorBase : public NetworkMonitorInterface,
                            public MessageHandler,
                            public sigslot::has_slots<> {