[Streams API] Rework some readable stream internals that can be common to writable...
authorcalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Oct 2015 09:51:09 +0000 (09:51 +0000)
committercalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Oct 2015 09:51:09 +0000 (09:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150133

Reviewed by Darin Adler.

Source/JavaScriptCore:

* runtime/CommonIdentifiers.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init): Added RangeError also as native functions.

Source/WebCore:

There are some things in ReadableStream internals that be be used also for Writable Streams so it was necessary
to move some functions and refactor some code that can be shared by both implementations.

Queue was written with the functions declared at the implementation and keeping the improvement of having the
total size calculated instead of having to transverse the whole array.

The strategy is kept as an object and a common method is used to validate it as per spec.

Promises are reworked to keep in an internal slot inside the promise object the resolve and reject
functions. For convinience three functions were written, one to create the promise (and keep internally the
resolve and reject functions), one to resolve and another to reject. Promises can still be created with
Promise.resolve or reject as the resolve and rejectStreamsPromise functions operate under the assumption that
the internal slots might not exist.

invokeOrNoop and promiseInvokeOrNoop were moved to the common code as they will be also used by WritableStream.

Current test set suffices.

* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMWindowBase.cpp:
* bindings/js/WebCoreJSBuiltinInternals.h:
* bindings/js/WebCoreJSBuiltins.cpp:
* bindings/js/WebCoreJSBuiltins.h: Build infrastructure.
* Modules/streams/ReadableStream.js:
(initializeReadableStream): Reworked queue and strategy.
* Modules/streams/ReadableStreamInternals.js:
(privateInitializeReadableStreamReader):
(errorReadableStream):
(getReadableStreamDesiredSize):
(cancelReadableStream):
(closeReadableStream):
(closeReadableStreamReader):
(enqueueInReadableStream):
(readFromReadableStreamReader): Reworked queue, strategy and promises.
(invokeOrNoop): Deleted.
(promiseInvokeOrNoop): Deleted.
* Modules/streams/StreamInternals.js: Added.
(invokeOrNoop):
(promiseInvokeOrNoop): Moved from ReadableStreamInternals.js.
(validateAndNormalizeQueuingStrategy):
(createNewStreamsPromise):
(resolveStreamsPromise):
(rejectStreamsPromise):
(newQueue):
(dequeueValue):
(enqueueValueWithSize): Added according to the spec.
* bindings/js/WebCoreBuiltinNames.h: Updated private names according to the new slots.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191335 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/CommonIdentifiers.h
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/streams/ReadableStream.js
Source/WebCore/Modules/streams/ReadableStreamInternals.js
Source/WebCore/Modules/streams/StreamInternals.js [new file with mode: 0644]
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSDOMWindowBase.cpp
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/bindings/js/WebCoreJSBuiltinInternals.h
Source/WebCore/bindings/js/WebCoreJSBuiltins.cpp
Source/WebCore/bindings/js/WebCoreJSBuiltins.h

index 4341bf4dbe505b83cd1feaf3a4c61bf21594c3e7..72999f4314ca950e108b43c0b87f3a246eb78d20 100644 (file)
@@ -1,3 +1,14 @@
+2015-10-20  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
+        [Streams API] Rework some readable stream internals that can be common to writable streams
+        https://bugs.webkit.org/show_bug.cgi?id=150133
+
+        Reviewed by Darin Adler.
+
+        * runtime/CommonIdentifiers.h:
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init): Added RangeError also as native functions.
+
 2015-10-20  Yoav Weiss  <yoav@yoav.ws>
 
         Rename the PICTURE_SIZES flag to CURRENTSRC
index 92c9bb0f098167d7c706a0084cd2e5bace35d0bd..7901ef0c202d145747f84b82b5d48edb98d9d4f3 100644 (file)
     macro(isFinite) \
     macro(getPrototypeOf) \
     macro(getOwnPropertyNames) \
+    macro(RangeError) \
     macro(TypeError) \
     macro(typedArrayLength) \
     macro(typedArraySort) \
