Reland "Refactor IceControllerEvent" 1/n

This is a partial reland of commit 794e68cf3dbc3b16ee8b12b5615d8a1622154dbd
which
- adds a new enum - IceSwitchReason
- adds a member for the new enum in IceControllerEvent
- adds methods to IceControllerInterface accepting the new enum
- adds conversion between the old and new enums for compatibility

Original change's description:
> Refactor IceControllerEvent
>
> This change is the first step in decoupling IceControllerEvent from
> the ICE switch reason. Further cleanup is earmarked, and will be
> landed after some internal cleanup.
>
> This change
> - adds a new enum - IceSwitchReason
> - adds a member for the new enum in IceControllerEvent
> - uses the new enum within P2PTransportChannel
> - adds methods to IceControllerInterface accepting the new enum
> - deprecates usages of the old enum in IceControllerInterface
> - adds conversion between the old and new enums for compatibility
>
> Bug: webrtc:14125, webrtc:14131
> Change-Id: I5b7201c3f631eb40db334dfeec842841a7e58174
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264140
> Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
> Commit-Queue: Sameer Vijaykar <samvi@google.com>
> Cr-Commit-Position: refs/heads/main@{#37051}

Bug: webrtc:14125, webrtc:14131
Change-Id: I2ccdd53c80e38dc139669aa3f438864befed3dc0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/264506
Commit-Queue: Sameer Vijaykar <samvi@google.com>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37094}
diff --git a/p2p/base/ice_controller_interface.h b/p2p/base/ice_controller_interface.h
index a33315a..52bbd5b 100644
--- a/p2p/base/ice_controller_interface.h
+++ b/p2p/base/ice_controller_interface.h
@@ -15,7 +15,9 @@
 #include <utility>
 #include <vector>
 
+#include "absl/types/optional.h"
 #include "p2p/base/connection.h"
+#include "p2p/base/ice_switch_reason.h"
 #include "p2p/base/ice_transport_internal.h"
 
 namespace cricket {
@@ -23,6 +25,7 @@
 struct IceFieldTrials;  // Forward declaration to avoid circular dependency.
 
 struct IceControllerEvent {
+  // TODO(bugs.webrtc.org/14125) replace with IceSwitchReason.
   enum Type {
     REMOTE_CANDIDATE_GENERATION_CHANGE,
     NETWORK_PREFERENCE_CHANGE,
@@ -39,11 +42,23 @@
     ICE_CONTROLLER_RECHECK,
   };
 
+  // TODO(bugs.webrtc.org/14125) remove.
   IceControllerEvent(const Type& _type)  // NOLINT: runtime/explicit
-      : type(_type) {}
+      : type(_type), reason(FromType(_type)) {}
+
+  IceControllerEvent(IceSwitchReason _reason, int _recheck_delay_ms)
+      : type(FromIceSwitchReason(_reason)),
+        reason(_reason),
+        recheck_delay_ms(_recheck_delay_ms) {}
+
+  static Type FromIceSwitchReason(IceSwitchReason reason);
+  static IceSwitchReason FromType(Type type);
+
   std::string ToString() const;
 
+  // TODO(bugs.webrtc.org/14125) replace usage with IceSwitchReason.
   Type type;
+  IceSwitchReason reason;
   int recheck_delay_ms = 0;
 };
 
@@ -134,13 +149,22 @@
   virtual void MarkConnectionPinged(const Connection* con) = 0;
 
   // Check if we should switch to `connection`.
-  // This method is called for IceControllerEvent's that can switch directly
+  // This method is called for IceSwitchReasons that can switch directly
   // i.e without resorting.
   virtual SwitchResult ShouldSwitchConnection(IceControllerEvent reason,
                                               const Connection* connection) = 0;
+  virtual SwitchResult ShouldSwitchConnection(IceSwitchReason reason,
+                                              const Connection* connection) {
+    return ShouldSwitchConnection(
+        IceControllerEvent::FromIceSwitchReason(reason), connection);
+  }
 
   // Sort connections and check if we should switch.
   virtual SwitchResult SortAndSwitchConnection(IceControllerEvent reason) = 0;
+  virtual SwitchResult SortAndSwitchConnection(IceSwitchReason reason) {
+    return SortAndSwitchConnection(
+        IceControllerEvent::FromIceSwitchReason(reason));
+  }
 
   // Prune connections.
   virtual std::vector<const Connection*> PruneConnections() = 0;