Update DataChannelControllerTests to exercise teardown path.
This updates DataChannelControllerTests to shut down the DCC in the
same way it's shut down by the owning PeerConnection instance:
* Call TeardownDataChannelTransport_n()
* Call PrepareForShutdown()
Also calling PrepareForShutdown() from PC's dtor to be consistent with
how `sdp_handler_->PrepareForShutdown()` is called since it appears
that many tests do not call PC::Close() before destruction.
Bug: b/276434297
Change-Id: I0379baa0df0e764bc255b83ae0667032acfe3db0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/300220
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39756}
diff --git a/pc/data_channel_controller.cc b/pc/data_channel_controller.cc
index 92cdba3..36e8be1 100644
--- a/pc/data_channel_controller.cc
+++ b/pc/data_channel_controller.cc
@@ -22,17 +22,10 @@
namespace webrtc {
DataChannelController::~DataChannelController() {
-#if RTC_DCHECK_IS_ON
- // `sctp_data_channels_n_` might be empty while `sctp_data_channels_` is
- // not. An example of that is when the `DataChannelController` goes out of
- // scope with outstanding channels that have been properly terminated on the
- // network thread but not yet cleared from `sctp_data_channels_`. However,
- // if `sctp_data_channels_n_` is not empty, then `sctp_data_channels_n_` and
- // sctp_data_channels_ should hold the same contents.
- if (!sctp_data_channels_n_.empty()) {
- RTC_DCHECK_EQ(sctp_data_channels_n_.size(), sctp_data_channels_.size());
- }
-#endif
+ RTC_DCHECK(sctp_data_channels_n_.empty())
+ << "Missing call to TeardownDataChannelTransport_n?";
+ RTC_DCHECK(!signaling_safety_.flag()->alive())
+ << "Missing call to PrepareForShutdown?";
}
bool DataChannelController::HasDataChannelsForTest() const {
@@ -167,7 +160,7 @@
void DataChannelController::PrepareForShutdown() {
RTC_DCHECK_RUN_ON(signaling_thread());
- signaling_safety_.reset();
+ signaling_safety_.reset(PendingTaskSafetyFlag::CreateDetachedInactive());
}
void DataChannelController::TeardownDataChannelTransport_n() {