Modify IceControllerInterface::SelectConnectionToPing - step 1

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: I6ebb8658a77e0ef5c24acb382c0cb6413403c168
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171691
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30902}
diff --git a/p2p/base/basic_ice_controller.cc b/p2p/base/basic_ice_controller.cc
index 09bc4f1..32febb5 100644
--- a/p2p/base/basic_ice_controller.cc
+++ b/p2p/base/basic_ice_controller.cc
@@ -92,7 +92,7 @@
   });
 }
 
-std::pair<Connection*, int> BasicIceController::SelectConnectionToPing(
+IceControllerInterface::PingResult BasicIceController::SelectConnectionToPing(
     int64_t last_ping_sent_ms) {
   // When the selected connection is not receiving or not writable, or any
   // active connection has not been pinged enough times, use the weak ping
@@ -110,8 +110,8 @@
   if (rtc::TimeMillis() >= last_ping_sent_ms + ping_interval) {
     conn = FindNextPingableConnection();
   }
-  int delay = std::min(ping_interval, check_receiving_interval());
-  return std::make_pair(const_cast<Connection*>(conn), delay);
+  return std::make_pair(const_cast<Connection*>(conn),
+                        std::min(ping_interval, check_receiving_interval()));
 }
 
 void BasicIceController::MarkConnectionPinged(const Connection* conn) {
diff --git a/p2p/base/basic_ice_controller.h b/p2p/base/basic_ice_controller.h
index ae1339f..2e46272 100644
--- a/p2p/base/basic_ice_controller.h
+++ b/p2p/base/basic_ice_controller.h
@@ -40,8 +40,8 @@
 
   bool HasPingableConnection() const override;
 
-  std::pair<Connection*, int> SelectConnectionToPing(
-      int64_t last_ping_sent_ms) override;
+  PingResult SelectConnectionToPing(int64_t last_ping_sent_ms) override;
+
   bool GetUseCandidateAttr(const Connection* conn,
                            NominationMode mode,
                            IceMode remote_ice_mode) const override;
diff --git a/p2p/base/ice_controller_interface.h b/p2p/base/ice_controller_interface.h
index 43bb884..ecfb0c8 100644
--- a/p2p/base/ice_controller_interface.h
+++ b/p2p/base/ice_controller_interface.h
@@ -73,6 +73,10 @@
     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;
+
   virtual ~IceControllerInterface() = default;
 
   // These setters are called when the state of P2PTransportChannel is mutated.
@@ -90,8 +94,7 @@
   virtual bool HasPingableConnection() const = 0;
 
   // Select a connection to Ping, or nullptr if none.
-  virtual std::pair<Connection*, int> SelectConnectionToPing(
-      int64_t last_ping_sent_ms) = 0;
+  virtual PingResult SelectConnectionToPing(int64_t last_ping_sent_ms) = 0;
 
   // Compute the "STUN_ATTR_USE_CANDIDATE" for |conn|.
   virtual bool GetUseCandidateAttr(const Connection* conn,
diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc
index 2a4ad59..fe6df20 100644
--- a/p2p/base/p2p_transport_channel.cc
+++ b/p2p/base/p2p_transport_channel.cc
@@ -1888,7 +1888,7 @@
   UpdateConnectionStates();
 
   auto result = ice_controller_->SelectConnectionToPing(last_ping_sent_ms_);
-  Connection* conn = result.first;
+  Connection* conn = const_cast<Connection*>(result.first);
   int delay = result.second;
 
   if (conn) {