index f380ff2a85ceb8bdcc419eb380fa2261f4b2e838..b30ebf3ceef136376aa533b14635ac324343e78c 100644 (file)
@@ -516,6 +516,7 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct
         GlobalPropertyInfo(vm.propertyNames->ownEnumerablePropertyKeysPrivateName, JSFunction::create(vm, this, 0, String(), ownEnumerablePropertyKeys), DontEnum | DontDelete | ReadOnly),
         GlobalPropertyInfo(vm.propertyNames->getTemplateObjectPrivateName, privateFuncGetTemplateObject, DontEnum | DontDelete | ReadOnly),
         GlobalPropertyInfo(vm.propertyNames->enqueueJobPrivateName, JSFunction::create(vm, this, 0, String(), enqueueJob), DontEnum | DontDelete | ReadOnly),
+        GlobalPropertyInfo(vm.propertyNames->RangeErrorPrivateName, m_rangeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly),
         GlobalPropertyInfo(vm.propertyNames->TypeErrorPrivateName, m_typeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly),
         GlobalPropertyInfo(vm.propertyNames->typedArrayLengthPrivateName, privateFuncTypedArrayLength, DontEnum | DontDelete | ReadOnly),
         GlobalPropertyInfo(vm.propertyNames->typedArraySortPrivateName, privateFuncTypedArraySort, DontEnum | DontDelete | ReadOnly),
index f4a37cac6c2d40c3786f94b056bb65d7ed3150f9..07ec3c81e4766ab857dda28b93ffb7183396fac8 100644 (file)
@@ -3369,6 +3369,7 @@ set(WEBCORE_JS_BUILTINS
     ${WEBCORE_DIR}/Modules/streams/ReadableStreamController.js
     ${WEBCORE_DIR}/Modules/streams/ReadableStreamInternals.js
     ${WEBCORE_DIR}/Modules/streams/ReadableStreamReader.js
+    ${WEBCORE_DIR}/Modules/streams/StreamInternals.js
     ${WEBCORE_DIR}/Modules/streams/WritableStream.js
 )
 
index 9309980883fc7ee66e217436ce7afa42bfb93831..a782717f00a1dcec6d50ecdd6047657d9ccfff36 100644 (file)
@@ -1,3 +1,60 @@
+2015-10-20  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
+        [Streams API] Rework some readable stream internals that can be common to writable streams
+        https://bugs.webkit.org/show_bug.cgi?id=150133
+
+        Reviewed by Darin Adler.
+
+        There are some things in ReadableStream internals that be be used also for Writable Streams so it was necessary
+        to move some functions and refactor some code that can be shared by both implementations.
+
+        Queue was written with the functions declared at the implementation and keeping the improvement of having the
+        total size calculated instead of having to transverse the whole array.
+
+        The strategy is kept as an object and a common method is used to validate it as per spec.
+
+        Promises are reworked to keep in an internal slot inside the promise object the resolve and reject
+        functions. For convinience three functions were written, one to create the promise (and keep internally the
+        resolve and reject functions), one to resolve and another to reject. Promises can still be created with
+        Promise.resolve or reject as the resolve and rejectStreamsPromise functions operate under the assumption that
+        the internal slots might not exist.
+
+        invokeOrNoop and promiseInvokeOrNoop were moved to the common code as they will be also used by WritableStream.
+
+        Current test set suffices.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSDOMWindowBase.cpp:
+        * bindings/js/WebCoreJSBuiltinInternals.h:
+        * bindings/js/WebCoreJSBuiltins.cpp:
+        * bindings/js/WebCoreJSBuiltins.h: Build infrastructure.
+        * Modules/streams/ReadableStream.js:
+        (initializeReadableStream): Reworked queue and strategy.
+        * Modules/streams/ReadableStreamInternals.js:
+        (privateInitializeReadableStreamReader):
+        (errorReadableStream):
+        (getReadableStreamDesiredSize):
+        (cancelReadableStream):
+        (closeReadableStream):
+        (closeReadableStreamReader):
+        (enqueueInReadableStream):
+        (readFromReadableStreamReader): Reworked queue, strategy and promises.
+        (invokeOrNoop): Deleted.
+        (promiseInvokeOrNoop): Deleted.
+        * Modules/streams/StreamInternals.js: Added.
+        (invokeOrNoop):
+        (promiseInvokeOrNoop): Moved from ReadableStreamInternals.js.
+        (validateAndNormalizeQueuingStrategy):
+        (createNewStreamsPromise):
+        (resolveStreamsPromise):
+        (rejectStreamsPromise):
+        (newQueue):
+        (dequeueValue):
+        (enqueueValueWithSize): Added according to the spec.
+        * bindings/js/WebCoreBuiltinNames.h: Updated private names according to the new slots.
+
 2015-10-20  Yoav Weiss  <yoav@yoav.ws>
 
         Rename the PICTURE_SIZES flag to CURRENTSRC
