diff options
Diffstat (limited to 'components/script/dom/bluetoothremotegattcharacteristic.rs')
-rw-r--r-- | components/script/dom/bluetoothremotegattcharacteristic.rs | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index 6b7ba1dcfad..95b26ff66c1 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -14,7 +14,6 @@ use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::Bluetoot use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServiceBinding::BluetoothRemoteGATTServiceMethods; use dom::bindings::error::{ErrorResult, Fallible}; use dom::bindings::error::Error::{self, InvalidModification, Network, NotSupported, Security}; -use dom::bindings::global::GlobalRef; use dom::bindings::js::{JS, MutHeap, Root}; use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object}; use dom::bindings::str::{ByteString, DOMString}; @@ -23,6 +22,7 @@ use dom::bluetoothcharacteristicproperties::BluetoothCharacteristicProperties; use dom::bluetoothremotegattdescriptor::BluetoothRemoteGATTDescriptor; use dom::bluetoothremotegattservice::BluetoothRemoteGATTService; use dom::bluetoothuuid::{BluetoothDescriptorUUID, BluetoothUUID}; +use dom::globalscope::GlobalScope; use dom::promise::Promise; use ipc_channel::ipc::{self, IpcSender}; use net_traits::bluetooth_thread::BluetoothMethodMsg; @@ -59,7 +59,7 @@ impl BluetoothRemoteGATTCharacteristic { } } - pub fn new(global: GlobalRef, + pub fn new(global: &GlobalScope, service: &BluetoothRemoteGATTService, uuid: DOMString, properties: &BluetoothCharacteristicProperties, @@ -74,9 +74,7 @@ impl BluetoothRemoteGATTCharacteristic { } fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> { - let global_root = self.global(); - let global_ref = global_root.r(); - global_ref.as_window().bluetooth_thread() + self.global().as_window().bluetooth_thread() } fn get_instance_id(&self) -> String { @@ -95,7 +93,7 @@ impl BluetoothRemoteGATTCharacteristic { let descriptor = receiver.recv().unwrap(); match descriptor { Ok(descriptor) => { - Ok(BluetoothRemoteGATTDescriptor::new(self.global().r(), + Ok(BluetoothRemoteGATTDescriptor::new(&self.global(), self, DOMString::from(descriptor.uuid), descriptor.instance_id)) @@ -126,7 +124,7 @@ impl BluetoothRemoteGATTCharacteristic { match descriptors_vec { Ok(descriptor_vec) => { Ok(descriptor_vec.into_iter() - .map(|desc| BluetoothRemoteGATTDescriptor::new(self.global().r(), + .map(|desc| BluetoothRemoteGATTDescriptor::new(&self.global(), self, DOMString::from(desc.uuid), desc.instance_id)) @@ -214,7 +212,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris #[allow(unrooted_must_root)] // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-getdescriptor fn GetDescriptor(&self, descriptor: BluetoothDescriptorUUID) -> Rc<Promise> { - result_to_promise(self.global().r(), self.get_descriptor(descriptor)) + result_to_promise(&self.global(), self.get_descriptor(descriptor)) } #[allow(unrooted_must_root)] @@ -222,7 +220,7 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris fn GetDescriptors(&self, descriptor: Option<BluetoothDescriptorUUID>) -> Rc<Promise> { - result_to_promise(self.global().r(), self.get_descriptors(descriptor)) + result_to_promise(&self.global(), self.get_descriptors(descriptor)) } // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-value @@ -233,12 +231,12 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris #[allow(unrooted_must_root)] // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-readvalue fn ReadValue(&self) -> Rc<Promise> { - result_to_promise(self.global().r(), self.read_value()) + result_to_promise(&self.global(), self.read_value()) } #[allow(unrooted_must_root)] // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattcharacteristic-writevalue fn WriteValue(&self, value: Vec<u8>) -> Rc<Promise> { - result_to_promise(self.global().r(), self.write_value(value)) + result_to_promise(&self.global(), self.write_value(value)) } } |