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}
This commit is contained in:
Jonas Oreland 2020-03-26 20:59:03 +01:00 committed by Commit Bot
parent c59a304901
commit 4333600357
3 changed files with 21 additions and 7 deletions

View File

@ -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<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) {

View File

@ -73,9 +73,22 @@ class IceControllerInterface {
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;

View File

@ -1888,8 +1888,9 @@ void P2PTransportChannel::CheckAndPing() {
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);