Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(669)

Unified Diff: third_party/WebKit/Source/core/streams/WritableStream.js

Issue 2752133003: Use SimpleQueue in WritableStream implementation (Closed)
Patch Set: Remove stale comments and correct copyright date Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/streams/SimpleQueue.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/streams/WritableStream.js
diff --git a/third_party/WebKit/Source/core/streams/WritableStream.js b/third_party/WebKit/Source/core/streams/WritableStream.js
index 38f7adc1fa5c52471f8e4ae6017e6fcd8e87bd9a..ed39672b2175b71fe753f3c65e2ad50ae6e8f459 100644
--- a/third_party/WebKit/Source/core/streams/WritableStream.js
+++ b/third_party/WebKit/Source/core/streams/WritableStream.js
@@ -141,11 +141,8 @@
setDefaultControllerFlag(controller, FLAG_INCLOSE, value);
}
- function rejectPromises(array, e) {
- // array is an InternalPackedArray so forEach won't work.
- for (let i = 0; i < array.length; ++i) {
- v8.rejectPromise(array[i], e);
- }
+ function rejectPromises(queue, e) {
+ queue.forEach(promise => v8.rejectPromise(promise, e));
}
// https://tc39.github.io/ecma262/#sec-ispropertykey
@@ -178,7 +175,7 @@
this[_pendingWriteRequest] = undefined;
this[_pendingCloseRequest] = undefined;
this[_pendingAbortRequest] = undefined;
- this[_writeRequests] = new v8.InternalPackedArray();
+ this[_writeRequests] = new binding.SimpleQueue();
const type = underlyingSink.type;
if (type !== undefined) {
throw new RangeError(streamErrors.invalidType);
@@ -331,7 +328,7 @@
const storedError = stream[_storedError];
rejectPromises(stream[_writeRequests], storedError);
- stream[_writeRequests] = new v8.InternalPackedArray();
+ stream[_writeRequests] = new binding.SimpleQueue();
if (stream[_pendingCloseRequest] !== undefined) {
TEMP_ASSERT(
@@ -623,7 +620,7 @@
}
this[_controlledWritableStream] = stream;
this[_underlyingSink] = underlyingSink;
- this[_queue] = new v8.InternalPackedArray();
+ this[_queue] = new binding.SimpleQueue();
this[_queueSize] = 0;
this[_defaultControllerFlags] = 0;
const normalizedStrategy =
@@ -665,7 +662,7 @@
}
function WritableStreamDefaultControllerAbort(controller, reason) {
- controller[_queue] = v8.InternalPackedArray();
+ controller[_queue] = new binding.SimpleQueue();
controller[_queueSize] = 0;
const sinkAbortPromise =
PromiseInvokeOrNoop(controller[_underlyingSink], 'abort', [reason]);
@@ -805,7 +802,7 @@
stream[_pendingWriteRequest] = stream[_writeRequests].shift();
const sinkWritePromise = PromiseInvokeOrNoop(controller[_underlyingSink],
- 'write', [chunk, controller]);
+ 'write', [chunk, controller]);
thenPromise(
sinkWritePromise,
() => {
@@ -881,16 +878,12 @@
TEMP_ASSERT(state === WRITABLE || state === CLOSING,
'stream.[[state]] is "writable" or "closing".');
WritableStreamError(stream, e);
- controller[_queue] = new v8.InternalPackedArray();
+ controller[_queue] = new binding.SimpleQueue();
controller[_queueSize] = 0;
}
// Queue-with-Sizes Operations
//
- // These differ from the versions in the standard: they take a controller
- // argument in order to cache the total queue size. This is necessary to avoid
- // O(N^2) behaviour.
- //
// TODO(ricea): Share these operations with ReadableStream.js.
function DequeueValueForController(controller) {
TEMP_ASSERT(controller[_queue].length !== 0,
@@ -917,7 +910,7 @@
function PeekQueueValue(queue) {
TEMP_ASSERT(queue.length !== 0,
'queue is not empty.');
- return queue[0].value;
+ return queue.peek().value;
}
// Miscellaneous Operations
« no previous file with comments | « third_party/WebKit/Source/core/streams/SimpleQueue.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698