Support an equivalent of Trusted<T> for Rc<Promise> objects named TrustedPromise.

This commit is contained in:
Josh Matthews 2016-09-10 16:50:52 -04:00
parent 27d44c8d10
commit 498ccd41e8
7 changed files with 145 additions and 10 deletions

View file

@ -79,6 +79,14 @@ impl Promise {
}
}
#[allow(unsafe_code, unrooted_must_root)]
pub fn duplicate(&self) -> Rc<Promise> {
let cx = self.global().r().get_cx();
unsafe {
Promise::new_with_js_promise(self.reflector().get_jsobject(), cx)
}
}
#[allow(unsafe_code, unrooted_must_root)]
unsafe fn new_with_js_promise(obj: HandleObject, cx: *mut JSContext) -> Rc<Promise> {
assert!(IsPromiseObject(obj));