<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[185406] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/185406">185406</a></dd>
<dt>Author</dt> <dd>youenn.fablet@crf.canon.fr</dd>
<dt>Date</dt> <dd>2015-06-10 01:09:02 -0700 (Wed, 10 Jun 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Streams API] Implement pulling of a source by a ReadableStream
https://bugs.webkit.org/show_bug.cgi?id=145262
Reviewed by Darin Adler
Source/WebCore:
Introduced abstract ReadableStream::doPull() which is overriden in ReadableJSStream.
Added support to call the "pull" JS callback in ReadableJSStream::doPull().
Added calls to pull as requested by the spec (when resolving a read callback, at start time...).
Fixed issue in ReadableStreamReader::read() (use of successCallback(JSValue()) in lieu of endCallback())
Covered by rebased tests.
* Modules/streams/ReadableStream.cpp:
(WebCore::ReadableStream::start): calling pull() once start.
(WebCore::ReadableStream::pull): calling doPull() if readableStream states requires to.
(WebCore::ReadableStream::read): calling pull() after resolving a read callback.
* Modules/streams/ReadableStream.h:
* Modules/streams/ReadableStreamReader.cpp:
(WebCore::ReadableStreamReader::read): fixed JSValue() bug.
* bindings/js/ReadableJSStream.cpp:
(WebCore::ReadableJSStream::doPull): calling of JS callback.
(WebCore::ReadableJSStream::storeException): catches exception and store them.
(WebCore::ReadableJSStream::storeError): refactoring for checkForException.
(WebCore::ReadableJSStream::enqueue):
* bindings/js/ReadableJSStream.h:
LayoutTests:
Rebased expectations, removed some "timeout: 50" parameters.
Removed a test from streams/reference-implementation/readable-stream.html that cannot pass
until promises returned to start and pull JS callbacks are handled.
Fixed bug in streams-utils.js (was using the old API replaced by controller).
* streams/reference-implementation/bad-underlying-sources-expected.txt:
* streams/reference-implementation/bad-underlying-sources.html:
* streams/reference-implementation/readable-stream-expected.txt:
* streams/reference-implementation/readable-stream.html:
* streams/reference-implementation/resources/streams-utils.js:
(.stream.new.ReadableStream.):
(.stream.new.ReadableStream):
(sequentialReadableStream):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationbadunderlyingsourcesexpectedtxt">trunk/LayoutTests/streams/reference-implementation/bad-underlying-sources-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationbadunderlyingsourceshtml">trunk/LayoutTests/streams/reference-implementation/bad-underlying-sources.html</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationreadablestreamexpectedtxt">trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationreadablestreamhtml">trunk/LayoutTests/streams/reference-implementation/readable-stream.html</a></li>
<li><a href="#trunkLayoutTestsstreamsreferenceimplementationresourcesstreamsutilsjs">trunk/LayoutTests/streams/reference-implementation/resources/streams-utils.js</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamcpp">trunk/Source/WebCore/Modules/streams/ReadableStream.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamh">trunk/Source/WebCore/Modules/streams/ReadableStream.h</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamReadercpp">trunk/Source/WebCore/Modules/streams/ReadableStreamReader.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsReadableJSStreamcpp">trunk/Source/WebCore/bindings/js/ReadableJSStream.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsReadableJSStreamh">trunk/Source/WebCore/bindings/js/ReadableJSStream.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/LayoutTests/ChangeLog        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2015-06-10 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr>
+
+ [Streams API] Implement pulling of a source by a ReadableStream
+ https://bugs.webkit.org/show_bug.cgi?id=145262
+
+ Reviewed by Darin Adler
+
+ Rebased expectations, removed some "timeout: 50" parameters.
+ Removed a test from streams/reference-implementation/readable-stream.html that cannot pass
+ until promises returned to start and pull JS callbacks are handled.
+ Fixed bug in streams-utils.js (was using the old API replaced by controller).
+
+ * streams/reference-implementation/bad-underlying-sources-expected.txt:
+ * streams/reference-implementation/bad-underlying-sources.html:
+ * streams/reference-implementation/readable-stream-expected.txt:
+ * streams/reference-implementation/readable-stream.html:
+ * streams/reference-implementation/resources/streams-utils.js:
+ (.stream.new.ReadableStream.):
+ (.stream.new.ReadableStream):
+ (sequentialReadableStream):
+
</ins><span class="cx"> 2015-06-09 Daegyu Lee <daegyu.lee@navercorp.com>
</span><span class="cx">
</span><span class="cx"> 3D-transformed video does not display on platforms without accelerated video rendering
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationbadunderlyingsourcesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/bad-underlying-sources-expected.txt (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/bad-underlying-sources-expected.txt        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/LayoutTests/streams/reference-implementation/bad-underlying-sources-expected.txt        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -1,10 +1,10 @@
</span><span class="cx">
</span><span class="cx"> PASS Underlying source start: throwing getter
</span><span class="cx"> PASS Underlying source start: throwing method
</span><del>-TIMEOUT Underlying source: throwing pull getter (initial pull) Test timed out
-TIMEOUT Underlying source: throwing pull method (initial pull) Test timed out
-TIMEOUT Underlying source: throwing pull getter (second pull) Test timed out
-TIMEOUT Underlying source: throwing pull method (second pull) Test timed out
</del><ins>+PASS Underlying source: throwing pull getter (initial pull)
+PASS Underlying source: throwing pull method (initial pull)
+PASS Underlying source: throwing pull getter (second pull)
+PASS Underlying source: throwing pull method (second pull)
</ins><span class="cx"> FAIL Underlying source: throwing cancel getter cancel is not implemented
</span><span class="cx"> FAIL Underlying source: throwing cancel method cancel is not implemented
</span><span class="cx"> FAIL Underlying source: throwing strategy getter assert_throws: enqueue should throw the error function "function () { c.enqueue('a'); }" did not throw
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationbadunderlyingsourceshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/bad-underlying-sources.html (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/bad-underlying-sources.html        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/LayoutTests/streams/reference-implementation/bad-underlying-sources.html        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -27,7 +27,7 @@
</span><span class="cx"> }, 'constructing the stream should re-throw the error');
</span><span class="cx"> }, 'Underlying source start: throwing method');
</span><span class="cx">
</span><del>-var test1 = async_test('Underlying source: throwing pull getter (initial pull)', { timeout: 50 });
</del><ins>+var test1 = async_test('Underlying source: throwing pull getter (initial pull)');
</ins><span class="cx"> test1.step(function() {
</span><span class="cx"> var theError = new Error('a unique string');
</span><span class="cx"> var rs = new ReadableStream({
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx"> }));
</span><span class="cx"> });
</span><span class="cx">
</span><del>-var test2 = async_test('Underlying source: throwing pull method (initial pull)', { timeout: 50 });
</del><ins>+var test2 = async_test('Underlying source: throwing pull method (initial pull)');
</ins><span class="cx"> test2.step(function() {
</span><span class="cx"> var theError = new Error('a unique string');
</span><span class="cx"> var rs = new ReadableStream({
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx"> }));
</span><span class="cx"> });
</span><span class="cx">
</span><del>-var test3 = async_test('Underlying source: throwing pull getter (second pull)', { timeout: 50 });
</del><ins>+var test3 = async_test('Underlying source: throwing pull getter (second pull)');
</ins><span class="cx"> test3.step(function() {
</span><span class="cx"> var theError = new Error('a unique string');
</span><span class="cx"> var counter = 0;
</span><span class="lines">@@ -89,7 +89,7 @@
</span><span class="cx"> }));
</span><span class="cx"> });
</span><span class="cx">
</span><del>-var test4 = async_test('Underlying source: throwing pull method (second pull)', { timeout: 50 });
</del><ins>+var test4 = async_test('Underlying source: throwing pull method (second pull)');
</ins><span class="cx"> test4.step(function() {
</span><span class="cx"> var theError = new Error('a unique string');
</span><span class="cx"> var counter = 0;
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationreadablestreamexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream-expected.txt        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -10,10 +10,10 @@
</span><span class="cx"> PASS ReadableStream should be able to enqueue different objects.
</span><span class="cx"> PASS ReadableStream: if start throws an error, it should be re-thrown
</span><span class="cx"> TIMEOUT ReadableStream: if pull rejects, it should error the stream Test timed out
</span><del>-FAIL ReadableStream: should not call pull until the previous pull call's promise fulfills assert_equals: pull should have been called once after start, but not yet have been called a second time expected 1 but got 0
</del><ins>+FAIL ReadableStream: should not call pull until the previous pull call's promise fulfills assert_equals: after the promise returned by pull is fulfilled, pull should be called a second time expected 2 but got 1
</ins><span class="cx"> PASS ReadableStream: should not call pull after start if the stream is now closed
</span><del>-FAIL ReadableStream: should call pull after enqueueing from inside pull (with no read requests), if strategy allows assert_equals: pull() should have been called four times expected 4 but got 0
-TIMEOUT ReadableStream pull should be able to close a stream. Test timed out
</del><ins>+FAIL ReadableStream: should call pull after enqueueing from inside pull (with no read requests), if strategy allows assert_equals: pull() should have been called four times expected 4 but got 1
+PASS ReadableStream pull should be able to close a stream.
</ins><span class="cx"> FAIL ReadableStream: enqueue should throw when the stream is readable but draining assert_equals: the first enqueue should return true expected (boolean) true but got (undefined) undefined
</span><span class="cx"> PASS ReadableStream: enqueue should throw when the stream is closed
</span><span class="cx"> PASS ReadableStream: enqueue should throw the stored error when the stream is errored
</span><span class="lines">@@ -21,6 +21,5 @@
</span><span class="cx"> FAIL ReadableStream strategies: the default strategy should return false for all but the first enqueue call assert_equals: first enqueue should return true expected (boolean) true but got (undefined) undefined
</span><span class="cx"> FAIL ReadableStream strategies: the default strategy should continue returning true from enqueue if the chunks are read immediately assert_equals: first enqueue should return true expected (boolean) true but got (undefined) undefined
</span><span class="cx"> TIMEOUT ReadableStream integration test: adapting a random push source Test timed out
</span><del>-TIMEOUT ReadableStream integration test: adapting a sync pull source Test timed out
-TIMEOUT ReadableStream integration test: adapting an async pull source Test timed out
</del><ins>+PASS ReadableStream integration test: adapting a sync pull source
</ins><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationreadablestreamhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/readable-stream.html (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/readable-stream.html        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/LayoutTests/streams/reference-implementation/readable-stream.html        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -516,7 +516,7 @@
</span><span class="cx"> }));
</span><span class="cx"> });
</span><span class="cx">
</span><del>-var test15 = async_test('ReadableStream pull should be able to close a stream.', { timeout: 50 });
</del><ins>+var test15 = async_test('ReadableStream pull should be able to close a stream.');
</ins><span class="cx"> test15.step(function() {
</span><span class="cx"> var pullCalled = false;
</span><span class="cx"> var rs = new ReadableStream({
</span><span class="lines">@@ -702,7 +702,7 @@
</span><span class="cx"> }), test18.step_func(function(e) { assert_reached(e); }));
</span><span class="cx"> });
</span><span class="cx">
</span><del>-var test19 = async_test('ReadableStream integration test: adapting a sync pull source', { timeout: 50 });
</del><ins>+var test19 = async_test('ReadableStream integration test: adapting a sync pull source');
</ins><span class="cx"> test19.step(function() {
</span><span class="cx"> var rs = sequentialReadableStream(10);
</span><span class="cx">
</span><span class="lines">@@ -713,7 +713,7 @@
</span><span class="cx"> test19.done();
</span><span class="cx"> }));
</span><span class="cx"> });
</span><del>-
</del><ins>+/*
</ins><span class="cx"> var test20 = async_test('ReadableStream integration test: adapting an async pull source', { timeout: 50 });
</span><span class="cx"> test20.step(function() {
</span><span class="cx"> var rs = sequentialReadableStream(10, { async: true });
</span><span class="lines">@@ -725,4 +725,5 @@
</span><span class="cx"> test20.done();
</span><span class="cx"> }));
</span><span class="cx"> });
</span><ins>+*/
</ins><span class="cx"> </script>
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsreferenceimplementationresourcesstreamsutilsjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/reference-implementation/resources/streams-utils.js (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/reference-implementation/resources/streams-utils.js        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/LayoutTests/streams/reference-implementation/resources/streams-utils.js        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -150,25 +150,27 @@
</span><span class="cx"> sequentialSource.open(function(err) {
</span><span class="cx"> if (err) {
</span><span class="cx"> reject(err);
</span><ins>+ return;
</ins><span class="cx"> }
</span><span class="cx"> resolve();
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> },
</span><span class="cx">
</span><del>- pull: function(enqueue, finish, error) {
</del><ins>+ pull: function(c) {
</ins><span class="cx"> sequentialSource.read(function(err, done, chunk) {
</span><span class="cx"> if (err) {
</span><del>- error(err);
</del><ins>+ c.error(err);
</ins><span class="cx"> } else if (done) {
</span><span class="cx"> sequentialSource.close(function(err) {
</span><span class="cx"> if (err) {
</span><del>- error(err);
</del><ins>+ c.error(err);
+ return;
</ins><span class="cx"> }
</span><del>- finish();
</del><ins>+ c.close();
</ins><span class="cx"> });
</span><span class="cx"> } else {
</span><del>- enqueue(chunk);
</del><ins>+ c.enqueue(chunk);
</ins><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx"> },
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/Source/WebCore/ChangeLog        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2015-06-10 Xabier Rodriguez Calvar <calvaris@igalia.com> and Youenn Fablet <youenn.fablet@crf.canon.fr>
+
+ [Streams API] Implement pulling of a source by a ReadableStream
+ https://bugs.webkit.org/show_bug.cgi?id=145262
+
+ Reviewed by Darin Adler
+
+ Introduced abstract ReadableStream::doPull() which is overriden in ReadableJSStream.
+ Added support to call the "pull" JS callback in ReadableJSStream::doPull().
+ Added calls to pull as requested by the spec (when resolving a read callback, at start time...).
+
+ Fixed issue in ReadableStreamReader::read() (use of successCallback(JSValue()) in lieu of endCallback())
+
+ Covered by rebased tests.
+
+ * Modules/streams/ReadableStream.cpp:
+ (WebCore::ReadableStream::start): calling pull() once start.
+ (WebCore::ReadableStream::pull): calling doPull() if readableStream states requires to.
+ (WebCore::ReadableStream::read): calling pull() after resolving a read callback.
+ * Modules/streams/ReadableStream.h:
+ * Modules/streams/ReadableStreamReader.cpp:
+ (WebCore::ReadableStreamReader::read): fixed JSValue() bug.
+ * bindings/js/ReadableJSStream.cpp:
+ (WebCore::ReadableJSStream::doPull): calling of JS callback.
+ (WebCore::ReadableJSStream::storeException): catches exception and store them.
+ (WebCore::ReadableJSStream::storeError): refactoring for checkForException.
+ (WebCore::ReadableJSStream::enqueue):
+ * bindings/js/ReadableJSStream.h:
+
</ins><span class="cx"> 2015-06-09 Youenn Fablet <youenn.fablet@crf.canon.fr>
</span><span class="cx">
</span><span class="cx"> DeferredWrapper should clear its JS strong references once its promise is resolved/rejected
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStream.cpp (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStream.cpp        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/Source/WebCore/Modules/streams/ReadableStream.cpp        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -112,6 +112,23 @@
</span><span class="cx"> clearCallbacks();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void ReadableStream::start()
+{
+ m_isStarted = true;
+ pull();
+}
+
+void ReadableStream::pull()
+{
+ if (!m_isStarted || m_state == State::Closed || m_state == State::Errored || m_closeRequested)
+ return;
+ // FIXME: Implement queueSize check.
+ if (m_readRequests.isEmpty() && hasValue())
+ return;
+ // FIXME: Implement async pull check.
+ doPull();
+}
+
</ins><span class="cx"> ReadableStreamReader& ReadableStream::getReader()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!m_reader);
</span><span class="lines">@@ -154,12 +171,14 @@
</span><span class="cx"> }
</span><span class="cx"> if (hasValue()) {
</span><span class="cx"> successCallback(read());
</span><del>- if (m_closeRequested && !hasValue())
</del><ins>+ if (!m_closeRequested)
+ pull();
+ else if (!hasValue())
</ins><span class="cx"> close();
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx"> m_readRequests.append({ WTF::move(successCallback), WTF::move(endCallback), WTF::move(failureCallback) });
</span><del>- // FIXME: We should try to pull.
</del><ins>+ pull();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool ReadableStream::resolveReadCallback(JSC::JSValue value)
</span><span class="lines">@@ -171,11 +190,6 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void ReadableStream::start()
-{
- notImplemented();
-}
-
</del><span class="cx"> const char* ReadableStream::activeDOMObjectName() const
</span><span class="cx"> {
</span><span class="cx"> return "ReadableStream";
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStream.h (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStream.h        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/Source/WebCore/Modules/streams/ReadableStream.h        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -89,6 +89,7 @@
</span><span class="cx"> explicit ReadableStream(ScriptExecutionContext&);
</span><span class="cx">
</span><span class="cx"> bool resolveReadCallback(JSC::JSValue);
</span><ins>+ void pull();
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> // ActiveDOMObject API.
</span><span class="lines">@@ -100,6 +101,7 @@
</span><span class="cx">
</span><span class="cx"> virtual bool hasValue() const = 0;
</span><span class="cx"> virtual JSC::JSValue read() = 0;
</span><ins>+ virtual void doPull() = 0;
</ins><span class="cx">
</span><span class="cx"> std::unique_ptr<ReadableStreamReader> m_reader;
</span><span class="cx"> Vector<std::unique_ptr<ReadableStreamReader>> m_releasedReaders;
</span><span class="lines">@@ -114,6 +116,7 @@
</span><span class="cx"> };
</span><span class="cx"> Deque<ReadCallbacks> m_readRequests;
</span><span class="cx">
</span><ins>+ bool m_isStarted { false };
</ins><span class="cx"> bool m_closeRequested { false };
</span><span class="cx"> State m_state { State::Readable };
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamReadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamReader.cpp (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStreamReader.cpp        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamReader.cpp        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> void ReadableStreamReader::read(ReadableStream::ReadSuccessCallback&& successCallback, ReadableStream::ReadEndCallback&& endCallback, ReadableStream::FailureCallback&& failureCallback)
</span><span class="cx"> {
</span><span class="cx"> if (m_stream.isReadable() && m_stream.reader() != this) {
</span><del>- successCallback(JSC::JSValue());
</del><ins>+ endCallback();
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx"> m_stream.read(WTF::move(successCallback), WTF::move(endCallback), WTF::move(failureCallback));
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsReadableJSStreamcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/ReadableJSStream.cpp (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ReadableJSStream.cpp        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/Source/WebCore/bindings/js/ReadableJSStream.cpp        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> #include "NotImplemented.h"
</span><span class="cx"> #include "ScriptExecutionContext.h"
</span><span class="cx"> #include <runtime/Error.h>
</span><ins>+#include <runtime/Exception.h>
</ins><span class="cx"> #include <runtime/JSCJSValueInlines.h>
</span><span class="cx"> #include <runtime/JSString.h>
</span><span class="cx"> #include <runtime/StructureInlines.h>
</span><span class="lines">@@ -102,6 +103,21 @@
</span><span class="cx"> startReadableStreamAsync(*this);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void ReadableJSStream::doPull()
+{
+ ExecState& state = *globalObject()->globalExec();
+ JSLockHolder lock(&state);
+
+ invoke(state, "pull");
+
+ if (state.hadException()) {
+ storeException(state);
+ ASSERT(!state.hadException());
+ return;
+ }
+ // FIXME: Implement handling promise as result of calling pull function.
+}
+
</ins><span class="cx"> RefPtr<ReadableJSStream> ReadableJSStream::create(ExecState& exec, ScriptExecutionContext& scriptExecutionContext)
</span><span class="cx"> {
</span><span class="cx"> JSObject* jsSource;
</span><span class="lines">@@ -136,11 +152,22 @@
</span><span class="cx"> return toJS(&exec, globalObject, m_controller.get());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void ReadableJSStream::storeException(JSC::ExecState& state)
+{
+ JSValue exception = state.exception()->value();
+ state.clearException();
+ storeError(state, exception);
+}
+
</ins><span class="cx"> void ReadableJSStream::storeError(JSC::ExecState& exec)
</span><span class="cx"> {
</span><ins>+ storeError(exec, exec.argumentCount() ? exec.argument(0) : createError(&exec, ASCIILiteral("Error function called.")));
+}
+
+void ReadableJSStream::storeError(JSC::ExecState& exec, JSValue error)
+{
</ins><span class="cx"> if (m_error)
</span><span class="cx"> return;
</span><del>- JSValue error = exec.argumentCount() ? exec.argument(0) : createError(&exec, ASCIILiteral("Error function called."));
</del><span class="cx"> m_error.set(exec.vm(), error);
</span><span class="cx">
</span><span class="cx"> changeStateToErrored();
</span><span class="lines">@@ -166,12 +193,14 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> JSValue chunk = exec.argumentCount() ? exec.argument(0) : jsUndefined();
</span><del>- if (resolveReadCallback(chunk))
</del><ins>+ if (resolveReadCallback(chunk)) {
+ pull();
</ins><span class="cx"> return;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> m_chunkQueue.append(JSC::Strong<JSC::Unknown>(exec.vm(), chunk));
</span><span class="cx"> // FIXME: Compute chunk size.
</span><del>- // FIXME: Add pulling of data here and also when data is passed to resolve callback.
</del><ins>+ pull();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsReadableJSStreamh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/ReadableJSStream.h (185405 => 185406)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ReadableJSStream.h        2015-06-10 07:29:36 UTC (rev 185405)
+++ trunk/Source/WebCore/bindings/js/ReadableJSStream.h        2015-06-10 08:09:02 UTC (rev 185406)
</span><span class="lines">@@ -62,9 +62,12 @@
</span><span class="cx"> void doStart(JSC::ExecState&);
</span><span class="cx">
</span><span class="cx"> JSC::JSValue invoke(JSC::ExecState&, const char*);
</span><ins>+ void storeException(JSC::ExecState&);
+ void storeError(JSC::ExecState&, JSC::JSValue);
</ins><span class="cx">
</span><span class="cx"> virtual bool hasValue() const override;
</span><span class="cx"> virtual JSC::JSValue read() override;
</span><ins>+ virtual void doPull() override;
</ins><span class="cx">
</span><span class="cx"> JSDOMGlobalObject* globalObject();
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>