mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Use task! to reject promises
This commit is contained in:
parent
ad41ce7a6f
commit
851d40b204
1 changed files with 8 additions and 12 deletions
|
@ -123,18 +123,14 @@ impl TrustedPromise {
|
||||||
/// A task which will reject the promise.
|
/// A task which will reject the promise.
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
pub fn reject_task(self, error: Error) -> impl Send + Task {
|
pub fn reject_task(self, error: Error) -> impl Send + Task {
|
||||||
struct RejectPromise(TrustedPromise, Error);
|
let this = self;
|
||||||
impl Task for RejectPromise {
|
task!(reject_promise: move || {
|
||||||
fn run(self: Box<Self>) {
|
debug!("Rejecting promise.");
|
||||||
debug!("Rejecting promise.");
|
let this = this.root();
|
||||||
let this = *self;
|
let cx = this.global().get_cx();
|
||||||
let promise = this.0.root();
|
let _ac = JSAutoCompartment::new(cx, this.reflector().get_jsobject().get());
|
||||||
let cx = promise.global().get_cx();
|
this.reject_error(cx, error);
|
||||||
let _ac = JSAutoCompartment::new(cx, promise.reflector().get_jsobject().get());
|
})
|
||||||
promise.reject_error(cx, this.1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RejectPromise(self, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A task which will resolve the promise.
|
/// A task which will resolve the promise.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue