Move messaging -> PostTask for freeing datachannels
I could find no reason for the extra complexity of doing messaging in order to schedule a task to be done after the current cycle. It also simplifies the peerconnection/datachannelcontroller coupling. Bug: webrtc:11146 Change-Id: I68f45059b9f4a6869fb44b856e05a480f4652365 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161232 Commit-Queue: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29997}
This commit is contained in:
parent
e19a375f8c
commit
246724b0fe
@ -348,7 +348,13 @@ void DataChannelController::OnSctpDataChannelClosed(DataChannel* channel) {
|
||||
// we can't free it directly here; we need to free it asynchronously.
|
||||
sctp_data_channels_to_free_.push_back(*it);
|
||||
sctp_data_channels_.erase(it);
|
||||
pc_->SignalFreeDataChannels();
|
||||
signaling_thread()->PostTask(
|
||||
RTC_FROM_HERE, [self = weak_factory_.GetWeakPtr()] {
|
||||
if (self) {
|
||||
RTC_DCHECK_RUN_ON(self->signaling_thread());
|
||||
self->sctp_data_channels_to_free_.clear();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
#include "pc/channel.h"
|
||||
#include "pc/data_channel.h"
|
||||
#include "rtc_base/weak_ptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -77,12 +78,6 @@ class DataChannelController : public DataChannelProviderInterface,
|
||||
return !rtp_data_channels_.empty();
|
||||
}
|
||||
|
||||
// Called when it's appropriate to delete released datachannels.
|
||||
void FreeDataChannels() {
|
||||
RTC_DCHECK_RUN_ON(signaling_thread());
|
||||
sctp_data_channels_to_free_.clear();
|
||||
}
|
||||
|
||||
void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams);
|
||||
void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams);
|
||||
|
||||
@ -207,6 +202,7 @@ class DataChannelController : public DataChannelProviderInterface,
|
||||
|
||||
// Owning PeerConnection.
|
||||
PeerConnection* const pc_;
|
||||
rtc::WeakPtrFactory<DataChannelController> weak_factory_{this};
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -136,7 +136,6 @@ enum {
|
||||
MSG_SET_SESSIONDESCRIPTION_FAILED,
|
||||
MSG_CREATE_SESSIONDESCRIPTION_FAILED,
|
||||
MSG_GETSTATS,
|
||||
MSG_FREE_DATACHANNELS,
|
||||
MSG_REPORT_USAGE_PATTERN,
|
||||
};
|
||||
|
||||
@ -4496,10 +4495,6 @@ void PeerConnection::OnMessage(rtc::Message* msg) {
|
||||
delete param;
|
||||
break;
|
||||
}
|
||||
case MSG_FREE_DATACHANNELS: {
|
||||
data_channel_controller_.FreeDataChannels();
|
||||
break;
|
||||
}
|
||||
case MSG_REPORT_USAGE_PATTERN: {
|
||||
ReportUsagePattern();
|
||||
break;
|
||||
@ -5676,10 +5671,6 @@ void PeerConnection::OnSctpDataChannelClosed(DataChannel* channel) {
|
||||
data_channel_controller_.OnSctpDataChannelClosed(channel);
|
||||
}
|
||||
|
||||
void PeerConnection::SignalFreeDataChannels() {
|
||||
signaling_thread()->Post(RTC_FROM_HERE, this, MSG_FREE_DATACHANNELS, nullptr);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
||||
PeerConnection::GetAudioTransceiver() const {
|
||||
// This method only works with Plan B SDP, where there is a single
|
||||
|
||||
@ -317,8 +317,6 @@ class PeerConnection : public PeerConnectionInternal,
|
||||
bool GetSctpSslRole(rtc::SSLRole* role);
|
||||
// Handler for the "channel closed" signal
|
||||
void OnSctpDataChannelClosed(DataChannel* channel);
|
||||
// Sends the MSG_FREE_DATACHANNELS signal
|
||||
void SignalFreeDataChannels();
|
||||
|
||||
// Functions made public for testing.
|
||||
void ReturnHistogramVeryQuicklyForTesting() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user