aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/rtcpeerconnection.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/rtcpeerconnection.rs')
-rw-r--r--components/script/dom/rtcpeerconnection.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs
index c92233b59bf..5d84b155216 100644
--- a/components/script/dom/rtcpeerconnection.rs
+++ b/components/script/dom/rtcpeerconnection.rs
@@ -311,17 +311,20 @@ impl RTCPeerConnection {
event.upcast::<Event>().fire(self.upcast());
},
_ => {
- if let Some(ref channel) = self.data_channels.borrow().get(&channel_id) {
- match event {
- DataChannelEvent::Open => channel.on_open(),
- DataChannelEvent::Close => channel.on_close(),
- DataChannelEvent::Error(error) => channel.on_error(error),
- DataChannelEvent::OnMessage(message) => channel.on_message(message),
- DataChannelEvent::StateChange(state) => channel.on_state_change(state),
- DataChannelEvent::NewChannel => unreachable!(),
- }
+ let channel = if let Some(channel) = self.data_channels.borrow().get(&channel_id) {
+ DomRoot::from_ref(&**channel)
} else {
debug_assert!(false, "Got an event for an unregistered data channel");
+ return;
+ };
+
+ match event {
+ DataChannelEvent::Open => channel.on_open(),
+ DataChannelEvent::Close => channel.on_close(),
+ DataChannelEvent::Error(error) => channel.on_error(error),
+ DataChannelEvent::OnMessage(message) => channel.on_message(message),
+ DataChannelEvent::StateChange(state) => channel.on_state_change(state),
+ DataChannelEvent::NewChannel => unreachable!(),
}
},
};