diff options
author | Jonas Oreland <jonaso@webrtc.org> | 2020-03-26 12:59:44 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-26 13:33:05 +0000 |
commit | 2f3c01941bd51563ab9f2a731e81286be29f1c50 (patch) | |
tree | 4b4344a3521d51fefc42077f634c82a18943fa93 /p2p/base | |
parent | 4bdd873f6e154619bea5e84f73b33efcc9a21938 (diff) | |
download | webrtc-2f3c01941bd51563ab9f2a731e81286be29f1c50.tar.gz |
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}
Diffstat (limited to 'p2p/base')
-rw-r--r-- | p2p/base/basic_ice_controller.cc | 6 | ||||
-rw-r--r-- | p2p/base/basic_ice_controller.h | 4 | ||||
-rw-r--r-- | p2p/base/ice_controller_interface.h | 7 | ||||
-rw-r--r-- | p2p/base/p2p_transport_channel.cc | 2 |
4 files changed, 11 insertions, 8 deletions
diff --git a/p2p/base/basic_ice_controller.cc b/p2p/base/basic_ice_controller.cc index 09bc4f1f5f..32febb5a33 100644 --- a/p2p/base/basic_ice_controller.cc +++ b/p2p/base/basic_ice_controller.cc @@ -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) { diff --git a/p2p/base/basic_ice_controller.h b/p2p/base/basic_ice_controller.h index ae1339fc03..2e462720f3 100644 --- a/p2p/base/basic_ice_controller.h +++ b/p2p/base/basic_ice_controller.h @@ -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; diff --git a/p2p/base/ice_controller_interface.h b/p2p/base/ice_controller_interface.h index 43bb88471b..ecfb0c845d 100644 --- a/p2p/base/ice_controller_interface.h +++ b/p2p/base/ice_controller_interface.h @@ -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, diff --git a/p2p/base/p2p_transport_channel.cc b/p2p/base/p2p_transport_channel.cc index 2a4ad59b55..fe6df2015f 100644 --- a/p2p/base/p2p_transport_channel.cc +++ b/p2p/base/p2p_transport_channel.cc @@ -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) { |