+2015-03-31 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr>
+
+ [Streams API] Implement a barebone ReadableStreamReader interface
+ https://bugs.webkit.org/show_bug.cgi?id=142866
+
+ Reviewed by Benjamin Poulain.
+
+ Adding tests to check API, constructor and link with ReadableStream.getReader.
+ Rebasing of global-constructors-attributes.html to include ReadableStreamReader.
+
+ * js/dom/global-constructors-attributes-expected.txt:
+ * platform/efl/js/dom/global-constructors-attributes-expected.txt:
+ * platform/gtk/js/dom/global-constructors-attributes-expected.txt:
+ * platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt:
+ * platform/mac/js/dom/global-constructors-attributes-expected.txt:
+ * platform/win/js/dom/global-constructors-attributes-expected.txt:
+ * streams/readablestreamreader-constructor-expected.txt: Added.
+ * streams/readablestreamreader-constructor.html: Added.
+
2015-03-30 Ryosuke Niwa <rniwa@webkit.org>
Extending null should set __proto__ to null
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').value is ReadableStreamReader
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'Rect').value is Rect
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').value is ReadableStreamReader
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'Rect').value is Rect
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').value is ReadableStreamReader
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'Rect').value is Rect
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').value is ReadableStreamReader
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'Rect').value is Rect
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').value is ReadableStreamReader
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'Rect').value is Rect
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'ReadableStream').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').value is ReadableStreamReader
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'ReadableStreamReader').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'Rect').value is Rect
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'Rect').hasOwnProperty('set') is false
--- /dev/null
+
+PASS ReadableStreamReader constructor should get a ReadableStream object as argument
+PASS ReadableStream instances should have the correct list of properties
+PASS ReadableStreamReader closed should always return the same promise object
+PASS ReadableStream getReader should throw if ReadableStream is locked
+
--- /dev/null
+<!DOCTYPE html>
+<script src='../resources/testharness.js'></script>
+<script src='../resources/testharnessreport.js'></script>
+<script>
+
+test(function() {
+ assert_throws(new TypeError(), function() {
+ new ReadableStreamReader('potato');
+ });
+ assert_throws(new TypeError(), function() {
+ new ReadableStreamReader({});
+ });
+ assert_throws(new TypeError(), function() {
+ new ReadableStreamReader();
+ });
+}, 'ReadableStreamReader constructor should get a ReadableStream object as argument');
+
+test(function() {
+ var rsReader = new ReadableStreamReader(new ReadableStream());
+
+ assert_array_equals(Object.getOwnPropertyNames(rsReader), ['closed']);
+ assert_array_equals(Object.getOwnPropertyNames(Object.getPrototypeOf(rsReader)), ['constructor', 'read', 'cancel', 'releaseLock']);
+
+ assert_true(Object.getOwnPropertyDescriptor(rsReader, 'closed').enumerable);
+ assert_false(Object.getOwnPropertyDescriptor(rsReader, 'closed').configurable);
+
+ assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rsReader), 'cancel').enumerable);
+ assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rsReader), 'cancel').configurable);
+ assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rsReader), 'cancel').writable);
+
+ assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rsReader), 'read').enumerable);
+ assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rsReader), 'read').configurable);
+ assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rsReader), 'read').writable);
+
+ assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rsReader), 'releaseLock').enumerable);
+ assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rsReader), 'releaseLock').configurable);
+ assert_true(Object.getOwnPropertyDescriptor(Object.getPrototypeOf(rsReader), 'releaseLock').writable);
+
+ assert_exists(rsReader, 'closed', 'has a closed property');
+ assert_equals(typeof rsReader.closed.then, 'function', 'closed property is thenable');
+ assert_equals(typeof rsReader.cancel, 'function', 'has a cancel method');
+ assert_equals(rsReader.cancel.length, 1);
+ assert_equals(typeof rsReader.read, 'function', 'has a getReader method');
+ assert_equals(rsReader.read.length, 0);
+ assert_equals(typeof rsReader.releaseLock, 'function', 'has a releaseLock method');
+ assert_equals(rsReader.releaseLock.length, 0);
+
+}, 'ReadableStream instances should have the correct list of properties');
+
+test(function() {
+ rsReader = new ReadableStreamReader(new ReadableStream());
+
+ closedPromise = rsReader.closed;
+ assert_equals(closedPromise, rsReader.closed);
+
+ assert_array_equals(Object.keys(rsReader), ['closed']);
+ assert_array_equals(Object.getOwnPropertyNames(rsReader), ['closed']);
+}, 'ReadableStreamReader closed should always return the same promise object');
+
+test(function() {
+
+ rs = new ReadableStream();
+ assert_throws(new TypeError(), function() {
+ rs.getReader();
+ new ReadableStreamReader(rs);
+ });
+ rs = new ReadableStream();
+ assert_throws(new TypeError(), function() {
+ new ReadableStreamReader(rs);
+ rs.getReader();
+ });
+ rs = new ReadableStream();
+ assert_throws(new TypeError(), function() {
+ rs.getReader();
+ rs.getReader();
+ });
+ rs = new ReadableStream();
+ assert_throws(new TypeError(), function() {
+ new ReadableStreamReader(rs);
+ new ReadableStreamReader(rs);
+ });
+
+}, 'ReadableStream getReader should throw if ReadableStream is locked');
+
+</script>
Modules/speech/SpeechSynthesisVoice.idl
Modules/streams/ReadableStream.idl
+ Modules/streams/ReadableStreamReader.idl
Modules/vibration/NavigatorVibration.idl
Modules/speech/SpeechSynthesisVoice.cpp
Modules/streams/ReadableStream.cpp
+ Modules/streams/ReadableStreamReader.cpp
Modules/vibration/NavigatorVibration.cpp
Modules/vibration/Vibration.cpp
bindings/js/JSRTCSessionDescriptionCustom.cpp
bindings/js/JSRTCStatsResponseCustom.cpp
bindings/js/JSReadableStreamCustom.cpp
+ bindings/js/JSReadableStreamReaderCustom.cpp
bindings/js/ReadableStreamJSSource.cpp
bindings/js/JSRequestAnimationFrameCallbackCustom.cpp
bindings/js/JSSQLResultSetRowListCustom.cpp
+2015-03-31 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr>
+
+ [Streams API] Implement a barebone ReadableStreamReader interface
+ https://bugs.webkit.org/show_bug.cgi?id=142866
+
+ Reviewed by Benjamin Poulain.
+
+ This patch implements a barebone ReadableStreamReader as described in https://streams.spec.whatwg.org/#reader-class.
+ It implements the IDL without implementing most of the functionality behind.
+ It implements ReadableStreamReader JS constructor and the link with ReadableStream.getReader:
+ - Raise an error if stream is already locked
+ - Set the stream reader to the newly created ReadableStreamReader instance.
+
+ Test: streams/readablestreamreader-constructor.html
+
+ * CMakeLists.txt: Adding ReadableStreamReader files.
+ * DerivedSources.cpp: Ditto.
+ * DerivedSources.make: Ditto.
+ * Modules/streams/ReadableStream.cpp:
+ (WebCore::ReadableStream::createReader): Used by JS binding to get access to the reader.
+ * Modules/streams/ReadableStream.h: Declaration of createReader, reader and lock.
+ (WebCore::ReadableStream::reader):
+ (WebCore::ReadableStream::lock):
+ * Modules/streams/ReadableStream.idl: Cleaning-up the IDL.
+ * Modules/streams/ReadableStreamReader.cpp: Added.
+ (WebCore::ReadableStreamReader::create):
+ (WebCore::ReadableStreamReader::ReadableStreamReader):
+ (WebCore::ReadableStreamReader::~ReadableStreamReader):
+ (WebCore::ReadableStreamReader::closed):
+ (WebCore::ReadableStreamReader::activeDOMObjectName):
+ (WebCore::ReadableStreamReader::canSuspend):
+ * Modules/streams/ReadableStreamReader.h: Added.
+ (WebCore::ReadableStreamReader::stream):
+ * Modules/streams/ReadableStreamReader.idl: Added.
+ * WebCore.vcxproj/WebCore.vcxproj:
+ * WebCore.vcxproj/WebCore.vcxproj.filters:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSBindingsAllInOne.cpp:
+ * bindings/js/JSReadableStreamCustom.cpp:
+ (WebCore::JSReadableStream::getReader):
+ * bindings/js/JSReadableStreamReaderCustom.cpp: Added.
+ (WebCore::JSReadableStreamReader::read):
+ (WebCore::getOrCreatePromiseDeferredFromObject):
+ (WebCore::closedPromiseSlotName):
+ (WebCore::JSReadableStreamReader::closed):
+ (WebCore::JSReadableStreamReader::cancel):
+ (WebCore::JSReadableStreamReader::releaseLock):
+ (WebCore::constructJSReadableStreamReader):
+
2015-03-31 Carlos Garcia Campos <cgarcia@igalia.com>
[GTK] DnD icon/widget has odd background
#include "JSRangeException.cpp"
#if ENABLE(STREAMS_API)
#include "JSReadableStream.cpp"
+#include "JSReadableStreamReader.cpp"
#endif
#include "JSRect.cpp"
#include "JSRequestAnimationFrameCallback.cpp"
$(WebCore)/Modules/speech/SpeechSynthesisUtterance.idl \
$(WebCore)/Modules/speech/SpeechSynthesisVoice.idl \
$(WebCore)/Modules/streams/ReadableStream.idl \
+ $(WebCore)/Modules/streams/ReadableStreamReader.idl \
$(WebCore)/Modules/webaudio/AudioBuffer.idl \
$(WebCore)/Modules/webaudio/AudioBufferCallback.idl \
$(WebCore)/Modules/webaudio/AudioBufferSourceNode.idl \
#if ENABLE(STREAMS_API)
#include "NotImplemented.h"
+#include "ReadableStreamReader.h"
#include <wtf/RefCountedLeakCounter.h>
namespace WebCore {
return false;
}
+Ref<ReadableStreamReader> ReadableStream::createReader()
+{
+ return ReadableStreamReader::create(*this);
+}
+
}
#endif
namespace WebCore {
+class ReadableStreamReader;
class ScriptExecutionContext;
// ReadableStream implements the core of the streams API ReadableStream functionality.
static Ref<ReadableStream> create(ScriptExecutionContext&, Ref<ReadableStreamSource>&&);
virtual ~ReadableStream();
+ ReadableStreamReader* reader() { return m_reader; }
+ void lock(ReadableStreamReader& reader) { m_reader = &reader; }
+ void release() { m_reader = nullptr; }
+ Ref<ReadableStreamReader> createReader();
+
State internalState() { return m_state; }
private:
State m_state;
Ref<ReadableStreamSource> m_source;
+ ReadableStreamReader* m_reader { nullptr };
};
}
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-enum ReadableStreamStateType { "readable", "waiting", "closed", "errored" };
-
[
CustomConstructor(any properties),
Conditional=STREAMS_API
] interface ReadableStream {
// FIXME: Remove RaisesException once methods are actually implemented.
[Custom, RaisesException] Promise cancel(DOMString reason);
- [Custom, RaisesException] Object getReader();
+ [Custom, RaisesException] ReadableStreamReader getReader();
[Custom, RaisesException] Promise pipeTo(any streams, any options);
[Custom, RaisesException] Object pipeThrough(any dest, any options);
};
--- /dev/null
+/*
+ * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "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 CANON INC. AND ITS 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.
+ */
+
+#include "config.h"
+#include "ReadableStreamReader.h"
+
+#if ENABLE(STREAMS_API)
+
+#include "NotImplemented.h"
+#include <wtf/RefCountedLeakCounter.h>
+
+namespace WebCore {
+
+DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, readableStreamReaderCounter, ("ReadableStreamReader"));
+
+Ref<ReadableStreamReader> ReadableStreamReader::create(ReadableStream& stream)
+{
+ auto readableStreamReader = adoptRef(*new ReadableStreamReader(stream));
+ return readableStreamReader;
+}
+
+ReadableStreamReader::ReadableStreamReader(ReadableStream& stream)
+ : ActiveDOMObject(stream.scriptExecutionContext())
+{
+#ifndef NDEBUG
+ readableStreamReaderCounter.increment();
+#endif
+ suspendIfNeeded();
+ ASSERT_WITH_MESSAGE(!stream.reader(), "A ReadableStream cannot be locked by two readers at the same time.");
+ m_stream = &stream;
+ stream.lock(*this);
+}
+
+ReadableStreamReader::~ReadableStreamReader()
+{
+#ifndef NDEBUG
+ readableStreamReaderCounter.decrement();
+#endif
+ if (m_stream) {
+ m_stream->release();
+ m_stream = nullptr;
+ }
+}
+
+void ReadableStreamReader::closed(ClosedSuccessCallback, ClosedErrorCallback)
+{
+ notImplemented();
+}
+
+const char* ReadableStreamReader::activeDOMObjectName() const
+{
+ return "ReadableStreamReader";
+}
+
+bool ReadableStreamReader::canSuspend() const
+{
+ // FIXME: We should try and do better here.
+ return false;
+}
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "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 CANON INC. AND ITS 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.
+ */
+
+#ifndef ReadableStreamReader_h
+#define ReadableStreamReader_h
+
+#if ENABLE(STREAMS_API)
+
+#include "ActiveDOMObject.h"
+#include "ReadableStream.h"
+#include "ScriptWrappable.h"
+#include <functional>
+#include <wtf/Ref.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+// ReadableStreamReader implements the core of the streams API ReadableStreamReader functionality.
+// It handles in particular access to the chunks and state of a ReadableStream.
+// See https://streams.spec.whatwg.org/#reader-class for more information.
+class ReadableStreamReader : public ActiveDOMObject, public ScriptWrappable, public RefCounted<ReadableStreamReader> {
+public:
+ static Ref<ReadableStreamReader> create(ReadableStream&);
+ virtual ~ReadableStreamReader();
+
+ ReadableStream* stream() { return m_stream.get(); }
+
+ typedef std::function<void()> ClosedSuccessCallback;
+ typedef std::function<void()> ClosedErrorCallback;
+ void closed(ClosedSuccessCallback, ClosedErrorCallback);
+
+private:
+ ReadableStreamReader(ReadableStream&);
+
+ // ActiveDOMObject API.
+ const char* activeDOMObjectName() const override;
+ bool canSuspend() const override;
+
+ RefPtr<ReadableStream> m_stream;
+};
+
+}
+
+#endif
+
+#endif // ReadableStream_h
--- /dev/null
+/*
+ * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "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 CANON INC. AND ITS 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.
+ */
+
+[
+ ActiveDOMObject,
+ CustomConstructor(any properties),
+ Conditional=STREAMS_API
+] interface ReadableStreamReader {
+ // FIXME: Remove RaisesException once methods are implemented.
+ [Custom, RaisesException] Object read();
+ [Custom, RaisesException] Promise cancel(DOMString reason);
+ [Custom, RaisesException] void releaseLock();
+
+ [CustomGetter] readonly attribute Promise closed;
+};
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
+ <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSReadableStreamReader.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>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+ </ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSRect.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ClCompile Include="..\Modules\notifications\NotificationCenter.cpp" />
<ClCompile Include="..\Modules\notifications\WorkerGlobalScopeNotifications.cpp" />
<ClCompile Include="..\Modules\streams\ReadableStream.cpp" />
+ <ClCompile Include="..\Modules\streams\ReadableStreamReader.cpp" />
<ClCompile Include="..\Modules\webdatabase\ChangeVersionWrapper.cpp" />
<ClCompile Include="..\Modules\webdatabase\Database.cpp" />
<ClCompile Include="..\Modules\webdatabase\DatabaseAuthorizer.cpp" />
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
+ <ClCompile Include="..\bindings\js\JSReadableStreamReaderCustom.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>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+ </ClCompile>
<ClCompile Include="..\bindings\js\ReadableStreamJSSource.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSRange.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSRangeException.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSReadableStream.h" />
+ <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSReadableStreamReader.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSRect.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSRequestAnimationFrameCallback.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSRGBColor.h" />
<ClInclude Include="..\Modules\notifications\WorkerGlobalScopeNotifications.h" />
<ClInclude Include="..\Modules\plugins\PluginReplacement.h" />
<ClInclude Include="..\Modules\streams\ReadableStream.h" />
+ <ClInclude Include="..\Modules\streams\ReadableStreamReader.h" />
<ClInclude Include="..\Modules\streams\ReadableStreamSource.h" />
<ClInclude Include="..\Modules\webdatabase\AbstractDatabaseServer.h" />
<ClInclude Include="..\Modules\webdatabase\ChangeVersionData.h" />
<ClCompile Include="..\Modules\streams\ReadableStream.cpp">
<Filter>Modules\streams</Filter>
</ClCompile>
+ <ClCompile Include="..\Modules\streams\ReadableStreamReader.cpp">
+ <Filter>Modules\streams</Filter>
+ </ClCompile>
<ClCompile Include="..\Modules\webdatabase\ChangeVersionWrapper.cpp">
<Filter>Modules\webdatabase</Filter>
</ClCompile>
<ClCompile Include="..\bindings\js\JSReadableStreamCustom.cpp">
<Filter>bindings\js</Filter>
</ClCompile>
+ <ClCompile Include="..\bindings\js\JSReadableStreamReaderCustom.cpp">
+ <Filter>bindings\js</Filter>
+ </ClCompile>
<ClCompile Include="..\bindings\js\ReadableStreamJSSource.cpp">
<Filter>bindings\js</Filter>
</ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSReadableStream.cpp">
<Filter>DerivedSources</Filter>
</ClCompile>
+ <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSReadableStreamReader.cpp">
+ <Filter>DerivedSources</Filter>
+ </ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSRect.cpp">
<Filter>DerivedSources</Filter>
</ClCompile>
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSReadableStream.h">
<Filter>DerivedSources</Filter>
</ClInclude>
+ <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSReadableStreamReader.h">
+ <Filter>DerivedSources</Filter>
+ </ClInclude>
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSXMLHttpRequest.h">
<Filter>DerivedSources</Filter>
</ClInclude>
<ClInclude Include="..\Modules\streams\ReadableStream.h">
<Filter>Modules\streams</Filter>
</ClInclude>
+ <ClInclude Include="..\Modules\streams\ReadableStreamReader.h">
+ <Filter>Modules\streams</Filter>
+ </ClInclude>
<ClInclude Include="..\html\HTMLAttachmentElement.h">
<Filter>html</Filter>
</ClInclude>
4198BDF11A81143100B22FB5 /* ReadableStreamJSSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 4198BDEF1A81123600B22FB5 /* ReadableStreamJSSource.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 */; };
+ 419FAFAF1ABABD0C005B828B /* ReadableStreamReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 419FAFAC1ABABCD5005B828B /* ReadableStreamReader.h */; };
+ 419FAFB11ABABDED005B828B /* JSReadableStreamReaderCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 419FAFB01ABABD7B005B828B /* JSReadableStreamReaderCustom.cpp */; };
41A023EF1A39DB7A00F722CF /* ReadableStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41A023EB1A39DB7900F722CF /* ReadableStream.cpp */; };
41A023F01A39DB7A00F722CF /* ReadableStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 41A023EC1A39DB7900F722CF /* ReadableStream.h */; };
41A023F21A39DB7A00F722CF /* ReadableStreamSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 41A023EE1A39DB7A00F722CF /* ReadableStreamSource.h */; };
41A023F61A39DBCB00F722CF /* JSReadableStreamCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41A023F31A39DBCB00F722CF /* JSReadableStreamCustom.cpp */; };
- 41A024171A39FADC00F722CF /* JSReadableStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41A024151A39FADC00F722CF /* JSReadableStream.cpp */; };
- 41A024181A39FADC00F722CF /* JSReadableStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 41A024161A39FADC00F722CF /* JSReadableStream.h */; };
+ 41A024171A39FADC00F722CF /* JSReadableStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41A024151A39FADC00F722CF /* JSReadableStream.cpp */; }; 41A024181A39FADC00F722CF /* JSReadableStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 41A024161A39FADC00F722CF /* JSReadableStream.h */; };
+ 41A024271A39FADC00F722CF /* JSReadableStreamReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41A024251A39FADC00F722CF /* JSReadableStreamReader.cpp */; }; 41A024281A39FADC00F722CF /* JSReadableStreamReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 41A024162A39FADC00F722CF /* JSReadableStreamReader.h */; };
41A3D58E101C152D00316D07 /* DedicatedWorkerThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41A3D58C101C152D00316D07 /* DedicatedWorkerThread.cpp */; };
41A3D58F101C152D00316D07 /* DedicatedWorkerThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 41A3D58D101C152D00316D07 /* DedicatedWorkerThread.h */; };
41BF700C0FE86F49005E8DEC /* MessagePortChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
4198BDEF1A81123600B22FB5 /* ReadableStreamJSSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamJSSource.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>"; };
+ 419FAFAC1ABABCD5005B828B /* ReadableStreamReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamReader.h; sourceTree = "<group>"; };
+ 419FAFAD1ABABCD5005B828B /* ReadableStreamReader.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamReader.idl; sourceTree = "<group>"; };
+ 419FAFB01ABABD7B005B828B /* JSReadableStreamReaderCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamReaderCustom.cpp; sourceTree = "<group>"; };
41A023EB1A39DB7900F722CF /* ReadableStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadableStream.cpp; sourceTree = "<group>"; };
41A023EC1A39DB7900F722CF /* ReadableStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStream.h; sourceTree = "<group>"; };
41A023ED1A39DB7900F722CF /* ReadableStream.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStream.idl; sourceTree = "<group>"; };
41A023F31A39DBCB00F722CF /* JSReadableStreamCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamCustom.cpp; sourceTree = "<group>"; };
41A024151A39FADC00F722CF /* JSReadableStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStream.cpp; sourceTree = "<group>"; };
41A024161A39FADC00F722CF /* JSReadableStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStream.h; sourceTree = "<group>"; };
+ 41A024251A39FADC00F722CF /* JSReadableStreamReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamReader.cpp; sourceTree = "<group>"; };
+ 41A024261A39FADC00F722CF /* JSReadableStreamReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamReader.h; sourceTree = "<group>"; };
41A3D58C101C152D00316D07 /* DedicatedWorkerThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DedicatedWorkerThread.cpp; path = workers/DedicatedWorkerThread.cpp; sourceTree = "<group>"; };
41A3D58D101C152D00316D07 /* DedicatedWorkerThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DedicatedWorkerThread.h; path = workers/DedicatedWorkerThread.h; sourceTree = "<group>"; };
41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessagePortChannel.h; sourceTree = "<group>"; };
41A023EB1A39DB7900F722CF /* ReadableStream.cpp */,
41A023EC1A39DB7900F722CF /* ReadableStream.h */,
41A023ED1A39DB7900F722CF /* ReadableStream.idl */,
+ 419FAFAB1ABABCD5005B828B /* ReadableStreamReader.cpp */,
+ 419FAFAC1ABABCD5005B828B /* ReadableStreamReader.h */,
+ 419FAFAD1ABABCD5005B828B /* ReadableStreamReader.idl */,
41A023EE1A39DB7A00F722CF /* ReadableStreamSource.h */,
);
path = streams;
children = (
41A024151A39FADC00F722CF /* JSReadableStream.cpp */,
41A024161A39FADC00F722CF /* JSReadableStream.h */,
+ 41A024251A39FADC00F722CF /* JSReadableStreamReader.cpp */,
+ 41A024261A39FADC00F722CF /* JSReadableStreamReader.h */,
);
name = Streams;
sourceTree = "<group>";
FD8AA63D169514A700D2EA68 /* JSPannerNodeCustom.cpp */,
A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
41A023F31A39DBCB00F722CF /* JSReadableStreamCustom.cpp */,
+ 419FAFB01ABABD7B005B828B /* JSReadableStreamReaderCustom.cpp */,
4998AED313FC417F0090B1AA /* JSRequestAnimationFrameCallbackCustom.cpp */,
4AE0BF881836083100F3852D /* JSRTCIceCandidateCustom.cpp */,
07CA120D182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp */,
65DF320209D1CC60000BE325 /* JSRange.h in Headers */,
D23CA55D0AB0EAAE005108A5 /* JSRangeException.h in Headers */,
41A024181A39FADC00F722CF /* JSReadableStream.h in Headers */,
+ 41A024281A39FADC00F722CF /* JSReadableStreamReader.h in Headers */,
BCFE2F120C1B58380020235F /* JSRect.h in Headers */,
4998AECE13F9D6C90090B1AA /* JSRequestAnimationFrameCallback.h in Headers */,
BC74DA491013F468007987AD /* JSRGBColor.h in Headers */,
B2227AAC0D00BF220071B782 /* SVGStringList.h in Headers */,
B2227AB80D00BF220071B782 /* SVGStyleElement.h in Headers */,
B2227ABB0D00BF220071B782 /* SVGSVGElement.h in Headers */,
+ 419FAFAF1ABABD0C005B828B /* ReadableStreamReader.h in Headers */,
D3F3D3681A69B1A50059FC2B /* JSWebGLRenderingContextBase.h in Headers */,
B2227ABE0D00BF220071B782 /* SVGSwitchElement.h in Headers */,
B2227AC10D00BF220071B782 /* SVGSymbolElement.h in Headers */,
65DF320109D1CC60000BE325 /* JSRange.cpp in Sources */,
D23CA55F0AB0EAB6005108A5 /* JSRangeException.cpp in Sources */,
41A024171A39FADC00F722CF /* JSReadableStream.cpp in Sources */,
+ 41A024271A39FADC00F722CF /* JSReadableStreamReader.cpp in Sources */,
41A023F61A39DBCB00F722CF /* JSReadableStreamCustom.cpp in Sources */,
BCFE2F110C1B58370020235F /* JSRect.cpp in Sources */,
4998AECD13F9D6C90090B1AA /* JSRequestAnimationFrameCallback.cpp in Sources */,
B525A96611CA2340003A23A8 /* JSSQLException.cpp in Sources */,
1AE82FEC0CAB07EE002237AE /* JSSQLResultSet.cpp in Sources */,
1AFE11990CBFFCC4003017FA /* JSSQLResultSetRowList.cpp in Sources */,
+ 419FAFB11ABABDED005B828B /* JSReadableStreamReaderCustom.cpp in Sources */,
51DCE8020CAC9F1C00488358 /* JSSQLResultSetRowListCustom.cpp in Sources */,
B59DD6A611902A62007E9684 /* JSSQLStatementCallback.cpp in Sources */,
B59DD6AA11902A71007E9684 /* JSSQLStatementErrorCallback.cpp in Sources */,
9380F47809A11ACC001FDB34 /* WidgetMac.mm in Sources */,
939B02EE0EA2DBC400C54570 /* WidthIterator.cpp in Sources */,
BC8243E80D0CFD7500460C8F /* WindowFeatures.cpp in Sources */,
+ 419FAFAE1ABABD08005B828B /* ReadableStreamReader.cpp in Sources */,
7E99AF510B13846468FB01A5 /* WindowFocusAllowedIndicator.cpp in Sources */,
A14832BD187F64B400DA63A6 /* WKContentObservation.cpp in Sources */,
A14832C0187F656600DA63A6 /* WKGraphics.mm in Sources */,
#include "JSPopStateEventCustom.cpp"
#if ENABLE(STREAMS_API)
#include "JSReadableStreamCustom.cpp"
+#include "JSReadableStreamReaderCustom.cpp"
#include "ReadableStreamJSSource.cpp"
#endif
#include "JSRequestAnimationFrameCallbackCustom.cpp"
#include "ExceptionCode.h"
#include "JSDOMPromise.h"
+#include "JSReadableStreamReader.h"
#include "ReadableStream.h"
#include "ReadableStreamJSSource.h"
+#include "ReadableStreamReader.h"
#include <wtf/NeverDestroyed.h>
using namespace JSC;
JSValue JSReadableStream::getReader(ExecState* exec)
{
- JSValue error = createError(exec, ASCIILiteral("getReader is not implemented"));
- return exec->vm().throwException(exec, error);
+ if (impl().reader())
+ return exec->vm().throwException(exec, createTypeError(exec, ASCIILiteral("ReadableStream is locked")));
+ return toJS(exec, globalObject(), impl().createReader());
}
JSValue JSReadableStream::pipeTo(ExecState* exec)
--- /dev/null
+/*
+ * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "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 CANON INC. AND ITS 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.
+ */
+
+#include "config.h"
+
+#if ENABLE(STREAMS_API)
+#include "JSReadableStreamReader.h"
+
+#include "ExceptionCode.h"
+#include "JSDOMPromise.h"
+#include "JSReadableStream.h"
+#include "ReadableStreamJSSource.h"
+#include <runtime/Error.h>
+#include <wtf/NeverDestroyed.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSValue JSReadableStreamReader::read(ExecState* exec)
+{
+ JSValue error = createError(exec, ASCIILiteral("read is not implemented"));
+ 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);
+ auto successCallback = [this, wrapper]() mutable {
+ // FIXME: return jsUndefined().
+ wrapper.resolve(&impl());
+ };
+ auto failureCallback = [this, wrapper]() mutable {
+ // FIXME: return stored error.
+ wrapper.reject(&impl());
+ };
+
+ impl().closed(WTF::move(successCallback), WTF::move(failureCallback));
+
+ return wrapper.promise();
+}
+
+JSValue JSReadableStreamReader::cancel(ExecState* exec)
+{
+ JSValue error = createError(exec, ASCIILiteral("cancel is not implemented"));
+ return exec->vm().throwException(exec, error);
+}
+
+JSValue JSReadableStreamReader::releaseLock(ExecState* exec)
+{
+ JSValue error = createError(exec, ASCIILiteral("releaseLock is not implemented"));
+ return exec->vm().throwException(exec, error);
+}
+
+EncodedJSValue JSC_HOST_CALL constructJSReadableStreamReader(ExecState* exec)
+{
+ if (!exec->argumentCount())
+ return throwVMError(exec, createTypeError(exec, ASCIILiteral("ReadableStreamReader constructor takes a ReadableStream as parameter")));
+
+ JSReadableStream* stream = jsDynamicCast<JSReadableStream*>(exec->argument(0));
+ if (!stream)
+ return throwVMError(exec, createTypeError(exec, ASCIILiteral("ReadableStreamReader constructor parameter is not a ReadableStream")));
+
+ if (stream->impl().reader())
+ return throwVMError(exec, createTypeError(exec, ASCIILiteral("ReadableStreamReader constructor parameter is a locked ReadableStream")));
+
+ return JSValue::encode(toJS(exec, stream->globalObject(), stream->impl().createReader()));
+}
+
+} // namespace WebCore
+
+#endif
ReadableStreamJSSource::ReadableStreamJSSource(JSC::ExecState* exec)
{
if (exec->argumentCount()) {
- ASSERT(exec->argument(0).isObject());
+ ASSERT_WITH_MESSAGE(exec->argument(0).isObject(), "Caller of ReadableStreamJSSource constructor should ensure that passed argument is an object.");
// FIXME: Implement parameters support;
}
}