Reland "Add param to DCC::SetupDataChannelTransport_n, simplify DCC* setup code."
This reverts commit 298313534df2420e079ffc6fc9c6019d01d29a88.
Changes from the original commit:
* Call OnTransportClosed() from TeardownDataChannelTransport_n()
(same as before the original commit)
* Not call OnTransportClosed() from OnTransportChanged() when its
called with nullptr (also preserving the behaviour from before
the original commit).
Original change's description:
> Revert "Add param to DCC::SetupDataChannelTransport_n, simplify DCC* setup code."
>
> This reverts commit 2ec6a6c57830e06f601607c1b9473ad821b57e07.
>
> Reason for revert: It breaks WPT tests (e.g. https://ci.chromium.org/ui/p/chromium/builders/try/linux-rel/1361972/overview) blocking the roll into Chromium.
>
> Original change's description:
> > Add param to DCC::SetupDataChannelTransport_n, simplify DCC* setup code.
> >
> > * DCC = DataChannelController.
> >
> > * Consolidate steps to set the mid and transport name. They're now
> > set at the same time and without a separate PostTask.
> > * Transport sink is now consistently set in DCC
> > * Order of notifications for setting up the transport is now the same
> > regardless of the first time the transport is being set or if it's
> > being replaced.
> > * Made set_data_channel_transport() private.
> >
> > Bug: webrtc:11547
> > Change-Id: I39e89c6e269e6f06d55981d7944678bf23c8817a
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/300562
> > Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> > Cr-Commit-Position: refs/heads/main@{#39859}
>
> Bug: webrtc:11547
> Change-Id: I0d8d7453b71be80fbf1b7eba7d161336e29de091
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301360
> Auto-Submit: Mirko Bonadei <mbonadei@webrtc.org>
> Owners-Override: Mirko Bonadei <mbonadei@webrtc.org>
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
> Cr-Commit-Position: refs/heads/main@{#39864}
Bug: webrtc:11547
Change-Id: I8ebbc3d3a12786dff2096350a77e03e98466ff00
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/301702
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39884}
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index f76ce63..d9602ea 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -2113,12 +2113,14 @@
return sctp_mid_s_;
}
-void PeerConnection::SetSctpDataMid(const std::string& mid) {
+void PeerConnection::SetSctpDataInfo(absl::string_view mid,
+ absl::string_view transport_name) {
RTC_DCHECK_RUN_ON(signaling_thread());
- sctp_mid_s_ = mid;
+ sctp_mid_s_ = std::string(mid);
+ SetSctpTransportName(std::string(transport_name));
}
-void PeerConnection::ResetSctpDataMid() {
+void PeerConnection::ResetSctpDataInfo() {
RTC_DCHECK_RUN_ON(signaling_thread());
sctp_mid_s_.reset();
SetSctpTransportName("");
@@ -2511,37 +2513,32 @@
return absl::nullopt;
}
-bool PeerConnection::SetupDataChannelTransport_n(const std::string& mid) {
+absl::optional<std::string> PeerConnection::SetupDataChannelTransport_n(
+ absl::string_view mid) {
+ sctp_mid_n_ = std::string(mid);
DataChannelTransportInterface* transport =
- transport_controller_->GetDataChannelTransport(mid);
+ transport_controller_->GetDataChannelTransport(*sctp_mid_n_);
if (!transport) {
RTC_LOG(LS_ERROR)
<< "Data channel transport is not available for data channels, mid="
<< mid;
- return false;
+ sctp_mid_n_ = absl::nullopt;
+ return absl::nullopt;
}
- RTC_LOG(LS_INFO) << "Setting up data channel transport for mid=" << mid;
- data_channel_controller_.set_data_channel_transport(transport);
- data_channel_controller_.SetupDataChannelTransport_n();
- sctp_mid_n_ = mid;
+ absl::optional<std::string> transport_name;
cricket::DtlsTransportInternal* dtls_transport =
- transport_controller_->GetDtlsTransport(mid);
+ transport_controller_->GetDtlsTransport(*sctp_mid_n_);
if (dtls_transport) {
- signaling_thread()->PostTask(
- SafeTask(signaling_thread_safety_.flag(),
- [this, name = dtls_transport->transport_name()] {
- RTC_DCHECK_RUN_ON(signaling_thread());
- SetSctpTransportName(std::move(name));
- }));
+ transport_name = dtls_transport->transport_name();
+ } else {
+ // Make sure we still set a valid string.
+ transport_name = std::string("");
}
- // Note: setting the data sink and checking initial state must be done last,
- // after setting up the data channel. Setting the data sink may trigger
- // callbacks to PeerConnection which require the transport to be completely
- // set up (eg. OnReadyToSend()).
- transport->SetDataSink(&data_channel_controller_);
- return true;
+ data_channel_controller_.SetupDataChannelTransport_n(transport);
+
+ return transport_name;
}
void PeerConnection::TeardownDataChannelTransport_n(RTCError error) {