diff options
author | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2020-06-22 16:25:39 +0200 |
---|---|---|
committer | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2020-06-29 16:53:50 +0200 |
commit | 7eb44f81f21551ee4c81d1cf62976fed2979c9a3 (patch) | |
tree | 70d33d152ca20267b9afff63e38dba0d5f42a90b /components/script/dom/rtcdatachannel.rs | |
parent | b968852456abba89cc1ec55fc467858f91c9b319 (diff) | |
download | servo-7eb44f81f21551ee4c81d1cf62976fed2979c9a3.tar.gz servo-7eb44f81f21551ee4c81d1cf62976fed2979c9a3.zip |
Fix data channels borrowing errors
Diffstat (limited to 'components/script/dom/rtcdatachannel.rs')
-rw-r--r-- | components/script/dom/rtcdatachannel.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/components/script/dom/rtcdatachannel.rs b/components/script/dom/rtcdatachannel.rs index c0a3db51cc4..7cf42b0f5fc 100644 --- a/components/script/dom/rtcdatachannel.rs +++ b/components/script/dom/rtcdatachannel.rs @@ -30,6 +30,7 @@ use script_traits::serializable::BlobImpl; use servo_media::webrtc::{ DataChannelId, DataChannelInit, DataChannelMessage, DataChannelState, WebRtcError, }; +use std::cell::Cell; use std::ptr; #[dom_struct] @@ -45,7 +46,7 @@ pub struct RTCDataChannel { protocol: USVString, negotiated: bool, id: Option<u16>, - ready_state: DomRefCell<RTCDataChannelState>, + ready_state: Cell<RTCDataChannelState>, binary_type: DomRefCell<DOMString>, } @@ -80,7 +81,7 @@ impl RTCDataChannel { protocol: options.protocol.clone(), negotiated: options.negotiated, id: options.id, - ready_state: DomRefCell::new(RTCDataChannelState::Connecting), + ready_state: Cell::new(RTCDataChannelState::Connecting), binary_type: DomRefCell::new(DOMString::from("blob")), }; @@ -209,11 +210,11 @@ impl RTCDataChannel { }, _ => {}, }; - *self.ready_state.borrow_mut() = state.into(); + self.ready_state.set(state.into()); } fn send(&self, source: &SendSource) -> Fallible<()> { - if *self.ready_state.borrow() != RTCDataChannelState::Open { + if self.ready_state.get() != RTCDataChannelState::Open { return Err(Error::InvalidState); } @@ -304,7 +305,7 @@ impl RTCDataChannelMethods for RTCDataChannel { // https://www.w3.org/TR/webrtc/#dom-datachannel-readystate fn ReadyState(&self) -> RTCDataChannelState { - *self.ready_state.borrow() + self.ready_state.get() } // XXX We need a way to know when the underlying data transport |