index fda593cd5304a0c7d834b4013fbcd6938b1e7252..c37167e9975c616c4e313f0112f13f4ce7c526b7 100644 (file)
@@ -1264,6 +1264,7 @@ WEBCORE_JS_BUILTINS = \
     $(WebCore)/Modules/streams/ReadableStreamController.js \
     $(WebCore)/Modules/streams/ReadableStreamInternals.js \
     $(WebCore)/Modules/streams/ReadableStreamReader.js \
+    $(WebCore)/Modules/streams/StreamInternals.js \
     $(WebCore)/Modules/streams/WritableStream.js \
 #
 
index 1a52cf8161dd1d24d93d5c163346ebca3d0c1e8d..5f56f1ec2f06fe989c0f1074c2ebb481cc1c00b2 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -42,8 +43,7 @@ function initializeReadableStream(underlyingSource, strategy)
 
     this.@underlyingSource = underlyingSource;
 
-    this.@queue = [];
-    this.@queueSize = 0;
+    this.@queue = @newQueue();
     this.@state = @readableStreamReadable;
     this.@started = false;
     this.@closeRequested = false;
@@ -52,13 +52,7 @@ function initializeReadableStream(underlyingSource, strategy)
     this.@reader = undefined;
     this.@storedError = undefined;
     this.@controller = new @ReadableStreamController(this);
-    this.@strategySize = strategy.size;
-    this.@highWaterMark = Number(strategy.highWaterMark);
-
-    if (Number.isNaN(this.@highWaterMark))
-        throw new TypeError("highWaterMark parameter is not correct");
-    if (this.@highWaterMark < 0)
-        throw new RangeError("highWaterMark is negative");
+    this.@strategy = @validateAndNormalizeQueuingStrategy(strategy.size, strategy.highWaterMark);
 
     var result = @invokeOrNoop(underlyingSource, "start", [this.@controller]);
     var _this = this;
index a77027a1e3b5e524ecf86296b2e5c3d378ff5263..8ad13a709a182dd753b17bc056bbc731e2d5970f 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2015 Canon Inc. All rights reserved.
+ * Copyright (C) 2015 Igalia.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,10 +42,7 @@ function privateInitializeReadableStreamReader(stream)
         this.@ownerReadableStream = stream;
         this.@storedError = undefined;
         stream.@reader = this;
-        this.@closedPromise = new Promise(function(resolve, reject) {
-            stream.@reader.@closedPromiseResolve = resolve;
-            stream.@reader.@closedPromiseReject = reject;
-        });
+        this.@closedPromise = @createNewStreamsPromise();
         return this;
     }
     if (stream.@state === @readableStreamClosed) {
@@ -199,7 +197,7 @@ function errorReadableStream(stream, error)
     "use strict";
 
     // TODO: ASSERT(stream.@state === @readableStreamReadable);
-    stream.@queue = [];
+    stream.@queue = @newQueue();
     stream.@storedError = error;
     stream.@state = @readableStreamErrored;
 
@@ -209,14 +207,14 @@ function errorReadableStream(stream, error)
 
     var requests = reader.@readRequests;
     for (var index = 0, length = requests.length; index < length; ++index)
-        requests[index].reject(error);
+        @rejectStreamsPromise(requests[index], error);
     reader.@readRequests = [];
 
     @releaseReadableStreamReader(reader);
     reader.@storedError = error;
     reader.@state = @readableStreamErrored;
 
-    reader.@closedPromiseReject(error);
+    @rejectStreamsPromise(reader.@closedPromise, error);
 }
 
 function requestReadableStreamPull(stream)
@@ -262,7 +260,7 @@ function getReadableStreamDesiredSize(stream)
 {
    "use strict";
 
-   return stream.@highWaterMark - stream.@queueSize;
+   return stream.@strategy.highWaterMark - stream.@queue.size;
 }
 
 function releaseReadableStreamReader(reader)
