From 044a04d8b53973d14aba58376ec339529bec5d46 Mon Sep 17 00:00:00 2001 From: Steve Anton Date: Fri, 31 Aug 2018 13:51:19 -0700 Subject: [PATCH] Use AsyncInvoker in DataChannel instead of MessageHandler Bug: webrtc:9702 Change-Id: I76a6a97f792be632c1c2f4f5cbbd26a7ec243006 Reviewed-on: https://webrtc-review.googlesource.com/97183 Reviewed-by: Seth Hampson Commit-Queue: Steve Anton Cr-Commit-Position: refs/heads/master@{#24517} --- pc/datachannel.cc | 15 ++------------- pc/datachannel.h | 10 +++------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/pc/datachannel.cc b/pc/datachannel.cc index 6971ca8f66..f819d26695 100644 --- a/pc/datachannel.cc +++ b/pc/datachannel.cc @@ -24,10 +24,6 @@ namespace webrtc { static size_t kMaxQueuedReceivedDataBytes = 16 * 1024 * 1024; static size_t kMaxQueuedSendDataBytes = 16 * 1024 * 1024; -enum { - MSG_CHANNELREADY, -}; - bool SctpSidAllocator::AllocateSid(rtc::SSLRole role, int* sid) { int potential_sid = (role == rtc::SSL_CLIENT) ? 0 : 1; while (!IsSidAvailable(potential_sid)) { @@ -187,7 +183,8 @@ bool DataChannel::Init(const InternalDataChannelInit& config) { // Chrome glue and WebKit) are not wired up properly until after this // function returns. if (provider_->ReadyToSendData()) { - rtc::Thread::Current()->Post(RTC_FROM_HERE, this, MSG_CHANNELREADY, NULL); + invoker_.AsyncInvoke(RTC_FROM_HERE, rtc::Thread::Current(), + [this] { OnChannelReady(true); }); } } @@ -346,14 +343,6 @@ void DataChannel::SetSendSsrc(uint32_t send_ssrc) { UpdateState(); } -void DataChannel::OnMessage(rtc::Message* msg) { - switch (msg->message_id) { - case MSG_CHANNELREADY: - OnChannelReady(true); - break; - } -} - void DataChannel::OnDataReceived(const cricket::ReceiveDataParams& params, const rtc::CopyOnWriteBuffer& payload) { if (data_channel_type_ == cricket::DCT_RTP && params.ssrc != receive_ssrc_) { diff --git a/pc/datachannel.h b/pc/datachannel.h index d29ee59ce3..cbb0c8b2cf 100644 --- a/pc/datachannel.h +++ b/pc/datachannel.h @@ -19,7 +19,7 @@ #include "api/proxy.h" #include "media/base/mediachannel.h" #include "pc/channel.h" -#include "rtc_base/messagehandler.h" +#include "rtc_base/asyncinvoker.h" #include "rtc_base/scoped_ref_ptr.h" #include "rtc_base/third_party/sigslot/sigslot.h" @@ -114,9 +114,7 @@ class SctpSidAllocator { // 5. Bob sends outgoing stream reset. 6. Alice receives incoming reset, // Bob receives acknowledgement. Both receive OnClosingProcedureComplete // callback and transition to kClosed. -class DataChannel : public DataChannelInterface, - public sigslot::has_slots<>, - public rtc::MessageHandler { +class DataChannel : public DataChannelInterface, public sigslot::has_slots<> { public: static rtc::scoped_refptr Create( DataChannelProviderInterface* provider, @@ -146,9 +144,6 @@ class DataChannel : public DataChannelInterface, virtual uint64_t bytes_received() const { return bytes_received_; } virtual bool Send(const DataBuffer& buffer); - // rtc::MessageHandler override. - virtual void OnMessage(rtc::Message* msg); - // Called when the channel's ready to use. That can happen when the // underlying DataMediaChannel becomes ready, or when this channel is a new // stream on an existing DataMediaChannel, and we've finished negotiation. @@ -291,6 +286,7 @@ class DataChannel : public DataChannelInterface, PacketQueue queued_control_data_; PacketQueue queued_received_data_; PacketQueue queued_send_data_; + rtc::AsyncInvoker invoker_; }; // Define proxy for DataChannelInterface.