mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Use normal tasks to reject and resolve promises
This commit is contained in:
parent
9a267e53fe
commit
95dc54d216
1 changed files with 5 additions and 5 deletions
|
@ -32,7 +32,7 @@ use dom::promise::Promise;
|
|||
use js::jsapi::JSAutoCompartment;
|
||||
use js::jsapi::JSTracer;
|
||||
use libc;
|
||||
use script_thread::{ScriptThread, Task};
|
||||
use script_thread::Task;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::hash_map::Entry::{Occupied, Vacant};
|
||||
use std::collections::hash_map::HashMap;
|
||||
|
@ -125,11 +125,11 @@ impl TrustedPromise {
|
|||
pub fn reject_task(self, error: Error) -> impl Send + Task {
|
||||
struct RejectPromise(TrustedPromise, Error);
|
||||
impl Task for RejectPromise {
|
||||
fn run_with_script_thread(self: Box<Self>, script_thread: &ScriptThread) {
|
||||
fn run(self: Box<Self>) {
|
||||
debug!("Rejecting promise.");
|
||||
let this = *self;
|
||||
let cx = script_thread.get_cx();
|
||||
let promise = this.0.root();
|
||||
let cx = promise.global().get_cx();
|
||||
let _ac = JSAutoCompartment::new(cx, promise.reflector().get_jsobject().get());
|
||||
promise.reject_error(cx, this.1);
|
||||
}
|
||||
|
@ -145,11 +145,11 @@ impl TrustedPromise {
|
|||
{
|
||||
struct ResolvePromise<T>(TrustedPromise, T);
|
||||
impl<T: ToJSValConvertible> Task for ResolvePromise<T> {
|
||||
fn run_with_script_thread(self: Box<Self>, script_thread: &ScriptThread) {
|
||||
fn run(self: Box<Self>) {
|
||||
debug!("Resolving promise.");
|
||||
let this = *self;
|
||||
let cx = script_thread.get_cx();
|
||||
let promise = this.0.root();
|
||||
let cx = promise.global().get_cx();
|
||||
let _ac = JSAutoCompartment::new(cx, promise.reflector().get_jsobject().get());
|
||||
promise.resolve_native(cx, &this.1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue