[Streams API] ReadableStreamReader closed promise should use CachedAttribute
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Aug 2015 10:01:31 +0000 (10:01 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Aug 2015 10:01:31 +0000 (10:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147487

Reviewed by Darin Adler.

Covered by existing tests.

* Modules/streams/ReadableStreamReader.idl: Made closed a CachedAttribute.
* bindings/js/JSReadableStreamReaderCustom.cpp:
(WebCore::JSReadableStreamReader::closed): Updated according CachedAttribute specific field.

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/streams/ReadableStreamReader.idl
Source/WebCore/bindings/js/JSReadableStreamReaderCustom.cpp

index d7f4e72..89dcf19 100644 (file)
@@ -1,3 +1,16 @@
+2015-08-10  Youenn Fablet  <youenn.fablet@crf.canon.fr>
+
+        [Streams API] ReadableStreamReader closed promise should use CachedAttribute
+        https://bugs.webkit.org/show_bug.cgi?id=147487
+
+        Reviewed by Darin Adler.
+
+        Covered by existing tests.
+
+        * Modules/streams/ReadableStreamReader.idl: Made closed a CachedAttribute.
+        * bindings/js/JSReadableStreamReaderCustom.cpp:
+        (WebCore::JSReadableStreamReader::closed): Updated according CachedAttribute specific field.
+
 2015-08-09  Hunseop Jeong  <hs85.jeong@samsung.com>
 
         [EFL] Use the non-overlay scrollbar
index da9ce93..41afe25 100644 (file)
@@ -37,5 +37,5 @@
     Promise cancel([Default=Undefined] optional any reason);
     [RaisesException] void releaseLock();
 
-    [CustomGetter] readonly attribute Promise closed;
+    [CustomGetter, CachedAttribute] readonly attribute Promise closed;
 };
index 13e2e1c..063accb 100644 (file)
@@ -46,13 +46,12 @@ namespace WebCore {
 
 JSValue JSReadableStreamReader::closed(ExecState* exec) const
 {
-    if (m_closedPromiseDeferred)
-        return m_closedPromiseDeferred->promise();
-
-    const_cast<JSReadableStreamReader*>(this)->m_closedPromiseDeferred.set(exec->vm(), JSPromiseDeferred::create(exec, globalObject()));
-    impl().closed(DeferredWrapper(exec, globalObject(), m_closedPromiseDeferred.get()));
-
-    return m_closedPromiseDeferred->promise();
+    if (!m_closed) {
+        JSPromiseDeferred* closedPromise = JSPromiseDeferred::create(exec, globalObject());
+        const_cast<JSReadableStreamReader*>(this)->m_closed.set(exec->vm(), this, closedPromise->promise());
+        impl().closed(DeferredWrapper(exec, globalObject(), closedPromise));
+    }
+    return m_closed.get();
 }
 
 EncodedJSValue JSC_HOST_CALL constructJSReadableStreamReader(ExecState* exec)