ReadableStream does not not need to pass itself as callback parameter
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Mar 2015 11:31:47 +0000 (11:31 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Mar 2015 11:31:47 +0000 (11:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142399

Reviewed by Darin Adler.

No change in behavior.

* Modules/streams/ReadableStream.h: Remove ReadableStream parameter from SuccessCallback definition.
* bindings/js/JSReadableStreamCustom.cpp:
(WebCore::JSReadableStream::ready): Capture JSReadableStream instance instead.
(WebCore::JSReadableStream::closed): Capture JSReadableStream instance instead.

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

Source/WebCore/ChangeLog
Source/WebCore/Modules/streams/ReadableStream.h
Source/WebCore/bindings/js/JSReadableStreamCustom.cpp

index 4372d451f2367da4c99c8db3eac462667b9c5ce4..4a006033c30bd3dc5323ec0bdcc186d9831e9cd6 100644 (file)
@@ -1,3 +1,17 @@
+2015-03-09  Xabier Rodriguez Calvar  <calvaris@igalia.com> and Youenn Fablet  <youenn.fablet@crf.canon.fr>
+
+        ReadableStream does not not need to pass itself as callback parameter
+        https://bugs.webkit.org/show_bug.cgi?id=142399
+
+        Reviewed by Darin Adler.
+
+        No change in behavior.
+
+        * Modules/streams/ReadableStream.h: Remove ReadableStream parameter from SuccessCallback definition.
+        * bindings/js/JSReadableStreamCustom.cpp:
+        (WebCore::JSReadableStream::ready): Capture JSReadableStream instance instead.
+        (WebCore::JSReadableStream::closed): Capture JSReadableStream instance instead.
+
 2015-03-08  Dean Jackson  <dino@apple.com>
 
         [iOS Media] Video buffer progress missing on iPhones
index 00b49502bc6306deead855500a2b2bc52b4551a4..76473e15872497f3678ead6540d92f4088e0620a 100644 (file)
@@ -61,7 +61,7 @@ public:
     // JS API implementation.
     String state() const;
 
-    typedef std::function<void(RefPtr<ReadableStream>)> SuccessCallback;
+    typedef std::function<void()> SuccessCallback;
     void closed(SuccessCallback);
     void ready(SuccessCallback);
 
index 0f7993deece88edf5a13f085a6b97eb800c454be..5b6d1d5f6a24c7a3d5f3477e01a560c2c7272cc6 100644 (file)
@@ -70,8 +70,8 @@ JSValue JSReadableStream::ready(ExecState* exec) const
 {
     JSPromiseDeferred* promiseDeferred = getOrCreatePromiseDeferredFromObject(exec, this, globalObject(), readyPromiseSlotName());
     DeferredWrapper wrapper(exec, globalObject(), promiseDeferred);
-    auto successCallback = [wrapper](RefPtr<ReadableStream> stream) mutable {
-        wrapper.resolve(stream.get());
+    auto successCallback = [wrapper, this]() mutable {
+        wrapper.resolve(&impl());
     };
     impl().ready(WTF::move(successCallback));
 
@@ -88,8 +88,8 @@ JSValue JSReadableStream::closed(ExecState* exec) const
 {
     JSPromiseDeferred* promiseDeferred = getOrCreatePromiseDeferredFromObject(exec, this, globalObject(), closedPromiseSlotName());
     DeferredWrapper wrapper(exec, globalObject(), promiseDeferred);
-    auto successCallback = [wrapper](RefPtr<ReadableStream> stream) mutable {
-        wrapper.resolve(stream.get());
+    auto successCallback = [wrapper, this]() mutable {
+        wrapper.resolve(&impl());
     };
     impl().closed(WTF::move(successCallback));