diff --git a/p2p/base/basic_ice_controller.cc b/p2p/base/basic_ice_controller.cc index 32febb5a33..aa20025b2c 100644 --- a/p2p/base/basic_ice_controller.cc +++ b/p2p/base/basic_ice_controller.cc @@ -110,8 +110,8 @@ IceControllerInterface::PingResult BasicIceController::SelectConnectionToPing( if (rtc::TimeMillis() >= last_ping_sent_ms + ping_interval) { conn = FindNextPingableConnection(); } - return std::make_pair(const_cast(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 ecfb0c845d..8bc6ba9010 100644 --- a/p2p/base/ice_controller_interface.h +++ b/p2p/base/ice_controller_interface.h @@ -73,9 +73,22 @@ class IceControllerInterface { absl::optional recheck_event; }; - // A temporary typedef, so that we can migrate downstream - // to a new return value for SelectConnectionToPing. - typedef std::pair 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& pair) // NOLINT + : connection(pair.first), recheck_delay_ms(pair.second) {} + + // Connection that we should (optionally) ping. + const absl::optional 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 fe6df2015f..6937b20304 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -1888,8 +1888,9 @@ void P2PTransportChannel::CheckAndPing() { UpdateConnectionStates(); auto result = ice_controller_->SelectConnectionToPing(last_ping_sent_ms_); - Connection* conn = const_cast(result.first); - int delay = result.second; + Connection* conn = + const_cast(result.connection.value_or(nullptr)); + int delay = result.recheck_delay_ms; if (conn) { PingConnection(conn);