auto merge of #2442 : Manishearth/servo/xhr-async, r=jdm

(Note that only `getAllResponseHeaders()` is supported at the moment, I'll be adding the other header methods later.)
This commit is contained in:
bors-servo 2014-05-20 12:16:35 -04:00
commit 28e3c17340
8 changed files with 253 additions and 51 deletions

View file

@ -41,6 +41,7 @@
use dom::bindings::utils::{Reflector, Reflectable, cx_for_dom_object};
use dom::node::Node;
use dom::xmlhttprequest::{XMLHttpRequest, TrustedXHRAddress};
use js::jsapi::{JSObject, JS_AddObjectRoot, JS_RemoveObjectRoot};
use layout_interface::TrustedNodeAddress;
use script_task::StackRoots;
@ -141,6 +142,15 @@ impl JS<Node> {
}
}
impl JS<XMLHttpRequest> {
pub unsafe fn from_trusted_xhr_address(inner: TrustedXHRAddress) -> JS<XMLHttpRequest> {
let TrustedXHRAddress(addr) = inner;
JS {
ptr: RefCell::new(addr as *mut XMLHttpRequest)
}
}
}
impl<T: Reflectable> JS<T> {
/// Create a new JS-owned value wrapped from a raw Rust pointer.
pub unsafe fn from_raw(raw: *mut T) -> JS<T> {