aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bluetoothremotegattdescriptor.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-09-21 18:22:20 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2017-09-22 02:15:22 +0200
commitaf2e83f37882994918fe6e9a66e23638da20c30f (patch)
treee8009f9b30dbe957bc8cd2ad22d4e776554a6d36 /components/script/dom/bluetoothremotegattdescriptor.rs
parent15acd1525ed2b2c3ec2bef7d8a9652dc63b795ab (diff)
downloadservo-af2e83f37882994918fe6e9a66e23638da20c30f.tar.gz
servo-af2e83f37882994918fe6e9a66e23638da20c30f.zip
Make Promise::reject_error sound
Diffstat (limited to 'components/script/dom/bluetoothremotegattdescriptor.rs')
-rw-r--r--components/script/dom/bluetoothremotegattdescriptor.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs
index 941683cbe95..1ab100fb522 100644
--- a/components/script/dom/bluetoothremotegattdescriptor.rs
+++ b/components/script/dom/bluetoothremotegattdescriptor.rs
@@ -89,17 +89,16 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
fn ReadValue(&self) -> Rc<Promise> {
let p = Promise::new(&self.global());
- let p_cx = p.global().get_cx();
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Reads) {
- p.reject_error(p_cx, Security);
+ p.reject_error(Security);
return p;
}
// Step 2.
if !self.Characteristic().Service().Device().get_gatt().Connected() {
- p.reject_error(p_cx, Network);
+ p.reject_error(Network);
return p;
}
@@ -116,23 +115,22 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-writevalue
fn WriteValue(&self, value: Vec<u8>) -> Rc<Promise> {
let p = Promise::new(&self.global());
- let p_cx = p.global().get_cx();
// Step 1.
if uuid_is_blocklisted(self.uuid.as_ref(), Blocklist::Writes) {
- p.reject_error(p_cx, Security);
+ p.reject_error(Security);
return p;
}
// Step 2 - 3.
if value.len() > MAXIMUM_ATTRIBUTE_LENGTH {
- p.reject_error(p_cx, InvalidModification);
+ p.reject_error(InvalidModification);
return p;
}
// Step 4.
if !self.Characteristic().Service().Device().get_gatt().Connected() {
- p.reject_error(p_cx, Network);
+ p.reject_error(Network);
return p;
}
@@ -147,7 +145,11 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor {
}
impl AsyncBluetoothListener for BluetoothRemoteGATTDescriptor {
- fn handle_response(&self, response: BluetoothResponse, promise_cx: *mut JSContext, promise: &Rc<Promise>) {
+ fn handle_response(
+ &self, response: BluetoothResponse,
+ _promise_cx: *mut JSContext,
+ promise: &Rc<Promise>,
+ ) {
match response {
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattdescriptor-readvalue
BluetoothResponse::ReadValue(result) => {
@@ -173,7 +175,7 @@ impl AsyncBluetoothListener for BluetoothRemoteGATTDescriptor {
// TODO: Resolve promise with undefined instead of a value.
promise.resolve_native(&());
},
- _ => promise.reject_error(promise_cx, Error::Type("Something went wrong...".to_owned())),
+ _ => promise.reject_error(Error::Type("Something went wrong...".to_owned())),
}
}
}