@@ -281,7 +279,7 @@ function cancelReadableStream(stream, reason)
         return Promise.resolve();
     if (stream.@state === @readableStreamErrored)
         return Promise.reject(stream.@storedError);
-    stream.@queue = [];
+    stream.@queue = @newQueue();
     @finishClosingReadableStream(stream);
     return @promiseInvokeOrNoop(stream.@underlyingSource, "cancel", [reason]).then(function() { });
 }
@@ -306,7 +304,7 @@ function closeReadableStream(stream)
     if (stream.@state === @readableStreamClosed)
         return; 
     stream.@closeRequested = true;
-    if (!stream.@queue.length)
+    if (!stream.@queue.content.length)
         @finishClosingReadableStream(stream);
 }
 
@@ -316,11 +314,11 @@ function closeReadableStreamReader(reader)
 
     var requests = reader.@readRequests;
     for (var index = 0, length = requests.length; index < length; ++index)
-        requests[index].resolve({value:undefined, done: true});
+        @resolveStreamsPromise(requests[index], {value:undefined, done: true});
     reader.@readRequests = [];
     @releaseReadableStreamReader(reader);
     reader.@state = @readableStreamClosed;
-    reader.@closedPromiseResolve();
+    @resolveStreamsPromise(reader.@closedPromise);
 }
 
 function enqueueInReadableStream(stream, chunk)
