Move ReadableStreamJSSource.h/.cpp to ReadableJSStream.h/.cpp
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 May 2015 11:59:41 +0000 (11:59 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 May 2015 11:59:41 +0000 (11:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144567

Reviewed by Darin Adler.

In addition to renaming ReadableStreamJSSource.h/.cpp, ReadableStreamJSSource is now made a private class of
ReadableJSStream, called ReadableJSStream::Source.
Made some minor refactoring (passing some ExecState by ref and not by pointer).
No functional change, existing tests cover the changes.

* bindings/js/JSReadableStreamCustom.cpp:
* bindings/js/ReadableJSStream.cpp:
(WebCore::ReadableJSStream::Source::create):
(WebCore::ReadableJSStream::Source::Source):
(WebCore::ReadableJSStream::Source::~Source):
(WebCore::ReadableJSStream::Source::globalObject):
(WebCore::ReadableJSStream::Source::start):
(WebCore::ReadableJSStream::create):
(WebCore::ReadableJSStream::ReadableJSStream):
* bindings/js/ReadableJSStream.h:

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

12 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/streams/ReadableStreamController.h
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSReadableStreamControllerCustom.cpp
Source/WebCore/bindings/js/JSReadableStreamCustom.cpp
Source/WebCore/bindings/js/JSReadableStreamReaderCustom.cpp
Source/WebCore/bindings/js/ReadableJSStream.cpp [moved from Source/WebCore/bindings/js/ReadableStreamJSSource.cpp with 82% similarity]
Source/WebCore/bindings/js/ReadableJSStream.h [moved from Source/WebCore/bindings/js/ReadableStreamJSSource.h with 81% similarity]

index d6deb1d..b2b7227 100644 (file)
@@ -1158,7 +1158,7 @@ set(WebCore_SOURCES
     bindings/js/JSReadableStreamCustom.cpp
     bindings/js/JSReadableStreamControllerCustom.cpp
     bindings/js/JSReadableStreamReaderCustom.cpp
-    bindings/js/ReadableStreamJSSource.cpp
+    bindings/js/ReadableJSStream.cpp
     bindings/js/JSRequestAnimationFrameCallbackCustom.cpp
     bindings/js/JSSQLResultSetRowListCustom.cpp
     bindings/js/JSSQLTransactionCustom.cpp
index d6802c2..6f07907 100644 (file)
@@ -1,3 +1,26 @@
+2015-05-06  Xabier Rodriguez Calvar  <calvaris@igalia.com> and Youenn Fablet  <youenn.fablet@crf.canon.fr>
+
+        Move ReadableStreamJSSource.h/.cpp to ReadableJSStream.h/.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=144567
+
+        Reviewed by Darin Adler.
+
+        In addition to renaming ReadableStreamJSSource.h/.cpp, ReadableStreamJSSource is now made a private class of
+        ReadableJSStream, called ReadableJSStream::Source.
+        Made some minor refactoring (passing some ExecState by ref and not by pointer).
+        No functional change, existing tests cover the changes.
+
+        * bindings/js/JSReadableStreamCustom.cpp:
+        * bindings/js/ReadableJSStream.cpp:
+        (WebCore::ReadableJSStream::Source::create):
+        (WebCore::ReadableJSStream::Source::Source):
+        (WebCore::ReadableJSStream::Source::~Source):
+        (WebCore::ReadableJSStream::Source::globalObject):
+        (WebCore::ReadableJSStream::Source::start):
+        (WebCore::ReadableJSStream::create):
+        (WebCore::ReadableJSStream::ReadableJSStream):
+        * bindings/js/ReadableJSStream.h:
+
 2015-05-05  Tim Horton  <timothy_horton@apple.com>
 
         REGRESSION (r183517): Yellow find-in-page highlight gets stuck forever
index f3415c1..e5958d1 100644 (file)
@@ -32,7 +32,7 @@
 
 #if ENABLE(STREAMS_API)
 
-#include "ReadableStreamJSSource.h"
+#include "ReadableJSStream.h"
 
 namespace WebCore {
 
index 09040a2..2b44c95 100644 (file)
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
-    <ClCompile Include="..\bindings\js\ReadableStreamJSSource.cpp">
+    <ClCompile Include="..\bindings\js\ReadableJSStream.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
index 2a5349d..22ee568 100644 (file)
     <ClCompile Include="..\bindings\js\JSReadableStreamReaderCustom.cpp">
       <Filter>bindings\js</Filter>
     </ClCompile>
-    <ClCompile Include="..\bindings\js\ReadableStreamJSSource.cpp">
+    <ClCompile Include="..\bindings\js\ReadableJSStream.cpp">
       <Filter>bindings\js</Filter>
     </ClCompile>
     <ClCompile Include="..\bindings\js\JSRequestAnimationFrameCallbackCustom.cpp">
index acdc998..02d06c1 100644 (file)
                418A06D1133C04D500CD379C /* EventDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 418A06CF133C04D500CD379C /* EventDispatcher.cpp */; };
                418F88040FF957AE0080F045 /* JSAbstractWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 418F88020FF957AE0080F045 /* JSAbstractWorker.cpp */; };
                418F88050FF957AF0080F045 /* JSAbstractWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 418F88030FF957AE0080F045 /* JSAbstractWorker.h */; };
-               4198BDF01A81142200B22FB5 /* ReadableStreamJSSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4198BDEE1A81123600B22FB5 /* ReadableStreamJSSource.cpp */; };
-               4198BDF11A81143100B22FB5 /* ReadableStreamJSSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 4198BDEF1A81123600B22FB5 /* ReadableStreamJSSource.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               4198BDF01A81142200B22FB5 /* ReadableJSStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4198BDEE1A81123600B22FB5 /* ReadableJSStream.cpp */; };
+               4198BDF11A81143100B22FB5 /* ReadableJSStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 4198BDEF1A81123600B22FB5 /* ReadableJSStream.h */; settings = {ATTRIBUTES = (Private, ); }; };
                419BC2DE1685329900D64D6D /* VisitedLinkState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 419BC2DC1685329900D64D6D /* VisitedLinkState.cpp */; };
                419BC2DF1685329900D64D6D /* VisitedLinkState.h in Headers */ = {isa = PBXBuildFile; fileRef = 419BC2DD1685329900D64D6D /* VisitedLinkState.h */; };
                419FAFAE1ABABD08005B828B /* ReadableStreamReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 419FAFAB1ABABCD5005B828B /* ReadableStreamReader.cpp */; };
                418A06CF133C04D500CD379C /* EventDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventDispatcher.cpp; sourceTree = "<group>"; };
                418F88020FF957AE0080F045 /* JSAbstractWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAbstractWorker.cpp; sourceTree = "<group>"; };
                418F88030FF957AE0080F045 /* JSAbstractWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAbstractWorker.h; sourceTree = "<group>"; };
-               4198BDEE1A81123600B22FB5 /* ReadableStreamJSSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadableStreamJSSource.cpp; sourceTree = "<group>"; };
-               4198BDEF1A81123600B22FB5 /* ReadableStreamJSSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamJSSource.h; sourceTree = "<group>"; };
+               4198BDEE1A81123600B22FB5 /* ReadableJSStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadableJSStream.cpp; sourceTree = "<group>"; };
+               4198BDEF1A81123600B22FB5 /* ReadableJSStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableJSStream.h; sourceTree = "<group>"; };
                419BC2DC1685329900D64D6D /* VisitedLinkState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisitedLinkState.cpp; sourceTree = "<group>"; };
                419BC2DD1685329900D64D6D /* VisitedLinkState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisitedLinkState.h; sourceTree = "<group>"; };
                419FAFAB1ABABCD5005B828B /* ReadableStreamReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadableStreamReader.cpp; sourceTree = "<group>"; };
                                E1C36D320EB0A094007410BC /* JSWorkerGlobalScopeBase.cpp */,
                                E1C36D330EB0A094007410BC /* JSWorkerGlobalScopeBase.h */,
                                41189EF81AD8233C00B90A0D /* JSReadableStreamControllerCustom.cpp */,
