Changeset 206814 in webkit
- Timestamp:
- Oct 5, 2016 9:46:19 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r206812 r206814 1 2016-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 1 40 2016-10-05 Chris Dumez <cdumez@apple.com> 2 41 -
trunk/Source/WebCore/Modules/fetch/FetchInternals.js
r203772 r206814 69 69 return @Response.prototype.@finishConsumingStream.@call(response); 70 70 @Response.prototype.@consumeChunk.@call(response, result.value); 71 return @Promise.prototype.@then.@call(@read FromReadableStreamDefaultReader(reader), pull);71 return @Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(reader), pull); 72 72 } 73 return @Promise.prototype.@then.@call(@read FromReadableStreamDefaultReader(reader), pull);73 return @Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(reader), pull); 74 74 } catch(e) { 75 75 return @Promise.@reject(e); -
trunk/Source/WebCore/Modules/fetch/FetchResponse.js
r205549 r206814 108 108 109 109 if (this.@body) { 110 var teedReadableStreams = @ teeReadableStream(this.@body, true);110 var teedReadableStreams = @readableStreamTee(this.@body, true); 111 111 this.@body = teedReadableStreams[0]; 112 112 cloned.@body = teedReadableStreams[1]; -
trunk/Source/WebCore/Modules/streams/ReadableStream.js
r206508 r206814 207 207 throw @makeThisTypeError("ReadableStream", "tee"); 208 208 209 return @ teeReadableStream(this, false);209 return @readableStreamTee(this, false); 210 210 } 211 211 -
trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultController.js
r205549 r206814 39 39 throw new @TypeError("ReadableStream is not readable"); 40 40 41 return @ enqueueInReadableStream(this, chunk);41 return @readableStreamDefaultControllerEnqueue(this, chunk); 42 42 } 43 43 … … 53 53 throw new @TypeError("ReadableStream is not readable"); 54 54 55 @ errorReadableStream(stream, error);55 @readableStreamError(stream, error); 56 56 } 57 57 -
trunk/Source/WebCore/Modules/streams/ReadableStreamDefaultReader.js
r206508 r206814 48 48 return @Promise.@reject(new @TypeError("read() called on a reader owned by no readable stream")); 49 49 50 return @read FromReadableStreamDefaultReader(this);50 return @readableStreamDefaultReaderRead(this); 51 51 } 52 52 -
trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js
r206508 r206814 77 77 const startResult = @promiseInvokeOrNoopNoCatch(underlyingSource, "start", [this]).@then(() => { 78 78 controller.@started = true; 79 @re questReadableStreamPull(controller);79 @readableStreamDefaultControllerCallPullIfNeeded(controller); 80 80 }, (error) => { 81 81 if (stream.@state === @streamReadable) … … 97 97 @assert(stream.@state === @streamReadable); 98 98 controller.@queue = @newQueue(); 99 @ errorReadableStream(stream, error);100 } 101 102 function teeReadableStream(stream, shouldClone)99 @readableStreamError(stream, error); 100 } 101 102 function readableStreamTee(stream, shouldClone) 103 103 { 104 104 "use strict"; … … 119 119 teeState.cancelPromiseCapability = @newPromiseCapability(@InternalPromise); 120 120 121 const pullFunction = @ teeReadableStreamPullFunction(teeState, reader, shouldClone);121 const pullFunction = @readableStreamTeePullFunction(teeState, reader, shouldClone); 122 122 123 123 const branch1 = new @ReadableStream({ 124 124 "pull": pullFunction, 125 "cancel": @ teeReadableStreamBranch1CancelFunction(teeState, stream)125 "cancel": @readableStreamTeeBranch1CancelFunction(teeState, stream) 126 126 }); 127 127 const branch2 = new @ReadableStream({ 128 128 "pull": pullFunction, 129 "cancel": @ teeReadableStreamBranch2CancelFunction(teeState, stream)129 "cancel": @readableStreamTeeBranch2CancelFunction(teeState, stream) 130 130 }); 131 131 … … 161 161 } 162 162 163 function teeReadableStreamPullFunction(teeState, reader, shouldClone)163 function readableStreamTeePullFunction(teeState, reader, shouldClone) 164 164 { 165 165 "use strict"; 166 166 167 167 return function() { 168 @Promise.prototype.@then.@call(@read FromReadableStreamDefaultReader(reader), function(result) {168 @Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(reader), function(result) { 169 169 @assert(@isObject(result)); 170 170 @assert(typeof result.done === "boolean"); … … 179 179 return; 180 180 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); 182 182 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); 184 184 }); 185 185 } 186 186 } 187 187 188 function teeReadableStreamBranch1CancelFunction(teeState, stream)188 function readableStreamTeeBranch1CancelFunction(teeState, stream) 189 189 { 190 190 "use strict"; … … 202 202 } 203 203 204 function teeReadableStreamBranch2CancelFunction(teeState, stream)204 function readableStreamTeeBranch2CancelFunction(teeState, stream) 205 205 { 206 206 "use strict"; … … 249 249 } 250 250 251 function errorReadableStream(stream, error)251 function readableStreamError(stream, error) 252 252 { 253 253 "use strict"; … … 275 275 } 276 276 277 function re questReadableStreamPull(controller)277 function readableStreamDefaultControllerCallPullIfNeeded(controller) 278 278 { 279 279 "use strict"; … … 301 301 if (controller.@pullAgain) { 302 302 controller.@pullAgain = false; 303 @re questReadableStreamPull(controller);303 @readableStreamDefaultControllerCallPullIfNeeded(controller); 304 304 } 305 305 }, function(error) { … … 333 333 if (stream.@state === @streamErrored) 334 334 return @Promise.@reject(stream.@storedError); 335 @ closeReadableStream(stream);335 @readableStreamClose(stream); 336 336 return stream.@readableStreamController.@cancel(stream.@readableStreamController, reason).@then(function() { }); 337 337 } … … 353 353 const chunk = @dequeueValue(controller.@queue); 354 354 if (controller.@closeRequested && controller.@queue.content.length === 0) 355 @ closeReadableStream(stream);355 @readableStreamClose(stream); 356 356 else 357 @re questReadableStreamPull(controller);357 @readableStreamDefaultControllerCallPullIfNeeded(controller); 358 358 return @Promise.@resolve({value: chunk, done: false}); 359 359 } 360 360 const pendingPromise = @readableStreamAddReadRequest(stream); 361 @re questReadableStreamPull(controller);361 @readableStreamDefaultControllerCallPullIfNeeded(controller); 362 362 return pendingPromise; 363 363 } … … 372 372 controller.@closeRequested = true; 373 373 if (controller.@queue.content.length === 0) 374 @ closeReadableStream(stream);375 } 376 377 function closeReadableStream(stream)374 @readableStreamClose(stream); 375 } 376 377 function readableStreamClose(stream) 378 378 { 379 379 "use strict"; … … 396 396 } 397 397 398 function enqueueInReadableStream(controller, chunk)398 function readableStreamDefaultControllerEnqueue(controller, chunk) 399 399 { 400 400 "use strict"; … … 406 406 if (@isReadableStreamLocked(stream) && stream.@reader.@readRequests.length) { 407 407 stream.@reader.@readRequests.@shift().@resolve.@call(@undefined, {value: chunk, done: false}); 408 @re questReadableStreamPull(controller);408 @readableStreamDefaultControllerCallPullIfNeeded(controller); 409 409 return; 410 410 } … … 421 421 throw error; 422 422 } 423 @re questReadableStreamPull(controller);424 } 425 426 function read FromReadableStreamDefaultReader(reader)423 @readableStreamDefaultControllerCallPullIfNeeded(controller); 424 } 425 426 function readableStreamDefaultReaderRead(reader) 427 427 { 428 428 "use strict";
Note: See TracChangeset
for help on using the changeset viewer.