diff --git a/index.bs b/index.bs index d7b270d4d..a5f7848bd 100644 --- a/index.bs +++ b/index.bs @@ -954,7 +954,7 @@ called with argument reason, it performs the following steps: methods for these functions, with the state stored as instance variables. -

Readable Stream Abstract Operations Used by Controllers

+

The Interface Between Readable Streams and Controllers

In terms of specification factoring, the way that the {{ReadableStream}} class encapsulates the behavior of both simple readable streams and readable byte streams into a single class is by centralizing most of the @@ -963,9 +963,24 @@ potentially-varying logic inside the two controller classes, {{ReadableStreamDef operations for how a stream's internal queue is managed and how it interfaces with its underlying source or underlying byte source. -The abstract operations in this section are interfaces that are used by the controller implementations to affect their -associated {{ReadableStream}} object, translating those internal state changes into developer-facing results -visible through the {{ReadableStream}}'s public API. +Each controller class defines two internal methods, which are called by the {{ReadableStream}} algorithms: + +
+
\[[CancelSteps]](reason)
+
The controller's steps that run in reaction to the stream being canceled, + used to clean up the state stored in the controller and inform the underlying source.
+ +
\[[PullSteps]]()
+
The controller's steps that run when a default reader is read from, used to pull from the controller any + queued chunks, or pull from the underlying source to get more chunks.
+
+ +(These are defined as internal methods, instead of as abstract operations, so that they can be called polymorphically by +the {{ReadableStream}} algorithms, without having to branch on which type of controller is present.) + +The rest of this section concerns abstract operations that go in the other direction: they are used by the controller +implementations to affect their associated {{ReadableStream}} object. This translates internal state changes of the +controller into developer-facing results visible through the {{ReadableStream}}'s public API.

ReadableStreamAddReadIntoRequest ( stream )

@@ -999,7 +1014,7 @@ nothrow>ReadableStreamAddReadIntoRequest ( stream ) 1. If _stream_.[[state]] is `"closed"`, return a promise resolved with *undefined*. 1. If _stream_.[[state]] is `"errored"`, return a promise rejected with _stream_.[[storedError]]. 1. Perform ! ReadableStreamClose(_stream_). - 1. Let _sourceCancelPromise_ be ! _stream_.[[readableStreamController]].[[CancelSteps]](_reason_). + 1. Let _sourceCancelPromise_ be ! _stream_.[[readableStreamController]].[[CancelSteps]](_reason_). 1. Return the result of transforming _sourceCancelPromise_ with a fulfillment handler that returns *undefined*. @@ -1472,7 +1487,7 @@ export>ReadableStreamDefaultReaderRead ( reader ) *true*). 1. If _stream_.[[state]] is `"errored"`, return a promise rejected with _stream_.[[storedError]]. 1. Assert: _stream_.[[state]] is `"readable"`. - 1. Return ! _stream_.[[readableStreamController]].[[PullSteps]](). + 1. Return ! _stream_.[[readableStreamController]].[[PullSteps]]().

Class @@ -1657,14 +1672,14 @@ desiredSize

The following are additional internal methods implemented by each {{ReadableStreamDefaultController}} instance. The readable stream implementation will polymorphically call to either these or their counterparts for BYOB controllers. -
\[[CancelSteps]](reason)
+
\[[CancelSteps]](reason)
1. Perform ! ResetQueue(*this*). 1. Return ! PromiseInvokeOrNoop(*this*.[[underlyingSource]], `"cancel"`, « _reason_ ») -
\[[PullSteps]]()
+
\[[PullSteps]]()
1. Let _stream_ be *this*.[[controlledReadableStream]]. @@ -2055,7 +2070,7 @@ ReadableByteStreamController(stream, underlyingByteSource, The following are additional internal methods implemented by each {{ReadableByteStreamController}} instance. The readable stream implementation will polymorphically call to either these or their counterparts for default controllers. -
\[[CancelSteps]](reason)
+
\[[CancelSteps]](reason)
1. If *this*.[[pendingPullIntos]] is not empty, @@ -2065,7 +2080,7 @@ readable stream implementation will polymorphically call to either these or thei 1. Return ! PromiseInvokeOrNoop(*this*.[[underlyingByteSource]], `"cancel"`, « _reason_ ») -
\[[PullSteps]]()
+
\[[PullSteps]]()
1. Let _stream_ be *this*.[[controlledReadableStream]].