Changeset 206814 in webkit


Ignore:
Timestamp:
Oct 5, 2016 9:46:19 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

[Readable Streams API] Align function names with spec
https://bugs.webkit.org/show_bug.cgi?id=162967

Patch by Romain Bellessort <romain.bellessort@crf.canon.fr> on 2016-10-05
Reviewed by Darin Adler.

Align function names with spec. Behaviour was already in line with spec, but previous function names had
sometimes been preserved to track the changes more easily. This led to some inconsistencies (for instance,
enqueueInReadableStream was still used even though it works on a controller instead of a stream) and it
also made it more difficult to compare spec and implementation.

No change in behaviour.

  • Modules/fetch/FetchInternals.js:

(consumeStream): Updated with new function names.

  • Modules/fetch/FetchResponse.js:

(clone): Updated with new function names.

  • Modules/streams/ReadableStream.js:

(tee): Updated with new function names.

  • Modules/streams/ReadableStreamDefaultController.js:

(enqueue): Updated with new function names.
(error): Updated with new function names.

  • Modules/streams/ReadableStreamDefaultReader.js:

(read): Updated with new function names.

  • Modules/streams/ReadableStreamInternals.js:

(privateInitializeReadableStreamDefaultController): Updated with new function names.
(readableStreamDefaultControllerError): Updated with new function names.
(readableStreamTee): Updated with new function names.
(readableStreamTeePullFunction): Updated with new function names.
(readableStreamTeeBranch2CancelFunction): Updated with new function names.
(readableStreamError): Updated with new function names.
(readableStreamCancel): Updated with new function names.
(readableStreamDefaultControllerPull): Updated with new function names.
(readableStreamDefaultControllerClose): Updated with new function names.
(readableStreamClose): Updated with new function names.
(readableStreamDefaultControllerEnqueue): Updated with new function names.
(readableStreamDefaultReaderRead): Updated with new function names.

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r206812 r206814  
     12016-10-05  Romain Bellessort  <romain.bellessort@crf.canon.fr>
     2
     3        [Readable Streams API] Align function names with spec
     4        https://bugs.webkit.org/show_bug.cgi?id=162967
     5
     6        Reviewed by Darin Adler.
     7
     8        Align function names with spec. Behaviour was already in line with spec, but previous function names had
     9        sometimes been preserved to track the changes more easily. This led to some inconsistencies (for instance,
     10        enqueueInReadableStream was still used even though it works on a controller instead of a stream) and it
     11        also made it more difficult to compare spec and implementation.
     12
     13        No change in behaviour.
     14
     15        * Modules/fetch/FetchInternals.js:
     16        (consumeStream): Updated with new function names.
     17        * Modules/fetch/FetchResponse.js:
     18        (clone): Updated with new function names.
     19        * Modules/streams/ReadableStream.js:
     20        (tee): Updated with new function names.
     21        * Modules/streams/ReadableStreamDefaultController.js:
     22        (enqueue): Updated with new function names.
     23        (error): Updated with new function names.
     24        * Modules/streams/ReadableStreamDefaultReader.js:
     25        (read): Updated with new function names.
     26        * Modules/streams/ReadableStreamInternals.js:
     27        (privateInitializeReadableStreamDefaultController): Updated with new function names.
     28        (readableStreamDefaultControllerError): Updated with new function names.
     29        (readableStreamTee): Updated with new function names.
     30        (readableStreamTeePullFunction): Updated with new function names.
     31        (readableStreamTeeBranch2CancelFunction): Updated with new function names.
     32        (readableStreamError): Updated with new function names.
     33        (readableStreamCancel): Updated with new function names.
     34        (readableStreamDefaultControllerPull): Updated with new function names.
     35        (readableStreamDefaultControllerClose): Updated with new function names.
     36        (readableStreamClose): Updated with new function names.
     37        (readableStreamDefaultControllerEnqueue): Updated with new function names.
     38        (readableStreamDefaultReaderRead): Updated with new function names.
     39
    1402016-10-05  Chris Dumez  <cdumez@apple.com>
    241
  • trunk/Source/WebCore/Modules/fetch/FetchInternals.js

    r203772 r206814  
    6969                return @Response.prototype.@finishConsumingStream.@call(response);
    7070            @Response.prototype.@consumeChunk.@call(response, result.value);
    71             return @Promise.prototype.@then.@call(@readFromReadableStreamDefaultReader(reader), pull);
     71            return @Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(reader), pull);
    7272        }
    73         return @Promise.prototype.@then.@call(@readFromReadableStreamDefaultReader(reader), pull);
     73        return @Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(reader), pull);
    7474    } catch(e) {
    7575        return @Promise.@reject(e);
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.js

    r205549 r206814  
    108108
    109109    if (this.@body) {
    110         var teedReadableStreams = @teeReadableStream(this.@body, true);
     110        var teedReadableStreams = @readableStreamTee(this.@body, true);
    111111        this.@body = teedReadableStreams[0];
    112112        cloned.@body = teedReadableStreams[1];
  • trunk/Source/WebCore/Modules/streams/ReadableStream.js

    r206508 r206814  
    207207        throw @makeThisTypeError("ReadableStream", "tee");
    208208
    209     return @teeReadableStream(this, false);
     209    return @readableStreamTee(this, false);
    210210}
    211211
  • trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultController.js

    r205549 r206814  
    3939        throw new @TypeError("ReadableStream is not readable");
    4040
    41     return @enqueueInReadableStream(this, chunk);
     41    return @readableStreamDefaultControllerEnqueue(this, chunk);
    4242}
    4343
     
    5353        throw new @TypeError("ReadableStream is not readable");
    5454
    55     @errorReadableStream(stream, error);
     55    @readableStreamError(stream, error);
    5656}
    5757
  • trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultReader.js

    r206508 r206814  
    4848        return @Promise.@reject(new @TypeError("read() called on a reader owned by no readable stream"));
    4949
    50     return @readFromReadableStreamDefaultReader(this);
     50    return @readableStreamDefaultReaderRead(this);
    5151}
    5252
  • trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js

    r206508 r206814  
    7777    const startResult = @promiseInvokeOrNoopNoCatch(underlyingSource, "start", [this]).@then(() => {
    7878        controller.@started = true;
    79         @requestReadableStreamPull(controller);
     79        @readableStreamDefaultControllerCallPullIfNeeded(controller);
    8080    }, (error) => {
    8181        if (stream.@state === @streamReadable)
     
    9797    @assert(stream.@state === @streamReadable);
    9898    controller.@queue = @newQueue();
    99     @errorReadableStream(stream, error);
    100 }
    101 
    102 function teeReadableStream(stream, shouldClone)
     99    @readableStreamError(stream, error);
     100}
     101
     102function readableStreamTee(stream, shouldClone)
    103103{
    104104    "use strict";
     
    119119    teeState.cancelPromiseCapability = @newPromiseCapability(@InternalPromise);
    120120
    121     const pullFunction = @teeReadableStreamPullFunction(teeState, reader, shouldClone);
     121    const pullFunction = @readableStreamTeePullFunction(teeState, reader, shouldClone);
    122122
    123123    const branch1 = new @ReadableStream({
    124124        "pull": pullFunction,
    125         "cancel": @teeReadableStreamBranch1CancelFunction(teeState, stream)
     125        "cancel": @readableStreamTeeBranch1CancelFunction(teeState, stream)
    126126    });
    127127    const branch2 = new @ReadableStream({
    128128        "pull": pullFunction,
    129         "cancel": @teeReadableStreamBranch2CancelFunction(teeState, stream)
     129        "cancel": @readableStreamTeeBranch2CancelFunction(teeState, stream)
    130130    });
    131131
     
    161161}
    162162
    163 function teeReadableStreamPullFunction(teeState, reader, shouldClone)
     163function readableStreamTeePullFunction(teeState, reader, shouldClone)
    164164{
    165165    "use strict";
    166166
    167167    return function() {
    168         @Promise.prototype.@then.@call(@readFromReadableStreamDefaultReader(reader), function(result) {
     168        @Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(reader), function(result) {
    169169            @assert(@isObject(result));
    170170            @assert(typeof result.done === "boolean");
     
    179179                return;
    180180            if (!teeState.canceled1)
    181                 @enqueueInReadableStream(teeState.branch1.@readableStreamController, shouldClone ? @doStructuredClone(result.value) : result.value);
     181                @readableStreamDefaultControllerEnqueue(teeState.branch1.@readableStreamController, shouldClone ? @doStructuredClone(result.value) : result.value);
    182182            if (!teeState.canceled2)
    183                 @enqueueInReadableStream(teeState.branch2.@readableStreamController, shouldClone ? @doStructuredClone(result.value) : result.value);
     183                @readableStreamDefaultControllerEnqueue(teeState.branch2.@readableStreamController, shouldClone ? @doStructuredClone(result.value) : result.value);
    184184        });
    185185    }
    186186}
    187187
    188 function teeReadableStreamBranch1CancelFunction(teeState, stream)
     188function readableStreamTeeBranch1CancelFunction(teeState, stream)
    189189{
    190190    "use strict";
     
    202202}
    203203
    204 function teeReadableStreamBranch2CancelFunction(teeState, stream)
     204function readableStreamTeeBranch2CancelFunction(teeState, stream)
    205205{
    206206    "use strict";
     
    249249}
    250250
    251 function errorReadableStream(stream, error)
     251function readableStreamError(stream, error)
    252252{
    253253    "use strict";
     
    275275}
    276276
    277 function requestReadableStreamPull(controller)
     277function readableStreamDefaultControllerCallPullIfNeeded(controller)
    278278{
    279279    "use strict";
     
    301301        if (controller.@pullAgain) {
    302302            controller.@pullAgain = false;
    303             @requestReadableStreamPull(controller);
     303            @readableStreamDefaultControllerCallPullIfNeeded(controller);
    304304        }
    305305    }, function(error) {
     
    333333    if (stream.@state === @streamErrored)
    334334        return @Promise.@reject(stream.@storedError);
    335     @closeReadableStream(stream);
     335    @readableStreamClose(stream);
    336336    return stream.@readableStreamController.@cancel(stream.@readableStreamController, reason).@then(function() {  });
    337337}
     
    353353        const chunk = @dequeueValue(controller.@queue);
    354354        if (controller.@closeRequested && controller.@queue.content.length === 0)
    355             @closeReadableStream(stream);
     355            @readableStreamClose(stream);
    356356        else
    357             @requestReadableStreamPull(controller);
     357            @readableStreamDefaultControllerCallPullIfNeeded(controller);
    358358        return @Promise.@resolve({value: chunk, done: false});
    359359    }
    360360    const pendingPromise = @readableStreamAddReadRequest(stream);
    361     @requestReadableStreamPull(controller);
     361    @readableStreamDefaultControllerCallPullIfNeeded(controller);
    362362    return pendingPromise;
    363363}
     
    372372    controller.@closeRequested = true;
    373373    if (controller.@queue.content.length === 0)
    374         @closeReadableStream(stream);
    375 }
    376 
    377 function closeReadableStream(stream)
     374        @readableStreamClose(stream);
     375}
     376
     377function readableStreamClose(stream)
    378378{
    379379    "use strict";
     
    396396}
    397397
    398 function enqueueInReadableStream(controller, chunk)
     398function readableStreamDefaultControllerEnqueue(controller, chunk)
    399399{
    400400    "use strict";
     
    406406    if (@isReadableStreamLocked(stream) && stream.@reader.@readRequests.length) {
    407407        stream.@reader.@readRequests.@shift().@resolve.@call(@undefined, {value: chunk, done: false});
    408         @requestReadableStreamPull(controller);
     408        @readableStreamDefaultControllerCallPullIfNeeded(controller);
    409409        return;
    410410    }
     
    421421        throw error;
    422422    }
    423     @requestReadableStreamPull(controller);
    424 }
    425 
    426 function readFromReadableStreamDefaultReader(reader)
     423    @readableStreamDefaultControllerCallPullIfNeeded(controller);
     424}
     425
     426function readableStreamDefaultReaderRead(reader)
    427427{
    428428    "use strict";
Note: See TracChangeset for help on using the changeset viewer.