Remove SctpDataChannel::Init()
This is a small tweak to explicitly remove this second construction
step from SctpDataChannel (async call to OnTransportReady) and move
it over to DataChannelController, which is where OnTransportReady()
is called from otherwise.
Bug: webrtc:11547
Change-Id: Ie86fa85cbb79b405248f88b47d5920c7f163dba6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/297921
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39627}
diff --git a/pc/sctp_data_channel.cc b/pc/sctp_data_channel.cc
index 4adf2b8..f028954 100644
--- a/pc/sctp_data_channel.cc
+++ b/pc/sctp_data_channel.cc
@@ -148,18 +148,10 @@
rtc::Thread* signaling_thread,
rtc::Thread* network_thread) {
RTC_DCHECK(controller);
-
- if (!config.IsValid()) {
- RTC_LOG(LS_ERROR) << "Failed to initialize the SCTP data channel due to "
- "invalid DataChannelInit.";
- return nullptr;
- }
-
- auto channel = rtc::make_ref_counted<SctpDataChannel>(
+ RTC_DCHECK(config.IsValid());
+ return rtc::make_ref_counted<SctpDataChannel>(
config, std::move(controller), label, connected_to_transport,
signaling_thread, network_thread);
- channel->Init();
- return channel;
}
// static
@@ -215,26 +207,6 @@
}
}
-void SctpDataChannel::Init() {
- RTC_DCHECK_RUN_ON(signaling_thread_);
-
- // Checks if the transport is ready to send because the initial channel
- // ready signal may have been sent before the DataChannel creation.
- // This has to be done async because the upper layer objects (e.g.
- // Chrome glue and WebKit) are not wired up properly until after this
- // function returns.
- if (controller_->ReadyToSendData()) {
- RTC_DCHECK(connected_to_transport_);
- AddRef();
- absl::Cleanup release = [this] { Release(); };
- rtc::Thread::Current()->PostTask([this, release = std::move(release)] {
- RTC_DCHECK_RUN_ON(signaling_thread_);
- if (state_ != kClosed)
- OnTransportReady();
- });
- }
-}
-
SctpDataChannel::~SctpDataChannel() {
RTC_DCHECK_RUN_ON(signaling_thread_);
}