<!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>[203726] 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/203726">203726</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-07-26 10:13:38 -0700 (Tue, 26 Jul 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Unreviewed, rolling out <a href="http://trac.webkit.org/projects/webkit/changeset/203719">r203719</a>.
https://bugs.webkit.org/show_bug.cgi?id=160200

It is breaking win build (Requested by youenn on #webkit).

Reverted changeset:

&quot;[Fetch API] Response constructor should be able to take a
ReadableStream as body&quot;
https://bugs.webkit.org/show_bug.cgi?id=159804
http://trac.webkit.org/changeset/203719</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumeemptyexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumehtml">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html</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="#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="#trunkSourceWebCoreModulesfetchFetchInternalsjs">trunk/Source/WebCore/Modules/fetch/FetchInternals.js</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="#trunkSourceWebCoreModulesfetchFetchResponsejs">trunk/Source/WebCore/Modules/fetch/FetchResponse.js</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSDOMPromiseh">trunk/Source/WebCore/bindings/js/JSDOMPromise.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh">trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreModulesfetchFetchBodyConsumercpp">trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchBodyConsumerh">trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-07-26  Commit Queue  &lt;commit-queue@webkit.org&gt;
+
+        Unreviewed, rolling out r203719.
+        https://bugs.webkit.org/show_bug.cgi?id=160200
+
+        It is breaking win build (Requested by youenn on #webkit).
+
+        Reverted changeset:
+
+        &quot;[Fetch API] Response constructor should be able to take a
+        ReadableStream as body&quot;
+        https://bugs.webkit.org/show_bug.cgi?id=159804
+        http://trac.webkit.org/changeset/203719
+
</ins><span class="cx"> 2016-07-26  Youenn Fablet  &lt;youenn@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove ClientCredentialPolicy cross-origin option from ResourceLoaderOptions
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumeemptyexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-empty-expected.txt        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -3,7 +3,7 @@
</span><span class="cx"> PASS Consume response's body as blob 
</span><span class="cx"> PASS Consume response's body as arrayBuffer 
</span><span class="cx"> PASS Consume response's body as json 
</span><del>-FAIL Consume response's body as formData promise_test: Unhandled rejection with value: &quot;Not implemented&quot;
</del><ins>+FAIL Consume response's body as formData promise_test: Unhandled rejection with value: undefined
</ins><span class="cx"> PASS Consume empty blob response body as arrayBuffer 
</span><span class="cx"> PASS Consume empty text response body as arrayBuffer 
</span><span class="cx"> PASS Consume empty blob response body as text 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -3,13 +3,9 @@
</span><span class="cx"> PASS Consume response's body as blob 
</span><span class="cx"> PASS Consume response's body as arrayBuffer 
</span><span class="cx"> PASS Consume response's body as json 
</span><del>-FAIL Consume response's body as formData promise_test: Unhandled rejection with value: &quot;Not implemented&quot;
</del><ins>+FAIL Consume response's body as formData promise_test: Unhandled rejection with value: undefined
</ins><span class="cx"> PASS Consume blob response's body as blob 
</span><span class="cx"> PASS Consume blob response's body as text 
</span><span class="cx"> PASS Consume blob response's body as json 
</span><span class="cx"> PASS Consume blob response's body as arrayBuffer 
</span><del>-PASS Consume stream response's body as blob 
-PASS Consume stream response's body as text 
-PASS Consume stream response's body as json 
-PASS Consume stream response's body as arrayBuffer 
</del><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapiresponseresponseconsumehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -92,25 +92,6 @@
</span><span class="cx">     checkBlobResponseBody(blob, textData, &quot;json&quot;, checkBodyJSON);
</span><span class="cx">     checkBlobResponseBody(blob, textData, &quot;arrayBuffer&quot;, checkBodyArrayBuffer);
</span><span class="cx"> 
</span><del>-    function checkReadableStreamResponseBody(streamData, bodyType, checkFunction) {
-      promise_test(function(test) {
-        var stream = new ReadableStream({
-          start: function(controller) {
-            controller.enqueue((stringToArray(streamData)));
-            controller.close();
-          }
-        });
-        var response = new Response(stream);
-        assert_false(response.bodyUsed, &quot;bodyUsed is false at init&quot;);
-        return checkFunction(response, streamData);
-      }, &quot;Consume stream response's body as &quot; + bodyType);
-    }
-
-    checkReadableStreamResponseBody(textData, &quot;blob&quot;, checkBodyBlob);
-    checkReadableStreamResponseBody(textData, &quot;text&quot;, checkBodyText);
-    checkReadableStreamResponseBody(textData, &quot;json&quot;, checkBodyJSON);
-    checkReadableStreamResponseBody(textData, &quot;arrayBuffer&quot;, checkBodyArrayBuffer);
-
</del><span class="cx">     &lt;/script&gt;
</span><span class="cx">   &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -818,7 +818,6 @@
</span><span class="cx"> 
</span><span class="cx">     Modules/fetch/DOMWindowFetch.cpp
</span><span class="cx">     Modules/fetch/FetchBody.cpp
</span><del>-    Modules/fetch/FetchBodyConsumer.cpp
</del><span class="cx">     Modules/fetch/FetchBodyOwner.cpp
</span><span class="cx">     Modules/fetch/FetchHeaders.cpp
</span><span class="cx">     Modules/fetch/FetchLoader.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/ChangeLog        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-07-26  Commit Queue  &lt;commit-queue@webkit.org&gt;
+
+        Unreviewed, rolling out r203719.
+        https://bugs.webkit.org/show_bug.cgi?id=160200
+
+        It is breaking win build (Requested by youenn on #webkit).
+
+        Reverted changeset:
+
+        &quot;[Fetch API] Response constructor should be able to take a
+        ReadableStream as body&quot;
+        https://bugs.webkit.org/show_bug.cgi?id=159804
+        http://trac.webkit.org/changeset/203719
+
</ins><span class="cx"> 2016-07-26  John Wilander  &lt;wilander@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Stop supporting compressed character sets BOCU-1 and SCSU
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -39,11 +39,12 @@
</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><del>-#include &quot;JSReadableStream.h&quot;
</del><span class="cx"> #include &quot;ReadableStreamSource.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+static Ref&lt;Blob&gt; blobFromArrayBuffer(ArrayBuffer*, const String&amp;);
+
</ins><span class="cx"> FetchBody::FetchBody(Ref&lt;Blob&gt;&amp;&amp; blob)
</span><span class="cx">     : m_type(Type::Blob)
</span><span class="cx">     , m_mimeType(blob-&gt;type())
</span><span class="lines">@@ -74,8 +75,6 @@
</span><span class="cx">         return FetchBody(*JSDOMFormData::toWrapped(value));
</span><span class="cx">     if (value.isString())
</span><span class="cx">         return FetchBody(value.toWTFString(&amp;state));
</span><del>-    if (value.inherits(JSReadableStream::info()))
-        return { Type::ReadableStream };
</del><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -90,16 +89,13 @@
</span><span class="cx"> void FetchBody::arrayBuffer(FetchBodyOwner&amp; owner, DeferredWrapper&amp;&amp; promise)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_type != Type::None);
</span><del>-    m_consumer.setType(FetchBodyConsumer::Type::ArrayBuffer);
-    consume(owner, WTFMove(promise));
</del><ins>+    consume(owner, Consumer::Type::ArrayBuffer, WTFMove(promise));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FetchBody::blob(FetchBodyOwner&amp; owner, DeferredWrapper&amp;&amp; promise)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_type != Type::None);
</span><del>-    m_consumer.setType(FetchBodyConsumer::Type::Blob);
-    m_consumer.setContentType(Blob::normalizedContentType(extractMIMETypeFromMediaType(m_mimeType)));
-    consume(owner, WTFMove(promise));
</del><ins>+    consume(owner, Consumer::Type::Blob, WTFMove(promise));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FetchBody::json(FetchBodyOwner&amp; owner, DeferredWrapper&amp;&amp; promise)
</span><span class="lines">@@ -110,8 +106,7 @@
</span><span class="cx">         fulfillPromiseWithJSON(promise, m_text);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    m_consumer.setType(FetchBodyConsumer::Type::JSON);
-    consume(owner, WTFMove(promise));
</del><ins>+    consume(owner, Consumer::Type::JSON, WTFMove(promise));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FetchBody::text(FetchBodyOwner&amp; owner, DeferredWrapper&amp;&amp; promise)
</span><span class="lines">@@ -122,95 +117,113 @@
</span><span class="cx">         promise.resolve(m_text);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    m_consumer.setType(FetchBodyConsumer::Type::Text);
-    consume(owner, WTFMove(promise));
</del><ins>+    consume(owner, Consumer::Type::Text, WTFMove(promise));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FetchBody::consume(FetchBodyOwner&amp; owner, DeferredWrapper&amp;&amp; promise)
</del><ins>+void FetchBody::consume(FetchBodyOwner&amp; owner, Consumer::Type type, DeferredWrapper&amp;&amp; promise)
</ins><span class="cx"> {
</span><del>-    // This should be handled by FetchBodyOwner
-    ASSERT(m_type != Type::None);
-    // This should be handled by JS built-ins
-    ASSERT(m_type != Type::ReadableStream);
-
-    switch (m_type) {
-    case Type::ArrayBuffer:
-        consumeArrayBuffer(promise);
</del><ins>+    if (m_type == Type::ArrayBuffer) {
+        consumeArrayBuffer(type, promise);
</ins><span class="cx">         return;
</span><del>-    case Type::Text:
-        consumeText(promise);
</del><ins>+    }
+    if (m_type == Type::Text) {
+        consumeText(type, promise);
</ins><span class="cx">         return;
</span><del>-    case Type::Blob:
-        consumeBlob(owner, WTFMove(promise));
</del><ins>+    }
+    if (m_type == Type::Blob) {
+        consumeBlob(owner, type, WTFMove(promise));
</ins><span class="cx">         return;
</span><del>-    case Type::Loading:
-        m_consumePromise = WTFMove(promise);
</del><ins>+    }
+    if (m_type == Type::Loading) {
+        // FIXME: We should be able to change the loading type to text if consumer type is JSON or Text.
+        m_consumer = Consumer({type, WTFMove(promise)});
</ins><span class="cx">         return;
</span><del>-    case Type::Loaded:
-        m_consumer.resolve(promise);
-        return;
-    default:
-        // FIXME: Support other types.
-        promise.reject(0);
</del><span class="cx">     }
</span><ins>+
+    // FIXME: Support other types.
+    promise.reject(0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(STREAMS_API)
</span><span class="cx"> void FetchBody::consumeAsStream(FetchBodyOwner&amp; owner, FetchResponseSource&amp; source)
</span><span class="cx"> {
</span><del>-    // This should be handled by FetchResponse
</del><span class="cx">     ASSERT(m_type != Type::Loading);
</span><del>-    // This should be handled by JS built-ins
-    ASSERT(m_type != Type::ReadableStream);
</del><span class="cx"> 
</span><del>-    bool closeStream = false;
</del><span class="cx">     switch (m_type) {
</span><span class="cx">     case Type::ArrayBuffer:
</span><span class="cx">         ASSERT(m_data);
</span><del>-        closeStream = source.enqueue(RefPtr&lt;JSC::ArrayBuffer&gt;(m_data));
-        break;
</del><ins>+        if (source.enqueue(RefPtr&lt;JSC::ArrayBuffer&gt;(m_data)))
+            source.close();
+        return;
</ins><span class="cx">     case Type::Text: {
</span><span class="cx">         Vector&lt;uint8_t&gt; data = extractFromText();
</span><del>-        closeStream = source.enqueue(ArrayBuffer::tryCreate(data.data(), data.size()));
-        break;
</del><ins>+        if (source.enqueue(ArrayBuffer::tryCreate(data.data(), data.size())))
+            source.close();
+        return;
</ins><span class="cx">     }
</span><span class="cx">     case Type::Blob:
</span><span class="cx">         ASSERT(m_blob);
</span><del>-        owner.loadBlob(*m_blob, nullptr);
-        break;
</del><ins>+        owner.loadBlob(*m_blob, FetchLoader::Type::Stream);
+        return;
</ins><span class="cx">     case Type::None:
</span><del>-        closeStream = true;
-        break;
-    case Type::Loaded: {
-        closeStream = source.enqueue(m_consumer.takeAsArrayBuffer());
-        break;
-    }
</del><ins>+        source.close();
+        return;
</ins><span class="cx">     default:
</span><span class="cx">         source.error(ASCIILiteral(&quot;not implemented&quot;));
</span><span class="cx">     }
</span><del>-
-    if (closeStream)
-        source.close();
</del><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void FetchBody::consumeArrayBuffer(DeferredWrapper&amp; promise)
</del><ins>+void FetchBody::consumeArrayBuffer(Consumer::Type type, DeferredWrapper&amp; promise)
</ins><span class="cx"> {
</span><del>-    m_consumer.resolveWithData(promise, static_cast&lt;const uint8_t*&gt;(m_data-&gt;data()), m_data-&gt;byteLength());
</del><ins>+    if (type == Consumer::Type::ArrayBuffer) {
+        fulfillPromiseWithArrayBuffer(promise, m_data.get());
+        return;
+    }
+    if (type == Consumer::Type::Blob) {
+        promise.resolve(blobFromArrayBuffer(m_data.get(), Blob::normalizedContentType(extractMIMETypeFromMediaType(m_mimeType))));
+        return;
+    }
+
+    ASSERT(type == Consumer::Type::Text || type == Consumer::Type::JSON);
+    // FIXME: Do we need TextResourceDecoder to create a String to decode UTF-8 data.
+    fulfillTextPromise(type, TextResourceDecoder::create(ASCIILiteral(&quot;text/plain&quot;), &quot;UTF-8&quot;)-&gt;decodeAndFlush(static_cast&lt;const char*&gt;(m_data-&gt;data()), m_data-&gt;byteLength()), promise);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FetchBody::consumeText(DeferredWrapper&amp; promise)
</del><ins>+void FetchBody::consumeText(Consumer::Type type, DeferredWrapper&amp; promise)
</ins><span class="cx"> {
</span><del>-    Vector&lt;uint8_t&gt; data = extractFromText();
-    m_consumer.resolveWithData(promise, data.data(), data.size());
</del><ins>+    ASSERT(type == Consumer::Type::ArrayBuffer || type == Consumer::Type::Blob);
+
+    if (type == Consumer::Type::ArrayBuffer) {
+        Vector&lt;uint8_t&gt; data = extractFromText();
+        fulfillPromiseWithArrayBuffer(promise, data.data(), data.size());
+        return;
+    }
+    String contentType = Blob::normalizedContentType(extractMIMETypeFromMediaType(m_mimeType));
+    promise.resolve(Blob::create(extractFromText(), contentType));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FetchBody::consumeBlob(FetchBodyOwner&amp; owner, DeferredWrapper&amp;&amp; promise)
</del><ins>+FetchLoader::Type FetchBody::loadingType(Consumer::Type type)
</ins><span class="cx"> {
</span><ins>+    switch (type) {
+    case Consumer::Type::JSON:
+    case Consumer::Type::Text:
+        return FetchLoader::Type::Text;
+    case Consumer::Type::Blob:
+    case Consumer::Type::ArrayBuffer:
+        return FetchLoader::Type::ArrayBuffer;
+    default:
+        ASSERT_NOT_REACHED();
+        return FetchLoader::Type::ArrayBuffer;
+    };
+}
+
+void FetchBody::consumeBlob(FetchBodyOwner&amp; owner, Consumer::Type type, DeferredWrapper&amp;&amp; promise)
+{
</ins><span class="cx">     ASSERT(m_blob);
</span><span class="cx"> 
</span><del>-    m_consumePromise = WTFMove(promise);
-    owner.loadBlob(*m_blob, &amp;m_consumer);
</del><ins>+    m_consumer = Consumer({type, WTFMove(promise)});
+    owner.loadBlob(*m_blob, loadingType(type));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Vector&lt;uint8_t&gt; FetchBody::extractFromText() const
</span><span class="lines">@@ -223,23 +236,65 @@
</span><span class="cx">     return value;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static inline Ref&lt;Blob&gt; blobFromArrayBuffer(ArrayBuffer* buffer, const String&amp; contentType)
+{
+    if (!buffer)
+        return Blob::create(Vector&lt;uint8_t&gt;(), contentType);
+
+    // FIXME: We should try to move buffer to Blob without doing this copy.
+    Vector&lt;uint8_t&gt; value(buffer-&gt;byteLength());
+    memcpy(value.data(), buffer-&gt;data(), buffer-&gt;byteLength());
+    return Blob::create(WTFMove(value), contentType);
+}
+
+void FetchBody::fulfillTextPromise(FetchBody::Consumer::Type type, const String&amp; text, DeferredWrapper&amp; promise)
+{
+    ASSERT(type == Consumer::Type::Text || type == Consumer::Type::JSON);
+    if (type == FetchBody::Consumer::Type::Text)
+        promise.resolve(text);
+    else
+        fulfillPromiseWithJSON(promise, text);
+}
+
</ins><span class="cx"> void FetchBody::loadingFailed()
</span><span class="cx"> {
</span><del>-    if (m_consumePromise) {
-        m_consumePromise-&gt;reject(0);
-        m_consumePromise = Nullopt;
-    }
</del><ins>+    ASSERT(m_consumer);
+    m_consumer-&gt;promise.reject(0);
+    m_consumer = Nullopt;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FetchBody::loadingSucceeded()
</del><ins>+void FetchBody::loadedAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp; buffer)
</ins><span class="cx"> {
</span><del>-    m_type = m_consumer.hasData() ? Type::Loaded : Type::None;
-    if (m_consumePromise) {
-        m_consumer.resolve(*m_consumePromise);
-        m_consumePromise = Nullopt;
</del><ins>+    if (m_type == Type::Loading) {
+        m_type = Type::ArrayBuffer;
+        m_data = buffer;
+        if (m_consumer) {
+            consumeArrayBuffer(m_consumer-&gt;type, m_consumer-&gt;promise);
+            m_consumer = Nullopt;
+        }
+        return;
</ins><span class="cx">     }
</span><ins>+
+    ASSERT(m_consumer);
+    ASSERT(m_consumer-&gt;type == Consumer::Type::Blob || m_consumer-&gt;type == Consumer::Type::ArrayBuffer);
+    if (m_consumer-&gt;type == Consumer::Type::ArrayBuffer)
+        fulfillPromiseWithArrayBuffer(m_consumer-&gt;promise, buffer.get());
+    else {
+        ASSERT(m_blob);
+        m_consumer-&gt;promise.resolve(blobFromArrayBuffer(buffer.get(), m_blob-&gt;type()));
+    }
+    m_consumer = Nullopt;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FetchBody::loadedAsText(String&amp;&amp; text)
+{
+    ASSERT(m_consumer);
+    ASSERT(m_consumer-&gt;type == Consumer::Type::Text || m_consumer-&gt;type == Consumer::Type::JSON);
+
+    fulfillTextPromise(m_consumer-&gt;type, text, m_consumer-&gt;promise);
+    m_consumer = Nullopt;
+}
+
</ins><span class="cx"> RefPtr&lt;FormData&gt; FetchBody::bodyForInternalRequest() const
</span><span class="cx"> {
</span><span class="cx">     if (m_type == Type::None)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBody.h        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -33,7 +33,6 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Blob.h&quot;
</span><span class="cx"> #include &quot;DOMFormData.h&quot;
</span><del>-#include &quot;FetchBodyConsumer.h&quot;
</del><span class="cx"> #include &quot;FetchLoader.h&quot;
</span><span class="cx"> #include &quot;JSDOMPromise.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -71,15 +70,14 @@
</span><span class="cx">     FetchBody() = default;
</span><span class="cx"> 
</span><span class="cx">     void loadingFailed();
</span><del>-    void loadingSucceeded();
</del><ins>+    void loadedAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp;);
+    void loadedAsText(String&amp;&amp;);
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;FormData&gt; bodyForInternalRequest() const;
</span><span class="cx"> 
</span><del>-    enum class Type { None, ArrayBuffer, Blob, FormData, Text, Loading, Loaded, ReadableStream };
</del><ins>+    enum class Type { None, ArrayBuffer, Loading, Text, Blob, FormData };
</ins><span class="cx">     Type type() const { return m_type; }
</span><span class="cx"> 
</span><del>-    FetchBodyConsumer&amp; consumer() { return m_consumer; }
-
</del><span class="cx"> private:
</span><span class="cx">     FetchBody(Ref&lt;Blob&gt;&amp;&amp;);
</span><span class="cx">     FetchBody(Ref&lt;DOMFormData&gt;&amp;&amp;);
</span><span class="lines">@@ -86,12 +84,21 @@
</span><span class="cx">     FetchBody(String&amp;&amp;);
</span><span class="cx">     FetchBody(Type type) : m_type(type) { }
</span><span class="cx"> 
</span><del>-    void consume(FetchBodyOwner&amp;, DeferredWrapper&amp;&amp;);
</del><ins>+    struct Consumer {
+        enum class Type { Text, Blob, JSON, ArrayBuffer };
</ins><span class="cx"> 
</span><ins>+        Type type;
+        DeferredWrapper promise;
+    };
+    void consume(FetchBodyOwner&amp;, Consumer::Type, DeferredWrapper&amp;&amp;);
+
</ins><span class="cx">     Vector&lt;uint8_t&gt; extractFromText() const;
</span><del>-    void consumeArrayBuffer(DeferredWrapper&amp;);
-    void consumeText(DeferredWrapper&amp;);
-    void consumeBlob(FetchBodyOwner&amp;, DeferredWrapper&amp;&amp;);
</del><ins>+    void consumeArrayBuffer(Consumer::Type, DeferredWrapper&amp;);
+    void consumeText(Consumer::Type, DeferredWrapper&amp;);
+    void consumeBlob(FetchBodyOwner&amp;, Consumer::Type, DeferredWrapper&amp;&amp;);
+    static FetchLoader::Type loadingType(Consumer::Type);
+    static void fulfillTextPromise(FetchBody::Consumer::Type, const String&amp;, DeferredWrapper&amp;);
+    static void fulfillArrayBufferPromise(FetchBody::Consumer::Type, const String&amp;, DeferredWrapper&amp;);
</ins><span class="cx"> 
</span><span class="cx">     Type m_type { Type::None };
</span><span class="cx">     String m_mimeType;
</span><span class="lines">@@ -102,8 +109,7 @@
</span><span class="cx">     RefPtr&lt;ArrayBuffer&gt; m_data;
</span><span class="cx">     String m_text;
</span><span class="cx"> 
</span><del>-    FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::None };
-    Optional&lt;DeferredWrapper&gt; m_consumePromise;
</del><ins>+    Optional&lt;Consumer&gt; m_consumer;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyConsumercpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -1,140 +0,0 @@
</span><del>-/*
- * Copyright (C) 2016 Apple 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 Apple 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 APPLE 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 APPLE 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;FetchBodyConsumer.h&quot;
-
-#if ENABLE(FETCH_API)
-
-#include &quot;JSBlob.h&quot;
-#include &quot;JSDOMPromise.h&quot;
-
-namespace WebCore {
-
-static inline Ref&lt;Blob&gt; blobFromData(const unsigned char* data, unsigned length, const String&amp; contentType)
-{
-    Vector&lt;uint8_t&gt; value(length);
-    memcpy(value.data(), data, length);
-    return Blob::create(WTFMove(value), contentType);
-}
-
-void FetchBodyConsumer::resolveWithData(DeferredWrapper&amp; promise, const unsigned char* data, unsigned length)
-{
-    switch (m_type) {
-    case Type::ArrayBuffer:
-        fulfillPromiseWithArrayBuffer(promise, data, length);
-        return;
-    case Type::Blob:
-        promise.resolveWithNewlyCreated(blobFromData(data, length, m_contentType));
-        return;
-    case Type::JSON:
-        fulfillPromiseWithJSON(promise, String(data, length));
-        return;
-    case Type::Text:
-        promise.resolve(String(data, length));
-        return;
-    case Type::None:
-        ASSERT_NOT_REACHED();
-        return;
-    }
-}
-
-void FetchBodyConsumer::resolve(DeferredWrapper&amp; promise)
-{
-    ASSERT(m_type != Type::None);
-    switch (m_type) {
-    case Type::ArrayBuffer:
-        fulfillPromiseWithArrayBuffer(promise, takeAsArrayBuffer().get());
-        return;
-    case Type::Blob:
-        promise.resolveWithNewlyCreated(takeAsBlob());
-        return;
-    case Type::JSON:
-        fulfillPromiseWithJSON(promise, takeAsText());
-        return;
-    case Type::Text:
-        promise.resolve(takeAsText());
-        return;
-    case Type::None:
-        ASSERT_NOT_REACHED();
-        return;
-    }
-}
-
-void FetchBodyConsumer::append(const char* data, unsigned length)
-{
-    if (!m_buffer) {
-        m_buffer = SharedBuffer::create(data, length);
-        return;
-    }
-    m_buffer-&gt;append(data, length);
-}
-
-void FetchBodyConsumer::append(const unsigned char* data, unsigned length)
-{
-    append(reinterpret_cast&lt;const char*&gt;(data), length);
-}
-
-RefPtr&lt;SharedBuffer&gt; FetchBodyConsumer::takeData()
-{
-    return WTFMove(m_buffer);
-}
-
-RefPtr&lt;JSC::ArrayBuffer&gt; FetchBodyConsumer::takeAsArrayBuffer()
-{
-    if (!m_buffer)
-        return ArrayBuffer::tryCreate(nullptr, 0);
-
-    auto arrayBuffer = m_buffer-&gt;createArrayBuffer();
-    m_buffer = nullptr;
-    return arrayBuffer;
-}
-
-Ref&lt;Blob&gt; FetchBodyConsumer::takeAsBlob()
-{
-    ASSERT(m_buffer);
-    if (!m_buffer)
-        return Blob::create();
-
-    // FIXME: We should try to move m_buffer to Blob without doing extra copy.
-    return blobFromData(reinterpret_cast&lt;const unsigned char*&gt;(m_buffer-&gt;data()), m_buffer-&gt;size(), m_contentType);
-}
-
-String FetchBodyConsumer::takeAsText()
-{
-    if (!m_buffer)
-        return String();
-
-    auto text = String(m_buffer-&gt;data(), m_buffer-&gt;size());
-    m_buffer = nullptr;
-    return text;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(FETCH_API)
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyConsumerh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.h        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -1,73 +0,0 @@
</span><del>-/*
- * Copyright (C) 2016 Apple 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 Apple 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 APPLE 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 APPLE 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.
- */
-
-#pragma once
-
-#if ENABLE(FETCH_API)
-
-#include &quot;SharedBuffer.h&quot;
-
-namespace WebCore {
-
-class Blob;
-class DeferredWrapper;
-
-class FetchBodyConsumer {
-public:
-    // Type is used in FetchResponse.js and should be kept synchronized with it.
-    enum class Type { None, ArrayBuffer, Blob, JSON, Text };
-
-    FetchBodyConsumer(Type type) : m_type(type) { }
-
-    void append(const char* data, unsigned);
-    void append(const unsigned char* data, unsigned);
-
-    RefPtr&lt;SharedBuffer&gt; takeData();
-    RefPtr&lt;JSC::ArrayBuffer&gt; takeAsArrayBuffer();
-    Ref&lt;Blob&gt; takeAsBlob();
-    String takeAsText();
-
-    void setContentType(const String&amp; contentType) { m_contentType = contentType; }
-    void setType(Type type) { m_type = type; }
-
-    void clean() { m_buffer = nullptr; }
-
-    void resolve(DeferredWrapper&amp;);
-    void resolveWithData(DeferredWrapper&amp;, const unsigned char*, unsigned);
-
-    bool hasData() const { return !!m_buffer; }
-
-private:
-    Type m_type;
-    String m_contentType;
-    RefPtr&lt;SharedBuffer&gt; m_buffer;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(FETCH_API)
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyOwnercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx">     m_body.text(*this, WTFMove(promise));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FetchBodyOwner::loadBlob(Blob&amp; blob, FetchBodyConsumer* consumer)
</del><ins>+void FetchBodyOwner::loadBlob(Blob&amp; blob, FetchLoader::Type type)
</ins><span class="cx"> {
</span><span class="cx">     // Can only be called once for a body instance.
</span><span class="cx">     ASSERT(isDisturbed());
</span><span class="lines">@@ -150,7 +150,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_blobLoader = { *this };
</span><del>-    m_blobLoader-&gt;loader = std::make_unique&lt;FetchLoader&gt;(*m_blobLoader, consumer);
</del><ins>+    m_blobLoader-&gt;loader = std::make_unique&lt;FetchLoader&gt;(type, *m_blobLoader);
</ins><span class="cx"> 
</span><span class="cx">     m_blobLoader-&gt;loader-&gt;start(*scriptExecutionContext(), blob);
</span><span class="cx">     if (!m_blobLoader-&gt;loader-&gt;isStarted()) {
</span><span class="lines">@@ -169,6 +169,11 @@
</span><span class="cx">     unsetPendingActivity(this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FetchBodyOwner::loadedBlobAsText(String&amp;&amp; text)
+{
+    m_body.loadedAsText(WTFMove(text));
+}
+
</ins><span class="cx"> void FetchBodyOwner::blobLoadingSucceeded()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_body.type() == FetchBody::Type::Blob);
</span><span class="lines">@@ -179,7 +184,7 @@
</span><span class="cx">         m_readableStreamSource = nullptr;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><del>-    m_body.loadingSucceeded();
</del><ins>+
</ins><span class="cx">     finishBlobLoading();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyOwnerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx">     void json(DeferredWrapper&amp;&amp;);
</span><span class="cx">     void text(DeferredWrapper&amp;&amp;);
</span><span class="cx"> 
</span><del>-    void loadBlob(Blob&amp;, FetchBodyConsumer*);
</del><ins>+    void loadBlob(Blob&amp;, FetchLoader::Type);
</ins><span class="cx"> 
</span><span class="cx">     bool isActive() const { return !!m_blobLoader; }
</span><span class="cx"> 
</span><span class="lines">@@ -67,6 +67,8 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     // Blob loading routines
</span><ins>+    void loadedBlobAsText(String&amp;&amp;);
+    void loadedBlobAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp; buffer) { m_body.loadedAsArrayBuffer(WTFMove(buffer)); }
</ins><span class="cx">     void blobChunk(const char*, size_t);
</span><span class="cx">     void blobLoadingSucceeded();
</span><span class="cx">     void blobLoadingFailed();
</span><span class="lines">@@ -76,6 +78,8 @@
</span><span class="cx">         BlobLoader(FetchBodyOwner&amp;);
</span><span class="cx"> 
</span><span class="cx">         // FetchLoaderClient API
</span><ins>+        void didFinishLoadingAsText(String&amp;&amp; text) final { owner.loadedBlobAsText(WTFMove(text)); }
+        void didFinishLoadingAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp; buffer) final { owner.loadedBlobAsArrayBuffer(WTFMove(buffer)); }
</ins><span class="cx">         void didReceiveResponse(const ResourceResponse&amp;) final;
</span><span class="cx">         void didReceiveData(const char* data, size_t size) final { owner.blobChunk(data, size); }
</span><span class="cx">         void didFail() final;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchInternalsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchInternals.js (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchInternals.js        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchInternals.js        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -51,27 +51,3 @@
</span><span class="cx">         @Headers.prototype.@appendFromJS.@call(headers, name, headersInit[name]);
</span><span class="cx">     }
</span><span class="cx"> }
</span><del>-
-function consumeStream(response, type)
-{
-    @assert(response instanceof @Response);
-    @assert(response.@body instanceof @ReadableStream);
-
-    if (@isReadableStreamDisturbed(response.@body))
-        return @Promise.@reject(new @TypeError(&quot;Cannot consume a disturbed Response body ReadableStream&quot;));
-
-    try {
-        let reader = new @ReadableStreamReader(response.@body);
-
-        @Response.prototype.@startConsumingStream.@call(response, type);
-        let pull = (result) =&gt; {
-            if (result.done)
-                return @Response.prototype.@finishConsumingStream.@call(response);
-            @Response.prototype.@consumeChunk.@call(response, result.value);
-            return @Promise.prototype.@then.@call(@readFromReadableStreamReader(reader), pull);
-        }
-        return @Promise.prototype.@then.@call(@readFromReadableStreamReader(reader), pull);
-    } catch(e) {
-        return @Promise.@reject(e);
-    }
-}
</del></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -89,16 +89,15 @@
</span><span class="cx">     m_isStarted = m_loader;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-FetchLoader::FetchLoader(FetchLoaderClient&amp; client, FetchBodyConsumer* consumer)
-    : m_client(client)
-    , m_consumer(consumer)
</del><ins>+FetchLoader::FetchLoader(Type type, FetchLoaderClient&amp; client)
+    : m_type(type)
+    , m_client(client)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FetchLoader::stop()
</span><span class="cx"> {
</span><del>-    if (m_consumer)
-        m_consumer-&gt;clean();
</del><ins>+    m_data = nullptr;
</ins><span class="cx">     if (m_loader)
</span><span class="cx">         m_loader-&gt;cancel();
</span><span class="cx"> }
</span><span class="lines">@@ -105,10 +104,9 @@
</span><span class="cx"> 
</span><span class="cx"> RefPtr&lt;SharedBuffer&gt; FetchLoader::startStreaming()
</span><span class="cx"> {
</span><del>-    ASSERT(m_consumer);
-    auto firstChunk = m_consumer-&gt;takeData();
-    m_consumer = nullptr;
-    return firstChunk;
</del><ins>+    ASSERT(m_type == Type::ArrayBuffer);
+    m_type = Type::Stream;
+    return WTFMove(m_data);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FetchLoader::didReceiveResponse(unsigned long, const ResourceResponse&amp; response)
</span><span class="lines">@@ -116,17 +114,29 @@
</span><span class="cx">     m_client.didReceiveResponse(response);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// FIXME: We should make text and blob creation more efficient.
+// We might also want to merge this class with FileReaderLoader.
</ins><span class="cx"> void FetchLoader::didReceiveData(const char* value, int size)
</span><span class="cx"> {
</span><del>-    if (!m_consumer) {
</del><ins>+    if (m_type == Type::Stream) {
</ins><span class="cx">         m_client.didReceiveData(value, size);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    m_consumer-&gt;append(value, size);
</del><ins>+    if (!m_data) {
+        m_data = SharedBuffer::create(value, size);
+        return;
+    }
+    m_data-&gt;append(value, size);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FetchLoader::didFinishLoading(unsigned long, double)
</span><span class="cx"> {
</span><ins>+    if (m_type == Type::ArrayBuffer)
+        m_client.didFinishLoadingAsArrayBuffer(m_data ? m_data-&gt;createArrayBuffer() : ArrayBuffer::tryCreate(nullptr, 0));
+    else if (m_type == Type::Text)
+        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());
+    m_data = nullptr;
+
</ins><span class="cx">     m_client.didSucceed();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchLoader.h (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoader.h        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoader.h        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -26,11 +26,12 @@
</span><span class="cx">  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-#pragma once
</del><ins>+#ifndef FetchLoader_h
+#define FetchLoader_h
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(FETCH_API)
</span><span class="cx"> 
</span><del>-#include &quot;FetchBodyConsumer.h&quot;
</del><ins>+#include &quot;SharedBuffer.h&quot;
</ins><span class="cx"> #include &quot;ThreadableLoader.h&quot;
</span><span class="cx"> #include &quot;ThreadableLoaderClient.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -43,8 +44,10 @@
</span><span class="cx"> 
</span><span class="cx"> class FetchLoader final : public ThreadableLoaderClient {
</span><span class="cx"> public:
</span><del>-    FetchLoader(FetchLoaderClient&amp;, FetchBodyConsumer*);
</del><ins>+    enum class Type { ArrayBuffer, Stream, Text };
</ins><span class="cx"> 
</span><ins>+    FetchLoader(Type, FetchLoaderClient&amp;);
+
</ins><span class="cx">     RefPtr&lt;SharedBuffer&gt; startStreaming();
</span><span class="cx"> 
</span><span class="cx">     void start(ScriptExecutionContext&amp;, const FetchRequest&amp;);
</span><span class="lines">@@ -60,10 +63,13 @@
</span><span class="cx">     void didFinishLoading(unsigned long, double) final;
</span><span class="cx">     void didFail(const ResourceError&amp;) final;
</span><span class="cx"> 
</span><ins>+    Type type() const { return m_type; }
+
</ins><span class="cx"> private:
</span><ins>+    Type m_type { Type::ArrayBuffer };
</ins><span class="cx">     FetchLoaderClient&amp; m_client;
</span><span class="cx">     RefPtr&lt;ThreadableLoader&gt; m_loader;
</span><del>-    FetchBodyConsumer* m_consumer;
</del><ins>+    RefPtr&lt;SharedBuffer&gt; m_data;
</ins><span class="cx">     bool m_isStarted { false };
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -70,3 +76,5 @@
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(FETCH_API)
</span><ins>+
+#endif // FetchLoader_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoaderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -47,6 +47,8 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void didReceiveResponse(const ResourceResponse&amp;) { }
</span><span class="cx"> 
</span><ins>+    virtual void didFinishLoadingAsText(String&amp;&amp;) { }
+    virtual void didFinishLoadingAsArrayBuffer(RefPtr&lt;JSC::ArrayBuffer&gt;&amp;&amp;) { }
</ins><span class="cx">     virtual void didReceiveData(const char*, size_t) { }
</span><span class="cx"> 
</span><span class="cx">     virtual void didSucceed() = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponsecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -34,7 +34,6 @@
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="cx"> #include &quot;FetchRequest.h&quot;
</span><span class="cx"> #include &quot;HTTPParsers.h&quot;
</span><del>-#include &quot;JSBlob.h&quot;
</del><span class="cx"> #include &quot;JSFetchResponse.h&quot;
</span><span class="cx"> #include &quot;ScriptExecutionContext.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -94,11 +93,13 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Ref&lt;FetchResponse&gt; FetchResponse::cloneForJS()
</del><ins>+RefPtr&lt;FetchResponse&gt; FetchResponse::clone(ScriptExecutionContext&amp; context, ExceptionCode&amp; ec)
</ins><span class="cx"> {
</span><del>-    ASSERT(scriptExecutionContext());
-    ASSERT(!isDisturbed());
-    return adoptRef(*new FetchResponse(*scriptExecutionContext(), FetchBody(m_body), FetchHeaders::create(headers()), ResourceResponse(m_response)));
</del><ins>+    if (isDisturbed()) {
+        ec = TypeError;
+        return nullptr;
+    }
+    return adoptRef(*new FetchResponse(context, FetchBody(m_body), FetchHeaders::create(headers()), ResourceResponse(m_response)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FetchResponse::fetch(ScriptExecutionContext&amp; context, FetchRequest&amp; request, FetchPromise&amp;&amp; promise)
</span><span class="lines">@@ -129,8 +130,6 @@
</span><span class="cx">         m_response.m_readableStreamSource = nullptr;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><del>-    m_response.m_body.loadingSucceeded();
-
</del><span class="cx">     if (m_loader-&gt;isStarted())
</span><span class="cx">         m_response.m_bodyLoader = Nullopt;
</span><span class="cx">     m_response.unsetPendingActivity(&amp;m_response);
</span><span class="lines">@@ -188,9 +187,14 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FetchResponse::BodyLoader::didFinishLoadingAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp; buffer)
+{
+    m_response.body().loadedAsArrayBuffer(WTFMove(buffer));
+}
+
</ins><span class="cx"> bool FetchResponse::BodyLoader::start(ScriptExecutionContext&amp; context, const FetchRequest&amp; request)
</span><span class="cx"> {
</span><del>-    m_loader = std::make_unique&lt;FetchLoader&gt;(*this, &amp;m_response.m_body.consumer());
</del><ins>+    m_loader = std::make_unique&lt;FetchLoader&gt;(FetchLoader::Type::ArrayBuffer, *this);
</ins><span class="cx">     m_loader-&gt;start(context, request);
</span><span class="cx">     return m_loader-&gt;isStarted();
</span><span class="cx"> }
</span><span class="lines">@@ -201,46 +205,7 @@
</span><span class="cx">         m_loader-&gt;stop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FetchResponse::consume(unsigned type, DeferredWrapper&amp;&amp; wrapper)
-{
-    ASSERT(type &lt;= static_cast&lt;unsigned&gt;(FetchBodyConsumer::Type::Text));
-
-    switch (static_cast&lt;FetchBodyConsumer::Type&gt;(type)) {
-    case FetchBodyConsumer::Type::ArrayBuffer:
-        arrayBuffer(WTFMove(wrapper));
-        return;
-    case FetchBodyConsumer::Type::Blob:
-        blob(WTFMove(wrapper));
-        return;
-    case FetchBodyConsumer::Type::JSON:
-        json(WTFMove(wrapper));
-        return;
-    case FetchBodyConsumer::Type::Text:
-        text(WTFMove(wrapper));
-        return;
-    case FetchBodyConsumer::Type::None:
-        ASSERT_NOT_REACHED();
-        return;
-    }
-}
-
</del><span class="cx"> #if ENABLE(STREAMS_API)
</span><del>-void FetchResponse::startConsumingStream(unsigned type)
-{
-    m_isDisturbed = true;
-    m_consumer.setType(static_cast&lt;FetchBodyConsumer::Type&gt;(type));
-}
-
-void FetchResponse::consumeChunk(Ref&lt;JSC::Uint8Array&gt;&amp;&amp; chunk)
-{
-    m_consumer.append(chunk-&gt;data(), chunk-&gt;byteLength());
-}
-
-void FetchResponse::finishConsumingStream(DeferredWrapper&amp;&amp; promise)
-{
-    m_consumer.resolve(promise);
-}
-
</del><span class="cx"> void FetchResponse::consumeBodyAsStream()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_readableStreamSource);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.h (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.h        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.h        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -33,7 +33,6 @@
</span><span class="cx"> #include &quot;FetchBodyOwner.h&quot;
</span><span class="cx"> #include &quot;FetchHeaders.h&quot;
</span><span class="cx"> #include &quot;ResourceResponse.h&quot;
</span><del>-#include &lt;runtime/TypedArrays.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> class ArrayBuffer;
</span><span class="lines">@@ -60,13 +59,6 @@
</span><span class="cx">     using FetchPromise = DOMPromise&lt;FetchResponse&gt;;
</span><span class="cx">     static void fetch(ScriptExecutionContext&amp;, FetchRequest&amp;, FetchPromise&amp;&amp;);
</span><span class="cx"> 
</span><del>-    void consume(unsigned, DeferredWrapper&amp;&amp;);
-#if ENABLE(STREAMS_API)
-    void startConsumingStream(unsigned);
-    void consumeChunk(Ref&lt;JSC::Uint8Array&gt;&amp;&amp;);
-    void finishConsumingStream(DeferredWrapper&amp;&amp;);
-#endif
-
</del><span class="cx">     void setStatus(int, const String&amp;, ExceptionCode&amp;);
</span><span class="cx">     void initializeWith(JSC::ExecState&amp;, JSC::JSValue);
</span><span class="cx"> 
</span><span class="lines">@@ -78,7 +70,7 @@
</span><span class="cx">     const String&amp; statusText() const { return m_response.httpStatusText(); }
</span><span class="cx"> 
</span><span class="cx">     FetchHeaders&amp; headers() { return m_headers; }
</span><del>-    Ref&lt;FetchResponse&gt; cloneForJS();
</del><ins>+    RefPtr&lt;FetchResponse&gt; clone(ScriptExecutionContext&amp;, ExceptionCode&amp;);
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(STREAMS_API)
</span><span class="cx">     ReadableStreamSource* createReadableStreamSource();
</span><span class="lines">@@ -113,6 +105,7 @@
</span><span class="cx">         void didFail() final;
</span><span class="cx">         void didReceiveResponse(const ResourceResponse&amp;) final;
</span><span class="cx">         void didReceiveData(const char*, size_t) final;
</span><ins>+        void didFinishLoadingAsArrayBuffer(RefPtr&lt;ArrayBuffer&gt;&amp;&amp;) final;
</ins><span class="cx"> 
</span><span class="cx">         FetchResponse&amp; m_response;
</span><span class="cx">         Optional&lt;FetchPromise&gt; m_promise;
</span><span class="lines">@@ -123,8 +116,6 @@
</span><span class="cx">     Ref&lt;FetchHeaders&gt; m_headers;
</span><span class="cx">     Optional&lt;BodyLoader&gt; m_bodyLoader;
</span><span class="cx">     mutable String m_responseURL;
</span><del>-
-    FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::ArrayBuffer  };
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponseidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.idl (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.idl        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.idl        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -53,25 +53,11 @@
</span><span class="cx">     readonly attribute FetchHeaders headers;
</span><span class="cx">     [JSBuiltin] readonly attribute ReadableStream? body;
</span><span class="cx"> 
</span><del>-    // Copy of FetchBody IDL as we want to implement some of these as built-ins.
-    [ImplementedAs=isDisturbed] readonly attribute boolean bodyUsed;
-    [JSBuiltin] Promise arrayBuffer();
-    [JSBuiltin] Promise blob();
-    [JSBuiltin] Promise formData();
-    [JSBuiltin] Promise json();
-    [JSBuiltin] Promise text();
</del><ins>+    [NewObject, CallWith=ScriptExecutionContext, RaisesException] FetchResponse clone();
</ins><span class="cx"> 
</span><del>-    [JSBuiltin] FetchResponse clone();
-
-    [PrivateIdentifier, NewObject] FetchResponse cloneForJS();
-
-    [Conditional=STREAMS_API, PrivateIdentifier] void startConsumingStream(unsigned short type);
-    [Conditional=STREAMS_API, PrivateIdentifier] void consumeChunk(Uint8Array chunk);
-    [Conditional=STREAMS_API, PrivateIdentifier] Promise finishConsumingStream();
-
-    [PrivateIdentifier] Promise consume(unsigned short type);
</del><span class="cx">     [PrivateIdentifier, RaisesException] void setStatus(unsigned short status, DOMString statusText);
</span><span class="cx">     [CallWith=ScriptState, PrivateIdentifier] void initializeWith(any body);
</span><span class="cx">     [PrivateIdentifier, NewObject] ReadableStreamSource createReadableStreamSource();
</span><span class="cx">     [PrivateIdentifier] boolean isDisturbed();
</span><span class="cx"> };
</span><ins>+FetchResponse implements FetchBody;
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponsejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.js (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.js        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.js        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -48,12 +48,6 @@
</span><span class="cx">     if (body !== @undefined &amp;&amp; body !== null) {
</span><span class="cx">         if (status == 101 || status == 204 || status == 205 || status == 304)
</span><span class="cx">             throw new @TypeError(&quot;Response cannot have a body with the given status&quot;);
</span><del>-
-        // FIXME: Use @isReadableStream once it is no longer guarded by STREAMS_API guard.
-        let isBodyReadableStream = (@isObject(body) &amp;&amp; !!body.@underlyingSource);
-        if (isBodyReadableStream)
-          this.@body = body;
-
</del><span class="cx">         this.@initializeWith(body);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -74,77 +68,3 @@
</span><span class="cx">     }
</span><span class="cx">     return this.@body;
</span><span class="cx"> }
</span><del>-
-function clone()
-{
-    if (!this instanceof @Response)
-        throw new @TypeError(&quot;Function should be called on a Response&quot;);
-
-    if (@Response.prototype.@isDisturbed.@call(this))
-        throw new @TypeError(&quot;Cannot clone a disturbed Response&quot;);
-
-    var cloned = @Response.prototype.@cloneForJS.@call(this);
-    if (this.@body) {
-        var teedReadableStreams = @teeReadableStream(this.@body, false);
-        this.@body = teedReadableStreams[0];
-        cloned.@body = teedReadableStreams[1];
-    }
-    return cloned;
-}
-
-// consume and consumeStream single parameter should be kept in sync with FetchBodyConsumer::Type.
-function arrayBuffer()
-{
-    if (!this instanceof @Response)
-        throw new @TypeError(&quot;Function should be called on a Response&quot;);
-
-    const arrayBufferConsumerType = 1;
-    if (!this.@body)
-        return @Response.prototype.@consume.@call(this, arrayBufferConsumerType);
-
-    return @consumeStream(this, arrayBufferConsumerType);
-}
-
-function blob()
-{
-    if (!this instanceof @Response)
-        throw new @TypeError(&quot;Function should be called on a Response&quot;);
-
-    const blobConsumerType = 2;
-    if (!this.@body)
-        return @Response.prototype.@consume.@call(this, blobConsumerType);
-
-    return @consumeStream(this, blobConsumerType);
-}
-
-function formData()
-{
-    if (!this instanceof @Response)
-        throw new @TypeError(&quot;Function should be called on a Response&quot;);
-
-    return @Promise.@reject(&quot;Not implemented&quot;);
-}
-
-function json()
-{
-    if (!this instanceof @Response)
-        throw new @TypeError(&quot;Function should be called on a Response&quot;);
-
-    const jsonConsumerType = 3;
-    if (!this.@body)
-        return @Response.prototype.@consume.@call(this, jsonConsumerType);
-
-    return @consumeStream(this, jsonConsumerType);
-}
-
-function text()
-{
-    if (!this instanceof @Response)
-        throw new @TypeError(&quot;Function should be called on a Response&quot;);
-
-    const textConsumerType = 4;
-    if (!this.@body)
-        return @Response.prototype.@consume.@call(this, textConsumerType);
-
-    return @consumeStream(this, textConsumerType);
-}
</del></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -1631,7 +1631,6 @@
</span><span class="cx">                 41BF700F0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41BF700D0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp */; };
</span><span class="cx">                 41BF70100FE86F61005E8DEC /* PlatformMessagePortChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 41BF700E0FE86F61005E8DEC /* PlatformMessagePortChannel.h */; };
</span><span class="cx">                 41C760B10EDE03D300C1655F /* ScriptState.h in Headers */ = {isa = PBXBuildFile; fileRef = 41C760B00EDE03D300C1655F /* ScriptState.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><del>-                41CF8BE71D46226700707DC9 /* FetchBodyConsumer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41CF8BE41D46222000707DC9 /* FetchBodyConsumer.cpp */; };
</del><span class="cx">                 41D015CA0F4B5C71004A662F /* ContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 41D015C80F4B5C71004A662F /* ContentType.h */; };
</span><span class="cx">                 41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D015C90F4B5C71004A662F /* ContentType.cpp */; };
</span><span class="cx">                 41E1B1D00FF5986900576B3B /* AbstractWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41E1B1CA0FF5986900576B3B /* AbstractWorker.cpp */; };
</span><span class="lines">@@ -9219,9 +9218,6 @@
</span><span class="cx">                 41BF700D0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PlatformMessagePortChannel.cpp; path = default/PlatformMessagePortChannel.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 41BF700E0FE86F61005E8DEC /* PlatformMessagePortChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatformMessagePortChannel.h; path = default/PlatformMessagePortChannel.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 41C760B00EDE03D300C1655F /* ScriptState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptState.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                41CF8BE41D46222000707DC9 /* FetchBodyConsumer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchBodyConsumer.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
-                41CF8BE51D46222000707DC9 /* FetchBodyConsumer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchBodyConsumer.h; sourceTree = &quot;&lt;group&gt;&quot;; };
-                41CF8BE61D46222C00707DC9 /* FetchInternals.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = FetchInternals.js; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 41D015C80F4B5C71004A662F /* ContentType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentType.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 41D015C90F4B5C71004A662F /* ContentType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentType.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 41E1B1CA0FF5986900576B3B /* AbstractWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractWorker.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -17102,8 +17098,6 @@
</span><span class="cx">                                 41F54F7D1C50C4F600338488 /* FetchBody.cpp */,
</span><span class="cx">                                 41F54F7E1C50C4F600338488 /* FetchBody.h */,
</span><span class="cx">                                 41F54F7F1C50C4F600338488 /* FetchBody.idl */,
</span><del>-                                41CF8BE41D46222000707DC9 /* FetchBodyConsumer.cpp */,
-                                41CF8BE51D46222000707DC9 /* FetchBodyConsumer.h */,
</del><span class="cx">                                 4147E2B31C89912600A7E715 /* FetchBodyOwner.cpp */,
</span><span class="cx">                                 4147E2B21C88337F00A7E715 /* FetchBodyOwner.h */,
</span><span class="cx">                                 41F54F821C50C4F600338488 /* FetchHeaders.cpp */,
</span><span class="lines">@@ -17110,7 +17104,6 @@
</span><span class="cx">                                 41F54F831C50C4F600338488 /* FetchHeaders.h */,
</span><span class="cx">                                 41F54F841C50C4F600338488 /* FetchHeaders.idl */,
</span><span class="cx">                                 41F54F851C50C4F600338488 /* FetchHeaders.js */,
</span><del>-                                41CF8BE61D46222C00707DC9 /* FetchInternals.js */,
</del><span class="cx">                                 4147E2B41C89912600A7E715 /* FetchLoader.cpp */,
</span><span class="cx">                                 4147E2B51C89912600A7E715 /* FetchLoader.h */,
</span><span class="cx">                                 4147E2B61C89912600A7E715 /* FetchLoaderClient.h */,
</span><span class="lines">@@ -30779,7 +30772,6 @@
</span><span class="cx">                                 BC06EDE30BFD6D0D00856E9D /* JSHTMLTableCellElement.cpp in Sources */,
</span><span class="cx">                                 BC06ED9D0BFD660600856E9D /* JSHTMLTableColElement.cpp in Sources */,
</span><span class="cx">                                 BC06EE040BFD71AA00856E9D /* JSHTMLTableElement.cpp in Sources */,
</span><del>-                                41CF8BE71D46226700707DC9 /* FetchBodyConsumer.cpp in Sources */,
</del><span class="cx">                                 BC06ED9F0BFD660600856E9D /* JSHTMLTableRowElement.cpp in Sources */,
</span><span class="cx">                                 BC06ED060BFD5BAE00856E9D /* JSHTMLTableSectionElement.cpp in Sources */,
</span><span class="cx">                                 D6489D25166FFCF1007C031B /* JSHTMLTemplateElement.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSDOMPromiseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSDOMPromise.h (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSDOMPromise.h        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromise.h        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -118,8 +118,6 @@
</span><span class="cx">     template&lt;class RejectResultType&gt; typename std::enable_if&lt;PromiseResultInspector&lt;RejectResultType&gt;::passByConstRef, void&gt;::type
</span><span class="cx">     reject(const RejectResultType&amp; result) { rejectWithValue(result); }
</span><span class="cx"> 
</span><del>-    template&lt;class ResolveResultType&gt; void resolveWithNewlyCreated(Ref&lt;ResolveResultType&gt;&amp;&amp;);
-
</del><span class="cx">     void reject(ExceptionCode, const String&amp; = { });
</span><span class="cx"> 
</span><span class="cx">     JSDOMGlobalObject&amp; globalObject() const;
</span><span class="lines">@@ -183,16 +181,6 @@
</span><span class="cx">     resolve(*exec, toJS(exec, m_globalObject.get(), std::forward&lt;ResolveResultType&gt;(result)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-template&lt;class ResolveResultType&gt;
-inline void DeferredWrapper::resolveWithNewlyCreated(Ref&lt;ResolveResultType&gt;&amp;&amp; result)
-{
-    ASSERT(m_deferred);
-    ASSERT(m_globalObject);
-    JSC::ExecState* exec = m_globalObject-&gt;globalExec();
-    JSC::JSLockHolder locker(exec);
-    resolve(*exec, toJSNewlyCreated(exec, m_globalObject.get(), WTFMove(result)));
-}
-
</del><span class="cx"> template&lt;class RejectResultType&gt;
</span><span class="cx"> inline void DeferredWrapper::rejectWithValue(RejectResultType&amp;&amp; result)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (203725 => 203726)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h        2016-07-26 16:57:24 UTC (rev 203725)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h        2016-07-26 17:13:38 UTC (rev 203726)
</span><span class="lines">@@ -35,11 +35,8 @@
</span><span class="cx">     macro(addTrack) \
</span><span class="cx">     macro(appendFromJS) \
</span><span class="cx">     macro(body) \
</span><del>-    macro(cloneForJS) \
</del><span class="cx">     macro(closeRequested) \
</span><span class="cx">     macro(closedPromiseCapability) \
</span><del>-    macro(consume) \
-    macro(consumeChunk) \
</del><span class="cx">     macro(controlledReadableStream) \
</span><span class="cx">     macro(controller) \
</span><span class="cx">     macro(createReadableStreamSource) \
</span><span class="lines">@@ -46,7 +43,6 @@
</span><span class="cx">     macro(disturbed) \
</span><span class="cx">     macro(fetchRequest) \
</span><span class="cx">     macro(fillFromJS) \
</span><del>-    macro(finishConsumingStream) \
</del><span class="cx">     macro(firstReadCallback) \
</span><span class="cx">     macro(getUserMediaFromJS) \
</span><span class="cx">     macro(getRemoteStreams) \
</span><span class="lines">@@ -76,7 +72,6 @@
</span><span class="cx">     macro(setBody) \
</span><span class="cx">     macro(setStatus) \
</span><span class="cx">     macro(state) \
</span><del>-    macro(startConsumingStream) \
</del><span class="cx">     macro(started) \
</span><span class="cx">     macro(startedPromise) \
</span><span class="cx">     macro(storedError) \
</span></span></pre>
</div>
</div>

</body>
</html>