-                               4198BDEE1A81123600B22FB5 /* ReadableStreamJSSource.cpp */,
-                               4198BDEF1A81123600B22FB5 /* ReadableStreamJSSource.h */,
+                               4198BDEE1A81123600B22FB5 /* ReadableJSStream.cpp */,
+                               4198BDEF1A81123600B22FB5 /* ReadableJSStream.h */,
                                BCA378BA0D15F64200B793D6 /* ScheduledAction.cpp */,
                                BCA378BB0D15F64200B793D6 /* ScheduledAction.h */,
                                41F1D21E0EF35C2A00DA8753 /* ScriptCachedFrameData.cpp */,
                                0709D78F1AE55554004E42F8 /* WebMediaSessionManager.h in Headers */,
                                84B6B978120F13E500B8EFAF /* SVGPathSegListSource.h in Headers */,
                                83C1D435178D5AB500141E68 /* SVGPathSegMovetoAbs.h in Headers */,
-                               4198BDF11A81143100B22FB5 /* ReadableStreamJSSource.h in Headers */,
+                               4198BDF11A81143100B22FB5 /* ReadableJSStream.h in Headers */,
                                83C1D436178D5AB500141E68 /* SVGPathSegMovetoRel.h in Headers */,
                                082DE42D1292621600D923DF /* SVGPathSegWithContext.h in Headers */,
                                84300BD8120C9AD40021954A /* SVGPathSource.h in Headers */,
                                FB484F4C171F821E00040755 /* TransformFunctions.cpp in Sources */,
                                49E911CF0EF86D47009D0CAF /* TransformOperations.cpp in Sources */,
                                5DB1BC6B10715A6400EFAA49 /* TransformSourceLibxslt.cpp in Sources */,
-                               4198BDF01A81142200B22FB5 /* ReadableStreamJSSource.cpp in Sources */,
+                               4198BDF01A81142200B22FB5 /* ReadableJSStream.cpp in Sources */,
                                4945BFD313CF809000CC3B38 /* TransformState.cpp in Sources */,
                                E17B491516A9B094001C8839 /* TransitionEvent.cpp in Sources */,
                                49E911D10EF86D47009D0CAF /* TranslateTransformOperation.cpp in Sources */,
index 9a62dd6..8a5eae7 100644 (file)
 #include "JSReadableStreamControllerCustom.cpp"
 #include "JSReadableStreamCustom.cpp"
 #include "JSReadableStreamReaderCustom.cpp"
-#include "ReadableStreamJSSource.cpp"
+#include "ReadableJSStream.cpp"
 #endif
 #include "JSRequestAnimationFrameCallbackCustom.cpp"
 #include "JSSQLResultSetRowListCustom.cpp"
index fb5d6f8..695cf29 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "JSDOMBinding.h"
 #include "NotImplemented.h"
-#include "ReadableStreamJSSource.h"
+#include "ReadableJSStream.h"
 #include <runtime/Error.h>
 
 using namespace JSC;
index 11a0153..bc18679 100644 (file)
@@ -36,8 +36,8 @@
 #include "JSDOMBinding.h"
 #include "JSDOMPromise.h"
 #include "JSReadableStreamReader.h"
+#include "ReadableJSStream.h"
 #include "ReadableStream.h"
-#include "ReadableStreamJSSource.h"
 #include "ReadableStreamReader.h"
 #include <runtime/Error.h>
 #include <wtf/NeverDestroyed.h>
index e4adda7..48db54f 100644 (file)
@@ -35,7 +35,7 @@
 #include "ExceptionCode.h"
 #include "JSDOMPromise.h"
 #include "JSReadableStream.h"
-#include "ReadableStreamJSSource.h"
+#include "ReadableJSStream.h"
 #include <runtime/Error.h>
 #include <wtf/NeverDestroyed.h>
 
@@ -28,7 +28,7 @@
  */
 
 #include "config.h"
-#include "ReadableStreamJSSource.h"
+#include "ReadableJSStream.h"
 
 #if ENABLE(STREAMS_API)
 
@@ -77,20 +77,21 @@ static inline JSValue callFunction(ExecState* exec, JSValue jsFunction, JSValue
     return call(exec, jsFunction, callType, callData, thisValue, arguments, exception);
 }
 
-Ref<ReadableStreamJSSource> ReadableStreamJSSource::create(JSC::ExecState* exec)
+Ref<ReadableJSStream::Source> ReadableJSStream::Source::create(ExecState& exec)
 {
-    return adoptRef(*new ReadableStreamJSSource(exec));
+    return adoptRef(*new Source(exec));
 }
 
-ReadableStreamJSSource::ReadableStreamJSSource(JSC::ExecState* exec)
+ReadableJSStream::Source::Source(ExecState& exec)
 {
-    ASSERT_WITH_MESSAGE(!exec->argumentCount() || exec->argument(0).isObject(), "Caller of ReadableStreamJSSource constructor should ensure that passed argument if any is an object.");
-    JSObject* source =  exec->argumentCount() ? exec->argument(0).getObject() : JSFinalObject::create(exec->vm(), JSFinalObject::createStructure(exec->vm(), exec->callee()->globalObject(), jsNull(), 1));
-    m_source.set(exec->vm(), source);
+    ASSERT_WITH_MESSAGE(!exec.argumentCount() || exec.argument(0).isObject(), "Caller of ReadableJSStream::Source constructor should ensure that passed argument if any is an object.");
+    JSObject* source =  exec.argumentCount() ? exec.argument(0).getObject() : JSFinalObject::create(exec.vm(), JSFinalObject::createStructure(exec.vm(), exec.callee()->globalObject(), jsNull(), 1));
+    m_source.set(exec.vm(), source);
 }
 
-ReadableStreamJSSource::~ReadableStreamJSSource()
+JSDOMGlobalObject* ReadableJSStream::Source::globalObject()
 {
+    return jsDynamicCast<JSDOMGlobalObject*>(m_source->globalObject());
 }
 
 static void startReadableStreamAsync(ReadableStream& readableStream)
@@ -101,12 +102,7 @@ static void startReadableStreamAsync(ReadableStream& readableStream)
     });
 }
 
