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}
This commit is contained in:
Jonas Oreland 2020-03-26 12:59:44 +01:00 committed by Commit Bot
parent 4bdd873f6e
commit 2f3c01941b
4 changed files with 11 additions and 8 deletions

View File

@ -92,7 +92,7 @@ bool BasicIceController::HasPingableConnection() const {
});
}
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 @@ std::pair<Connection*, int> BasicIceController::SelectConnectionToPing(
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) {

View File

@ -40,8 +40,8 @@ class BasicIceController : public IceControllerInterface {
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;

View File

@ -73,6 +73,10 @@ 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;
virtual ~IceControllerInterface() = default;
// These setters are called when the state of P2PTransportChannel is mutated.
@ -90,8 +94,7 @@ class IceControllerInterface {
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,

View File

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