mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
refactor: add CanGc as argument to Promise::reject_error (#35646)
Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
This commit is contained in:
parent
c844ed232a
commit
38b71087bd
43 changed files with 323 additions and 249 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue