aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bluetooth/bluetooth.rs
diff options
context:
space:
mode:
authorYerkebulan Tulibergenov <yerkebulan@gmail.com>2025-02-25 02:12:58 -0800
committerGitHub <noreply@github.com>2025-02-25 10:12:58 +0000
commit38b71087bd710dd0a96140affbb5bb38c23d8689 (patch)
tree62f64087a4ef2e508b8ce0679391799ac91a34d1 /components/script/dom/bluetooth/bluetooth.rs
parentc844ed232a86fef873dc661de60e282fdb86c0d3 (diff)
downloadservo-38b71087bd710dd0a96140affbb5bb38c23d8689.tar.gz
servo-38b71087bd710dd0a96140affbb5bb38c23d8689.zip
refactor: add CanGc as argument to Promise::reject_error (#35646)
Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
Diffstat (limited to 'components/script/dom/bluetooth/bluetooth.rs')
-rw-r--r--components/script/dom/bluetooth/bluetooth.rs36
1 files changed, 22 insertions, 14 deletions
diff --git a/components/script/dom/bluetooth/bluetooth.rs b/components/script/dom/bluetooth/bluetooth.rs
index e1401b9d04e..c2732f2e9fb 100644
--- a/components/script/dom/bluetooth/bluetooth.rs
+++ b/components/script/dom/bluetooth/bluetooth.rs
@@ -131,7 +131,7 @@ where
.handle_response(response, &promise, can_gc),
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice
// Step 3 - 4.
- Err(error) => promise.reject_error(error.convert()),
+ Err(error) => promise.reject_error(error.convert(), can_gc),
}
}
}
@@ -170,6 +170,7 @@ impl Bluetooth {
filters: &Option<Vec<BluetoothLEScanFilterInit>>,
optional_services: &[BluetoothServiceUUID],
sender: IpcSender<BluetoothResponseResult>,
+ can_gc: CanGc,
) {
// TODO: Step 1: Triggered by user activation.
@@ -179,7 +180,7 @@ impl Bluetooth {
if let Some(filters) = filters {
// Step 2.1.
if filters.is_empty() {
- p.reject_error(Type(FILTER_EMPTY_ERROR.to_owned()));
+ p.reject_error(Type(FILTER_EMPTY_ERROR.to_owned()), can_gc);
return;
}
@@ -192,7 +193,7 @@ impl Bluetooth {
// Step 2.4.2.
Ok(f) => uuid_filters.push(f),
Err(e) => {
- p.reject_error(e);
+ p.reject_error(e, can_gc);
return;
},
}
@@ -206,7 +207,7 @@ impl Bluetooth {
let uuid = match BluetoothUUID::service(opt_service.clone()) {
Ok(u) => u.to_string(),
Err(e) => {
- p.reject_error(e);
+ p.reject_error(e, can_gc);
return;
},
};
@@ -229,7 +230,7 @@ impl Bluetooth {
if let PermissionState::Denied =
descriptor_permission_state(PermissionName::Bluetooth, None)
{
- return p.reject_error(Error::NotFound);
+ return p.reject_error(Error::NotFound, can_gc);
}
// Note: Step 3, 6 - 8 are implemented in
@@ -307,13 +308,13 @@ where
let canonicalized = match uuid_canonicalizer(u) {
Ok(canonicalized_uuid) => canonicalized_uuid.to_string(),
Err(e) => {
- p.reject_error(e);
+ p.reject_error(e, can_gc);
return p;
},
};
// Step 2.
if uuid_is_blocklisted(canonicalized.as_ref(), Blocklist::All) {
- p.reject_error(Security);
+ p.reject_error(Security, can_gc);
return p;
}
Some(canonicalized)
@@ -323,7 +324,7 @@ where
// Step 3 - 4.
if !connected {
- p.reject_error(Network);
+ p.reject_error(Network, can_gc);
return p;
}
@@ -550,13 +551,19 @@ impl BluetoothMethods<crate::DomTypeHolder> for Bluetooth {
if (option.filters.is_some() && option.acceptAllDevices) ||
(option.filters.is_none() && !option.acceptAllDevices)
{
- p.reject_error(Error::Type(OPTIONS_ERROR.to_owned()));
+ p.reject_error(Error::Type(OPTIONS_ERROR.to_owned()), can_gc);
return p;
}
// Step 2.
let sender = response_async(&p, self);
- self.request_bluetooth_devices(&p, &option.filters, &option.optionalServices, sender);
+ self.request_bluetooth_devices(
+ &p,
+ &option.filters,
+ &option.optionalServices,
+ sender,
+ can_gc,
+ );
//Note: Step 3 - 4. in response function, Step 5. in handle_response function.
p
}
@@ -616,7 +623,7 @@ impl AsyncBluetoothListener for Bluetooth {
BluetoothResponse::GetAvailability(is_available) => {
promise.resolve_native(&is_available, can_gc);
},
- _ => promise.reject_error(Error::Type("Something went wrong...".to_owned())),
+ _ => promise.reject_error(Error::Type("Something went wrong...".to_owned()), can_gc),
}
}
}
@@ -689,7 +696,7 @@ impl PermissionAlgorithm for Bluetooth {
for filter in filters {
match canonicalize_filter(filter) {
Ok(f) => scan_filters.push(f),
- Err(error) => return promise.reject_error(error),
+ Err(error) => return promise.reject_error(error, CanGc::note()),
}
}
@@ -710,7 +717,7 @@ impl PermissionAlgorithm for Bluetooth {
match receiver.recv().unwrap() {
Ok(true) => (),
Ok(false) => continue,
- Err(error) => return promise.reject_error(error.convert()),
+ Err(error) => return promise.reject_error(error.convert(), CanGc::note()),
};
}
@@ -739,7 +746,7 @@ impl PermissionAlgorithm for Bluetooth {
) {
// Step 1.
if descriptor.filters.is_some() == descriptor.acceptAllDevices {
- return promise.reject_error(Error::Type(OPTIONS_ERROR.to_owned()));
+ return promise.reject_error(Error::Type(OPTIONS_ERROR.to_owned()), CanGc::note());
}
// Step 2.
@@ -750,6 +757,7 @@ impl PermissionAlgorithm for Bluetooth {
&descriptor.filters,
&descriptor.optionalServices,
sender,
+ CanGc::note(),
);
// NOTE: Step 3. is in BluetoothPermissionResult's `handle_response` function.