[Streams API] Remove ReadableStreamReader closed promise internal slot
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 May 2015 18:08:34 +0000 (18:08 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 May 2015 18:08:34 +0000 (18:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145215

Reviewed by Darin Adler.

Using the new JSPromiseDeferred member generated by binding generator to handle closed promise attribute.
Removed internal slots routines previously used to ensure persistency of the promise.

Existing tests cover the changes.

* bindings/js/JSReadableStreamReaderCustom.cpp:
(WebCore::JSReadableStreamReader::closed):
(WebCore::JSReadableStreamReader::cancel): Deleted.
(WebCore::JSReadableStreamReader::releaseLock): Deleted.
* bindings/js/ReadableJSStream.cpp:
(WebCore::getPropertyFromObject): Deleted.
(WebCore::callFunction): Deleted.
(WebCore::ReadableJSStream::Source::create): Deleted.
(WebCore::ReadableJSStream::Source::Source): Deleted.
* bindings/js/ReadableJSStream.h:

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSReadableStreamReaderCustom.cpp
Source/WebCore/bindings/js/ReadableJSStream.cpp
Source/WebCore/bindings/js/ReadableJSStream.h

index 8a25181..486ff3e 100644 (file)
@@ -1,3 +1,26 @@
+2015-05-21  Xabier Rodriguez Calvar  <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr>
+
+        [Streams API] Remove ReadableStreamReader closed promise internal slot
+        https://bugs.webkit.org/show_bug.cgi?id=145215
+
+        Reviewed by Darin Adler.
+
+        Using the new JSPromiseDeferred member generated by binding generator to handle closed promise attribute.
+        Removed internal slots routines previously used to ensure persistency of the promise.
+
+        Existing tests cover the changes.
+
+        * bindings/js/JSReadableStreamReaderCustom.cpp:
+        (WebCore::JSReadableStreamReader::closed):
+        (WebCore::JSReadableStreamReader::cancel): Deleted.
+        (WebCore::JSReadableStreamReader::releaseLock): Deleted.
+        * bindings/js/ReadableJSStream.cpp:
+        (WebCore::getPropertyFromObject): Deleted.
+        (WebCore::callFunction): Deleted.
+        (WebCore::ReadableJSStream::Source::create): Deleted.
+        (WebCore::ReadableJSStream::Source::Source): Deleted.
+        * bindings/js/ReadableJSStream.h:
+
 2015-05-21  Roger Fong  <roger_fong@apple.com>
 
         Media Controls stop updating after hovering for a few seconds.
index d6ecac2..a77c988 100644 (file)
@@ -49,33 +49,16 @@ JSValue JSReadableStreamReader::read(ExecState* exec)
     return exec->vm().throwException(exec, error);
 }
 
-static JSPromiseDeferred* getOrCreatePromiseDeferredFromObject(ExecState* exec, JSValue thisObject, JSGlobalObject* globalObject, PrivateName &name)
-{
-    JSValue slot = getInternalSlotFromObject(exec, thisObject, name);
-    JSPromiseDeferred* promiseDeferred = slot ? jsDynamicCast<JSPromiseDeferred*>(slot) : nullptr;
-
-    if (!promiseDeferred) {
-        promiseDeferred = JSPromiseDeferred::create(exec, globalObject);
-        setInternalSlotToObject(exec, thisObject, name, promiseDeferred);
-    }
-    return promiseDeferred;
-}
-
-static JSC::PrivateName& closedPromiseSlotName()
-{
-    static NeverDestroyed<JSC::PrivateName> closedPromiseSlotName("closedPromise");
-    return closedPromiseSlotName;
-}
-
 JSValue JSReadableStreamReader::closed(ExecState* exec) const
 {
-    JSPromiseDeferred* promiseDeferred = getOrCreatePromiseDeferredFromObject(exec, this, globalObject(), closedPromiseSlotName());
-    DeferredWrapper wrapper(exec, globalObject(), promiseDeferred);
+    if (!m_closedPromiseDeferred)
+        const_cast<JSReadableStreamReader*>(this)->m_closedPromiseDeferred.set(exec->vm(), JSPromiseDeferred::create(exec, globalObject()));
+    DeferredWrapper wrapper(exec, globalObject(), m_closedPromiseDeferred.get());
 
     auto successCallback = [wrapper]() mutable {
         wrapper.resolve(jsUndefined());
     };
-    auto failureCallback = [wrapper](const JSValue& value) mutable {
+    auto failureCallback = [wrapper](JSValue value) mutable {
         wrapper.reject(value);
     };
 
index ad1ec79..367385f 100644 (file)
@@ -47,24 +47,6 @@ using namespace JSC;
 
 namespace WebCore {
 
-void setInternalSlotToObject(ExecState* exec, JSValue objectValue, PrivateName& name, JSValue value)
-{
-    JSObject* object = objectValue.toObject(exec);
-    PutPropertySlot propertySlot(objectValue);
-    object->put(object, exec, Identifier::fromUid(name), value, propertySlot);
-}
-
-JSValue getInternalSlotFromObject(ExecState* exec, JSValue objectValue, PrivateName& name)
-{
-    JSObject* object = objectValue.toObject(exec);
-    PropertySlot propertySlot(objectValue);
-
-    Identifier propertyName = Identifier::fromUid(name);
-    if (!object->getOwnPropertySlot(object, exec, propertyName, propertySlot))
-        return JSValue();
-    return propertySlot.getValue(exec, propertyName);
-}
-
 static inline JSValue getPropertyFromObject(ExecState* exec, JSObject* object, const char* identifier)
 {
     return object->get(exec, Identifier::fromString(exec, identifier));
index 4d51d01..4b73b89 100644 (file)
@@ -77,9 +77,6 @@ private:
     JSC::Strong<JSC::Unknown> m_error;
 };
 
-void setInternalSlotToObject(JSC::ExecState*, JSC::JSValue, JSC::PrivateName&, JSC::JSValue);
-JSC::JSValue getInternalSlotFromObject(JSC::ExecState*, JSC::JSValue, JSC::PrivateName&);
-
 } // namespace WebCore
 
 #endif // ENABLE(STREAMS_API)