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