mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Use task! to resolve promises
This commit is contained in:
parent
851d40b204
commit
a7655a3f84
1 changed files with 8 additions and 12 deletions
|
@ -139,18 +139,14 @@ impl TrustedPromise {
|
||||||
where
|
where
|
||||||
T: ToJSValConvertible + Send,
|
T: ToJSValConvertible + Send,
|
||||||
{
|
{
|
||||||
struct ResolvePromise<T>(TrustedPromise, T);
|
let this = self;
|
||||||
impl<T: ToJSValConvertible> Task for ResolvePromise<T> {
|
task!(resolve_promise: move || {
|
||||||
fn run(self: Box<Self>) {
|
|
||||||
debug!("Resolving promise.");
|
debug!("Resolving promise.");
|
||||||
let this = *self;
|
let this = this.root();
|
||||||
let promise = this.0.root();
|
let cx = this.global().get_cx();
|
||||||
let cx = promise.global().get_cx();
|
let _ac = JSAutoCompartment::new(cx, this.reflector().get_jsobject().get());
|
||||||
let _ac = JSAutoCompartment::new(cx, promise.reflector().get_jsobject().get());
|
this.resolve_native(cx, &value);
|
||||||
promise.resolve_native(cx, &this.1);
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
ResolvePromise(self, value)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue