Modify IceControllerInterface::SelectConnectionToPing - step 2

this is a NOP refactoring, that modify return type
of IceControllerInterface::SelectConnectionToPing to a struct
(rather than existing pair). The modification is done
so that one can safely add new return values in the struct.

Step 1) Create a typedef for return value.
- merge downstream and change it to start using new type.
Step 2) Change typedef to struct,
adding constructors from old type to new type
merge and change downstream to use "real" constructors
Step 3) remove temporary constructors
Step 4) Eat cake

Each step requires a merge downstream, with corresponding
changes there.

Bug: chromium:1024965
Change-Id: I79df9528f842ea73ca8896cedd62ad3a5cf5b767
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171807
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30914}
diff --git a/p2p/base/basic_ice_controller.cc b/p2p/base/basic_ice_controller.cc
index 32febb5..aa20025 100644
--- a/p2p/base/basic_ice_controller.cc
+++ b/p2p/base/basic_ice_controller.cc
@@ -110,8 +110,8 @@
   if (rtc::TimeMillis() >= last_ping_sent_ms + ping_interval) {
     conn = FindNextPingableConnection();
   }
-  return std::make_pair(const_cast<Connection*>(conn),
-                        std::min(ping_interval, check_receiving_interval()));
+  PingResult res(conn, std::min(ping_interval, check_receiving_interval()));
+  return res;
 }
 
 void BasicIceController::MarkConnectionPinged(const Connection* conn) {
diff --git a/p2p/base/ice_controller_interface.h b/p2p/base/ice_controller_interface.h
index ecfb0c8..8bc6ba9 100644
--- a/p2p/base/ice_controller_interface.h
+++ b/p2p/base/ice_controller_interface.h
@@ -73,9 +73,22 @@
     absl::optional<IceControllerEvent> recheck_event;
   };
 
-  // A temporary typedef, so that we can migrate downstream
-  // to a new return value for SelectConnectionToPing.
-  typedef std::pair<Connection*, int> PingResult;
+  // This represents the result of a call to SelectConnectionToPing.
+  struct PingResult {
+    PingResult(const Connection* conn, int _recheck_delay_ms)
+        : connection(conn), recheck_delay_ms(_recheck_delay_ms) {}
+
+    // A temporary constructor while merging.
+    // Will be removed once downstream has been updated.
+    PingResult(const std::pair<Connection*, int>& pair)  // NOLINT
+        : connection(pair.first), recheck_delay_ms(pair.second) {}
+
+    // Connection that we should (optionally) ping.
+    const absl::optional<const Connection*> connection;
+
+    // The delay before calling SelectConnectionToPing() again.
+    const int recheck_delay_ms = 0;
+  };
 
   virtual ~IceControllerInterface() = default;
 
diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc
index fe6df20..6937b20 100644
--- a/p2p/base/p2p_transport_channel.cc
+++ b/p2p/base/p2p_transport_channel.cc
@@ -1888,8 +1888,9 @@
   UpdateConnectionStates();
 
   auto result = ice_controller_->SelectConnectionToPing(last_ping_sent_ms_);
-  Connection* conn = const_cast<Connection*>(result.first);
-  int delay = result.second;
+  Connection* conn =
+      const_cast<Connection*>(result.connection.value_or(nullptr));
+  int delay = result.recheck_delay_ms;
 
   if (conn) {
     PingConnection(conn);