@@ -332,19 +330,18 @@ function enqueueInReadableStream(stream, chunk)
     if (stream.@state === @readableStreamClosed)
         return undefined;
     if (@isReadableStreamLocked(stream) && stream.@reader.@readRequests.length) {
-        stream.@reader.@readRequests.shift().resolve({value: chunk, done: false});
+        @resolveStreamsPromise(stream.@reader.@readRequests.shift(), {value: chunk, done: false});
         @requestReadableStreamPull(stream);
         return;
     }
     try {
         var size = 1;
-        if (stream.@strategySize) {
-            size = Number(stream.@strategySize(chunk));
+        if (stream.@strategy.size) {
+            size = Number(stream.@strategy.size(chunk));
             if (Number.isNaN(size) || size === +Infinity || size < 0)
                 throw new RangeError("Chunk size is not valid");
         }
-        stream.@queue.push({ value: chunk, size: size });
-        stream.@queueSize += size;
+        @enqueueValueWithSize(stream.@queue, chunk, size);
     }
     catch(error) {
         @errorReadableStream(stream, error);
@@ -364,47 +361,16 @@ function readFromReadableStreamReader(reader)
     // TODO: ASSERT(!!reader.@ownerReadableStream);
     // TODO: ASSERT(reader.@ownerReadableStream.@state === @readableStreamReadable);
     var stream = reader.@ownerReadableStream;
-    if (stream.@queue.length) {
-        var chunk = stream.@queue.shift();
-        stream.@queueSize -= chunk.size;
+    if (stream.@queue.content.length) {
+        var chunk = @dequeueValue(stream.@queue);
         if (!stream.@closeRequested)
             @requestReadableStreamPull(stream);
-        else if (!stream.@queue.length)
+        else if (!stream.@queue.content.length)
             @finishClosingReadableStream(stream);
-        return Promise.resolve({value: chunk.value, done: false});
+        return Promise.resolve({value: chunk, done: false});
     }
-    var readRequest = {};
-    var readPromise = new Promise(function(resolve, reject) {
-        readRequest.resolve = resolve;
-        readRequest.reject = reject;
-    });
-    reader.@readRequests.push(readRequest);
+    var readPromise = @createNewStreamsPromise();
+    reader.@readRequests.push(readPromise);
     @requestReadableStreamPull(stream);
     return readPromise;
 }
-
-function invokeOrNoop(object, key, args)
-{
-    "use strict";
-
-    var method = object[key];
-    if (typeof method === "undefined")
-        return;
-    return method.@apply(object, args);
-}
-
-function promiseInvokeOrNoop(object, key, args)
-{
-    "use strict";
-
-    try {
-        var method = object[key];
-        if (typeof method === "undefined")
-            return Promise.resolve();
-        var result = method.@apply(object, args);
-        return Promise.resolve(result);
-    }
-    catch(error) {
-        return Promise.reject(error);
-    }
-}
diff --git a/Source/WebCore/Modules/streams/StreamInternals.js b/Source/WebCore/Modules/streams/StreamInternals.js
new file mode 100644 (file)
index 0000000..7b3dfd5
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// @optional=STREAMS_API
+// @internals
+
+function invokeOrNoop(object, key, args)
+{
+    "use strict";
+
+    var method = object[key];
+    if (typeof method === "undefined")
+        return;
+    return method.@apply(object, args);
+}
+
+function promiseInvokeOrNoop(object, key, args)
+{
+    "use strict";
+
+    try {
+        var method = object[key];
+        if (typeof method === "undefined")
+            return Promise.resolve();
+        var result = method.@apply(object, args);
+        return Promise.resolve(result);
+    }
+    catch(error) {
+        return Promise.reject(error);
+    }
+
+}
+
+function validateAndNormalizeQueuingStrategy(size, highWaterMark)
+{
+    "use strict";
+
+    if (size !== undefined && typeof size !== "function")
+        throw new @TypeError("size parameter must be a function");
+
+    var normalizedStrategy = { };
+
+    normalizedStrategy.size = size;
+    normalizedStrategy.highWaterMark = Number(highWaterMark);
+
+    if (Number.isNaN(normalizedStrategy.highWaterMark))
+        throw new @TypeError("highWaterMark parameter is not a number");
+    if (normalizedStrategy.highWaterMark < 0)
+        throw new @RangeError("highWaterMark is negative");
+
+    return normalizedStrategy;
+}
+
+function createNewStreamsPromise()
+{
+    "use strict";
+
+    var resolveFunction;
+    var rejectFunction;
+    var promise = new Promise(function(resolve, reject) {
+        resolveFunction = resolve;
+        rejectFunction = reject;
+    });
+    promise.@resolve = resolveFunction;
+    promise.@reject = rejectFunction;
+    return promise;
+}
+
+function resolveStreamsPromise(promise, value)
+{
+    "use strict";
+
+    if (promise && promise.@resolve) {
+        promise.@resolve(value);
+        promise.@resolve = undefined;
+        promise.@reject = undefined;
+    }
+}
+
+function rejectStreamsPromise(promise, value)
+{
+    "use strict";
+
+    if (promise && promise.@reject) {
+        promise.@reject(value);
+        promise.@resolve = undefined;
+        promise.@reject = undefined;
+    }
+}
+
+function newQueue()
+{
+    return { content: [], size: 0 };
+}
+
+function dequeueValue(queue)
+{
+    "use strict";
+
+    var record = queue.content.shift();
+    queue.size -= record.size;
+    return record.value;
+}
+
+function enqueueValueWithSize(queue, value, size)
+{
+    size = Number(size);
+    if (Number.isNaN(size) || !Number.isFinite(size) || size < 0)
+        throw new @RangeError("size has an incorrect value");
+    queue.content.push({ value: value, size: size });
+    queue.size += size;
+
+    return undefined;
+}
index c3457a98191ca1a9f1a6a881f270316a909814fe..c7ab5c010bd2ff13217766320533d9337cc6c1a7 100644 (file)
                4162A4571011464700DFF3ED /* JSDedicatedWorkerGlobalScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4162A4551011464700DFF3ED /* JSDedicatedWorkerGlobalScope.cpp */; };
                4162A4581011464700DFF3ED /* JSDedicatedWorkerGlobalScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 4162A4561011464700DFF3ED /* JSDedicatedWorkerGlobalScope.h */; };
                416E29A6102FA962007FC14E /* WorkerReportingProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 416E29A5102FA962007FC14E /* WorkerReportingProxy.h */; };
