From b774d38d31434e2c09dbab2b1218bfcd221919d2 Mon Sep 17 00:00:00 2001 From: Tomas Gunnarsson Date: Sun, 20 Sep 2020 23:56:24 +0200 Subject: [PATCH] Remove use of AsyncInvoker from SctpDataChannel Bug: webrtc:11908 Change-Id: I4a32d9c3903d56994f2be365ab3fee2599ed6cdb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/184604 Reviewed-by: Markus Handell Commit-Queue: Tommi Cr-Commit-Position: refs/heads/master@{#32145} --- pc/BUILD.gn | 1 + pc/sctp_data_channel.cc | 11 +++++++++-- pc/sctp_data_channel.h | 2 -- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index dd35de0051..d182b43df9 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -274,6 +274,7 @@ rtc_library("peerconnection") { "../rtc_base/synchronization:sequence_checker", "../rtc_base/system:file_wrapper", "../rtc_base/system:rtc_export", + "../rtc_base/task_utils:to_queued_task", "../rtc_base/third_party/base64", "../rtc_base/third_party/sigslot", "../stats", diff --git a/pc/sctp_data_channel.cc b/pc/sctp_data_channel.cc index e603dddd0f..c4357a8da6 100644 --- a/pc/sctp_data_channel.cc +++ b/pc/sctp_data_channel.cc @@ -21,6 +21,7 @@ #include "rtc_base/location.h" #include "rtc_base/logging.h" #include "rtc_base/ref_counted_object.h" +#include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/thread.h" namespace webrtc { @@ -206,8 +207,14 @@ bool SctpDataChannel::Init() { // Chrome glue and WebKit) are not wired up properly until after this // function returns. if (provider_->ReadyToSendData()) { - invoker_.AsyncInvoke(RTC_FROM_HERE, rtc::Thread::Current(), - [this] { OnTransportReady(true); }); + AddRef(); + rtc::Thread::Current()->PostTask(ToQueuedTask( + [this] { + RTC_DCHECK_RUN_ON(signaling_thread_); + if (state_ != kClosed) + OnTransportReady(true); + }, + [this] { Release(); })); } return true; diff --git a/pc/sctp_data_channel.h b/pc/sctp_data_channel.h index 871f18af5c..6d121e6f80 100644 --- a/pc/sctp_data_channel.h +++ b/pc/sctp_data_channel.h @@ -21,7 +21,6 @@ #include "api/transport/data_channel_transport_interface.h" #include "media/base/media_channel.h" #include "pc/data_channel_utils.h" -#include "rtc_base/async_invoker.h" #include "rtc_base/ssl_stream_adapter.h" // For SSLRole #include "rtc_base/third_party/sigslot/sigslot.h" @@ -277,7 +276,6 @@ class SctpDataChannel : public DataChannelInterface, PacketQueue queued_control_data_ RTC_GUARDED_BY(signaling_thread_); PacketQueue queued_received_data_ RTC_GUARDED_BY(signaling_thread_); PacketQueue queued_send_data_ RTC_GUARDED_BY(signaling_thread_); - rtc::AsyncInvoker invoker_ RTC_GUARDED_BY(signaling_thread_); }; } // namespace webrtc