Skip to content

Commit cd34d11

Browse files
committed
Switch to owning
1 parent 5f2455a commit cd34d11

File tree

7 files changed

+23
-22
lines changed

7 files changed

+23
-22
lines changed

reference-implementation/lib/ReadableStream-impl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ exports.implementation = class ReadableStreamImpl {
2929
this, underlyingSource, underlyingSourceDict, highWaterMark
3030
);
3131
} else {
32-
assert(!('type' in underlyingSourceDict) || underlyingSourceDict.type === 'transfer');
32+
assert(!('type' in underlyingSourceDict) || underlyingSourceDict.type === 'owning');
3333
const sizeAlgorithm = ExtractSizeAlgorithm(strategy);
3434
const highWaterMark = ExtractHighWaterMark(strategy, 1);
3535
aos.SetUpReadableStreamDefaultControllerFromUnderlyingSource(

reference-implementation/lib/ReadableStreamDefaultController-impl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ exports.implementation = class ReadableStreamDefaultControllerImpl {
1919

2020
enqueue(chunk, optionsOrTransfer) {
2121
const hasTransfer = optionsOrTransfer && !Array.isArray(optionsOrTransfer);
22-
const transfer = hasTransfer ? optionsOrTransfer.transfer : optionsOrTransfer;
22+
const transferList = hasTransfer ? optionsOrTransfer.transfer : optionsOrTransfer;
2323
if (aos.ReadableStreamDefaultControllerCanCloseOrEnqueue(this) === false) {
2424
throw new TypeError('The stream is not in a state that permits enqueue');
2525
}
2626

27-
return aos.ReadableStreamDefaultControllerEnqueue(this, chunk, transfer);
27+
return aos.ReadableStreamDefaultControllerEnqueue(this, chunk, transferList);
2828
}
2929

3030
error(e) {

reference-implementation/lib/ReadableStreamDefaultController.webidl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ interface ReadableStreamDefaultController {
77
readonly attribute unrestricted double? desiredSize;
88

99
undefined close();
10-
undefined enqueue(any chunk, sequence<object> transfer);
1110
undefined enqueue(optional any chunk, optional StructuredSerializeOptions options = { });
1211
undefined error(optional any e);
1312
};

reference-implementation/lib/UnderlyingSource.webidl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ callback UnderlyingSourceStartCallback = any (ReadableStreamController controlle
1212
callback UnderlyingSourcePullCallback = Promise<undefined> (ReadableStreamController controller);
1313
callback UnderlyingSourceCancelCallback = Promise<undefined> (optional any reason);
1414

15-
enum ReadableStreamType { "bytes", "transfer" };
15+
enum ReadableStreamType { "bytes", "owning" };

reference-implementation/lib/abstract-ops/miscellaneous.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ exports.CloneAsUint8Array = O => {
2121
return new Uint8Array(buffer);
2222
};
2323

24-
exports.StructuredTransferOrClone = (value, transfer) => {
25-
// FIXME: We should check whether value is an array buffer or is transferable and update transfer accordingly.
26-
if (self.structuredClone)
27-
return structuredClone(value, transfer);
24+
exports.StructuredTransferOrClone = (value, transferList) => {
25+
console.log(globalThis);
26+
console.log(globalThis.structuredClone);
27+
28+
if (globalThis.structuredClone)
29+
return globalThis.structuredClone(value, transferList);
2830

2931
return JSON.parse(JSON.stringify(value));
3032
};

reference-implementation/lib/abstract-ops/queue-with-sizes.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exports.DequeueValue = container => {
1515
return pair.value;
1616
};
1717

18-
exports.EnqueueValueWithSize = (container, value, size, transfer) => {
18+
exports.EnqueueValueWithSize = (container, value, size, transferList) => {
1919
assert('_queue' in container && '_queueTotalSize' in container);
2020

2121
if (!IsNonNegativeNumber(size)) {
@@ -24,8 +24,8 @@ exports.EnqueueValueWithSize = (container, value, size, transfer) => {
2424
if (size === Infinity) {
2525
throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
2626
}
27-
if (container.isTransferring) {
28-
value = StructuredTransferOrClone(value, transfer);
27+
if (container.isOwning) {
28+
value = StructuredTransferOrClone(value, transferList);
2929
}
3030
container._queue.push({ value, size });
3131
container._queueTotalSize += size;
@@ -42,7 +42,7 @@ exports.PeekQueueValue = container => {
4242
exports.ResetQueue = container => {
4343
assert('_queue' in container && '_queueTotalSize' in container);
4444

45-
if (container.isTransferring) {
45+
if (container.isOwning) {
4646
while (container._queue.length > 0) {
4747
const value = exports.DequeueValue(container);
4848
if (typeof value.close === 'function') {

reference-implementation/lib/abstract-ops/readable-streams.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ function ReadableStreamTee(stream, cloneForBranch2) {
340340
if (ReadableByteStreamController.isImpl(stream._controller)) {
341341
return ReadableByteStreamTee(stream);
342342
}
343-
return ReadableStreamDefaultTee(stream, stream._controller.isTransferring ? true : cloneForBranch2);
343+
return ReadableStreamDefaultTee(stream, stream._controller.isOwning ? true : cloneForBranch2);
344344
}
345345

346346
function ReadableStreamDefaultTee(stream, cloneForBranch2) {
@@ -1074,17 +1074,17 @@ function ReadableStreamDefaultControllerClose(controller) {
10741074
}
10751075
}
10761076

1077-
function ReadableStreamDefaultControllerEnqueue(controller, chunk, transfer) {
1077+
function ReadableStreamDefaultControllerEnqueue(controller, chunk, transferList) {
10781078
if (ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) === false) {
10791079
return;
10801080
}
10811081

10821082
const stream = controller._stream;
10831083

10841084
if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
1085-
if (controller.isTransferring) {
1085+
if (controller.isOwning) {
10861086
try {
1087-
chunk = StructuredTransferOrClone(chunk, transfer);
1087+
chunk = StructuredTransferOrClone(chunk, transferList);
10881088
} catch (chunkCloneError) {
10891089
ReadableStreamDefaultControllerError(controller, chunkCloneError);
10901090
throw chunkCloneError;
@@ -1101,7 +1101,7 @@ function ReadableStreamDefaultControllerEnqueue(controller, chunk, transfer) {
11011101
}
11021102

11031103
try {
1104-
EnqueueValueWithSize(controller, chunk, chunkSize, transfer);
1104+
EnqueueValueWithSize(controller, chunk, chunkSize, transferList);
11051105
} catch (enqueueE) {
11061106
ReadableStreamDefaultControllerError(controller, enqueueE);
11071107
throw enqueueE;
@@ -1156,7 +1156,7 @@ function ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) {
11561156
}
11571157

11581158
function SetUpReadableStreamDefaultController(
1159-
stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm, isTransferring) {
1159+
stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm, isOwning) {
11601160
assert(stream._controller === undefined);
11611161

11621162
controller._stream = stream;
@@ -1177,7 +1177,7 @@ function SetUpReadableStreamDefaultController(
11771177
controller._pullAlgorithm = pullAlgorithm;
11781178
controller._cancelAlgorithm = cancelAlgorithm;
11791179

1180-
controller.isTransferring = isTransferring;
1180+
controller.isOwning= isOwning;
11811181

11821182
stream._controller = controller;
11831183

@@ -1205,7 +1205,7 @@ function SetUpReadableStreamDefaultControllerFromUnderlyingSource(
12051205
let startAlgorithm = () => undefined;
12061206
let pullAlgorithm = () => promiseResolvedWith(undefined);
12071207
let cancelAlgorithm = () => promiseResolvedWith(undefined);
1208-
const isTransferring = underlyingSourceDict.type === 'transfer';
1208+
const isOwning = underlyingSourceDict.type === 'owning';
12091209
if ('start' in underlyingSourceDict) {
12101210
startAlgorithm = () => underlyingSourceDict.start.call(underlyingSource, controller);
12111211
}
@@ -1218,7 +1218,7 @@ function SetUpReadableStreamDefaultControllerFromUnderlyingSource(
12181218

12191219
SetUpReadableStreamDefaultController(
12201220
stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm,
1221-
isTransferring);
1221+
isOwning);
12221222
}
12231223

12241224
// Byte stream controllers

0 commit comments

Comments
 (0)