+               416E6FE81BBD12DF000A6033 /* StreamInternalsBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764C9 /* StreamInternalsBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               416E6FEA1BBD1684000A6034 /* StreamInternalsBuiltinsWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8071BB3110D00B764CA /* StreamInternalsBuiltinsWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
                416E6FE81BBD12DF000A6043 /* ReadableStreamInternalsBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764D9 /* ReadableStreamInternalsBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
                416E6FE91BBD12E5000A6043 /* ReadableStreamBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764D8 /* ReadableStreamBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
                416E6FEA1BBD1684000A6044 /* ReadableStreamInternalsBuiltinsWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8071BB3110D00B764DA /* ReadableStreamInternalsBuiltinsWrapper.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9908B0EC1BCACF1F00ED0F65 /* generate-js-builtins */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = "generate-js-builtins"; sourceTree = "<group>"; };
                9908B0ED1BCACF9100ED0F65 /* ByteLengthQueuingStrategy.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ByteLengthQueuingStrategy.js; sourceTree = "<group>"; };
                9908B0EE1BCACF9100ED0F65 /* CountQueuingStrategy.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = CountQueuingStrategy.js; sourceTree = "<group>"; };
+               9908B0F11BCACF9100ED0F55 /* StreamInternals.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = StreamInternals.js; sourceTree = "<group>"; };
+               9908B0FD1BCAD07D00ED0F55 /* StreamInternalsBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StreamInternalsBuiltins.cpp; sourceTree = "<group>"; };
                9908B0EF1BCACF9100ED0F65 /* ReadableStream.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ReadableStream.js; sourceTree = "<group>"; };
                9908B0F01BCACF9100ED0F65 /* ReadableStreamController.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ReadableStreamController.js; sourceTree = "<group>"; };
                9908B0F11BCACF9100ED0F65 /* ReadableStreamInternals.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ReadableStreamInternals.js; sourceTree = "<group>"; };
                9A528E8217D7F52F00AA9518 /* FloatingObjects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatingObjects.h; sourceTree = "<group>"; };
                9AB1F37E18E2489A00534743 /* CSSToLengthConversionData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSToLengthConversionData.h; sourceTree = "<group>"; };
                9AB1F37F18E2489A00534743 /* CSSToLengthConversionData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSToLengthConversionData.cpp; sourceTree = "<group>"; };
+               9B03D8061BB3110D00B764C9 /* StreamInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamInternalsBuiltins.h; sourceTree = "<group>"; };
+               9B03D8071BB3110D00B764CA /* StreamInternalsBuiltinsWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StreamInternalsBuiltinsWrapper.h; sourceTree = "<group>"; };
                9B03D8061BB3110D00B764D8 /* ReadableStreamBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamBuiltins.h; sourceTree = "<group>"; };
                9B03D8061BB3110D00B764D9 /* ReadableStreamInternalsBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamInternalsBuiltins.h; sourceTree = "<group>"; };
                9B03D8071BB3110D00B764D8 /* ReadableStreamBuiltinsWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamBuiltinsWrapper.h; sourceTree = "<group>"; };
                                4129DF821BB5B7A600322A16 /* ReadableStreamReader.h */,
                                419FAFAD1ABABCD5005B828B /* ReadableStreamReader.idl */,
                                9908B0F21BCACF9100ED0F65 /* ReadableStreamReader.js */,
+                               9908B0F11BCACF9100ED0F55 /* StreamInternals.js */,
                                41A023ED1A39DB7900F722DF /* WritableStream.idl */,
                                9908B0EF1BCACF9100ED0F75 /* WritableStream.js */,
 
                                26AA0F9D18D2A18B00419381 /* SelectorPseudoElementTypeMap.cpp */,
                                26AA0F9F18D2A1C100419381 /* SelectorPseudoElementTypeMap.gperf */,
                                53EF766A16530A61004CBE49 /* SettingsMacros.h */,
+                               9908B0FD1BCAD07D00ED0F55 /* StreamInternalsBuiltins.cpp */,
+                               9B03D8061BB3110D00B764C9 /* StreamInternalsBuiltins.h */,
+                               9B03D8071BB3110D00B764CA /* StreamInternalsBuiltinsWrapper.h */,
                                8386A96E19F61E4F00E1EC4A /* StyleBuilder.cpp */,
                                83C05A581A686212007E5DEA /* StylePropertyShorthandFunctions.cpp */,
                                83C05A591A686212007E5DEA /* StylePropertyShorthandFunctions.h */,
                                51E0BB380DA5ACB600A9E417 /* StorageMap.h in Headers */,
                                C50D0E830FF4272900AC2644 /* StorageNamespace.h in Headers */,
                                1A37636C1A2E68BB009A7EE2 /* StorageNamespaceProvider.h in Headers */,
