integrate readablestream with fetch and blob

This commit is contained in:
Gregory Terzian 2020-02-29 11:59:10 +08:00
parent 0281acea95
commit bd5796c90b
74 changed files with 2219 additions and 899 deletions

View file

@ -7,13 +7,14 @@ use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::trace::JSTraceable;
use crate::dom::globalscope::GlobalScope;
use crate::realms::InRealm;
use crate::script_runtime::JSContext as SafeJSContext;
use dom_struct::dom_struct;
use js::jsapi::JSContext;
use js::rust::HandleValue;
use malloc_size_of::MallocSizeOf;
pub trait Callback: JSTraceable + MallocSizeOf {
fn callback(&self, cx: *mut JSContext, v: HandleValue, realm: InRealm);
fn callback(&self, cx: SafeJSContext, v: HandleValue, realm: InRealm);
}
#[dom_struct]
@ -39,12 +40,14 @@ impl PromiseNativeHandler {
)
}
#[allow(unsafe_code)]
fn callback(
callback: &Option<Box<dyn Callback>>,
cx: *mut JSContext,
v: HandleValue,
realm: InRealm,
) {
let cx = unsafe { SafeJSContext::from_ptr(cx) };
if let Some(ref callback) = *callback {
callback.callback(cx, v, realm)
}