<!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>[198133] 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/198133">198133</a></dd>
<dt>Author</dt> <dd>youenn.fablet@crf.canon.fr</dd>
<dt>Date</dt> <dd>2016-03-14 08:58:14 -0700 (Mon, 14 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Fetch API] Implement data resolution for blob stored in Body
https://bugs.webkit.org/show_bug.cgi?id=155359
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
* web-platform-tests/fetch/api/request/request-consume-expected.txt:
* web-platform-tests/fetch/api/request/request-consume.html:
* web-platform-tests/fetch/api/request/request-init-002-expected.txt:
* web-platform-tests/fetch/api/response/response-consume-expected.txt:
* web-platform-tests/fetch/api/response/response-consume.html:
* web-platform-tests/fetch/api/response/response-init-002-expected.txt:
Source/WebCore:
Introducing FetchLoader as a wrapper around ThreadableLoader to load resources.
FetchLoader can retrieve data as text or array buffer. It only supports blob currently.
Introducing FetchLoaderClient interface and FetchBodyOwner::BlobLoader as specifc blob loader client.
Covered by existing rebased tests.
* CMakeLists.txt:
* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::loadingType):
(WebCore::FetchBody::loadedAsArrayBuffer):
(WebCore::FetchBody::loadedAsText):
* Modules/fetch/FetchBody.h:
* Modules/fetch/FetchBodyOwner.cpp: Added.
(WebCore::FetchBodyOwner::FetchBodyOwner):
(WebCore::FetchBodyOwner::loadBlob):
(WebCore::FetchBodyOwner::finishBlobLoading):
(WebCore::FetchBodyOwner::blobLoadingFailed):
(WebCore::FetchBodyOwner::BlobLoader::didReceiveResponse):
* Modules/fetch/FetchBodyOwner.h:
(WebCore::FetchBodyOwner::loadedBlobAsText):
(WebCore::FetchBodyOwner::loadedBlobAsArrayBuffer):
(WebCore::FetchBodyOwner::blobLoadingSucceeded):
* Modules/fetch/FetchLoader.cpp: Added.
(WebCore::FetchLoader::start):
(WebCore::FetchLoader::FetchLoader):
(WebCore::FetchLoader::stop):
(WebCore::FetchLoader::didReceiveResponse):
(WebCore::FetchLoader::didReceiveData):
(WebCore::FetchLoader::didFinishLoading):
(WebCore::FetchLoader::didFail):
* Modules/fetch/FetchLoader.h: Added.
* Modules/fetch/FetchLoaderClient.h: Added.
(WebCore::FetchLoaderClient::~FetchLoaderClient):
(WebCore::FetchLoaderClient::didReceiveResponse):
(WebCore::FetchLoaderClient::didFinishLoadingAsText):
(WebCore::FetchLoaderClient::didFinishLoadingAsArrayBuffer):
* WebCore.xcodeproj/project.pbxproj:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestconsumeexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-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="#trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestinit002expectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-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="#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="#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="#trunkSourceWebCoreModulesfetchFetchBodyOwnerh">trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchRequestcpp">trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesfetchFetchResponsecpp">trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreModulesfetchFetchBodyOwnercpp">trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp</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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -1,5 +1,19 @@
</span><span class="cx"> 2016-03-14 Youenn Fablet <youenn.fablet@crf.canon.fr>
</span><span class="cx">
</span><ins>+ [Fetch API] Implement data resolution for blob stored in Body
+ https://bugs.webkit.org/show_bug.cgi?id=155359
+
+ Reviewed by Darin Adler.
+
+ * web-platform-tests/fetch/api/request/request-consume-expected.txt:
+ * web-platform-tests/fetch/api/request/request-consume.html:
+ * web-platform-tests/fetch/api/request/request-init-002-expected.txt:
+ * web-platform-tests/fetch/api/response/response-consume-expected.txt:
+ * web-platform-tests/fetch/api/response/response-consume.html:
+ * web-platform-tests/fetch/api/response/response-init-002-expected.txt:
+
+2016-03-14 Youenn Fablet <youenn.fablet@crf.canon.fr>
+
</ins><span class="cx"> Web platform test server should not try to launch servers on already bound sockets
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=141157
</span><span class="cx">
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestconsumeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-expected.txt (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-expected.txt        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume-expected.txt        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -5,9 +5,9 @@
</span><span class="cx"> PASS Consume request's body as json
</span><span class="cx"> FAIL Consume request's body as formData promise_test: Unhandled rejection with value: undefined
</span><span class="cx"> PASS Consume blob response's body as blob
</span><del>-FAIL Consume blob response's body as text promise_test: Unhandled rejection with value: undefined
-FAIL Consume blob response's body as json promise_test: Unhandled rejection with value: undefined
-FAIL Consume blob response's body as arrayBuffer promise_test: Unhandled rejection with value: undefined
</del><ins>+PASS Consume blob response's body as text
+PASS Consume blob response's body as json
+PASS Consume blob response's body as arrayBuffer
</ins><span class="cx"> PASS Consume JSON from text: '"null"'
</span><span class="cx"> PASS Consume JSON from text: '"1"'
</span><span class="cx"> PASS Consume JSON from text: '"true"'
</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 (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume.html        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-consume.html        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx">
</span><span class="cx"> var formData = new FormData();
</span><span class="cx"> formData.append("name", "value")
</span><del>- var textData = "This is response's body";
</del><ins>+ var textData = JSON.stringify("This is response's body");
</ins><span class="cx"> var blob = new Blob([textData], { "type" : "text/plain" });
</span><span class="cx">
</span><span class="cx"> checkRequestBody(textData, "text", checkBodyText);
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsfetchapirequestrequestinit002expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-init-002-expected.txt        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx">
</span><span class="cx"> PASS Initialize Request with headers values
</span><del>-FAIL Initialize Request's body with application/octet-binary promise_test: Unhandled rejection with value: undefined
</del><ins>+PASS Initialize Request's body with application/octet-binary
</ins><span class="cx"> FAIL Initialize Request's body with multipart/form-data promise_test: Unhandled rejection with value: undefined
</span><span class="cx"> PASS Initialize Request's body with text/plain;charset=UTF-8
</span><span class="cx"> FAIL Initialize Request's body with application/x-www-form-urlencoded;charset=UTF-8 promise_test: Unhandled rejection with value: "URLSearchParams not supported"
</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 (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume-expected.txt        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -5,7 +5,7 @@
</span><span class="cx"> PASS Consume response's body as json
</span><span class="cx"> FAIL Consume response's body as formData promise_test: Unhandled rejection with value: undefined
</span><span class="cx"> PASS Consume blob response's body as blob
</span><del>-FAIL Consume blob response's body as text promise_test: Unhandled rejection with value: undefined
-FAIL Consume blob response's body as json promise_test: Unhandled rejection with value: undefined
-FAIL Consume blob response's body as arrayBuffer promise_test: Unhandled rejection with value: undefined
</del><ins>+PASS Consume blob response's body as text
+PASS Consume blob response's body as json
+PASS Consume blob response's body as arrayBuffer
</ins><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 (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-consume.html        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx">
</span><span class="cx"> var formData = new FormData();
</span><span class="cx"> formData.append("name", "value");
</span><del>- var textData = "This is response's body";
</del><ins>+ var textData = JSON.stringify("This is response's body");
</ins><span class="cx"> var blob = new Blob([textData], { "type" : "text/plain" });
</span><span class="cx">
</span><span class="cx"> checkResponseBody(textData, "text", checkBodyText);
</span></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 (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/fetch/api/response/response-init-002-expected.txt        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx">
</span><span class="cx"> PASS Initialize Response with headers values
</span><del>-FAIL Initialize Response's body with application/octet-binary promise_test: Unhandled rejection with value: undefined
</del><ins>+PASS Initialize Response's body with application/octet-binary
</ins><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 "application/x-www-form-urlencoded;charset=UTF-8" expected true got false
</span><span class="cx"> PASS Initialize Response's body with text/plain;charset=UTF-8
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -816,7 +816,9 @@
</span><span class="cx">
</span><span class="cx"> Modules/fetch/DOMWindowFetch.cpp
</span><span class="cx"> Modules/fetch/FetchBody.cpp
</span><ins>+ Modules/fetch/FetchBodyOwner.cpp
</ins><span class="cx"> Modules/fetch/FetchHeaders.cpp
</span><ins>+ Modules/fetch/FetchLoader.cpp
</ins><span class="cx"> Modules/fetch/FetchRequest.cpp
</span><span class="cx"> Modules/fetch/FetchResponse.cpp
</span><span class="cx"> Modules/fetch/WorkerGlobalScopeFetch.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/Source/WebCore/ChangeLog        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2016-03-14 Youenn Fablet <youenn.fablet@crf.canon.fr>
+
+ [Fetch API] Implement data resolution for blob stored in Body
+ https://bugs.webkit.org/show_bug.cgi?id=155359
+
+ Reviewed by Darin Adler.
+
+ Introducing FetchLoader as a wrapper around ThreadableLoader to load resources.
+ FetchLoader can retrieve data as text or array buffer. It only supports blob currently.
+
+ Introducing FetchLoaderClient interface and FetchBodyOwner::BlobLoader as specifc blob loader client.
+
+ Covered by existing rebased tests.
+
+ * CMakeLists.txt:
+ * Modules/fetch/FetchBody.cpp:
+ (WebCore::FetchBody::loadingType):
+ (WebCore::FetchBody::loadedAsArrayBuffer):
+ (WebCore::FetchBody::loadedAsText):
+ * Modules/fetch/FetchBody.h:
+ * Modules/fetch/FetchBodyOwner.cpp: Added.
+ (WebCore::FetchBodyOwner::FetchBodyOwner):
+ (WebCore::FetchBodyOwner::loadBlob):
+ (WebCore::FetchBodyOwner::finishBlobLoading):
+ (WebCore::FetchBodyOwner::blobLoadingFailed):
+ (WebCore::FetchBodyOwner::BlobLoader::didReceiveResponse):
+ * Modules/fetch/FetchBodyOwner.h:
+ (WebCore::FetchBodyOwner::loadedBlobAsText):
+ (WebCore::FetchBodyOwner::loadedBlobAsArrayBuffer):
+ (WebCore::FetchBodyOwner::blobLoadingSucceeded):
+ * Modules/fetch/FetchLoader.cpp: Added.
+ (WebCore::FetchLoader::start):
+ (WebCore::FetchLoader::FetchLoader):
+ (WebCore::FetchLoader::stop):
+ (WebCore::FetchLoader::didReceiveResponse):
+ (WebCore::FetchLoader::didReceiveData):
+ (WebCore::FetchLoader::didFinishLoading):
+ (WebCore::FetchLoader::didFail):
+ * Modules/fetch/FetchLoader.h: Added.
+ * Modules/fetch/FetchLoaderClient.h: Added.
+ (WebCore::FetchLoaderClient::~FetchLoaderClient):
+ (WebCore::FetchLoaderClient::didReceiveResponse):
+ (WebCore::FetchLoaderClient::didFinishLoadingAsText):
+ (WebCore::FetchLoaderClient::didFinishLoadingAsArrayBuffer):
+ * WebCore.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2016-03-14 Frederic Wang <fwang@igalia.com>
</span><span class="cx">
</span><span class="cx"> Make MathML colspan/rowspan consistent with HTML table cells.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -135,8 +135,11 @@
</span><span class="cx"> if (processIfEmptyOrDisturbed(Consumer::Type::JSON, promise))
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ if (!owner.scriptExecutionContext())
+ return;
+
</ins><span class="cx"> if (m_type == Type::Text) {
</span><del>- resolveAsJSON(owner.scriptExecutionContext(), m_text, WTFMove(promise));
</del><ins>+ resolveAsJSON(*owner.scriptExecutionContext(), m_text, WTFMove(promise));
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx"> consume(owner, Consumer::Type::JSON, WTFMove(promise));
</span><span class="lines">@@ -182,19 +185,18 @@
</span><span class="cx"> promise.resolve<RefPtr<Blob>>(Blob::create(extractFromText(), contentType));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-FetchLoadingType FetchBody::loadingType(Consumer::Type type)
</del><ins>+FetchLoader::Type FetchBody::loadingType(Consumer::Type type)
</ins><span class="cx"> {
</span><span class="cx"> switch (type) {
</span><span class="cx"> case Consumer::Type::JSON:
</span><span class="cx"> case Consumer::Type::Text:
</span><del>- return FetchLoadingType::Text;
</del><ins>+ return FetchLoader::Type::Text;
</ins><span class="cx"> case Consumer::Type::Blob:
</span><del>- return FetchLoadingType::Blob;
</del><span class="cx"> case Consumer::Type::ArrayBuffer:
</span><del>- return FetchLoadingType::ArrayBuffer;
</del><ins>+ return FetchLoader::Type::ArrayBuffer;
</ins><span class="cx"> default:
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><del>- return FetchLoadingType::ArrayBuffer;
</del><ins>+ return FetchLoader::Type::ArrayBuffer;
</ins><span class="cx"> };
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -206,9 +208,9 @@
</span><span class="cx"> owner.loadBlob(*m_blob, loadingType(type));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void FetchBody::resolveAsJSON(ScriptExecutionContext* context, const String& data, DeferredWrapper&& promise)
</del><ins>+void FetchBody::resolveAsJSON(ScriptExecutionContext& context, const String& data, DeferredWrapper&& promise)
</ins><span class="cx"> {
</span><del>- DOMRequestState state(context);
</del><ins>+ DOMRequestState state(&context);
</ins><span class="cx"> JSC::JSValue value = JSC::JSONParse(state.exec(), data);
</span><span class="cx"> if (!value)
</span><span class="cx"> promise.reject<ExceptionCode>(SYNTAX_ERR);
</span><span class="lines">@@ -233,13 +235,33 @@
</span><span class="cx"> m_consumer = Nullopt;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void FetchBody::loadedAsBlob(Blob& blob)
</del><ins>+void FetchBody::loadedAsArrayBuffer(RefPtr<ArrayBuffer>&& buffer)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(m_consumer);
</span><del>- m_consumer->promise.resolve(&blob);
</del><ins>+ ASSERT(m_consumer->type == Consumer::Type::Blob || m_consumer->type == Consumer::Type::ArrayBuffer);
+ if (m_consumer->type == Consumer::Type::ArrayBuffer)
+ m_consumer->promise.resolve(buffer);
+ else {
+ ASSERT(m_blob);
+ Vector<char> data;
+ data.reserveCapacity(buffer->byteLength());
+ data.append(static_cast<const char*>(buffer->data()), buffer->byteLength());
+ m_consumer->promise.resolve<RefPtr<Blob>>(Blob::create(WTFMove(data), m_blob->type()));
+ }
</ins><span class="cx"> m_consumer = Nullopt;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void FetchBody::loadedAsText(ScriptExecutionContext& context, String&& text)
+{
+ ASSERT(m_consumer);
+ ASSERT(m_consumer->type == Consumer::Type::Text || m_consumer->type == Consumer::Type::JSON);
+ if (m_consumer->type == Consumer::Type::Text)
+ m_consumer->promise.resolve(text);
+ else
+ resolveAsJSON(context, text, WTFMove(m_consumer->promise));
+ m_consumer = Nullopt;
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+}
+
</ins><span class="cx"> #endif // ENABLE(FETCH_API)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.h (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBody.h        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.h        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx">
</span><span class="cx"> #include "Blob.h"
</span><span class="cx"> #include "DOMFormData.h"
</span><ins>+#include "FetchLoader.h"
</ins><span class="cx"> #include "JSDOMPromise.h"
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="lines">@@ -43,7 +44,6 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> class FetchBodyOwner;
</span><del>-enum class FetchLoadingType;
</del><span class="cx">
</span><span class="cx"> class FetchBody {
</span><span class="cx"> public:
</span><span class="lines">@@ -64,7 +64,8 @@
</span><span class="cx"> FetchBody() = default;
</span><span class="cx">
</span><span class="cx"> void loadingFailed();
</span><del>- void loadedAsBlob(Blob&);
</del><ins>+ void loadedAsArrayBuffer(RefPtr<ArrayBuffer>&&);
+ void loadedAsText(ScriptExecutionContext&, String&&);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> enum class Type { None, Text, Blob, FormData };
</span><span class="lines">@@ -85,8 +86,8 @@
</span><span class="cx"> bool processIfEmptyOrDisturbed(Consumer::Type, DeferredWrapper&);
</span><span class="cx"> void consumeText(Consumer::Type, DeferredWrapper&&);
</span><span class="cx"> void consumeBlob(FetchBodyOwner&, Consumer::Type, DeferredWrapper&&);
</span><del>- void resolveAsJSON(ScriptExecutionContext*, const String&, DeferredWrapper&&);
- static FetchLoadingType loadingType(Consumer::Type);
</del><ins>+ void resolveAsJSON(ScriptExecutionContext&, const String&, DeferredWrapper&&);
+ static FetchLoader::Type loadingType(Consumer::Type);
</ins><span class="cx">
</span><span class="cx"> Type m_type = Type::None;
</span><span class="cx"> String m_mimeType;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyOwnercppfromrev198132trunkSourceWebCoreModulesfetchFetchBodyOwnerh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp (from rev 198132, trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h) (0 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp         (rev 0)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -0,0 +1,104 @@
</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 "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FetchBodyOwner.h"
+
+#if ENABLE(FETCH_API)
+
+#include "FetchLoader.h"
+#include "ResourceResponse.h"
+
+namespace WebCore {
+
+FetchBodyOwner::FetchBodyOwner(ScriptExecutionContext& context, FetchBody&& body)
+ : ActiveDOMObject(&context)
+ , m_body(WTFMove(body))
+{
+ suspendIfNeeded();
+}
+
+void FetchBodyOwner::stop()
+{
+ if (m_blobLoader) {
+ if (m_blobLoader->loader)
+ m_blobLoader->loader->stop();
+ finishBlobLoading();
+ }
+ ASSERT(!m_blobLoader);
+}
+
+void FetchBodyOwner::loadBlob(Blob& blob, FetchLoader::Type type)
+{
+ // Can only be called once for a body instance.
+ ASSERT(m_body.isDisturbed());
+ ASSERT(!m_blobLoader);
+
+ m_blobLoader = { *this };
+ m_blobLoader->loader = std::make_unique<FetchLoader>(type, *m_blobLoader);
+
+ setPendingActivity(this);
+ if (!scriptExecutionContext() || !m_blobLoader->loader->start(*scriptExecutionContext(), blob))
+ blobLoadingFailed();
+}
+
+void FetchBodyOwner::loadedBlobAsText(String&& text)
+{
+ ASSERT(*scriptExecutionContext());
+
+ m_body.loadedAsText(*scriptExecutionContext(), WTFMove(text));
+}
+
+void FetchBodyOwner::finishBlobLoading()
+{
+ ASSERT(m_blobLoader);
+
+ m_blobLoader = Nullopt;
+ unsetPendingActivity(this);
+}
+
+void FetchBodyOwner::blobLoadingFailed()
+{
+ m_body.loadingFailed();
+ finishBlobLoading();
+}
+
+FetchBodyOwner::BlobLoader::BlobLoader(FetchBodyOwner& owner)
+ : owner(owner)
+{
+}
+
+void FetchBodyOwner::BlobLoader::didReceiveResponse(const ResourceResponse& response)
+{
+ if (response.httpStatusCode() != 200)
+ didFail();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FETCH_API)
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchBodyOwnerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -33,11 +33,11 @@
</span><span class="cx">
</span><span class="cx"> #include "ActiveDOMObject.h"
</span><span class="cx"> #include "FetchBody.h"
</span><ins>+#include "FetchLoader.h"
+#include "FetchLoaderClient.h"
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-enum class FetchLoadingType { Text, ArrayBuffer, Blob };
-
</del><span class="cx"> class FetchBodyOwner : public RefCounted<FetchBodyOwner>, public ActiveDOMObject {
</span><span class="cx"> public:
</span><span class="cx"> FetchBodyOwner(ScriptExecutionContext&, FetchBody&&);
</span><span class="lines">@@ -50,30 +50,42 @@
</span><span class="cx"> void json(DeferredWrapper&& promise) { m_body.json(*this, WTFMove(promise)); }
</span><span class="cx"> void text(DeferredWrapper&& promise) { m_body.text(*this, WTFMove(promise)); }
</span><span class="cx">
</span><del>- void loadBlob(Blob&, FetchLoadingType);
</del><ins>+ void loadBlob(Blob&, FetchLoader::Type);
</ins><span class="cx">
</span><ins>+ bool isActive() const { return !!m_blobLoader; }
+
+private:
+ // Blob loading routines
+ void loadedBlobAsText(String&&);
+ void loadedBlobAsArrayBuffer(RefPtr<ArrayBuffer>&& buffer) { m_body.loadedAsArrayBuffer(WTFMove(buffer)); }
+ void blobLoadingSucceeded() { finishBlobLoading(); }
+ void blobLoadingFailed();
+ void finishBlobLoading();
+
+ // ActiveDOMObject API
+ void stop() override;
+
+ struct BlobLoader final : FetchLoaderClient {
+ BlobLoader(FetchBodyOwner&);
+
+ // FetchLoaderClient API
+ void didFinishLoadingAsText(String&& text) final { owner.loadedBlobAsText(WTFMove(text)); }
+ void didFinishLoadingAsArrayBuffer(RefPtr<ArrayBuffer>&& buffer) final { owner.loadedBlobAsArrayBuffer(WTFMove(buffer)); }
+ void didReceiveResponse(const ResourceResponse&) final;
+ void didFail() final { owner.blobLoadingFailed(); };
+ void didSucceed() final { owner.blobLoadingSucceeded(); }
+
+ FetchBodyOwner& owner;
+ std::unique_ptr<FetchLoader> loader;
+ };
+
</ins><span class="cx"> protected:
</span><span class="cx"> FetchBody m_body;
</span><ins>+
+private:
+ Optional<BlobLoader> m_blobLoader;
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-inline FetchBodyOwner::FetchBodyOwner(ScriptExecutionContext& context, FetchBody&& body)
- : ActiveDOMObject(&context)
- , m_body(WTFMove(body))
-{
- suspendIfNeeded();
-}
-
-inline void FetchBodyOwner::loadBlob(Blob& blob, FetchLoadingType type)
-{
- if (type == FetchLoadingType::Blob) {
- // FIXME: Clone blob.
- m_body.loadedAsBlob(blob);
- return;
- }
- // FIXME: Implement blob loading.
- m_body.loadingFailed();
-}
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> #endif // ENABLE(FETCH_API)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoadercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp (0 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp         (rev 0)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoader.cpp        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -0,0 +1,118 @@
</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 "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FetchLoader.h"
+
+#if ENABLE(FETCH_API)
+
+#include "BlobURL.h"
+#include "FetchBody.h"
+#include "FetchLoaderClient.h"
+#include "ResourceRequest.h"
+#include "ScriptExecutionContext.h"
+#include "SharedBuffer.h"
+#include "TextResourceDecoder.h"
+#include "ThreadableBlobRegistry.h"
+#include "ThreadableLoader.h"
+
+namespace WebCore {
+
+bool FetchLoader::start(ScriptExecutionContext& context, Blob& blob)
+{
+ auto urlForReading = BlobURL::createPublicURL(context.securityOrigin());
+ if (urlForReading.isEmpty())
+ return false;
+ ThreadableBlobRegistry::registerBlobURL(context.securityOrigin(), urlForReading, blob.url());
+
+ ResourceRequest request(urlForReading);
+ request.setHTTPMethod("GET");
+
+ ThreadableLoaderOptions options;
+ options.setSendLoadCallbacks(SendCallbacks);
+ options.setSniffContent(DoNotSniffContent);
+ options.setDataBufferingPolicy(DoNotBufferData);
+ options.preflightPolicy = ConsiderPreflight;
+ options.setAllowCredentials(AllowStoredCredentials);
+ options.crossOriginRequestPolicy = DenyCrossOriginRequests;
+ options.contentSecurityPolicyEnforcement = ContentSecurityPolicyEnforcement::DoNotEnforce;
+
+ m_loader = ThreadableLoader::create(&context, this, request, options);
+ return true;
+}
+
+FetchLoader::FetchLoader(Type type, FetchLoaderClient& client)
+ : m_type(type)
+ , m_client(client)
+{
+}
+
+void FetchLoader::stop()
+{
+ if (m_loader) {
+ m_loader->cancel();
+ m_loader = nullptr;
+ }
+ m_data = nullptr;
+}
+
+void FetchLoader::didReceiveResponse(unsigned long, const ResourceResponse& response)
+{
+ m_client.didReceiveResponse(response);
+}
+
+// FIXME: We should make text and blob creation more efficient.
+// We might also want to merge this class with FileReaderLoader.
+void FetchLoader::didReceiveData(const char* value, int size)
+{
+ if (!m_data) {
+ m_data = SharedBuffer::create(value, size);
+ return;
+ }
+ m_data->append(value, size);
+}
+
+void FetchLoader::didFinishLoading(unsigned long, double)
+{
+ if (m_type == Type::ArrayBuffer)
+ m_client.didFinishLoadingAsArrayBuffer(m_data->createArrayBuffer());
+ else
+ m_client.didFinishLoadingAsText(TextResourceDecoder::create(ASCIILiteral("text/plain"), "UTF-8")->decodeAndFlush(m_data->data(), m_data->size()));
+ m_data = nullptr;
+
+ m_client.didSucceed();
+}
+
+void FetchLoader::didFail(const ResourceError&)
+{
+ m_client.didFail();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FETCH_API)
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoaderhfromrev198132trunkSourceWebCoreModulesfetchFetchBodyOwnerh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/fetch/FetchLoader.h (from rev 198132, trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h) (0 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoader.h         (rev 0)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoader.h        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -0,0 +1,71 @@
</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 "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FetchLoader_h
+#define FetchLoader_h
+
+#if ENABLE(FETCH_API)
+
+#include "SharedBuffer.h"
+#include "ThreadableLoader.h"
+#include "ThreadableLoaderClient.h"
+
+namespace WebCore {
+
+class Blob;
+class FetchLoaderClient;
+class ScriptExecutionContext;
+
+class FetchLoader final : public ThreadableLoaderClient {
+public:
+ enum class Type { ArrayBuffer, Text };
+
+ FetchLoader(Type, FetchLoaderClient&);
+
+ bool start(ScriptExecutionContext&, Blob&);
+ void stop();
+
+private:
+ // ThreadableLoaderClient API.
+ void didReceiveResponse(unsigned long, const ResourceResponse&) final;
+ void didReceiveData(const char*, int) final;
+ void didFinishLoading(unsigned long, double) final;
+ void didFail(const ResourceError&) final;
+
+private:
+ Type m_type { Type::ArrayBuffer };
+ FetchLoaderClient& m_client;
+ RefPtr<ThreadableLoader> m_loader;
+ RefPtr<SharedBuffer> m_data;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(FETCH_API)
+
+#endif // FetchLoader_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchLoaderClienthfromrev198132trunkSourceWebCoreModulesfetchFetchBodyOwnerh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h (from rev 198132, trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h) (0 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h         (rev 0)
+++ trunk/Source/WebCore/Modules/fetch/FetchLoaderClient.h        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -0,0 +1,61 @@
</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 "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FetchLoaderClient_h
+#define FetchLoaderClient_h
+
+#if ENABLE(FETCH_API)
+
+#include <wtf/Forward.h>
+
+namespace JSC {
+class ArrayBuffer;
+}
+
+namespace WebCore {
+
+class ResourceResponse;
+
+class FetchLoaderClient {
+public:
+ virtual ~FetchLoaderClient() { }
+
+ virtual void didReceiveResponse(const ResourceResponse&) { }
+
+ virtual void didFinishLoadingAsText(String&&) { }
+ virtual void didFinishLoadingAsArrayBuffer(RefPtr<JSC::ArrayBuffer>&&) { }
+
+ virtual void didSucceed() = 0;
+ virtual void didFail() = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(FETCH_API)
+
+#endif // FetchLoaderClient_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchRequestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -453,7 +453,8 @@
</span><span class="cx">
</span><span class="cx"> bool FetchRequest::canSuspendForDocumentSuspension() const
</span><span class="cx"> {
</span><del>- return true;
</del><ins>+ // FIXME: We can probably do the same strategy as XHR.
+ return !isActive();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesfetchFetchResponsecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -160,7 +160,8 @@
</span><span class="cx">
</span><span class="cx"> bool FetchResponse::canSuspendForDocumentSuspension() const
</span><span class="cx"> {
</span><del>- return true;
</del><ins>+ // FIXME: We can probably do the same strategy as XHR.
+ return !isActive();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (198132 => 198133)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-03-14 15:42:54 UTC (rev 198132)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-03-14 15:58:14 UTC (rev 198133)
</span><span class="lines">@@ -1521,6 +1521,8 @@
</span><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><ins>+                4147E2B71C89912C00A7E715 /* FetchLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4147E2B41C89912600A7E715 /* FetchLoader.cpp */; };
+                4147E2B81C89912F00A7E715 /* FetchBodyOwner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4147E2B31C89912600A7E715 /* FetchBodyOwner.cpp */; };
</ins><span class="cx">                 415071571685067300C3C7B3 /* SelectorFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 415071551685067300C3C7B3 /* SelectorFilter.cpp */; };
</span><span class="cx">                 415071581685067300C3C7B3 /* SelectorFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = 415071561685067300C3C7B3 /* SelectorFilter.h */; };
</span><span class="cx">                 4150F9F112B6E0E70008C860 /* SliderThumbElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4150F9EF12B6E0E70008C860 /* SliderThumbElement.h */; };
</span><span class="lines">@@ -9001,6 +9003,10 @@
</span><span class="cx">                 4138D3341244054800323D33 /* EventContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventContext.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 413C2C331BC29A7B0075204C /* JSDOMConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDOMConstructor.h; sourceTree = "<group>"; };
</span><span class="cx">                 4147E2B21C88337F00A7E715 /* FetchBodyOwner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchBodyOwner.h; sourceTree = "<group>"; };
</span><ins>+                4147E2B31C89912600A7E715 /* FetchBodyOwner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchBodyOwner.cpp; sourceTree = "<group>"; };
+                4147E2B41C89912600A7E715 /* FetchLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FetchLoader.cpp; sourceTree = "<group>"; };
+                4147E2B51C89912600A7E715 /* FetchLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchLoader.h; sourceTree = "<group>"; };
+                4147E2B61C89912600A7E715 /* FetchLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchLoaderClient.h; sourceTree = "<group>"; };
</ins><span class="cx">                 415071551685067300C3C7B3 /* SelectorFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectorFilter.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 415071561685067300C3C7B3 /* SelectorFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectorFilter.h; sourceTree = "<group>"; };
</span><span class="cx">                 4150F9EF12B6E0E70008C860 /* SliderThumbElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SliderThumbElement.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -16823,11 +16829,15 @@
</span><span class="cx">                                 41F54F7D1C50C4F600338488 /* FetchBody.cpp */,
</span><span class="cx">                                 41F54F7E1C50C4F600338488 /* FetchBody.h */,
</span><span class="cx">                                 41F54F7F1C50C4F600338488 /* FetchBody.idl */,
</span><ins>+                                4147E2B31C89912600A7E715 /* FetchBodyOwner.cpp */,
</ins><span class="cx">                                 4147E2B21C88337F00A7E715 /* FetchBodyOwner.h */,
</span><span class="cx">                                 41F54F821C50C4F600338488 /* FetchHeaders.cpp */,
</span><span class="cx">                                 41F54F831C50C4F600338488 /* FetchHeaders.h */,
</span><span class="cx">                                 41F54F841C50C4F600338488 /* FetchHeaders.idl */,
</span><span class="cx">                                 41F54F851C50C4F600338488 /* FetchHeaders.js */,
</span><ins>+                                4147E2B41C89912600A7E715 /* FetchLoader.cpp */,
+                                4147E2B51C89912600A7E715 /* FetchLoader.h */,
+                                4147E2B61C89912600A7E715 /* FetchLoaderClient.h */,
</ins><span class="cx">                                 41F54F861C50C4F600338488 /* FetchOptions.h */,
</span><span class="cx">                                 41F54F871C50C4F600338488 /* FetchRequest.cpp */,
</span><span class="cx">                                 41F54F881C50C4F600338488 /* FetchRequest.h */,
</span><span class="lines">@@ -30547,6 +30557,7 @@
</span><span class="cx">                                 07969DC117D14151007FF842 /* JSRTCStatsReport.cpp in Sources */,
</span><span class="cx">                                 07969DC317D14151007FF842 /* JSRTCStatsResponse.cpp in Sources */,
</span><span class="cx">                                 07DC5FD417D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp in Sources */,
</span><ins>+                                4147E2B81C89912F00A7E715 /* FetchBodyOwner.cpp in Sources */,
</ins><span class="cx">                                 5E2C436B1BCF071E0001E2BC /* JSRTCTrackEvent.cpp in Sources */,
</span><span class="cx">                                 BCEC01C20C274DDD009F4EC9 /* JSScreen.cpp in Sources */,
</span><span class="cx">                                 FDA15ECD12B03F61003A583A /* JSScriptProcessorNode.cpp in Sources */,
</span><span class="lines">@@ -31881,6 +31892,7 @@
</span><span class="cx">                                 A77E1FEF14AACB6E005B7CB6 /* TreeScopeAdopter.cpp in Sources */,
</span><span class="cx">                                 854FE7380A2297BE0058D7AD /* TreeWalker.cpp in Sources */,
</span><span class="cx">                                 C375D7FD16639519006184AB /* TypeAhead.cpp in Sources */,
</span><ins>+                                4147E2B71C89912C00A7E715 /* FetchLoader.cpp in Sources */,
</ins><span class="cx">                                 93309E19099E64920056E581 /* TypingCommand.cpp in Sources */,
</span><span class="cx">                                 85031B4D0A44EFC700F992E0 /* UIEvent.cpp in Sources */,
</span><span class="cx">                                 93354A3C0B24F8C9003F6DEA /* UIEventWithKeyState.cpp in Sources */,
</span></span></pre>
</div>
</div>
</body>
</html>