+                               416E6FE81BBD12DF000A6033 /* StreamInternalsBuiltins.h in Headers */,
+                               416E6FEA1BBD1684000A6034 /* StreamInternalsBuiltinsWrapper.h in Headers */,
                                81AC6C36131C57D30009A7E0 /* StringCallback.h in Headers */,
                                B23540F30D00782E002382FA /* StringTruncator.h in Headers */,
                                9B6C41531344949000085B62 /* StringWithDirection.h in Headers */,
index 2af9799ed1ebed4fb9cb8d94f6768ac9562cfc02..fa2a309899041c52528fc79497c81ee83dcb6a8e 100644 (file)
@@ -50,6 +50,7 @@
 #if ENABLE(STREAMS_API)
 #include "JSReadableStreamPrivateConstructors.h"
 #include "ReadableStreamInternalsBuiltins.h"
+#include "StreamInternalsBuiltins.h"
 #endif
 
 using namespace JSC;
@@ -96,6 +97,12 @@ void JSDOMWindowBase::finishCreation(VM& vm, JSDOMWindowShell* shell)
             m_privateFunctions.readableStreamInternals().m_##name##Function.get() , DontDelete | ReadOnly),
         WEBCOREREADABLESTREAMINTERNALS_FOREACH_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
 #undef DECLARE_GLOBAL_STATIC
+#define DECLARE_GLOBAL_STATIC(name)\
+        GlobalPropertyInfo(\
+            static_cast<JSVMClientData*>(vm.clientData)->builtinFunctions().streamInternalsBuiltins().name##PrivateName(), \
+            m_privateFunctions.streamInternals().m_##name##Function.get() , DontDelete | ReadOnly),
+        WEBCORESTREAMINTERNALS_FOREACH_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
+#undef DECLARE_GLOBAL_STATIC
 #endif
     };
 
