Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Impl ReadableStream support #25827

Closed
wants to merge 9 commits into from

cleanup

  • Loading branch information
gterzian committed Feb 23, 2020
commit 14835482f424777eeaceb1531022c2794fcb713f
@@ -34,7 +34,7 @@ pub struct ReadableStream {
}

impl ReadableStream {
/// <https://streams.spec.whatwg.org/#rs-class>
/// <https://streams.spec.whatwg.org/#rs-constructor>
#[allow(non_snake_case)]
pub fn Constructor(
cx: SafeJSContext,
@@ -67,19 +67,23 @@ impl ReadableStream {
}

impl ReadableStreamMethods for ReadableStream {
/// <https://streams.spec.whatwg.org/#rs-cancel>
fn Cancel(&self, reason: DOMString) -> Fallible<Rc<Promise>> {
let cx = self.global().get_cx();
cancel_readablestream(cx, &self.stream, reason)
}

/// <https://streams.spec.whatwg.org/#rs-get-reader>
fn GetReader(&self, cx: SafeJSContext) -> Fallible<NonNull<JSObject>> {
get_stream_reader(cx, &self.stream)
}

/// <https://streams.spec.whatwg.org/#rs-locked>
fn Locked(&self) -> bool {
stream_is_locked(self.global().get_cx(), &self.stream)
}

/// <https://streams.spec.whatwg.org/#rs-tee>
fn Tee(&self, cx: SafeJSContext) -> Fallible<JSVal> {
tee_stream(cx, &self.stream)
}
@@ -206,7 +210,8 @@ fn cancel_readablestream(
rooted!(in(*cx) let mut reason_val = UndefinedValue());
(*reason).to_jsval(*cx, reason_val.handle_mut());

rooted!(in(*cx) let raw_cancel_promise = ReadableStreamCancel(*cx, stream.handle(), reason_val.handle().into_handle()));
rooted!(in(*cx) let raw_cancel_promise =
ReadableStreamCancel(*cx, stream.handle(), reason_val.handle().into_handle()));

let cancel_promise = Promise::new_with_js_promise(raw_cancel_promise.handle(), cx);

@@ -1,10 +1,8 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* The origin of this IDL file is: https://streams.spec.whatwg.org/#rs-class
*/

// https://streams.spec.whatwg.org/#rs-class
[Exposed=(Window,Worker)]
interface ReadableStream {
constructor(object underlyingSource, Function size, HighWatermark highWaterMark, object proto);
@@ -103,6 +103,7 @@ def wpt_path(*args):
b"//immersive-web.github.io/",
b"//github.com/immersive-web/webxr-test-api/",
b"//gpuweb.github.io",
b"//streams.spec.whatwg.org",
# Not a URL
b"// This interface is entirely internal to Servo, and should not be" +
b" accessible to\n// web pages."
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.