Remove dependency on MessageHandlerAutoCleanup from cricket::Port.

Bug: webrtc:11988
Change-Id: I15335cf49365de1274f5d3051dcb2de97e9e263b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/194562
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32673}
This commit is contained in:
Tomas Gunnarsson 2020-11-23 13:03:33 +01:00 committed by Commit Bot
parent fd53dd8660
commit 91e4156a8c
2 changed files with 26 additions and 3 deletions

View File

@ -188,6 +188,9 @@ void Port::Construct() {
}
Port::~Port() {
RTC_DCHECK_RUN_ON(thread_);
CancelPendingTasks();
// Delete all of the remaining connections. We copy the list up front
// because each deletion will cause it to be modified.
@ -609,6 +612,16 @@ rtc::DiffServCodePoint Port::StunDscpValue() const {
return rtc::DSCP_NO_CHANGE;
}
void Port::set_timeout_delay(int delay) {
RTC_DCHECK_RUN_ON(thread_);
// Although this method is meant to only be used by tests, some downstream
// projects have started using it. Ideally we should update our tests to not
// require to modify this state and instead use a testing harness that allows
// adjusting the clock and then just use the kPortTimeoutDelay constant
// directly.
timeout_delay_ = delay;
}
bool Port::ParseStunUsername(const StunMessage* stun_msg,
std::string* local_ufrag,
std::string* remote_ufrag) const {
@ -818,7 +831,14 @@ void Port::Prune() {
thread_->Post(RTC_FROM_HERE, this, MSG_DESTROY_IF_DEAD);
}
// Call to stop any currently pending operations from running.
void Port::CancelPendingTasks() {
RTC_DCHECK_RUN_ON(thread_);
thread_->Clear(this);
}
void Port::OnMessage(rtc::Message* pmsg) {
RTC_DCHECK_RUN_ON(thread_);
RTC_DCHECK(pmsg->message_id == MSG_DESTROY_IF_DEAD);
bool dead =
(state_ == State::INIT || state_ == State::PRUNED) &&

View File

@ -160,7 +160,7 @@ typedef std::set<rtc::SocketAddress> ServerAddresses;
// connections to similar mechanisms of the other client. Subclasses of this
// one add support for specific mechanisms like local UDP ports.
class Port : public PortInterface,
public rtc::MessageHandlerAutoCleanup,
public rtc::MessageHandler,
public sigslot::has_slots<> {
public:
// INIT: The state when a port is just created.
@ -209,6 +209,9 @@ class Port : public PortInterface,
// Allows a port to be destroyed if no connection is using it.
void Prune();
// Call to stop any currently pending operations from running.
void CancelPendingTasks();
// The thread on which this port performs its I/O.
rtc::Thread* thread() { return thread_; }
@ -322,7 +325,7 @@ class Port : public PortInterface,
uint16_t max_port() { return max_port_; }
// Timeout shortening function to speed up unit tests.
void set_timeout_delay(int delay) { timeout_delay_ = delay; }
void set_timeout_delay(int delay);
// This method will return local and remote username fragements from the
// stun username attribute if present.
@ -437,7 +440,7 @@ class Port : public PortInterface,
void OnNetworkTypeChanged(const rtc::Network* network);
rtc::Thread* thread_;
rtc::Thread* const thread_;
rtc::PacketSocketFactory* factory_;
std::string type_;
bool send_retransmit_count_attribute_;