-JSDOMGlobalObject* ReadableStreamJSSource::globalObject()
-{
-    return jsDynamicCast<JSDOMGlobalObject*>(m_source->globalObject());
-}
-
-void ReadableStreamJSSource::start(ExecState& exec, ReadableJSStream& readableStream)
+void ReadableJSStream::Source::start(ExecState& exec, ReadableJSStream& readableStream)
 {
     JSLockHolder lock(&exec);
 
@@ -136,9 +132,10 @@ void ReadableStreamJSSource::start(ExecState& exec, ReadableJSStream& readableSt
 
 Ref<ReadableJSStream> ReadableJSStream::create(ExecState& exec, ScriptExecutionContext& scriptExecutionContext)
 {
-    Ref<ReadableStreamJSSource> source = ReadableStreamJSSource::create(&exec);
+    Ref<ReadableJSStream::Source> source = ReadableJSStream::Source::create(exec);
     Ref<ReadableJSStream> readableStream = adoptRef(*new ReadableJSStream(scriptExecutionContext, WTF::move(source)));
-    readableStream->jsSource().start(exec, readableStream.get());
+
+    static_cast<ReadableJSStream::Source&>(readableStream->source()).start(exec, readableStream.get());
     return readableStream;
 }
 
@@ -147,14 +144,14 @@ Ref<ReadableStreamReader> ReadableJSStream::createReader()
     return Reader::create(*this);
 }
 
-ReadableJSStream::ReadableJSStream(ScriptExecutionContext& scriptExecutionContext, Ref<ReadableStreamJSSource>&& source)
+ReadableJSStream::ReadableJSStream(ScriptExecutionContext& scriptExecutionContext, Ref<ReadableJSStream::Source>&& source)
     : ReadableStream(scriptExecutionContext, WTF::move(source))
 {
 }
 
-ReadableStreamJSSource& ReadableJSStream::jsSource()
+ReadableJSStream::Source& ReadableJSStream::jsSource()
 {
-    return static_cast<ReadableStreamJSSource&>(source());
+    return static_cast<ReadableJSStream::Source&>(source());
 }
 
 JSValue ReadableJSStream::jsController(ExecState& exec, JSDOMGlobalObject* globalObject)
@@ -27,8 +27,8 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef ReadableStreamJSSource_h
-#define ReadableStreamJSSource_h
+#ifndef ReadableJSStream_h
+#define ReadableJSStream_h
 
 #if ENABLE(STREAMS_API)
 
 namespace WebCore {
 
 class JSDOMGlobalObject;
-class ReadableJSStream;
 class ReadableStreamController;
 
-class ReadableStreamJSSource: public ReadableStreamSource {
-public:
-    static Ref<ReadableStreamJSSource> create(JSC::ExecState*);
-    ~ReadableStreamJSSource();
+class ReadableJSStream: public ReadableStream {
+private:
+    class Reader: public ReadableStreamReader {
+    public:
+        static Ref<Reader> create(ReadableJSStream&);
+    private:
+        explicit Reader(ReadableJSStream&);
+    };
 
-    JSDOMGlobalObject* globalObject();
-    void start(JSC::ExecState&, ReadableJSStream&);
+    class Source: public ReadableStreamSource {
+    public:
+        static Ref<Source> create(JSC::ExecState&);
 
-private:
-    ReadableStreamJSSource(JSC::ExecState*);
+        JSDOMGlobalObject* globalObject();
+        void start(JSC::ExecState&, ReadableJSStream&);
 
-    // Object passed to constructor.
-    JSC::Strong<JSC::JSObject> m_source;
-};
+    private:
+        Source(JSC::ExecState&);
+
+        JSC::Strong<JSC::JSObject> m_source;
+    };
 
-class ReadableJSStream: public ReadableStream {
 public:
     static Ref<ReadableJSStream> create(JSC::ExecState&, ScriptExecutionContext&);
     virtual Ref<ReadableStreamReader> createReader() override;
 
-    ReadableStreamJSSource& jsSource();
+    ReadableJSStream::Source& jsSource();
     JSC::JSValue jsController(JSC::ExecState&, JSDOMGlobalObject*);
 
 private:
-    ReadableJSStream(ScriptExecutionContext&, Ref<ReadableStreamJSSource>&&);
-
-    class Reader: public ReadableStreamReader {
-    public:
-        static Ref<Reader> create(ReadableJSStream&);
-    private:
-        explicit Reader(ReadableJSStream&);
-    };
+    ReadableJSStream(ScriptExecutionContext&, Ref<ReadableJSStream::Source>&&);
 
     std::unique_ptr<ReadableStreamController> m_controller;
 };
@@ -90,4 +88,4 @@ JSC::JSValue getInternalSlotFromObject(JSC::ExecState*, JSC::JSValue, JSC::Priva
 
 #endif // ENABLE(STREAMS_API)
 
-#endif // ReadableStreamJSSource_h
+#endif // ReadableJSStream_h