<!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>[199641] 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/199641">199641</a></dd>
<dt>Author</dt> <dd>youenn.fablet@crf.canon.fr</dd>
<dt>Date</dt> <dd>2016-04-17 11:04:20 -0700 (Sun, 17 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>LayoutTests/imported/w3c:
[Fetch API] Consume HTTP data as a ReadableStream
https://bugs.webkit.org/show_bug.cgi?id=138968

Reviewed by Alex Christensen.

* web-platform-tests/fetch/api/basic/stream-response-expected.txt:
* web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt:
* web-platform-tests/fetch/api/request/request-consume.html:
* web-platform-tests/fetch/api/resources/data.json: Added.
* web-platform-tests/fetch/api/resources/utils.js:
(validateStreamFromString):
* web-platform-tests/fetch/api/response/response-cancel-stream-expected.txt: Added.
* web-platform-tests/fetch/api/response/response-cancel-stream.html: Added.
* web-platform-tests/fetch/api/response/response-clone-expected.txt:
* web-platform-tests/fetch/api/response/response-consume-stream-expected.txt: Added.
* web-platform-tests/fetch/api/response/response-consume-stream.html: Added.
* web-platform-tests/fetch/api/response/response-init-002-expected.txt:
* web-platform-tests/fetch/api/response/response-stream-disturbed-expected-1.txt: Added.
* web-platform-tests/fetch/api/response/response-stream-disturbed-1.html: Added.
* web-platform-tests/fetch/api/response/response-stream-disturbed-expected-2.txt: Added.
* web-platform-tests/fetch/api/response/response-stream-disturbed-2.html: Added.
* web-platform-tests/fetch/api/response/response-stream-disturbed-expected-3.txt: Added.
* web-platform-tests/fetch/api/response/response-stream-disturbed-3.html: Added.
* web-platform-tests/fetch/api/response/response-stream-disturbed-expected-4.txt: Added.
* web-platform-tests/fetch/api/response/response-stream-disturbed-4.html: Added.
* web-platform-tests/fetch/api/response/response-stream-disturbed-expected-5.txt: Added.
* web-platform-tests/fetch/api/response/response-stream-disturbed-5.html: Added.

Source/WebCore:
[Fetch API] Consume HTTP data as a ReadableStream
https://bugs.webkit.org/show_bug.cgi?id=138968

Reviewed by Alex Christensen.

This patch introduces ReadableStreamSource and ReadableStreamController which allow feeding a ReadableStream from DOM classes.
ReadableStreamSource is a base class for all DOM ReadableStream sources.
ReadableStreamController is a wrapper around JSReadableStreamController that can be invoked by DOM code to enqueue/close/error a ReadableStream.
A createReadableStream function is introduced to allow DOM classes creating ReadableStream.

Added support for a FetchResponse ReadableStream source.
Both synthetic FetchResponse and loading FetchResponse are supported.
A new &quot;Stream&quot; FetchLoader::Type is introduced to allow receiving data as chunks and feeding them to a ReadableStream through ReadableStreamSource.

Currently, FetchResponse is consumed and marked as disturbed as soon as a ReadableStreamSource is created.
This should be changed so that consumption happens on the first read call to the ReadableStreamReader, i.e. when stream gets disturbed.

FetchResponseSource never fulfills the start promise, which allows to enqueue, error or close the stream at any time.
FetchResponseSource must therefore always ensure to close or error the stream.
Added support for locked check in FetchResponse.

Tests: imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html
       imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream.html
       imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1.html
       imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2.html
       imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-3.html
       imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4.html
       imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5.html
Also covered by rebased tests.

* CMakeLists.txt:
* DerivedSources.make:
* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::consumeAsStream): Fill stream with body data.
* Modules/fetch/FetchBody.h:
(WebCore::FetchBody::type): Added accessor to body type, used for assertions.
* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::isDisturbed): Adding stream isLocked check.
(WebCore::FetchBodyOwner::blobLoadingSucceeded): Added assertion that body type is blob. Closing stream if created.
(WebCore::FetchBodyOwner::blobLoadingFailed): Erroring the stream if created and not cancelled.
(WebCore::FetchBodyOwner::blobChunk): Filling stream with chunk.
(WebCore::FetchBodyOwner::stop): Rmoved call to finishBlobLoading as it should be called as part of FetchLoaderCLient::didFail callbacki.
* Modules/fetch/FetchBodyOwner.h:
* Modules/fetch/FetchLoader.cpp: Fixing the case of cancel being called when creating the ThreadableLoader by introducing FetchLoader::m_isStarted.
(WebCore::FetchLoader::start): Setting m_isStarted at the end of the start method.
(WebCore::FetchLoader::stop): Fixing the case that FetchLoader can be destroyed when cancelling its loader.
(WebCore::FetchLoader::startStreaming): Introduced to switch the loading type from ArayBuffer to Stream. Already buffered data is returned.
(WebCore::FetchLoader::didReceiveData): Handling of the new Stream type.
(WebCore::FetchLoader::didFinishLoading):
* Modules/fetch/FetchLoader.h:
* Modules/fetch/FetchLoaderClient.h:
(WebCore::FetchLoaderClient::didReceiveData): Callback to get data as chunks if loader is of type Stream.
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::clone): Removed m_isLocked as it is handled within isDisturbed().
(WebCore::FetchResponse::isDisturbed): Checking whether related ReadableStream is locked.
(WebCore::FetchResponse::BodyLoader::didSucceed): Introduced to handle ReadableStream case.
(WebCore::FetchResponse::BodyLoader::didFail): Ditto.
(WebCore::FetchResponse::BodyLoader::didReceiveData): Ditto.
(WebCore::FetchResponse::BodyLoader::startStreaming): Ditto.
(WebCore::FetchResponse::consumeBodyAsStream): Start filling the ReadableStream with data. Changing loader to Stream if there is one.
(WebCore::FetchResponse::createReadableStreamSource): Called by custom binding to create the source.
(WebCore::FetchResponse::stop): Fixing potential crash in case of cancelling the ibody stream.
(WebCore::FetchResponse::startFetching):
(WebCore::FetchResponse::BodyLoader::didFinishLoadingAsArrayBuffer):
* Modules/fetch/FetchResponse.h:
* Modules/fetch/FetchResponse.idl:
* Modules/fetch/FetchResponseSource.cpp: Specialization of ReadableStreamSource for FetchResponse. It is a push source that never resolves the start promise.
(WebCore::FetchResponseSource::FetchResponseSource):
(WebCore::FetchResponseSource::isReadableStreamLocked):
(WebCore::FetchResponseSource::setActive):
(WebCore::FetchResponseSource::setInactive):
(WebCore::FetchResponseSource::doStart):
(WebCore::FetchResponseSource::doCancel):
(WebCore::FetchResponseSource::close):
(WebCore::FetchResponseSource::error):
* Modules/fetch/FetchResponseSource.h: Added.
* Modules/streams/ReadableStreamController.js:
(error):
* Modules/streams/ReadableStreamSource.h: Added (base class for ReadableStream DOM sources).
(WebCore::ReadableStreamSource::~ReadableStreamSource):
(WebCore::ReadableStreamSource::isStarting):
(WebCore::ReadableStreamSource::isPulling):
(WebCore::ReadableStreamSource::isCancelling):
(WebCore::ReadableStreamSource::controller):
(WebCore::ReadableStreamSource::doStart):
(WebCore::ReadableStreamSource::doCancel):
(WebCore::ReadableStreamSource::start):
(WebCore::ReadableStreamSource::cancel):
(WebCore::ReadableStreamSource::startFinished):
(WebCore::ReadableStreamSource::clean):
* Modules/streams/ReadableStreamSource.idl: Added.
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMGlobalObject.h:
* bindings/js/JSFetchResponseCustom.cpp: In case body is not created, call createReadableStreamSource.
(WebCore::JSFetchResponse::body):
* bindings/js/JSReadableStreamSourceCustom.cpp: Added.
(WebCore::JSReadableStreamSource::start):
(WebCore::JSReadableStreamSource::pull):
(WebCore::JSReadableStreamSource::controller):
* bindings/js/ReadableStreamController.cpp: Added.
(WebCore::callFunction):
(WebCore::ReadableStreamController::invoke):
(WebCore::ReadableStreamController::isControlledReadableStreamLocked):
(WebCore::createReadableStream):
* bindings/js/ReadableStreamController.h: The DOM wrapper for JSReadableStreamController.
(WebCore::ReadableStreamController::ReadableStreamController):
(WebCore::ReadableStreamController::close):
(WebCore::ReadableStreamController::error):
(WebCore::ReadableStreamController::enqueue):
(WebCore::ReadableStreamController::globalObject):
(WebCore::ReadableStreamController::enqueue&lt;RefPtr&lt;JSC::ArrayBuffer&gt;&gt;):
(WebCore::ReadableStreamController::error&lt;String&gt;):

LayoutTests:
[Streams] Consume HTTP data as a ReadableStream
https://bugs.webkit.org/show_bug.cgi?id=138968

Reviewed by Alex Christensen.

* fast/xmlhttprequest/xmlhttprequest-responsetype-stream-expected.txt: Added.
* fast/xmlhttprequest/xmlhttprequest-responsetype-stream.html: Added.
* http/tests/xmlhttprequest/streams/streams-read-api-cancelled-expected.txt: Added.
* http/tests/xmlhttprequest/streams/streams-read-api-cancelled.html: Added.
* http/tests/xmlhttprequest/streams/streams-read-api-closed-expected.txt: Added.
* http/tests/xmlhttprequest/streams/streams-read-api-closed.html: Added.
* http/tests/xmlhttprequest/streams/streams-read-api-expected.txt: Added.
* http/tests/xmlhttprequest/streams/streams-read-api.html: Added.
* http/tests/xmlhttprequest/streams/streams-read-expected.txt: Added.
* http/tests/xmlhttprequest/streams/streams-read.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicstreamresponseexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicstreamresponseworkerexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestconsumehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresourcesutilsjs">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/utils.js</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecloneexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseinit002expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesmake">trunk/Source/WebCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchBodycpp">trunk/Source/WebCore/Modules/fetch/FetchBody.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchBodyh">trunk/Source/WebCore/Modules/fetch/FetchBody.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchBodyOwnercpp">trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchBodyOwnerh">trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchLoadercpp">trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchLoaderh">trunk/Source/WebCore/Modules/fetch/FetchLoader.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchLoaderClienth">trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchResponsecpp">trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchResponseh">trunk/Source/WebCore/Modules/fetch/FetchResponse.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchResponseidl">trunk/Source/WebCore/Modules/fetch/FetchResponse.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamControllerjs">trunk/Source/WebCore/Modules/streams/ReadableStreamController.js</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMGlobalObjecth">trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresourcesdatajson">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/data.json</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecancelstreamexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecancelstreamhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumestreamexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumestreamhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed1expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed1html">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed2expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed2html">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed3expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-3-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed3html">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-3.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed4expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed4html">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed5expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed5html">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5.html</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchResponseSourcecpp">trunk/Source/WebCore/Modules/fetch/FetchResponseSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchResponseSourceh">trunk/Source/WebCore/Modules/fetch/FetchResponseSource.h</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamSourceh">trunk/Source/WebCore/Modules/streams/ReadableStreamSource.h</a></li>
<li><a href="#trunkSourceWebCoreModulesstreamsReadableStreamSourceidl">trunk/Source/WebCore/Modules/streams/ReadableStreamSource.idl</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSFetchResponseCustomcpp">trunk/Source/WebCore/bindings/js/JSFetchResponseCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSReadableStreamSourceCustomcpp">trunk/Source/WebCore/bindings/js/JSReadableStreamSourceCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsReadableStreamControllercpp">trunk/Source/WebCore/bindings/js/ReadableStreamController.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsReadableStreamControllerh">trunk/Source/WebCore/bindings/js/ReadableStreamController.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/LayoutTests/ChangeLog        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2016-04-17  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        [Streams] Consume HTTP data as a ReadableStream
+        https://bugs.webkit.org/show_bug.cgi?id=138968
+
+        Reviewed by Alex Christensen.
+
+        * fast/xmlhttprequest/xmlhttprequest-responsetype-stream-expected.txt: Added.
+        * fast/xmlhttprequest/xmlhttprequest-responsetype-stream.html: Added.
+        * http/tests/xmlhttprequest/streams/streams-read-api-cancelled-expected.txt: Added.
+        * http/tests/xmlhttprequest/streams/streams-read-api-cancelled.html: Added.
+        * http/tests/xmlhttprequest/streams/streams-read-api-closed-expected.txt: Added.
+        * http/tests/xmlhttprequest/streams/streams-read-api-closed.html: Added.
+        * http/tests/xmlhttprequest/streams/streams-read-api-expected.txt: Added.
+        * http/tests/xmlhttprequest/streams/streams-read-api.html: Added.
+        * http/tests/xmlhttprequest/streams/streams-read-expected.txt: Added.
+        * http/tests/xmlhttprequest/streams/streams-read.html: Added.
+
</ins><span class="cx"> 2016-04-16  Matt Baker  &lt;mattbaker@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Adopt Number.prototype.toLocaleString For All Sizes and Times
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2016-04-17  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        [Fetch API] Consume HTTP data as a ReadableStream
+        https://bugs.webkit.org/show_bug.cgi?id=138968
+
+        Reviewed by Alex Christensen.
+
+        * web-platform-tests/fetch/api/basic/stream-response-expected.txt:
+        * web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt:
+        * web-platform-tests/fetch/api/request/request-consume.html:
+        * web-platform-tests/fetch/api/resources/data.json: Added.
+        * web-platform-tests/fetch/api/resources/utils.js:
+        (validateStreamFromString):
+        * web-platform-tests/fetch/api/response/response-cancel-stream-expected.txt: Added.
+        * web-platform-tests/fetch/api/response/response-cancel-stream.html: Added.
+        * web-platform-tests/fetch/api/response/response-clone-expected.txt:
+        * web-platform-tests/fetch/api/response/response-consume-stream-expected.txt: Added.
+        * web-platform-tests/fetch/api/response/response-consume-stream.html: Added.
+        * web-platform-tests/fetch/api/response/response-init-002-expected.txt:
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-expected-1.txt: Added.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-1.html: Added.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-expected-2.txt: Added.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-2.html: Added.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-expected-3.txt: Added.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-3.html: Added.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-expected-4.txt: Added.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-4.html: Added.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-expected-5.txt: Added.
+        * web-platform-tests/fetch/api/response/response-stream-disturbed-5.html: Added.
+
</ins><span class="cx"> 2016-04-11  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         DOMTokenList.contains() should not throw
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicstreamresponseexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-expected.txt (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-expected.txt        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-expected.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><span class="cx"> 
</span><del>-FAIL Stream response's body assert_unreached: Body does not exist in response Reached unreachable code
</del><ins>+PASS Stream response's body 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapibasicstreamresponseworkerexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/basic/stream-response-worker-expected.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -1,3 +1,3 @@
</span><span class="cx"> 
</span><del>-FAIL Stream response's body assert_unreached: Body does not exist in response Reached unreachable code
</del><ins>+PASS Stream response's body 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestconsumehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume.html (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume.html        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume.html        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -11,6 +11,7 @@
</span><span class="cx">     &lt;script src=&quot;../resources/utils.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">   &lt;/head&gt;
</span><span class="cx">   &lt;body&gt;
</span><ins>+    &lt;script src=&quot;../resources/utils.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx">     &lt;script&gt;
</span><span class="cx">     function checkBodyText(request, expectedBody) {
</span><span class="cx">       return request.text().then( function(bodyAsText) {
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresourcesdatajson"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/data.json (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/data.json                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/data.json        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+{&quot;key&quot;: &quot;value&quot;}
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresourcesutilsjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/utils.js (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/utils.js        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/resources/utils.js        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -61,14 +61,16 @@
</span><span class="cx">     if (!data.done) {
</span><span class="cx">       var newBuffer;
</span><span class="cx">       if (retrievedArrayBuffer) {
</span><del>-        newBuffer =  new ArrayBuffer(data.value.length + retrievedArrayBuffer.length);
</del><ins>+        newBuffer =  new ArrayBuffer(data.value.byteLength + retrievedArrayBuffer.byteLength);
</ins><span class="cx">         newBuffer.set(retrievedArrayBuffer, 0);
</span><del>-        newBuffer.set(data.value, retrievedArrayBuffer.length);
</del><ins>+        newBuffer.set(data.value, retrievedArrayBuffer.byteLength);
</ins><span class="cx">       } else {
</span><span class="cx">         newBuffer = data.value;
</span><span class="cx">       }
</span><span class="cx">       return validateStreamFromString(reader, expectedValue, newBuffer);
</span><span class="cx">     }
</span><ins>+    if (!retrievedArrayBuffer)
+        retrievedArrayBuffer = new Uint8Array();
</ins><span class="cx">     validateBufferFromString(retrievedArrayBuffer, expectedValue, &quot;Retrieve and verify stream&quot;);
</span><span class="cx">   });
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecancelstreamexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream-expected.txt (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream-expected.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+
+PASS Cancelling a starting blob Response stream 
+PASS Cancelling a loading blob Response stream 
+PASS Cancelling a closed blob Response stream 
+PASS Cancelling a starting Response stream 
+PASS Cancelling a loading Response stream 
+PASS Cancelling a closed Response stream 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecancelstreamhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,71 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Response consume empty bodies&lt;/title&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#response&quot;&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#body-mixin&quot;&gt;
+    &lt;meta name=&quot;author&quot; title=&quot;Canon Research France&quot; href=&quot;https://www.crf.canon.fr&quot;&gt;
+    &lt;script src=&quot;/resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script src=&quot;../resources/utils.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+
+promise_test(function(test) {
+    return new Response(new Blob([], { &quot;type&quot; : &quot;text/plain&quot; })).body.cancel();
+}, &quot;Cancelling a starting blob Response stream&quot;);
+
+promise_test(function(test) {
+    var response = new Response(new Blob([&quot;This is data&quot;], { &quot;type&quot; : &quot;text/plain&quot; }));
+    var reader = response.body.getReader();
+    reader.read();
+    return reader.cancel();
+}, &quot;Cancelling a loading blob Response stream&quot;);
+
+promise_test(function(test) {
+    var response = new Response(new Blob([&quot;T&quot;], { &quot;type&quot; : &quot;text/plain&quot; }));
+    var reader = response.body.getReader();
+    var resolve;
+    var promise = new Promise(function(_resolve, _reject) {
+        resolve = _resolve;
+    });
+    promise.then(function() {
+        return reader.read().then(function(value) {
+        return reader.cancel();
+        });
+    });
+    setTimeout(resolve, 100);
+    return promise;
+}, &quot;Cancelling a closed blob Response stream&quot;);
+
+promise_test(function(test) {
+    return fetch(RESOURCES_DIR + &quot;trickle.py?ms=30&amp;count=100&quot;).then(function(response) {
+        return response.body.cancel();
+    });
+}, &quot;Cancelling a starting Response stream&quot;);
+
+promise_test(function() {
+    return fetch(RESOURCES_DIR + &quot;trickle.py?ms=30&amp;count=100&quot;).then(function(response) {
+        var reader = response.body.getReader();
+        return reader.read().then(function() {
+            return reader.cancel();
+        });
+    });
+}, &quot;Cancelling a loading Response stream&quot;);
+
+promise_test(function() {
+    return fetch(RESOURCES_DIR + &quot;top.txt&quot;).then(function(response) {
+        var reader = response.body.getReader();
+        var closedPromise = reader.closed.then(function() {
+            return reader.cancel();
+        });
+        reader.read();
+        return closedPromise;
+    });
+}, &quot;Cancelling a closed Response stream&quot;);
+
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsecloneexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone-expected.txt (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone-expected.txt        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-clone-expected.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> 
</span><span class="cx"> PASS Check Response's clone with default values, without body 
</span><span class="cx"> PASS Check Response's clone has the expected attribute values 
</span><del>-FAIL Check orginal response's body after cloning null is not an object (evaluating 'response.body.getReader')
-FAIL Check cloned response's body null is not an object (evaluating 'clonedResponse.body.getReader')
</del><ins>+PASS Check orginal response's body after cloning 
+PASS Check cloned response's body 
</ins><span class="cx"> FAIL Cannot clone a disturbed response assert_true: response is disturbed expected true got false
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumestreamexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream-expected.txt (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream-expected.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+
+PASS Read empty text response's body as readableStream 
+PASS Read empty blob response's body as readableStream 
+PASS Read blob response's body as readableStream 
+PASS Read text response's body as readableStream 
+FAIL Read form data response's body as readableStream promise_test: Unhandled rejection with value: &quot;not implemented&quot;
+PASS Getting an error Response stream 
+PASS Getting a redirect Response stream 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumestreamhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream.html (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream.html        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Response consume&lt;/title&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#response&quot;&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#body-mixin&quot;&gt;
+    &lt;meta name=&quot;author&quot; title=&quot;Canon Research France&quot; href=&quot;https://www.crf.canon.fr&quot;&gt;
+    &lt;script src=&quot;/resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../resources/utils.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script&gt;
+    promise_test(function(test) {
+      var body = &quot;&quot;;
+      var response = new Response(&quot;&quot;);
+      return validateStreamFromString(response.body.getReader(), &quot;&quot;);
+    }, &quot;Read empty text response's body as readableStream&quot;);
+
+    promise_test(function(test) {
+      var response = new Response(new Blob([], { &quot;type&quot; : &quot;text/plain&quot; }));
+      return validateStreamFromString(response.body.getReader(), &quot;&quot;);
+    }, &quot;Read empty blob response's body as readableStream&quot;);
+
+    var formData = new FormData();
+    formData.append(&quot;name&quot;, &quot;value&quot;);
+    var textData = JSON.stringify(&quot;This is response's body&quot;);
+    var blob = new Blob([textData], { &quot;type&quot; : &quot;text/plain&quot; });
+
+    promise_test(function(test) {
+      var response = new Response(blob);
+      return validateStreamFromString(response.body.getReader(), textData);
+    }, &quot;Read blob response's body as readableStream&quot;);
+
+    promise_test(function(test) {
+      var response = new Response(textData);
+      return validateStreamFromString(response.body.getReader(), textData);
+    }, &quot;Read text response's body as readableStream&quot;);
+
+    promise_test(function(test) {
+      var response = new Response(formData);
+      return validateStreamFromString(response.body.getReader(), &quot;name=value&quot;);
+    }, &quot;Read form data response's body as readableStream&quot;);
+
+    test(function() {
+        assert_equals(Response.error().body, null);
+    }, &quot;Getting an error Response stream&quot;);
+
+    promise_test(function(test) {
+        assert_equals(Response.redirect(301).body, null);
+    }, &quot;Getting a redirect Response stream&quot;);
+
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseinit002expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -4,5 +4,5 @@
</span><span class="cx"> FAIL Initialize Response's body with multipart/form-data promise_test: Unhandled rejection with value: undefined
</span><span class="cx"> FAIL Initialize Response's body with application/x-www-form-urlencoded;charset=UTF-8 assert_true: Content-Type header should be &quot;application/x-www-form-urlencoded;charset=UTF-8&quot;  expected true got false
</span><span class="cx"> PASS Initialize Response's body with text/plain;charset=UTF-8 
</span><del>-FAIL Read Response's body as readableStream null is not an object (evaluating 'response.body.getReader')
</del><ins>+PASS Read Response's body as readableStream 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1-expected.txt (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1-expected.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+
+FAIL Getting blob after getting the Response body - not disturbed, not locked promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+FAIL Getting text after getting the Response body - not disturbed, not locked promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+FAIL Getting json after getting the Response body - not disturbed, not locked promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+FAIL Getting arrayBuffer after getting the Response body - not disturbed, not locked promise_test: Unhandled rejection with value: object &quot;TypeError: Type error&quot;
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1.html (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1.html        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Consuming Response body after getting a ReadableStream&lt;/title&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#response&quot;&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#body-mixin&quot;&gt;
+    &lt;meta name=&quot;author&quot; title=&quot;Canon Research France&quot; href=&quot;https://www.crf.canon.fr&quot;&gt;
+    &lt;script src=&quot;/resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script&gt;
+
+function createResponseWithReadableStream(callback) {
+    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
+        var reader = response.body.getReader();
+        reader.releaseLock();
+        return callback(response);
+    });
+}
+
+function createResponseWithCancelledReadableStream(callback) {
+    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
+        response.body.cancel();
+        return callback(response);
+    });
+}
+
+promise_test(function() {
+    return createResponseWithReadableStream(function(response) {
+        return response.blob().then(function(blob) {
+            assert_true(blob instanceof Blob);
+        });
+    });
+}, &quot;Getting blob after getting the Response body - not disturbed, not locked&quot;);
+
+promise_test(function() {
+    return createResponseWithReadableStream(function(response) {
+        return response.text().then(function(text) {
+            assert_true(text.length &gt; 0);
+        });
+    });
+}, &quot;Getting text after getting the Response body - not disturbed, not locked&quot;);
+
+promise_test(function() {
+    return createResponseWithReadableStream(function(response) {
+        return response.json().then(function(json) {
+            assert_true(typeof json === &quot;object&quot;);
+        });
+    });
+}, &quot;Getting json after getting the Response body - not disturbed, not locked&quot;);
+
+promise_test(function() {
+    return createResponseWithReadableStream(function(response) {
+        return response.arrayBuffer().then(function(arrayBuffer) {
+            assert_true(arrayBuffer.byteLength &gt; 0);
+        });
+    });
+}, &quot;Getting arrayBuffer after getting the Response body - not disturbed, not locked&quot;);
+
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed2expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2-expected.txt (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2-expected.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+
+FAIL Getting blob after getting a locked Response body Can't find variable: createResponseWithReadableStream
+FAIL Getting text after getting a locked Response body Can't find variable: createResponseWithReadableStream
+FAIL Getting json after getting a locked Response body Can't find variable: createResponseWithReadableStream
+FAIL Getting arraybuffer after getting a locked Response body Can't find variable: createResponseWithReadableStream
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2.html (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2.html        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Consuming Response body after getting a ReadableStream&lt;/title&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#response&quot;&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#body-mixin&quot;&gt;
+    &lt;meta name=&quot;author&quot; title=&quot;Canon Research France&quot; href=&quot;https://www.crf.canon.fr&quot;&gt;
+    &lt;script src=&quot;/resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script&gt;
+
+function createResponseWithLockedReadableStream(callback) {
+    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
+        var reader = response.body.getReader();
+        return callback(response);
+    });
+}
+
+function createResponseWithCancelledReadableStream(callback) {
+    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
+        response.body.cancel();
+        return callback(response);
+    });
+}
+
+promise_test(function() {
+    return createResponseWithReadableStream(function(response) {
+        return response.blob().then(function(blob) {
+            assert_true(blob instanceof Blob);
+        });
+    });
+}, &quot;Getting blob after getting a locked Response body&quot;);
+
+promise_test(function() {
+    return createResponseWithReadableStream(function(response) {
+        return response.text().then(function(text) {
+            assert_true(text.length &gt; 0);
+        });
+    });
+}, &quot;Getting text after getting a locked Response body&quot;);
+
+promise_test(function() {
+    return createResponseWithReadableStream(function(response) {
+        return response.json().then(function(json) {
+            assert_true(typeof json === &quot;object&quot;);
+        });
+    });
+}, &quot;Getting json after getting a locked Response body&quot;);
+
+promise_test(function() {
+    return createResponseWithReadableStream(function(response) {
+        return response.arrayBuffer().then(function(arrayBuffer) {
+            assert_true(arrayBuffer.byteLength &gt; 0);
+        });
+    });
+}, &quot;Getting arraybuffer after getting a locked Response body&quot;);
+
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed3expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-3-expected.txt (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-3-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-3-expected.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+
+PASS Getting blob after reading the Response body 
+PASS Getting text after reading the Response body 
+PASS Getting json after reading the Response body 
+PASS Getting arrayBuffer after reading the Response body 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed3html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-3.html (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-3.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-3.html        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Consuming Response body after getting a ReadableStream&lt;/title&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#response&quot;&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#body-mixin&quot;&gt;
+    &lt;meta name=&quot;author&quot; title=&quot;Canon Research France&quot; href=&quot;https://www.crf.canon.fr&quot;&gt;
+    &lt;script src=&quot;/resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script&gt;
+
+function createResponseWithDisturbedReadableStream(callback) {
+    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
+        var reader = response.body.getReader();
+        reader.read();
+        return callback(response);
+    });
+}
+
+promise_test(function(test) {
+    return createResponseWithDisturbedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.blob());
+    });
+}, &quot;Getting blob after reading the Response body&quot;);
+
+promise_test(function(test) {
+    return createResponseWithDisturbedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.text());
+    });
+}, &quot;Getting text after reading the Response body&quot;);
+
+promise_test(function(test) {
+    return createResponseWithDisturbedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.json());
+    });
+}, &quot;Getting json after reading the Response body&quot;);
+
+promise_test(function(test) {
+    return createResponseWithDisturbedReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.arrayBuffer());
+    });
+}, &quot;Getting arrayBuffer after reading the Response body&quot;);
+
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed4expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4-expected.txt (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4-expected.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+
+PASS Getting blob after cancelling the Response body 
+PASS Getting text after cancelling the Response body 
+PASS Getting json after cancelling the Response body 
+PASS Getting arrayBuffer after cancelling the Response body 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed4html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4.html (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4.html        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Consuming Response body after getting a ReadableStream&lt;/title&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#response&quot;&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#body-mixin&quot;&gt;
+    &lt;meta name=&quot;author&quot; title=&quot;Canon Research France&quot; href=&quot;https://www.crf.canon.fr&quot;&gt;
+    &lt;script src=&quot;/resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script&gt;
+
+function createResponseWithCancelledReadableStream(callback) {
+    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
+        response.body.cancel();
+        return callback(response);
+    });
+}
+
+promise_test(function(test) {
+    return createResponseWithCancelledReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.blob());
+    });
+}, &quot;Getting blob after cancelling the Response body&quot;);
+
+promise_test(function(test) {
+    return createResponseWithCancelledReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.text());
+    });
+    return promise_rejects(test, new TypeError(), createResponseWithCancelledReadableStream().text());
+}, &quot;Getting text after cancelling the Response body&quot;);
+
+promise_test(function(test) {
+    return createResponseWithCancelledReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.json());
+    });
+    return promise_rejects(test, new TypeError(), createResponseWithCancelledReadableStream().json());
+}, &quot;Getting json after cancelling the Response body&quot;);
+
+promise_test(function(test) {
+    return createResponseWithCancelledReadableStream(function(response) {
+        return promise_rejects(test, new TypeError(), response.arrayBuffer());
+    });
+}, &quot;Getting arrayBuffer after cancelling the Response body&quot;);
+
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed5expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5-expected.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+
+PASS Getting a null body after consuming as blob 
+PASS Getting a null body after consuming as text 
+PASS Getting a null body after consuming as json 
+PASS Getting a null body after consuming as arrayBuffer 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponsestreamdisturbed5html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5.html (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5.html        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;meta charset=&quot;utf-8&quot;&gt;
+    &lt;title&gt;Consuming Response body after getting a ReadableStream&lt;/title&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#response&quot;&gt;
+    &lt;meta name=&quot;help&quot; href=&quot;https://fetch.spec.whatwg.org/#body-mixin&quot;&gt;
+    &lt;meta name=&quot;author&quot; title=&quot;Canon Research France&quot; href=&quot;https://www.crf.canon.fr&quot;&gt;
+    &lt;script src=&quot;/resources/testharness.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;/resources/testharnessreport.js&quot;&gt;&lt;/script&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;script&gt;
+        
+promise_test(function() {
+    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
+        response.blob();
+        assert_equals(response.body, null);
+    });
+}, &quot;Getting a null body after consuming as blob&quot;);
+
+promise_test(function() {
+    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
+        response.text();
+        assert_equals(response.body, null);
+    });
+}, &quot;Getting a null body after consuming as text&quot;);
+
+promise_test(function() {
+    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
+        response.json();
+        assert_equals(response.body, null);
+    });
+}, &quot;Getting a null body after consuming as json&quot;);
+
+promise_test(function() {
+    return fetch(&quot;../resources/data.json&quot;).then(function(response) {
+        response.arrayBuffer();
+        assert_equals(response.body, null);
+    });
+}, &quot;Getting a null body after consuming as arrayBuffer&quot;);
+
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -264,6 +264,7 @@
</span><span class="cx">     Modules/streams/ReadableStream.idl
</span><span class="cx">     Modules/streams/ReadableStreamController.idl
</span><span class="cx">     Modules/streams/ReadableStreamReader.idl
</span><ins>+    Modules/streams/ReadableStreamSource.idl
</ins><span class="cx">     Modules/streams/WritableStream.idl
</span><span class="cx"> 
</span><span class="cx">     Modules/vibration/NavigatorVibration.idl
</span><span class="lines">@@ -822,6 +823,7 @@
</span><span class="cx">     Modules/fetch/FetchLoader.cpp
</span><span class="cx">     Modules/fetch/FetchRequest.cpp
</span><span class="cx">     Modules/fetch/FetchResponse.cpp
</span><ins>+    Modules/fetch/FetchResponseSource.cpp
</ins><span class="cx">     Modules/fetch/WorkerGlobalScopeFetch.cpp
</span><span class="cx"> 
</span><span class="cx">     Modules/geolocation/Coordinates.cpp
</span><span class="lines">@@ -1143,6 +1145,7 @@
</span><span class="cx">     bindings/js/JSEventListener.cpp
</span><span class="cx">     bindings/js/JSEventTargetCustom.cpp
</span><span class="cx">     bindings/js/JSExceptionBase.cpp
</span><ins>+    bindings/js/JSFetchResponseCustom.cpp
</ins><span class="cx">     bindings/js/JSFileReaderCustom.cpp
</span><span class="cx">     bindings/js/JSGeolocationCustom.cpp
</span><span class="cx">     bindings/js/JSHTMLAllCollectionCustom.cpp
</span><span class="lines">@@ -1195,6 +1198,7 @@
</span><span class="cx">     bindings/js/JSPluginElementFunctions.cpp
</span><span class="cx">     bindings/js/JSPopStateEventCustom.cpp
</span><span class="cx">     bindings/js/JSReadableStreamPrivateConstructors.cpp
</span><ins>+    bindings/js/JSReadableStreamSourceCustom.cpp
</ins><span class="cx">     bindings/js/JSRTCIceCandidateCustom.cpp
</span><span class="cx">     bindings/js/JSRTCPeerConnectionCustom.cpp
</span><span class="cx">     bindings/js/JSRTCSessionDescriptionCustom.cpp
</span><span class="lines">@@ -1225,6 +1229,7 @@
</span><span class="cx">     bindings/js/JSXMLHttpRequestCustom.cpp
</span><span class="cx">     bindings/js/JSXPathResultCustom.cpp
</span><span class="cx">     bindings/js/JSXSLTProcessorCustom.cpp
</span><ins>+    bindings/js/ReadableStreamController.cpp
</ins><span class="cx">     bindings/js/ScheduledAction.cpp
</span><span class="cx">     bindings/js/ScriptCachedFrameData.cpp
</span><span class="cx">     bindings/js/ScriptController.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/ChangeLog        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -1,3 +1,118 @@
</span><ins>+2016-04-17  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        [Fetch API] Consume HTTP data as a ReadableStream
+        https://bugs.webkit.org/show_bug.cgi?id=138968
+
+        Reviewed by Alex Christensen.
+
+        This patch introduces ReadableStreamSource and ReadableStreamController which allow feeding a ReadableStream from DOM classes.
+        ReadableStreamSource is a base class for all DOM ReadableStream sources.
+        ReadableStreamController is a wrapper around JSReadableStreamController that can be invoked by DOM code to enqueue/close/error a ReadableStream.
+        A createReadableStream function is introduced to allow DOM classes creating ReadableStream.
+
+        Added support for a FetchResponse ReadableStream source.
+        Both synthetic FetchResponse and loading FetchResponse are supported.
+        A new &quot;Stream&quot; FetchLoader::Type is introduced to allow receiving data as chunks and feeding them to a ReadableStream through ReadableStreamSource.
+
+        Currently, FetchResponse is consumed and marked as disturbed as soon as a ReadableStreamSource is created.
+        This should be changed so that consumption happens on the first read call to the ReadableStreamReader, i.e. when stream gets disturbed.
+
+        FetchResponseSource never fulfills the start promise, which allows to enqueue, error or close the stream at any time.
+        FetchResponseSource must therefore always ensure to close or error the stream.
+        Added support for locked check in FetchResponse.
+
+        Tests: imported/w3c/web-platform-tests/fetch/api/response/response-cancel-stream.html
+               imported/w3c/web-platform-tests/fetch/api/response/response-consume-stream.html
+               imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-1.html
+               imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-2.html
+               imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-3.html
+               imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-4.html
+               imported/w3c/web-platform-tests/fetch/api/response/response-stream-disturbed-5.html
+        Also covered by rebased tests.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::FetchBody::consumeAsStream): Fill stream with body data.
+        * Modules/fetch/FetchBody.h:
+        (WebCore::FetchBody::type): Added accessor to body type, used for assertions.
+        * Modules/fetch/FetchBodyOwner.cpp:
+        (WebCore::FetchBodyOwner::isDisturbed): Adding stream isLocked check.
+        (WebCore::FetchBodyOwner::blobLoadingSucceeded): Added assertion that body type is blob. Closing stream if created.
+        (WebCore::FetchBodyOwner::blobLoadingFailed): Erroring the stream if created and not cancelled.
+        (WebCore::FetchBodyOwner::blobChunk): Filling stream with chunk.
+        (WebCore::FetchBodyOwner::stop): Rmoved call to finishBlobLoading as it should be called as part of FetchLoaderCLient::didFail callbacki.
+        * Modules/fetch/FetchBodyOwner.h:
+        * Modules/fetch/FetchLoader.cpp: Fixing the case of cancel being called when creating the ThreadableLoader by introducing FetchLoader::m_isStarted.
+        (WebCore::FetchLoader::start): Setting m_isStarted at the end of the start method.
+        (WebCore::FetchLoader::stop): Fixing the case that FetchLoader can be destroyed when cancelling its loader.
+        (WebCore::FetchLoader::startStreaming): Introduced to switch the loading type from ArayBuffer to Stream. Already buffered data is returned.
+        (WebCore::FetchLoader::didReceiveData): Handling of the new Stream type.
+        (WebCore::FetchLoader::didFinishLoading):
+        * Modules/fetch/FetchLoader.h:
+        * Modules/fetch/FetchLoaderClient.h:
+        (WebCore::FetchLoaderClient::didReceiveData): Callback to get data as chunks if loader is of type Stream.
+        * Modules/fetch/FetchResponse.cpp:
+        (WebCore::FetchResponse::clone): Removed m_isLocked as it is handled within isDisturbed().
+        (WebCore::FetchResponse::isDisturbed): Checking whether related ReadableStream is locked.
+        (WebCore::FetchResponse::BodyLoader::didSucceed): Introduced to handle ReadableStream case.
+        (WebCore::FetchResponse::BodyLoader::didFail): Ditto.
+        (WebCore::FetchResponse::BodyLoader::didReceiveData): Ditto.
+        (WebCore::FetchResponse::BodyLoader::startStreaming): Ditto.
+        (WebCore::FetchResponse::consumeBodyAsStream): Start filling the ReadableStream with data. Changing loader to Stream if there is one.
+        (WebCore::FetchResponse::createReadableStreamSource): Called by custom binding to create the source.
+        (WebCore::FetchResponse::stop): Fixing potential crash in case of cancelling the ibody stream.
+        (WebCore::FetchResponse::startFetching):
+        (WebCore::FetchResponse::BodyLoader::didFinishLoadingAsArrayBuffer):
+        * Modules/fetch/FetchResponse.h:
+        * Modules/fetch/FetchResponse.idl:
+        * Modules/fetch/FetchResponseSource.cpp: Specialization of ReadableStreamSource for FetchResponse. It is a push source that never resolves the start promise.
+        (WebCore::FetchResponseSource::FetchResponseSource):
+        (WebCore::FetchResponseSource::isReadableStreamLocked):
+        (WebCore::FetchResponseSource::setActive):
+        (WebCore::FetchResponseSource::setInactive):
+        (WebCore::FetchResponseSource::doStart):
+        (WebCore::FetchResponseSource::doCancel):
+        (WebCore::FetchResponseSource::close):
+        (WebCore::FetchResponseSource::error):
+        * Modules/fetch/FetchResponseSource.h: Added.
+        * Modules/streams/ReadableStreamController.js:
+        (error):
+        * Modules/streams/ReadableStreamSource.h: Added (base class for ReadableStream DOM sources).
+        (WebCore::ReadableStreamSource::~ReadableStreamSource):
+        (WebCore::ReadableStreamSource::isStarting):
+        (WebCore::ReadableStreamSource::isPulling):
+        (WebCore::ReadableStreamSource::isCancelling):
+        (WebCore::ReadableStreamSource::controller):
+        (WebCore::ReadableStreamSource::doStart):
+        (WebCore::ReadableStreamSource::doCancel):
+        (WebCore::ReadableStreamSource::start):
+        (WebCore::ReadableStreamSource::cancel):
+        (WebCore::ReadableStreamSource::startFinished):
+        (WebCore::ReadableStreamSource::clean):
+        * Modules/streams/ReadableStreamSource.idl: Added.
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSDOMGlobalObject.h:
+        * bindings/js/JSFetchResponseCustom.cpp: In case body is not created, call createReadableStreamSource.
+        (WebCore::JSFetchResponse::body):
+        * bindings/js/JSReadableStreamSourceCustom.cpp: Added.
+        (WebCore::JSReadableStreamSource::start):
+        (WebCore::JSReadableStreamSource::pull):
+        (WebCore::JSReadableStreamSource::controller):
+        * bindings/js/ReadableStreamController.cpp: Added.
+        (WebCore::callFunction):
+        (WebCore::ReadableStreamController::invoke):
+        (WebCore::ReadableStreamController::isControlledReadableStreamLocked):
+        (WebCore::createReadableStream):
+        * bindings/js/ReadableStreamController.h: The DOM wrapper for JSReadableStreamController.
+        (WebCore::ReadableStreamController::ReadableStreamController):
+        (WebCore::ReadableStreamController::close):
+        (WebCore::ReadableStreamController::error):
+        (WebCore::ReadableStreamController::enqueue):
+        (WebCore::ReadableStreamController::globalObject):
+        (WebCore::ReadableStreamController::enqueue&lt;RefPtr&lt;JSC::ArrayBuffer&gt;&gt;):
+        (WebCore::ReadableStreamController::error&lt;String&gt;):
+
</ins><span class="cx"> 2016-04-16  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Element should be const in StyleResolver
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources.make (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources.make        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/DerivedSources.make        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -182,6 +182,7 @@
</span><span class="cx">     $(WebCore)/Modules/streams/ReadableStream.idl \
</span><span class="cx">     $(WebCore)/Modules/streams/ReadableStreamController.idl \
</span><span class="cx">     $(WebCore)/Modules/streams/ReadableStreamReader.idl \
</span><ins>+    $(WebCore)/Modules/streams/ReadableStreamSource.idl \
</ins><span class="cx">     $(WebCore)/Modules/streams/WritableStream.idl \
</span><span class="cx">     $(WebCore)/Modules/webaudio/AudioBuffer.idl \
</span><span class="cx">     $(WebCore)/Modules/webaudio/AudioBufferCallback.idl \
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -34,10 +34,12 @@
</span><span class="cx"> #include &quot;DOMRequestState.h&quot;
</span><span class="cx"> #include &quot;Dictionary.h&quot;
</span><span class="cx"> #include &quot;FetchBodyOwner.h&quot;
</span><ins>+#include &quot;FetchResponseSource.h&quot;
</ins><span class="cx"> #include &quot;FormData.h&quot;
</span><span class="cx"> #include &quot;HTTPParsers.h&quot;
</span><span class="cx"> #include &quot;JSBlob.h&quot;
</span><span class="cx"> #include &quot;JSDOMFormData.h&quot;
</span><ins>+#include &quot;ReadableStreamSource.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -142,6 +144,36 @@
</span><span class="cx">     promise.reject&lt;ExceptionCode&gt;(0);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(STREAMS_API)
+void FetchBody::consumeAsStream(FetchBodyOwner&amp; owner, FetchResponseSource&amp; source)
+{
+    ASSERT(m_type != Type::Loading);
+
+    switch (m_type) {
+    case Type::ArrayBuffer:
+        source.enqueue(m_data);
+        source.close();
+        return;
+    case Type::Text: {
+        Vector&lt;uint8_t&gt; data = extractFromText();
+        // FIXME: We should not close the source if ArrayBuffer;;tryCreate returns null.
+        source.enqueue(ArrayBuffer::tryCreate(data.data(), data.size()));
+        source.close();
+        return;
+    }
+    case Type::Blob:
+        ASSERT(m_blob);
+        owner.loadBlob(*m_blob, FetchLoader::Type::Stream);
+        return;
+    case Type::None:
+        source.close();
+        return;
+    default:
+        source.error(ASCIILiteral(&quot;not implemented&quot;));
+    }
+}
+#endif
+
</ins><span class="cx"> void FetchBody::consumeArrayBuffer(Consumer::Type type, DeferredWrapper&amp; promise)
</span><span class="cx"> {
</span><span class="cx">     if (type == Consumer::Type::ArrayBuffer) {
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBody.h        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class FetchBodyOwner;
</span><ins>+class FetchResponseSource;
</ins><span class="cx"> class FormData;
</span><span class="cx"> 
</span><span class="cx"> class FetchBody {
</span><span class="lines">@@ -54,6 +55,10 @@
</span><span class="cx">     void text(FetchBodyOwner&amp;, DeferredWrapper&amp;&amp;);
</span><span class="cx">     void formData(FetchBodyOwner&amp;, DeferredWrapper&amp;&amp; promise) { promise.reject&lt;ExceptionCode&gt;(0); }
</span><span class="cx"> 
</span><ins>+#if ENABLE(STREAMS_API)
+    void consumeAsStream(FetchBodyOwner&amp;, FetchResponseSource&amp;);
+#endif
+
</ins><span class="cx">     bool isEmpty() const { return m_type == Type::None; }
</span><span class="cx"> 
</span><span class="cx">     void setMimeType(const String&amp; mimeType) { m_mimeType = mimeType; }
</span><span class="lines">@@ -70,9 +75,10 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;FormData&gt; bodyForInternalRequest() const;
</span><span class="cx"> 
</span><del>-private:
</del><span class="cx">     enum class Type { None, ArrayBuffer, Loading, Text, Blob, FormData };
</span><ins>+    Type type() const { return m_type; }
</ins><span class="cx"> 
</span><ins>+private:
</ins><span class="cx">     FetchBody(Ref&lt;Blob&gt;&amp;&amp;);
</span><span class="cx">     FetchBody(Ref&lt;DOMFormData&gt;&amp;&amp;);
</span><span class="cx">     FetchBody(String&amp;&amp;);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyOwnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="cx"> #include &quot;FetchLoader.h&quot;
</span><ins>+#include &quot;FetchResponseSource.h&quot;
</ins><span class="cx"> #include &quot;JSBlob.h&quot;
</span><span class="cx"> #include &quot;ResourceResponse.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -50,11 +51,23 @@
</span><span class="cx">     if (m_blobLoader) {
</span><span class="cx">         if (m_blobLoader-&gt;loader)
</span><span class="cx">             m_blobLoader-&gt;loader-&gt;stop();
</span><del>-        finishBlobLoading();
</del><span class="cx">     }
</span><span class="cx">     ASSERT(!m_blobLoader);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool FetchBodyOwner::isDisturbed() const
+{
+    if (m_isDisturbed)
+        return true;
+
+#if ENABLE(STREAMS_API)
+    if (m_readableStreamSource &amp;&amp; m_readableStreamSource-&gt;isReadableStreamLocked())
+        return true;
+#endif
+
+    return false;
+}
+
</ins><span class="cx"> void FetchBodyOwner::arrayBuffer(DeferredWrapper&amp;&amp; promise)
</span><span class="cx"> {
</span><span class="cx">     if (m_body.isEmpty()) {
</span><span class="lines">@@ -161,12 +174,46 @@
</span><span class="cx">     m_body.loadedAsText(WTFMove(text));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FetchBodyOwner::blobLoadingSucceeded()
+{
+    ASSERT(m_body.type() == FetchBody::Type::Blob);
+
+#if ENABLE(STREAMS_API)
+    if (m_readableStreamSource) {
+        m_readableStreamSource-&gt;close();
+        m_readableStreamSource = nullptr;
+    }
+#endif
+
+    finishBlobLoading();
+}
+
</ins><span class="cx"> void FetchBodyOwner::blobLoadingFailed()
</span><span class="cx"> {
</span><del>-    m_body.loadingFailed();
</del><ins>+#if ENABLE(STREAMS_API)
+    if (m_readableStreamSource) {
+        if (!m_readableStreamSource-&gt;isCancelling())
+            m_readableStreamSource-&gt;error(ASCIILiteral(&quot;Blob loading failed&quot;));
+        m_readableStreamSource = nullptr;
+    } else
+#endif
+        m_body.loadingFailed();
+
</ins><span class="cx">     finishBlobLoading();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FetchBodyOwner::blobChunk(const char* data, size_t size)
+{
+#if ENABLE(STREAMS_API)
+    ASSERT(m_readableStreamSource);
+    // FIXME: If ArrayBuffer::tryCreate returns null, we should probably cancel the load.
+    m_readableStreamSource-&gt;enqueue(ArrayBuffer::tryCreate(data, size));
+#else
+    UNUSED_PARAM(data);
+    UNUSED_PARAM(size);
+#endif
+}
+
</ins><span class="cx"> FetchBodyOwner::BlobLoader::BlobLoader(FetchBodyOwner&amp; owner)
</span><span class="cx">     : owner(owner)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyOwnerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &quot;FetchBody.h&quot;
</span><span class="cx"> #include &quot;FetchLoader.h&quot;
</span><span class="cx"> #include &quot;FetchLoaderClient.h&quot;
</span><ins>+#include &quot;FetchResponseSource.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -43,7 +44,7 @@
</span><span class="cx">     FetchBodyOwner(ScriptExecutionContext&amp;, FetchBody&amp;&amp;);
</span><span class="cx"> 
</span><span class="cx">     // Exposed Body API
</span><del>-    bool isDisturbed() const { return m_isDisturbed; }
</del><ins>+    bool isDisturbed() const;
</ins><span class="cx"> 
</span><span class="cx">     void arrayBuffer(DeferredWrapper&amp;&amp;);
</span><span class="cx">     void blob(DeferredWrapper&amp;&amp;);
</span><span class="lines">@@ -68,7 +69,8 @@
</span><span class="cx">     // Blob loading routines
</span><span class="cx">     void loadedBlobAsText(String&amp;&amp;);
</span><span class="cx">     void loadedBlobAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp; buffer) { m_body.loadedAsArrayBuffer(WTFMove(buffer)); }
</span><del>-    void blobLoadingSucceeded() { finishBlobLoading(); }
</del><ins>+    void blobChunk(const char*, size_t);
+    void blobLoadingSucceeded();
</ins><span class="cx">     void blobLoadingFailed();
</span><span class="cx">     void finishBlobLoading();
</span><span class="cx"> 
</span><span class="lines">@@ -79,6 +81,7 @@
</span><span class="cx">         void didFinishLoadingAsText(String&amp;&amp; text) final { owner.loadedBlobAsText(WTFMove(text)); }
</span><span class="cx">         void didFinishLoadingAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp; buffer) final { owner.loadedBlobAsArrayBuffer(WTFMove(buffer)); }
</span><span class="cx">         void didReceiveResponse(const ResourceResponse&amp;) final;
</span><ins>+        void didReceiveData(const char* data, size_t size) final { owner.blobChunk(data, size); }
</ins><span class="cx">         void didFail() final;
</span><span class="cx">         void didSucceed() final { owner.blobLoadingSucceeded(); }
</span><span class="cx"> 
</span><span class="lines">@@ -89,6 +92,9 @@
</span><span class="cx"> protected:
</span><span class="cx">     FetchBody m_body;
</span><span class="cx">     bool m_isDisturbed { false };
</span><ins>+#if ENABLE(STREAMS_API)
+    RefPtr&lt;FetchResponseSource&gt; m_readableStreamSource;
+#endif
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     Optional&lt;BlobLoader&gt; m_blobLoader;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -68,6 +68,7 @@
</span><span class="cx">     options.contentSecurityPolicyEnforcement = ContentSecurityPolicyEnforcement::DoNotEnforce;
</span><span class="cx"> 
</span><span class="cx">     m_loader = ThreadableLoader::create(&amp;context, this, request, options);
</span><ins>+    m_isStarted = true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FetchLoader::start(ScriptExecutionContext&amp; context, const FetchRequest&amp; request)
</span><span class="lines">@@ -83,6 +84,7 @@
</span><span class="cx">     options.contentSecurityPolicyEnforcement = ContentSecurityPolicyEnforcement::DoNotEnforce;
</span><span class="cx"> 
</span><span class="cx">     m_loader = ThreadableLoader::create(&amp;context, this, request.internalRequest(), options);
</span><ins>+    m_isStarted = true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> FetchLoader::FetchLoader(Type type, FetchLoaderClient&amp; client)
</span><span class="lines">@@ -93,13 +95,20 @@
</span><span class="cx"> 
</span><span class="cx"> void FetchLoader::stop()
</span><span class="cx"> {
</span><ins>+    m_data = nullptr;
</ins><span class="cx">     if (m_loader) {
</span><del>-        m_loader-&gt;cancel();
-        m_loader = nullptr;
</del><ins>+        RefPtr&lt;ThreadableLoader&gt; loader = WTFMove(m_loader);
+        loader-&gt;cancel();
</ins><span class="cx">     }
</span><del>-    m_data = nullptr;
</del><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RefPtr&lt;SharedBuffer&gt; FetchLoader::startStreaming()
+{
+    ASSERT(m_type == Type::ArrayBuffer);
+    m_type = Type::Stream;
+    return WTFMove(m_data);
+}
+
</ins><span class="cx"> void FetchLoader::didReceiveResponse(unsigned long, const ResourceResponse&amp; response)
</span><span class="cx"> {
</span><span class="cx">     m_client.didReceiveResponse(response);
</span><span class="lines">@@ -109,6 +118,10 @@
</span><span class="cx"> // We might also want to merge this class with FileReaderLoader.
</span><span class="cx"> void FetchLoader::didReceiveData(const char* value, int size)
</span><span class="cx"> {
</span><ins>+    if (m_type == Type::Stream) {
+        m_client.didReceiveData(value, size);
+        return;
+    }
</ins><span class="cx">     if (!m_data) {
</span><span class="cx">         m_data = SharedBuffer::create(value, size);
</span><span class="cx">         return;
</span><span class="lines">@@ -120,7 +133,7 @@
</span><span class="cx"> {
</span><span class="cx">     if (m_type == Type::ArrayBuffer)
</span><span class="cx">         m_client.didFinishLoadingAsArrayBuffer(m_data ? m_data-&gt;createArrayBuffer() : ArrayBuffer::tryCreate(nullptr, 0));
</span><del>-    else
</del><ins>+    else if (m_type == Type::Text)
</ins><span class="cx">         m_client.didFinishLoadingAsText(m_data ? TextResourceDecoder::create(ASCIILiteral(&quot;text/plain&quot;), &quot;UTF-8&quot;)-&gt;decodeAndFlush(m_data-&gt;data(), m_data-&gt;size()): String());
</span><span class="cx">     m_data = nullptr;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchLoader.h (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoader.h        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoader.h        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -44,15 +44,18 @@
</span><span class="cx"> 
</span><span class="cx"> class FetchLoader final : public ThreadableLoaderClient {
</span><span class="cx"> public:
</span><del>-    enum class Type { ArrayBuffer, Text };
</del><ins>+    enum class Type { ArrayBuffer, Stream, Text };
</ins><span class="cx"> 
</span><span class="cx">     FetchLoader(Type, FetchLoaderClient&amp;);
</span><span class="cx"> 
</span><ins>+    RefPtr&lt;SharedBuffer&gt; startStreaming();
+
</ins><span class="cx">     void start(ScriptExecutionContext&amp;, const FetchRequest&amp;);
</span><span class="cx">     void start(ScriptExecutionContext&amp;, Blob&amp;);
</span><span class="cx">     void stop();
</span><span class="cx"> 
</span><del>-    bool isStarted() const { return !!m_loader; }
</del><ins>+    bool isStarted() const { return m_isStarted; }
+
</ins><span class="cx"> private:
</span><span class="cx">     // ThreadableLoaderClient API.
</span><span class="cx">     void didReceiveResponse(unsigned long, const ResourceResponse&amp;) final;
</span><span class="lines">@@ -61,11 +64,14 @@
</span><span class="cx">     void didFail(const ResourceError&amp;) final;
</span><span class="cx">     void didFailRedirectCheck() final;
</span><span class="cx"> 
</span><ins>+    Type type() const { return m_type; }
+
</ins><span class="cx"> private:
</span><span class="cx">     Type m_type { Type::ArrayBuffer };
</span><span class="cx">     FetchLoaderClient&amp; m_client;
</span><span class="cx">     RefPtr&lt;ThreadableLoader&gt; m_loader;
</span><span class="cx">     RefPtr&lt;SharedBuffer&gt; m_data;
</span><ins>+    bool m_isStarted { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoaderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void didFinishLoadingAsText(String&amp;&amp;) { }
</span><span class="cx">     virtual void didFinishLoadingAsArrayBuffer(RefPtr&lt;JSC::ArrayBuffer&gt;&amp;&amp;) { }
</span><ins>+    virtual void didReceiveData(const char*, size_t) { }
</ins><span class="cx"> 
</span><span class="cx">     virtual void didSucceed() = 0;
</span><span class="cx">     virtual void didFail() = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponsecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -119,7 +119,7 @@
</span><span class="cx"> 
</span><span class="cx"> RefPtr&lt;FetchResponse&gt; FetchResponse::clone(ScriptExecutionContext&amp; context, ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><del>-    if (isDisturbed() || m_isLocked) {
</del><ins>+    if (isDisturbed()) {
</ins><span class="cx">         ec = TypeError;
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="lines">@@ -148,12 +148,6 @@
</span><span class="cx">     return String();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// FIXME: Implement this, as a custom or through binding generator.
-JSC::JSValue JSFetchResponse::body(JSC::ExecState&amp;) const
-{
-    return JSC::jsNull();
-}
-
</del><span class="cx"> void FetchResponse::startFetching(ScriptExecutionContext&amp; context, const FetchRequest&amp; request, FetchPromise&amp;&amp; promise)
</span><span class="cx"> {
</span><span class="cx">     Ref&lt;FetchResponse&gt; response = adoptRef(*new FetchResponse(context, Type::Basic, FetchBody::loadingBody(), FetchHeaders::create(FetchHeaders::Guard::Immutable), ResourceResponse()));
</span><span class="lines">@@ -192,15 +186,31 @@
</span><span class="cx"> 
</span><span class="cx"> void FetchResponse::BodyLoader::didSucceed()
</span><span class="cx"> {
</span><ins>+    ASSERT(m_response.hasPendingActivity());
+#if ENABLE(STREAMS_API)
+    if (m_response.m_readableStreamSource) {
+        m_response.m_readableStreamSource-&gt;close();
+        m_response.m_readableStreamSource = nullptr;
+    }
+#endif
</ins><span class="cx">     m_response.m_bodyLoader = Nullopt;
</span><span class="cx">     m_response.unsetPendingActivity(&amp;m_response);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FetchResponse::BodyLoader::didFail()
</span><span class="cx"> {
</span><ins>+    ASSERT(m_response.hasPendingActivity());
</ins><span class="cx">     if (m_promise)
</span><span class="cx">         std::exchange(m_promise, Nullopt)-&gt;reject(TypeError);
</span><span class="cx"> 
</span><ins>+#if ENABLE(STREAMS_API)
+    if (m_response.m_readableStreamSource) {
+        if (!m_response.m_readableStreamSource-&gt;isCancelling())
+            m_response.m_readableStreamSource-&gt;error(ASCIILiteral(&quot;Loading failed&quot;));
+        m_response.m_readableStreamSource = nullptr;
+    }
+#endif
+
</ins><span class="cx">     // Check whether didFail is called as part of FetchLoader::start.
</span><span class="cx">     if (m_loader-&gt;isStarted())
</span><span class="cx">         m_response.m_bodyLoader = Nullopt;
</span><span class="lines">@@ -226,6 +236,19 @@
</span><span class="cx">     std::exchange(m_promise, Nullopt)-&gt;resolve(&amp;m_response);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FetchResponse::BodyLoader::didReceiveData(const char* data, size_t size)
+{
+#if ENABLE(STREAMS_API)
+    ASSERT(m_response.m_readableStreamSource);
+
+    // FIXME: If ArrayBuffer::tryCreate returns null, we should probably cancel the load.
+    m_response.m_readableStreamSource-&gt;enqueue(ArrayBuffer::tryCreate(data, size));
+#else
+    UNUSED_PARAM(data);
+    UNUSED_PARAM(size);
+#endif
+}
+
</ins><span class="cx"> void FetchResponse::BodyLoader::didFinishLoadingAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp; buffer)
</span><span class="cx"> {
</span><span class="cx">     m_response.body().loadedAsArrayBuffer(WTFMove(buffer));
</span><span class="lines">@@ -244,13 +267,53 @@
</span><span class="cx">         m_loader-&gt;stop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(STREAMS_API)
+void FetchResponse::consumeBodyAsStream()
+{
+    ASSERT(m_readableStreamSource);
+    m_isDisturbed = true;
+    if (body().type() != FetchBody::Type::Loading) {
+        body().consumeAsStream(*this, *m_readableStreamSource);
+        if (!m_readableStreamSource-&gt;isStarting())
+            m_readableStreamSource = nullptr;        
+        return;
+    }
+
+    ASSERT(m_bodyLoader);
+
+    RefPtr&lt;SharedBuffer&gt; data = m_bodyLoader-&gt;startStreaming();
+    if (data) {
+        // FIXME: We might want to enqueue each internal SharedBuffer chunk as an individual ArrayBuffer.
+        // Also, createArrayBuffer might return nullptr which will lead to erroring the stream.
+        // We might want to cancel the load and rename createArrayBuffer to tryCreateArrayBuffer.
+        m_readableStreamSource-&gt;enqueue(data-&gt;createArrayBuffer());
+    }
+}
+
+ReadableStreamSource* FetchResponse::createReadableStreamSource()
+{
+    ASSERT(!m_readableStreamSource);
+    if (body().isEmpty() || isDisturbed())
+        return nullptr;
+
+    m_readableStreamSource = adoptRef(*new FetchResponseSource(*this));
+    return m_readableStreamSource.get();
+}
+
+RefPtr&lt;SharedBuffer&gt; FetchResponse::BodyLoader::startStreaming()
+{
+    ASSERT(m_loader);
+    return m_loader-&gt;startStreaming();
+}
+#endif
+
</ins><span class="cx"> void FetchResponse::stop()
</span><span class="cx"> {
</span><ins>+    RefPtr&lt;FetchResponse&gt; protect(this);
</ins><span class="cx">     FetchBodyOwner::stop();
</span><span class="cx">     if (m_bodyLoader) {
</span><del>-        RefPtr&lt;FetchResponse&gt; protect(this);
</del><span class="cx">         m_bodyLoader-&gt;stop();
</span><del>-        m_bodyLoader = Nullopt;
</del><ins>+        ASSERT(!m_bodyLoader);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.h (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.h        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.h        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -43,6 +43,7 @@
</span><span class="cx"> 
</span><span class="cx"> class Dictionary;
</span><span class="cx"> class FetchRequest;
</span><ins>+class ReadableStreamSource;
</ins><span class="cx"> 
</span><span class="cx"> typedef int ExceptionCode;
</span><span class="cx"> 
</span><span class="lines">@@ -70,6 +71,11 @@
</span><span class="cx">     FetchHeaders&amp; headers() { return m_headers; }
</span><span class="cx">     RefPtr&lt;FetchResponse&gt; clone(ScriptExecutionContext&amp;, ExceptionCode&amp;);
</span><span class="cx"> 
</span><ins>+#if ENABLE(STREAMS_API)
+    ReadableStreamSource* createReadableStreamSource();
+    void consumeBodyAsStream();
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx">     enum class Type { Basic, Cors, Default, Error, Opaque, OpaqueRedirect };
</span><span class="cx"> 
</span><span class="lines">@@ -89,11 +95,16 @@
</span><span class="cx">         bool start(ScriptExecutionContext&amp;, const FetchRequest&amp;);
</span><span class="cx">         void stop();
</span><span class="cx"> 
</span><ins>+#if ENABLE(STREAMS_API)
+        RefPtr&lt;SharedBuffer&gt; startStreaming();
+#endif
+
</ins><span class="cx">     private:
</span><span class="cx">         // FetchLoaderClient API
</span><span class="cx">         void didSucceed() final;
</span><span class="cx">         void didFail() final;
</span><span class="cx">         void didReceiveResponse(const ResourceResponse&amp;);
</span><ins>+        void didReceiveData(const char*, size_t) final;
</ins><span class="cx">         void didFinishLoadingAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp;) final;
</span><span class="cx"> 
</span><span class="cx">         FetchResponse&amp; m_response;
</span><span class="lines">@@ -104,7 +115,6 @@
</span><span class="cx">     Type m_type;
</span><span class="cx">     ResourceResponse m_response;
</span><span class="cx">     Ref&lt;FetchHeaders&gt; m_headers;
</span><del>-    bool m_isLocked = false;
</del><span class="cx">     bool m_isRedirected = false;
</span><span class="cx">     Optional&lt;BodyLoader&gt; m_bodyLoader;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponseidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.idl (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.idl        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.idl        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx">     readonly attribute DOMString statusText;
</span><span class="cx">     // FIXME: Add support for SameObject keyword for headers
</span><span class="cx">     readonly attribute FetchHeaders headers;
</span><del>-    [Custom, RaisesException] readonly attribute ReadableStream? body;
</del><ins>+    [Custom, CachedAttribute] readonly attribute ReadableStream? body;
</ins><span class="cx"> 
</span><span class="cx">     [NewObject, CallWith=ScriptExecutionContext, RaisesException] FetchResponse clone();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponseSourcecppfromrev199640trunkSourceWebCoreModulesfetchFetchLoaderClienth"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/fetch/FetchResponseSource.cpp (from rev 199640, trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h) (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponseSource.cpp                                (rev 0)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponseSource.cpp        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+/*
+ * Copyright (C) 2016 Canon Inc.
+ *
+ * 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 &quot;AS IS&quot; 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 &quot;config.h&quot;
+#include &quot;FetchResponseSource.h&quot;
+
+#if ENABLE(FETCH_API) &amp;&amp; ENABLE(STREAMS_API)
+
+#include &quot;FetchResponse.h&quot;
+
+namespace WebCore {
+
+FetchResponseSource::FetchResponseSource(FetchResponse&amp; response)
+    : m_response(response)
+{
+}
+
+bool FetchResponseSource::isReadableStreamLocked() const
+{
+    return controller().isControlledReadableStreamLocked();
+}
+
+void FetchResponseSource::setActive()
+{
+    m_response.setPendingActivity(&amp;m_response);
+}
+
+void FetchResponseSource::setInactive()
+{
+    m_response.unsetPendingActivity(&amp;m_response);
+}
+
+void FetchResponseSource::doStart()
+{
+    // FIXME: We should consume body only if stream reader requested data, i.e. is disturbed.
+    // We might need a callback to be notified of the stream being disturbed.
+    m_response.consumeBodyAsStream();
+}
+
+void FetchResponseSource::doCancel()
+{
+    m_isCancelling = true;
+    static_cast&lt;ActiveDOMObject&amp;&gt;(m_response).stop();
+}
+
+void FetchResponseSource::close()
+{
+    ASSERT(isStarting());
+    controller().close();
+    clean();
+}
+void FetchResponseSource::error(const String&amp; value)
+{
+    ASSERT(isStarting());
+    controller().error(value);
+    clean();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FETCH_API) &amp;&amp; ENABLE(STREAMS_API)
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponseSourcehfromrev199640trunkSourceWebCoreModulesfetchFetchLoaderClienth"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/fetch/FetchResponseSource.h (from rev 199640, trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h) (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponseSource.h                                (rev 0)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponseSource.h        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,65 @@
</span><ins>+/*
+ * Copyright (C) 2016 Canon Inc.
+ *
+ * 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 &quot;AS IS&quot; 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 FetchResponseSource_h
+#define FetchResponseSource_h
+
+#if ENABLE(FETCH_API) &amp;&amp; ENABLE(STREAMS_API)
+
+#include &quot;ReadableStreamSource.h&quot;
+
+namespace WebCore {
+
+class FetchResponse;
+
+class FetchResponseSource final : public ReadableStreamSource {
+public:
+    FetchResponseSource(FetchResponse&amp;);
+
+    template&lt;typename T&gt; void enqueue(const T&amp; t) { controller().enqueue(t); }
+    void close();
+    void error(const String&amp;);
+
+    bool isCancelling() const { return m_isCancelling; }
+    bool isReadableStreamLocked() const;
+
+private:
+    void doStart() final;
+    void doCancel() final;
+    void setActive() final;
+    void setInactive() final;
+
+    FetchResponse&amp; m_response;
+    bool m_isCancelling { false };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(FETCH_API) &amp;&amp; ENABLE(STREAMS_API)
+
+#endif // FetchResponseSource_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamController.js (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStreamController.js        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamController.js        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx"> 
</span><span class="cx">     const stream = this.@controlledReadableStream;
</span><span class="cx">     if (stream.@state !== @streamReadable)
</span><del>-        throw new @TypeError(&quot;ReaableStream is not readable&quot;);
</del><ins>+        throw new @TypeError(&quot;ReadableStream is not readable&quot;);
</ins><span class="cx"> 
</span><span class="cx">     @errorReadableStream(stream, error);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamSourceh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/Modules/streams/ReadableStreamSource.h (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStreamSource.h                                (rev 0)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamSource.h        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,113 @@
</span><ins>+/*
+ * Copyright (C) 2016 Canon Inc.
+ *
+ * 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 &quot;AS IS&quot; 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 ReadableStreamSource_h
+#define ReadableStreamSource_h
+
+#if ENABLE(STREAMS_API)
+
+#include &quot;JSDOMPromise.h&quot;
+#include &quot;ReadableStreamController.h&quot;
+#include &lt;runtime/ArrayBuffer.h&gt;
+#include &lt;wtf/Optional.h&gt;
+
+namespace Deprecated {
+class ScriptValue;
+}
+
+namespace WebCore {
+
+typedef int ExceptionCode;
+
+class ReadableStreamSource : public RefCounted&lt;ReadableStreamSource&gt; {
+public:
+    virtual ~ReadableStreamSource() { }
+
+    typedef DOMPromise&lt;std::nullptr_t, ExceptionCode&gt; Promise;
+
+    void start(ReadableStreamController&amp;&amp;, Promise&amp;&amp;);
+    void cancel(const Deprecated::ScriptValue&amp;);
+
+    bool isStarting() const { return !!m_startPromise; }
+
+protected:
+    ReadableStreamController&amp; controller() { return m_controller.value(); }
+    const ReadableStreamController&amp; controller() const { return m_controller.value(); }
+
+    void startFinished();
+    void cancelFinished();
+    void clean();
+
+    virtual void setActive() = 0;
+    virtual void setInactive() = 0;
+
+    virtual void doStart() { startFinished(); }
+    virtual void doCancel() { }
+
+private:
+    Optional&lt;Promise&gt; m_startPromise;
+
+    Optional&lt;ReadableStreamController&gt; m_controller;
+};
+
+inline void ReadableStreamSource::start(ReadableStreamController&amp;&amp; controller, Promise&amp;&amp; promise)
+{
+    m_startPromise = WTFMove(promise);
+    m_controller = WTFMove(controller);
+
+    setActive();
+    doStart();
+}
+
+inline void ReadableStreamSource::startFinished()
+{
+    ASSERT(m_startPromise);
+    std::exchange(m_startPromise, Nullopt).value().resolve(nullptr);
+    setInactive();
+}
+
+inline void ReadableStreamSource::cancel(const Deprecated::ScriptValue&amp;)
+{
+    clean();
+    doCancel();
+}
+
+inline void ReadableStreamSource::clean()
+{
+    if (m_startPromise) {
+        m_startPromise = Nullopt;
+        setInactive();
+    }
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(STREAMS_API)
+
+#endif // ReadableStreamSource_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesstreamsReadableStreamSourceidlfromrev199640trunkSourceWebCoreModulesfetchFetchLoaderClienth"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/streams/ReadableStreamSource.idl (from rev 199640, trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h) (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/streams/ReadableStreamSource.idl                                (rev 0)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamSource.idl        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+/*
+ * Copyright (C) 2016 Canon Inc.
+ *
+ * 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 &quot;AS IS&quot; 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.
+ */
+
+[
+    NoInterfaceObject,
+    Conditional=STREAMS_API,
+    SkipVTableValidation
+] interface ReadableStreamSource {
+    // Methods to support push sources. To support all sources, pull method might need to be added, and cancel may return a promise.
+    [Custom] Promise start(ReadableStreamController controller);
+    void cancel(any reason);
+
+    // Place holder to keep the controller linked to the source.
+    [CachedAttribute, CustomGetter] readonly attribute any controller;
+};
</ins></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -1520,6 +1520,7 @@
</span><span class="cx">                 4129DF851BB5B80700322A16 /* JSReadableStreamPrivateConstructors.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4129DF831BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.cpp */; };
</span><span class="cx">                 4129DF861BB5B80C00322A16 /* JSReadableStreamPrivateConstructors.h in Headers */ = {isa = PBXBuildFile; fileRef = 4129DF841BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 413015D91C7B571400091C6E /* FetchResponse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 413015D51C7B570400091C6E /* FetchResponse.cpp */; };
</span><ins>+                413015D91C7B571400091C6F /* FetchResponseSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 413015D51C7B570400091C6F /* FetchResponseSource.cpp */; };
</ins><span class="cx">                 4138D3351244054800323D33 /* EventContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4138D3331244054800323D33 /* EventContext.h */; };
</span><span class="cx">                 4138D3361244054800323D33 /* EventContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4138D3341244054800323D33 /* EventContext.cpp */; };
</span><span class="cx">                 413C2C341BC29A8F0075204C /* JSDOMConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 413C2C331BC29A7B0075204C /* JSDOMConstructor.h */; };
</span><span class="lines">@@ -1556,6 +1557,9 @@
</span><span class="cx">                 418A06D1133C04D500CD379C /* EventDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 418A06CF133C04D500CD379C /* EventDispatcher.cpp */; };
</span><span class="cx">                 418C39561C8DAC7F0051C8A3 /* DOMWindowFetch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 418C39521C8DAC7B0051C8A3 /* DOMWindowFetch.cpp */; };
</span><span class="cx">                 418C395A1C8DD6990051C8A3 /* WorkerGlobalScopeFetch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 418C39571C8DD6960051C8A3 /* WorkerGlobalScopeFetch.cpp */; };
</span><ins>+                418C39601C8F0AAE0051C8A3 /* JSReadableStreamSourceCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */; };
+                418C39611C8F0AB10051C8A3 /* ReadableStreamController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 418C395E1C8F0AAB0051C8A3 /* ReadableStreamController.cpp */; };
+                418C39631C8F129B0051C8A3 /* JSFetchResponseCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 418C39621C8F12970051C8A3 /* JSFetchResponseCustom.cpp */; };
</ins><span class="cx">                 418F88040FF957AE0080F045 /* JSAbstractWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 418F88020FF957AE0080F045 /* JSAbstractWorker.cpp */; };
</span><span class="cx">                 418F88050FF957AF0080F045 /* JSAbstractWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 418F88030FF957AE0080F045 /* JSAbstractWorker.h */; };
</span><span class="cx">                 419BC2DE1685329900D64D6D /* VisitedLinkState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 419BC2DC1685329900D64D6D /* VisitedLinkState.cpp */; };
</span><span class="lines">@@ -2794,6 +2798,8 @@
</span><span class="cx">                 7E474E1E12494DC900235364 /* SQLiteDatabaseTrackerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E474E1B12494DC900235364 /* SQLiteDatabaseTrackerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 7E474E1F12494DC900235364 /* SQLiteDatabaseTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E474E1C12494DC900235364 /* SQLiteDatabaseTracker.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 7E474E2012494DC900235364 /* SQLiteDatabaseTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E474E1D12494DC900235364 /* SQLiteDatabaseTracker.cpp */; };
</span><ins>+                7E4C96DC1AD4483500365A51 /* JSReadableStreamSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4C96D81AD4483500365A51 /* JSReadableStreamSource.cpp */; };
+                7E4C96DD1AD4483500365A51 /* JSReadableStreamSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E4C96D91AD4483500365A51 /* JSReadableStreamSource.h */; };
</ins><span class="cx">                 7E4C96DC1AD4483500365A50 /* JSFetchRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7E4C96D81AD4483500365A50 /* JSFetchRequest.cpp */; };
</span><span class="cx">                 7E4C96DD1AD4483500365A50 /* JSFetchRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E4C96D91AD4483500365A50 /* JSFetchRequest.h */; };
</span><span class="cx">                 7E4DE10D198B10B60051CB02 /* DiskCacheMonitorCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E4DE10C198B10B60051CB02 /* DiskCacheMonitorCocoa.mm */; };
</span><span class="lines">@@ -8990,11 +8996,11 @@
</span><span class="cx">                 410D33231C19984100F7FDE2 /* WebCoreJSBuiltinInternals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCoreJSBuiltinInternals.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 41189EF71AD8232800B90A0D /* ReadableStreamController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamController.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 4127D5360F8AAB1D00E424F5 /* ScriptState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptState.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                4129DF811BB5B79B00322A16 /* ReadableStreamController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
-                4129DF821BB5B7A600322A16 /* ReadableStreamReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamReader.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 4129DF831BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamPrivateConstructors.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 4129DF841BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamPrivateConstructors.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 413015D51C7B570400091C6E /* FetchResponse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchResponse.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                413015D51C7B570400091C6F /* FetchResponseSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchResponseSource.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                413015D61C7B570400091C6F /* FetchResponseSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchResponseSource.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 413015D61C7B570400091C6E /* FetchResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchResponse.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 413015D71C7B570400091C6E /* FetchResponse.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FetchResponse.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 413015D81C7B570400091C6E /* FetchResponse.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = FetchResponse.js; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -9040,6 +9046,12 @@
</span><span class="cx">                 418C39571C8DD6960051C8A3 /* WorkerGlobalScopeFetch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerGlobalScopeFetch.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 418C39581C8DD6960051C8A3 /* WorkerGlobalScopeFetch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerGlobalScopeFetch.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 418C39591C8DD6960051C8A3 /* WorkerGlobalScopeFetch.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WorkerGlobalScopeFetch.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                418C395B1C8F0A610051C8A3 /* ReadableStreamSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamSource.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                418C395C1C8F0A610051C8A3 /* ReadableStreamSource.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamSource.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
+                418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamSourceCustom.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                418C395E1C8F0AAB0051C8A3 /* ReadableStreamController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadableStreamController.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                418C395F1C8F0AAB0051C8A3 /* ReadableStreamController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamController.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                418C39621C8F12970051C8A3 /* JSFetchResponseCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFetchResponseCustom.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 418F88020FF957AE0080F045 /* JSAbstractWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAbstractWorker.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 418F88030FF957AE0080F045 /* JSAbstractWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAbstractWorker.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 419BC2DC1685329900D64D6D /* VisitedLinkState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VisitedLinkState.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -10443,6 +10455,8 @@
</span><span class="cx">                 7E474E1B12494DC900235364 /* SQLiteDatabaseTrackerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLiteDatabaseTrackerClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7E474E1C12494DC900235364 /* SQLiteDatabaseTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLiteDatabaseTracker.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7E474E1D12494DC900235364 /* SQLiteDatabaseTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SQLiteDatabaseTracker.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                7E4C96D81AD4483500365A51 /* JSReadableStreamSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSReadableStreamSource.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                7E4C96D91AD4483500365A51 /* JSReadableStreamSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSReadableStreamSource.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 7E4C96D81AD4483500365A50 /* JSFetchRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFetchRequest.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7E4C96D91AD4483500365A50 /* JSFetchRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFetchRequest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7E4DE10C198B10B60051CB02 /* DiskCacheMonitorCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DiskCacheMonitorCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -16787,13 +16801,13 @@
</span><span class="cx">                                 9908B0EE1BCACF9100ED0F65 /* CountQueuingStrategy.js */,
</span><span class="cx">                                 41A023ED1A39DB7900F722CF /* ReadableStream.idl */,
</span><span class="cx">                                 9908B0EF1BCACF9100ED0F65 /* ReadableStream.js */,
</span><del>-                                4129DF811BB5B79B00322A16 /* ReadableStreamController.h */,
</del><span class="cx">                                 41189EF71AD8232800B90A0D /* ReadableStreamController.idl */,
</span><span class="cx">                                 9908B0F01BCACF9100ED0F65 /* ReadableStreamController.js */,
</span><span class="cx">                                 9908B0F11BCACF9100ED0F65 /* ReadableStreamInternals.js */,
</span><del>-                                4129DF821BB5B7A600322A16 /* ReadableStreamReader.h */,
</del><span class="cx">                                 419FAFAD1ABABCD5005B828B /* ReadableStreamReader.idl */,
</span><span class="cx">                                 9908B0F21BCACF9100ED0F65 /* ReadableStreamReader.js */,
</span><ins>+                                418C395B1C8F0A610051C8A3 /* ReadableStreamSource.h */,
+                                418C395C1C8F0A610051C8A3 /* ReadableStreamSource.idl */,
</ins><span class="cx">                                 9908B0F11BCACF9100ED0F55 /* StreamInternals.js */,
</span><span class="cx">                                 41A023ED1A39DB7900F722DF /* WritableStream.idl */,
</span><span class="cx">                                 9908B0EF1BCACF9100ED0F75 /* WritableStream.js */,
</span><span class="lines">@@ -16841,6 +16855,8 @@
</span><span class="cx">                                 41F54F891C50C4F600338488 /* FetchRequest.idl */,
</span><span class="cx">                                 413015D51C7B570400091C6E /* FetchResponse.cpp */,
</span><span class="cx">                                 413015D61C7B570400091C6E /* FetchResponse.h */,
</span><ins>+                                413015D51C7B570400091C6F /* FetchResponseSource.cpp */,
+                                413015D61C7B570400091C6F /* FetchResponseSource.h */,
</ins><span class="cx">                                 413015D71C7B570400091C6E /* FetchResponse.idl */,
</span><span class="cx">                                 413015D81C7B570400091C6E /* FetchResponse.js */,
</span><span class="cx">                                 418C39571C8DD6960051C8A3 /* WorkerGlobalScopeFetch.cpp */,
</span><span class="lines">@@ -16861,6 +16877,8 @@
</span><span class="cx">                                 7E4C96D91AD4483500365A50 /* JSFetchRequest.h */,
</span><span class="cx">                                 8E4C96D81AD4483500365A50 /* JSFetchResponse.cpp */,
</span><span class="cx">                                 8E4C96D91AD4483500365A50 /* JSFetchResponse.h */,
</span><ins>+                                7E4C96D81AD4483500365A51 /* JSReadableStreamSource.cpp */,
+                                7E4C96D91AD4483500365A51 /* JSReadableStreamSource.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         name = FetchAPI;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -22295,6 +22313,7 @@
</span><span class="cx">                                 46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */,
</span><span class="cx">                                 3314ACE910892086000F0E56 /* JSExceptionBase.cpp */,
</span><span class="cx">                                 3314ACEA10892086000F0E56 /* JSExceptionBase.h */,
</span><ins>+                                418C39621C8F12970051C8A3 /* JSFetchResponseCustom.cpp */,
</ins><span class="cx">                                 8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */,
</span><span class="cx">                                 8F934D831189F1EE00508D5D /* JSMainThreadExecState.h */,
</span><span class="cx">                                 B56576E417DA599F00A56BDC /* JSMainThreadExecStateInstrumentation.h */,
</span><span class="lines">@@ -22309,8 +22328,11 @@
</span><span class="cx">                                 93B70D5009EB0C7C009D8468 /* JSPluginElementFunctions.h */,
</span><span class="cx">                                 4129DF831BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.cpp */,
</span><span class="cx">                                 4129DF841BB5B7F700322A16 /* JSReadableStreamPrivateConstructors.h */,
</span><ins>+                                418C395D1C8F0AAB0051C8A3 /* JSReadableStreamSourceCustom.cpp */,
</ins><span class="cx">                                 E1C36D320EB0A094007410BC /* JSWorkerGlobalScopeBase.cpp */,
</span><span class="cx">                                 E1C36D330EB0A094007410BC /* JSWorkerGlobalScopeBase.h */,
</span><ins>+                                418C395E1C8F0AAB0051C8A3 /* ReadableStreamController.cpp */,
+                                418C395F1C8F0AAB0051C8A3 /* ReadableStreamController.h */,
</ins><span class="cx">                                 BCA378BA0D15F64200B793D6 /* ScheduledAction.cpp */,
</span><span class="cx">                                 BCA378BB0D15F64200B793D6 /* ScheduledAction.h */,
</span><span class="cx">                                 41F1D21E0EF35C2A00DA8753 /* ScriptCachedFrameData.cpp */,
</span><span class="lines">@@ -26581,6 +26603,7 @@
</span><span class="cx">                                 7F4C96DD1AD4483500365A50 /* JSFetchBody.h in Headers */,
</span><span class="cx">                                 7D4C96DD1AD4483500365A50 /* JSFetchHeaders.h in Headers */,
</span><span class="cx">                                 7E4C96DD1AD4483500365A50 /* JSFetchRequest.h in Headers */,
</span><ins>+                                7E4C96DD1AD4483500365A51 /* JSReadableStreamSource.h in Headers */,
</ins><span class="cx">                                 8E4C96DD1AD4483500365A50 /* JSFetchResponse.h in Headers */,
</span><span class="cx">                                 BC00F0150E0A189500FD04E3 /* JSFile.h in Headers */,
</span><span class="cx">                                 2E3BC0CB117D3E0800B9409A /* JSFileError.h in Headers */,
</span><span class="lines">@@ -29314,6 +29337,7 @@
</span><span class="cx">                                 CD3E252318046BCD00E27F56 /* CSSGridTemplateAreasValue.cpp in Sources */,
</span><span class="cx">                                 FBF89045169E9F1F0052D86E /* CSSGroupingRule.cpp in Sources */,
</span><span class="cx">                                 BC23E76C0DAE88A9009FDC91 /* CSSImageGeneratorValue.cpp in Sources */,
</span><ins>+                                418C39601C8F0AAE0051C8A3 /* JSReadableStreamSourceCustom.cpp in Sources */,
</ins><span class="cx">                                 9393E5FF151A99F200066F06 /* CSSImageSetValue.cpp in Sources */,
</span><span class="cx">                                 A80E6CFE0A1989CA007FB8C5 /* CSSImageValue.cpp in Sources */,
</span><span class="cx">                                 A80E6CEB0A1989CA007FB8C5 /* CSSImportRule.cpp in Sources */,
</span><span class="lines">@@ -29713,6 +29737,7 @@
</span><span class="cx">                                 41F54F8D1C50C50800338488 /* FetchHeaders.cpp in Sources */,
</span><span class="cx">                                 41F54F8E1C50C50C00338488 /* FetchRequest.cpp in Sources */,
</span><span class="cx">                                 413015D91C7B571400091C6E /* FetchResponse.cpp in Sources */,
</span><ins>+                                413015D91C7B571400091C6F /* FetchResponseSource.cpp in Sources */,
</ins><span class="cx">                                 84730D8A1248F0B300D3A9C9 /* FETile.cpp in Sources */,
</span><span class="cx">                                 84730D8C1248F0B300D3A9C9 /* FETurbulence.cpp in Sources */,
</span><span class="cx">                                 FD31609412B026F700C1A359 /* FFTConvolver.cpp in Sources */,
</span><span class="lines">@@ -29907,6 +29932,7 @@
</span><span class="cx">                                 A8EA79FC0A1916DF00A8EF5F /* HTMLLIElement.cpp in Sources */,
</span><span class="cx">                                 A871DC210A15205700B12A68 /* HTMLLinkElement.cpp in Sources */,
</span><span class="cx">                                 A8EA7D320A19385500A8EF5F /* HTMLMapElement.cpp in Sources */,
</span><ins>+                                418C39611C8F0AB10051C8A3 /* ReadableStreamController.cpp in Sources */,
</ins><span class="cx">                                 A8EA7CAC0A192B9C00A8EF5F /* HTMLMarqueeElement.cpp in Sources */,
</span><span class="cx">                                 E44613A40CD6331000FADA75 /* HTMLMediaElement.cpp in Sources */,
</span><span class="cx">                                 7AD3CDD91C8A002F00F12698 /* ResourceLoadStatisticsStore.cpp in Sources */,
</span><span class="lines">@@ -30273,6 +30299,7 @@
</span><span class="cx">                                 7F4C96DC1AD4483500365A50 /* JSFetchBody.cpp in Sources */,
</span><span class="cx">                                 7D4C96DC1AD4483500365A50 /* JSFetchHeaders.cpp in Sources */,
</span><span class="cx">                                 7E4C96DC1AD4483500365A50 /* JSFetchRequest.cpp in Sources */,
</span><ins>+                                7E4C96DC1AD4483500365A51 /* JSReadableStreamSource.cpp in Sources */,
</ins><span class="cx">                                 8E4C96DC1AD4483500365A50 /* JSFetchResponse.cpp in Sources */,
</span><span class="cx">                                 BC00F0140E0A189500FD04E3 /* JSFile.cpp in Sources */,
</span><span class="cx">                                 2E3BC0CA117D3E0800B9409A /* JSFileError.cpp in Sources */,
</span><span class="lines">@@ -30904,6 +30931,7 @@
</span><span class="cx">                                 078E08FE17D14CEE00420AA1 /* MediaConstraintsImpl.cpp in Sources */,
</span><span class="cx">                                 073794E119EE2D1B00E5A045 /* MediaConstraintsMock.cpp in Sources */,
</span><span class="cx">                                 417253AA1354BBBC00360F2A /* MediaControlElements.cpp in Sources */,
</span><ins>+                                418C39631C8F129B0051C8A3 /* JSFetchResponseCustom.cpp in Sources */,
</ins><span class="cx">                                 DEBCCDD516646EB200A452E1 /* MediaControlElementTypes.cpp in Sources */,
</span><span class="cx">                                 CD27F6E7145770D30078207D /* MediaController.cpp in Sources */,
</span><span class="cx">                                 1F3C3BEA135CAF3C00B8C1AC /* MediaControls.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMGlobalObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.h (199640 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.h        2016-04-17 17:56:47 UTC (rev 199640)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.h        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -69,6 +69,8 @@
</span><span class="cx">         DOMWrapperWorld&amp; world() { return *m_world; }
</span><span class="cx">         bool worldIsNormal() const { return m_worldIsNormal; }
</span><span class="cx"> 
</span><ins>+        JSBuiltinInternalFunctions&amp; builtinInternalFunctions() { return m_builtinInternalFunctions; }
+
</ins><span class="cx">     protected:
</span><span class="cx">         static const JSC::ClassInfo s_info;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSFetchResponseCustomcppfromrev199640trunkSourceWebCoreModulesfetchFetchLoaderClienth"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/bindings/js/JSFetchResponseCustom.cpp (from rev 199640, trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h) (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSFetchResponseCustom.cpp                                (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSFetchResponseCustom.cpp        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+ * Copyright (C) 2016 Canon Inc.
+ *
+ * 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 &quot;AS IS&quot; 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 &quot;config.h&quot;
+#include &quot;JSFetchResponse.h&quot;
+
+#if ENABLE(FETCH_API)
+
+#include &quot;JSReadableStreamSource.h&quot;
+
+namespace WebCore {
+
+JSC::JSValue JSFetchResponse::body(JSC::ExecState&amp; state) const
+{
+#if ENABLE(STREAMS_API)
+    if (!m_body)
+        m_body.set(state.vm(), this, createReadableStream(state, globalObject(), wrapped().createReadableStreamSource()));
+    return m_body.get();
+#else
+    UNUSED_PARAM(state);
+    return JSC::jsNull();
+#endif
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FETCH_API)
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSReadableStreamSourceCustomcppfromrev199640trunkSourceWebCoreModulesfetchFetchLoaderClienth"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/bindings/js/JSReadableStreamSourceCustom.cpp (from rev 199640, trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h) (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSReadableStreamSourceCustom.cpp                                (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSReadableStreamSourceCustom.cpp        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,59 @@
</span><ins>+/*
+ * Copyright (C) 2016 Canon Inc.
+ *
+ * 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 &quot;AS IS&quot; 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 &quot;config.h&quot;
+#include &quot;JSReadableStreamSource.h&quot;
+
+#if ENABLE(STREAMS_API)
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSValue JSReadableStreamSource::start(ExecState&amp; state)
+{
+    JSReadableStreamController* controller = jsDynamicCast&lt;JSReadableStreamController*&gt;(state.argument(0));
+    ASSERT(controller);
+
+    JSReadableStreamSource* jsSource = const_cast&lt;JSReadableStreamSource*&gt;(this);
+    m_controller.set(state.vm(), jsSource, state.argument(0));
+
+    JSC::JSPromiseDeferred* promiseDeferred = JSC::JSPromiseDeferred::create(&amp;state, globalObject());
+    wrapped().start(ReadableStreamController(controller), DeferredWrapper(&amp;state, globalObject(), promiseDeferred));
+    return promiseDeferred-&gt;promise();
+}
+
+JSValue JSReadableStreamSource::controller(ExecState&amp;) const
+{
+    ASSERT_NOT_REACHED();
+    return jsUndefined();
+}
+
+}
+
+#endif // ENABLE(STREAMS_API)
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsjsReadableStreamControllercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/js/ReadableStreamController.cpp (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ReadableStreamController.cpp                                (rev 0)
+++ trunk/Source/WebCore/bindings/js/ReadableStreamController.cpp        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,111 @@
</span><ins>+/*
+ * Copyright (C) 2016 Canon Inc.
+ *
+ * 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 &quot;AS IS&quot; 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 &quot;config.h&quot;
+#include &quot;ReadableStreamController.h&quot;
+
+#if ENABLE(STREAMS_API)
+
+#include &quot;JSReadableStream.h&quot;
+#include &quot;JSReadableStreamSource.h&quot;
+#include &quot;WebCoreJSClientData.h&quot;
+
+namespace WebCore {
+
+static inline JSC::JSValue callFunction(JSC::ExecState&amp; state, JSC::JSValue jsFunction, JSC::JSValue thisValue, const JSC::ArgList&amp; arguments)
+{
+    JSC::CallData callData;
+    JSC::CallType callType = JSC::getCallData(jsFunction, callData);
+    return JSC::call(&amp;state, jsFunction, callType, callData, thisValue, arguments);
+}
+
+JSC::JSValue ReadableStreamController::invoke(JSC::ExecState&amp; state, JSC::JSObject&amp; object, const char* propertyName, JSC::JSValue parameter)
+{
+    JSC::JSLockHolder lock(&amp;state);
+
+    JSC::JSValue function = getPropertyFromObject(state, object, propertyName);
+    if (state.hadException())
+        return JSC::jsUndefined();
+
+    if (!function.isFunction()) {
+        if (!function.isUndefined())
+            throwVMError(&amp;state, createTypeError(&amp;state, ASCIILiteral(&quot;ReadableStream trying to call a property that is not callable&quot;)));
+        return JSC::jsUndefined();
+    }
+
+    JSC::MarkedArgumentBuffer arguments;
+    arguments.append(parameter);
+
+    return callFunction(state, function, &amp;object, arguments);
+}
+
+bool ReadableStreamController::isControlledReadableStreamLocked() const
+{
+    JSC::ExecState&amp; state = *globalObject()-&gt;globalExec();
+    JSC::JSLockHolder lock(&amp;state);
+
+    JSVMClientData&amp; clientData = *static_cast&lt;JSVMClientData*&gt;(state.vm().clientData);
+    JSC::JSValue readableStream = m_jsController-&gt;get(&amp;state, clientData.builtinNames().controlledReadableStreamPrivateName());
+    ASSERT(!state.hadException());
+
+    JSC::JSValue isLocked = globalObject()-&gt;builtinInternalFunctions().readableStreamInternals().m_isReadableStreamLockedFunction.get();
+
+    JSC::MarkedArgumentBuffer arguments;
+    arguments.append(readableStream);
+    JSC::JSValue result = callFunction(state, isLocked, JSC::jsUndefined(), arguments);
+    ASSERT(!state.hadException());
+
+    return result.isTrue();
+}
+
+JSC::JSValue createReadableStream(JSC::ExecState&amp; state, JSDOMGlobalObject* globalObject, ReadableStreamSource* source)
+{
+    if (!source)
+        return JSC::jsNull();
+
+    JSC::JSLockHolder lock(&amp;state);
+
+    JSC::JSValue jsSource = toJS(&amp;state, globalObject, source);
+    JSC::Strong&lt;JSC::Unknown&gt; protect(state.vm(), jsSource);
+
+    JSC::MarkedArgumentBuffer arguments;
+    arguments.append(jsSource);
+
+    JSC::JSValue constructor = JSReadableStream::getConstructor(state.vm(), globalObject);
+
+    JSC::ConstructData constructData;
+    JSC::ConstructType constructType = JSC::getConstructData(constructor, constructData);
+    ASSERT(constructType != JSC::ConstructType::None);
+
+    return JSC::construct(&amp;state, constructor, constructType, constructData, arguments);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(STREAMS_API)
</ins></span></pre></div>
<a id="trunkSourceWebCorebindingsjsReadableStreamControllerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/bindings/js/ReadableStreamController.h (0 => 199641)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ReadableStreamController.h                                (rev 0)
+++ trunk/Source/WebCore/bindings/js/ReadableStreamController.h        2016-04-17 18:04:20 UTC (rev 199641)
</span><span class="lines">@@ -0,0 +1,101 @@
</span><ins>+/*
+ * Copyright (C) 2016 Canon Inc.
+ *
+ * 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 &quot;AS IS&quot; 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 ReadableStreamController_h
+#define ReadableStreamController_h
+
+#if ENABLE(STREAMS_API)
+
+#include &quot;JSDOMBinding.h&quot;
+#include &quot;JSReadableStreamController.h&quot;
+#include &lt;runtime/JSCJSValue.h&gt;
+#include &lt;runtime/JSCJSValueInlines.h&gt;
+
+namespace WebCore {
+
+class ReadableStreamSource;
+
+class ReadableStreamController {
+public:
+    explicit ReadableStreamController(JSReadableStreamController* controller) : m_jsController(controller) { }
+
+    static JSC::JSValue invoke(JSC::ExecState&amp;, JSC::JSObject&amp;, const char*, JSC::JSValue);
+
+    template&lt;class ResolveResultType&gt;
+    void enqueue(const ResolveResultType&amp;);
+
+    template&lt;class ResolveResultType&gt;
+    void error(const ResolveResultType&amp;);
+
+    void close() { invoke(*globalObject()-&gt;globalExec(), *m_jsController, &quot;close&quot;, JSC::jsUndefined()); }
+
+    bool isControlledReadableStreamLocked() const;
+
+private:
+    void error(JSC::ExecState&amp; state, JSC::JSValue value) { invoke(state, *m_jsController, &quot;error&quot;, value); }
+    void enqueue(JSC::ExecState&amp; state, JSC::JSValue value) { invoke(state, *m_jsController, &quot;enqueue&quot;, value); }
+
+    JSDOMGlobalObject* globalObject() const;
+
+    // The owner of ReadableStreamController is responsible to keep uncollected the JSReadableStreamController.
+    JSReadableStreamController* m_jsController { nullptr };
+};
+
+JSC::JSValue createReadableStream(JSC::ExecState&amp;, JSDOMGlobalObject*, ReadableStreamSource*);
+
+inline JSDOMGlobalObject* ReadableStreamController::globalObject() const
+{
+    ASSERT(m_jsController);
+    return static_cast&lt;JSDOMGlobalObject*&gt;(m_jsController-&gt;globalObject());
+}
+
+template&lt;&gt;
+inline void ReadableStreamController::enqueue&lt;RefPtr&lt;JSC::ArrayBuffer&gt;&gt;(const RefPtr&lt;JSC::ArrayBuffer&gt;&amp; result)
+{
+    JSC::ExecState&amp; state = *globalObject()-&gt;globalExec();
+    JSC::JSLockHolder locker(&amp;state);
+
+    if (result)
+        enqueue(state, toJS(&amp;state, globalObject(), result.get()));
+    else
+        error(state, createOutOfMemoryError(&amp;state));
+}
+
+template&lt;&gt;
+inline void ReadableStreamController::error&lt;String&gt;(const String&amp; result)
+{
+    JSC::ExecState* state = globalObject()-&gt;globalExec();
+    JSC::JSLockHolder locker(state);
+    error(*state, jsString(state, result));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(STREAMS_API)
+
+#endif // ReadableStreamController_h
</ins></span></pre>
</div>
</div>

</body>
</html>