index be726c1cc1b07f8d47effabb01632b4ec20ac2fd..0fef220d099e6bb50efbd3c90d0a38d458b68398 100644 (file)
@@ -34,17 +34,13 @@ namespace WebCore {
 #define WEBCORE_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro)\
     macro(closeRequested) \
     macro(closedPromise) \
-    macro(closedPromiseResolve) \
-    macro(closedPromiseReject) \
     macro(controlledReadableStream) \
     macro(controller) \
     macro(getUserMediaFromJS) \
-    macro(highWaterMark) \
     macro(ownerReadableStream) \
     macro(pulling) \
     macro(pullAgain) \
     macro(queue) \
-    macro(queueSize) \
     macro(readableStreamClosed) \
     macro(readableStreamErrored) \
     macro(readableStreamReadable) \
@@ -53,7 +49,7 @@ namespace WebCore {
     macro(state) \
     macro(started) \
     macro(storedError) \
-    macro(strategySize) \
+    macro(strategy) \
     macro(underlyingSource) \
     macro(ReadableStreamReader) \
     macro(ReadableStreamController) \
index 96344f9c4ad2c62e9b8d9392d09af5d49fb1b106..e29f1ef5d03a50bf8b90588d7ac7697a74fd6aa7 100644 (file)
@@ -29,6 +29,7 @@
 
 #if ENABLE(STREAMS_API)
 #include "ReadableStreamInternalsBuiltinsWrapper.h"
+#include "StreamInternalsBuiltinsWrapper.h"
 #endif
 
 namespace WebCore {
@@ -39,15 +40,18 @@ explicit JSBuiltinInternalFunctions(JSC::VM& v)
         : vm(v)
 #if ENABLE(STREAMS_API)
         , m_readableStreamInternalsFunctions(vm)
+        , m_streamInternalsFunctions(vm)
 #endif
     { }
 
 #if ENABLE(STREAMS_API)
     ReadableStreamInternalsBuiltinFunctions readableStreamInternals() { return m_readableStreamInternalsFunctions; }
+    StreamInternalsBuiltinFunctions streamInternals() { return m_streamInternalsFunctions; }
 #endif
     void visit(JSC::SlotVisitor& visitor) {
 #if ENABLE(STREAMS_API)
         m_readableStreamInternalsFunctions.visit(visitor);
+        m_streamInternalsFunctions.visit(visitor);
 #else
         UNUSED_PARAM(visitor);
 #endif
@@ -55,6 +59,7 @@ explicit JSBuiltinInternalFunctions(JSC::VM& v)
     void init(JSC::JSGlobalObject& globalObject) {
 #if ENABLE(STREAMS_API)
         m_readableStreamInternalsFunctions.init(globalObject);
+        m_streamInternalsFunctions.init(globalObject);
 #else
         UNUSED_PARAM(globalObject);
 #endif
@@ -63,7 +68,8 @@ explicit JSBuiltinInternalFunctions(JSC::VM& v)
 private:
     JSC::VM& vm;
 #if ENABLE(STREAMS_API)
-     ReadableStreamInternalsBuiltinFunctions m_readableStreamInternalsFunctions;
+    ReadableStreamInternalsBuiltinFunctions m_readableStreamInternalsFunctions;
+    StreamInternalsBuiltinFunctions m_streamInternalsFunctions;
 #endif
 
 };
index 41fe6e42d5d07e16e727fd390620ea6e0aefa08d..3460db34dae06e9c87a94ab9b738a124a304fc80 100644 (file)
@@ -37,5 +37,6 @@
 #include "ReadableStreamControllerBuiltins.cpp"
 #include "ReadableStreamInternalsBuiltins.cpp"
 #include "ReadableStreamReaderBuiltins.cpp"
+#include "StreamInternalsBuiltins.cpp"
 #include "WritableStreamBuiltins.cpp"
 #endif
index 4d141ff02a3e602bdbaa54b9d722b7d0182e4cb4..b4055c93edd2fe6a93d64a26dafca7c6a8304597 100644 (file)
@@ -38,6 +38,7 @@
 #include "ReadableStreamControllerBuiltinsWrapper.h"
 #include "ReadableStreamInternalsBuiltinsWrapper.h"
 #include "ReadableStreamReaderBuiltinsWrapper.h"
+#include "StreamInternalsBuiltinsWrapper.h"
 #include "WritableStreamBuiltinsWrapper.h"
 #endif
 
@@ -56,6 +57,7 @@ public:
         , m_readableStreamControllerBuiltins(&vm)
         , m_readableStreamInternalsBuiltins(&vm)
         , m_readableStreamReaderBuiltins(&vm)
+        , m_streamInternalsBuiltins(&vm)
         , m_writableStreamBuiltins(&vm)
 #endif
 #if ENABLE(MEDIA_STREAM)
@@ -64,6 +66,7 @@ public:
     {
 #if ENABLE(STREAMS_API)
         m_readableStreamInternalsBuiltins.exportNames();
+        m_streamInternalsBuiltins.exportNames();
 #endif
     }
 #if ENABLE(STREAMS_API)
@@ -73,6 +76,7 @@ public:
     ReadableStreamControllerBuiltinsWrapper& readableStreamControllerBuiltins() { return m_readableStreamControllerBuiltins; }
     ReadableStreamInternalsBuiltinsWrapper& readableStreamInternalsBuiltins() { return m_readableStreamInternalsBuiltins; }
     ReadableStreamReaderBuiltinsWrapper& readableStreamReaderBuiltins() { return m_readableStreamReaderBuiltins; }
+    StreamInternalsBuiltinsWrapper& streamInternalsBuiltins() { return m_streamInternalsBuiltins; }
     WritableStreamBuiltinsWrapper& writableStreamBuiltins() { return m_writableStreamBuiltins; }
 #endif
 #if ENABLE(MEDIA_STREAM)
@@ -88,6 +92,7 @@ private:
     ReadableStreamControllerBuiltinsWrapper m_readableStreamControllerBuiltins;
     ReadableStreamInternalsBuiltinsWrapper m_readableStreamInternalsBuiltins;
     ReadableStreamReaderBuiltinsWrapper m_readableStreamReaderBuiltins;
+    StreamInternalsBuiltinsWrapper m_streamInternalsBuiltins;
     WritableStreamBuiltinsWrapper m_writableStreamBuiltins;
 #endif
 #if ENABLE(MEDIA_STREAM)