<!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>[201924] trunk/Source/WebCore</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/201924">201924</a></dd>
<dt>Author</dt> <dd>youenn.fablet@crf.canon.fr</dd>
<dt>Date</dt> <dd>2016-06-10 06:26:30 -0700 (Fri, 10 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move preflight check code outside of DocumentThreadableLoader
https://bugs.webkit.org/show_bug.cgi?id=158425

Reviewed by Darin Adler.

Moving preflight check code in its own class.
This allows code to be easier to read, use/reuse and update.

Behavior should be the same as before except in the case of a preflight response
being a 3XX redirect response.
Before this patch, the 3XX response was directly passed to the code processing regular responses.
To keep compatibility with existing tests, a didFailRedirectCheck callback is called.
This should be change to a preflight failure.

Covered by existing tests.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* loader/CrossOriginPreflightChecker.cpp: Added.
(WebCore::CrossOriginPreflightChecker::CrossOriginPreflightChecker):
(WebCore::CrossOriginPreflightChecker::~CrossOriginPreflightChecker):
(WebCore::CrossOriginPreflightChecker::handleLoadingFailure):
(WebCore::CrossOriginPreflightChecker::validatePreflightResponse):
(WebCore::CrossOriginPreflightChecker::notifyFinished):
(WebCore::CrossOriginPreflightChecker::startPreflight):
(WebCore::CrossOriginPreflightChecker::doPreflight):
(WebCore::CrossOriginPreflightChecker::redirectReceived):
(WebCore::CrossOriginPreflightChecker::setDefersLoading):
(WebCore::CrossOriginPreflightChecker::isXMLHttpRequest):
* loader/CrossOriginPreflightChecker.h: Added.
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::create):
(WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequest):
(WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequestWithPreflight):
(WebCore::DocumentThreadableLoader::setDefersLoading):
(WebCore::DocumentThreadableLoader::clearResource):
(WebCore::DocumentThreadableLoader::didReceiveResponse):
(WebCore::DocumentThreadableLoader::didReceiveData):
(WebCore::DocumentThreadableLoader::notifyFinished):
(WebCore::DocumentThreadableLoader::didFinishLoading):
(WebCore::DocumentThreadableLoader::didFail):
(WebCore::DocumentThreadableLoader::preflightSuccess):
(WebCore::DocumentThreadableLoader::preflightFailure):
(WebCore::DocumentThreadableLoader::loadRequest):
(WebCore::DocumentThreadableLoader::responseReceived): Deleted.
(WebCore::DocumentThreadableLoader::dataReceived): Deleted.
(WebCore::DocumentThreadableLoader::isAllowedByContentSecurityPolicy): Deleted.
* loader/DocumentThreadableLoader.h:
(WebCore::DocumentThreadableLoader::options):
(WebCore::DocumentThreadableLoader::isLoading):
(WebCore::DocumentThreadableLoader::document):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentThreadableLoadercpp">trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentThreadableLoaderh">trunk/Source/WebCore/loader/DocumentThreadableLoader.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreloaderCrossOriginPreflightCheckercpp">trunk/Source/WebCore/loader/CrossOriginPreflightChecker.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderCrossOriginPreflightCheckerh">trunk/Source/WebCore/loader/CrossOriginPreflightChecker.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (201923 => 201924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-06-10 12:58:12 UTC (rev 201923)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-06-10 13:26:30 UTC (rev 201924)
</span><span class="lines">@@ -1900,6 +1900,7 @@
</span><span class="cx">     loader/ContentFilter.cpp
</span><span class="cx">     loader/CookieJar.cpp
</span><span class="cx">     loader/CrossOriginAccessControl.cpp
</span><ins>+    loader/CrossOriginPreflightChecker.cpp
</ins><span class="cx">     loader/CrossOriginPreflightResultCache.cpp
</span><span class="cx">     loader/DocumentLoadTiming.cpp
</span><span class="cx">     loader/DocumentLoader.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (201923 => 201924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-10 12:58:12 UTC (rev 201923)
+++ trunk/Source/WebCore/ChangeLog        2016-06-10 13:26:30 UTC (rev 201924)
</span><span class="lines">@@ -1,3 +1,57 @@
</span><ins>+2016-06-10  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        Move preflight check code outside of DocumentThreadableLoader
+        https://bugs.webkit.org/show_bug.cgi?id=158425
+
+        Reviewed by Darin Adler.
+
+        Moving preflight check code in its own class.
+        This allows code to be easier to read, use/reuse and update.
+
+        Behavior should be the same as before except in the case of a preflight response
+        being a 3XX redirect response.
+        Before this patch, the 3XX response was directly passed to the code processing regular responses.
+        To keep compatibility with existing tests, a didFailRedirectCheck callback is called.
+        This should be change to a preflight failure.
+
+        Covered by existing tests.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/CrossOriginPreflightChecker.cpp: Added.
+        (WebCore::CrossOriginPreflightChecker::CrossOriginPreflightChecker):
+        (WebCore::CrossOriginPreflightChecker::~CrossOriginPreflightChecker):
+        (WebCore::CrossOriginPreflightChecker::handleLoadingFailure):
+        (WebCore::CrossOriginPreflightChecker::validatePreflightResponse):
+        (WebCore::CrossOriginPreflightChecker::notifyFinished):
+        (WebCore::CrossOriginPreflightChecker::startPreflight):
+        (WebCore::CrossOriginPreflightChecker::doPreflight):
+        (WebCore::CrossOriginPreflightChecker::redirectReceived):
+        (WebCore::CrossOriginPreflightChecker::setDefersLoading):
+        (WebCore::CrossOriginPreflightChecker::isXMLHttpRequest):
+        * loader/CrossOriginPreflightChecker.h: Added.
+        * loader/DocumentThreadableLoader.cpp:
+        (WebCore::DocumentThreadableLoader::create):
+        (WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequest):
+        (WebCore::DocumentThreadableLoader::makeCrossOriginAccessRequestWithPreflight):
+        (WebCore::DocumentThreadableLoader::setDefersLoading):
+        (WebCore::DocumentThreadableLoader::clearResource):
+        (WebCore::DocumentThreadableLoader::didReceiveResponse):
+        (WebCore::DocumentThreadableLoader::didReceiveData):
+        (WebCore::DocumentThreadableLoader::notifyFinished):
+        (WebCore::DocumentThreadableLoader::didFinishLoading):
+        (WebCore::DocumentThreadableLoader::didFail):
+        (WebCore::DocumentThreadableLoader::preflightSuccess):
+        (WebCore::DocumentThreadableLoader::preflightFailure):
+        (WebCore::DocumentThreadableLoader::loadRequest):
+        (WebCore::DocumentThreadableLoader::responseReceived): Deleted.
+        (WebCore::DocumentThreadableLoader::dataReceived): Deleted.
+        (WebCore::DocumentThreadableLoader::isAllowedByContentSecurityPolicy): Deleted.
+        * loader/DocumentThreadableLoader.h:
+        (WebCore::DocumentThreadableLoader::options):
+        (WebCore::DocumentThreadableLoader::isLoading):
+        (WebCore::DocumentThreadableLoader::document):
+
</ins><span class="cx"> 2016-06-10  Adam Bergkvist  &lt;adam.bergkvist@ericsson.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebRTC: Imlement MediaEndpointPeerConnection::createAnswer()
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (201923 => 201924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-10 12:58:12 UTC (rev 201923)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-10 13:26:30 UTC (rev 201924)
</span><span class="lines">@@ -1569,6 +1569,8 @@
</span><span class="cx">                 419BE7591BC7F42B00E1C85B /* WebCoreBuiltinNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 419BE7521BC7F3DB00E1C85B /* WebCoreBuiltinNames.h */; };
</span><span class="cx">                 41A3D58E101C152D00316D07 /* DedicatedWorkerThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41A3D58C101C152D00316D07 /* DedicatedWorkerThread.cpp */; };
</span><span class="cx">                 41A3D58F101C152D00316D07 /* DedicatedWorkerThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 41A3D58D101C152D00316D07 /* DedicatedWorkerThread.h */; };
</span><ins>+                41ABE67B1D0580DB006D862D /* CrossOriginPreflightChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 41ABE67A1D0580D5006D862D /* CrossOriginPreflightChecker.h */; };
+                41ABE67C1D0580E0006D862D /* CrossOriginPreflightChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41ABE6791D0580D5006D862D /* CrossOriginPreflightChecker.cpp */; };
</ins><span class="cx">                 41AD753A1CEF6BD100A31486 /* FetchOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 41AD75391CEF6BCE00A31486 /* FetchOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 41BF700C0FE86F49005E8DEC /* MessagePortChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 41BF700F0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41BF700D0FE86F61005E8DEC /* PlatformMessagePortChannel.cpp */; };
</span><span class="lines">@@ -9083,6 +9085,8 @@
</span><span class="cx">                 41A023ED1A39DB7900F722DF /* WritableStream.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WritableStream.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 41A3D58C101C152D00316D07 /* DedicatedWorkerThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DedicatedWorkerThread.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 41A3D58D101C152D00316D07 /* DedicatedWorkerThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DedicatedWorkerThread.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                41ABE6791D0580D5006D862D /* CrossOriginPreflightChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CrossOriginPreflightChecker.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                41ABE67A1D0580D5006D862D /* CrossOriginPreflightChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossOriginPreflightChecker.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 41AD75391CEF6BCE00A31486 /* FetchOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchOptions.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 41BF700A0FE86F49005E8DEC /* MessagePortChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessagePortChannel.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</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="lines">@@ -22760,6 +22764,8 @@
</span><span class="cx">                                 E1424C92164B52C800F32D40 /* CookieJar.h */,
</span><span class="cx">                                 E1C416160F6563180092D2FB /* CrossOriginAccessControl.cpp */,
</span><span class="cx">                                 E1C416110F6562FD0092D2FB /* CrossOriginAccessControl.h */,
</span><ins>+                                41ABE6791D0580D5006D862D /* CrossOriginPreflightChecker.cpp */,
+                                41ABE67A1D0580D5006D862D /* CrossOriginPreflightChecker.h */,
</ins><span class="cx">                                 E1C415DD0F655D7C0092D2FB /* CrossOriginPreflightResultCache.cpp */,
</span><span class="cx">                                 E1C415D90F655D6F0092D2FB /* CrossOriginPreflightResultCache.h */,
</span><span class="cx">                                 93E227DB0AF589AD00D48324 /* DocumentLoader.cpp */,
</span><span class="lines">@@ -25598,6 +25604,7 @@
</span><span class="cx">                                 5CD9F5681AA0F74600DA45FF /* DFABytecodeInterpreter.h in Headers */,
</span><span class="cx">                                 26A807851B18F97700E219BE /* DFACombiner.h in Headers */,
</span><span class="cx">                                 26A517FE1AB92238006335DF /* DFAMinimizer.h in Headers */,
</span><ins>+                                41ABE67B1D0580DB006D862D /* CrossOriginPreflightChecker.h in Headers */,
</ins><span class="cx">                                 267725FF1A5B3AD9003C24DD /* DFANode.h in Headers */,
</span><span class="cx">                                 CD19A2681A13E700008D650E /* DiagnosticLoggingClient.h in Headers */,
</span><span class="cx">                                 46FCB6181A70820E00C5A21E /* DiagnosticLoggingKeys.h in Headers */,
</span><span class="lines">@@ -29702,6 +29709,7 @@
</span><span class="cx">                                 15FCC9FC1B4DF7F200E72326 /* DOMURLMediaStream.cpp in Sources */,
</span><span class="cx">                                 BC1A37BF097C715F0019F3D8 /* DOMUtility.mm in Sources */,
</span><span class="cx">                                 15C770A5100D41CD005BA267 /* DOMValidityState.mm in Sources */,
</span><ins>+                                41ABE67C1D0580E0006D862D /* CrossOriginPreflightChecker.cpp in Sources */,
</ins><span class="cx">                                 31C0FF4A0E4CEFDD007D6FE5 /* DOMWebKitAnimationEvent.mm in Sources */,
</span><span class="cx">                                 3106037A143281CD00ABF4BA /* DOMWebKitCSSFilterValue.mm in Sources */,
</span><span class="cx">                                 498391510F1E76B400C23782 /* DOMWebKitCSSMatrix.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderCrossOriginPreflightCheckercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/loader/CrossOriginPreflightChecker.cpp (0 => 201924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/CrossOriginPreflightChecker.cpp                                (rev 0)
+++ trunk/Source/WebCore/loader/CrossOriginPreflightChecker.cpp        2016-06-10 13:26:30 UTC (rev 201924)
</span><span class="lines">@@ -0,0 +1,160 @@
</span><ins>+/*
+ * Copyright (C) 2016 Canon Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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;CrossOriginPreflightChecker.h&quot;
+
+#include &quot;CachedRawResource.h&quot;
+#include &quot;CachedResourceLoader.h&quot;
+#include &quot;CachedResourceRequest.h&quot;
+#include &quot;ContentSecurityPolicy.h&quot;
+#include &quot;CrossOriginAccessControl.h&quot;
+#include &quot;CrossOriginPreflightResultCache.h&quot;
+#include &quot;DocumentThreadableLoader.h&quot;
+#include &quot;InspectorInstrumentation.h&quot;
+#include &quot;RuntimeEnabledFeatures.h&quot;
+#include &quot;ThreadableLoaderClient.h&quot;
+
+namespace WebCore {
+
+CrossOriginPreflightChecker::CrossOriginPreflightChecker(DocumentThreadableLoader&amp; loader, ResourceRequest&amp;&amp; request)
+    : m_loader(loader)
+    , m_request(WTFMove(request))
+{
+}
+
+CrossOriginPreflightChecker::~CrossOriginPreflightChecker()
+{
+    if (m_resource)
+        m_resource-&gt;removeClient(this);
+}
+
+void CrossOriginPreflightChecker::handleLoadingFailure(DocumentThreadableLoader&amp; loader, unsigned long identifier, const ResourceError&amp; error)
+{
+    // FIXME: We might want to call preflightFailure instead.
+    Frame* frame = loader.document().frame();
+    ASSERT(frame);
+    InspectorInstrumentation::didFailLoading(frame, frame-&gt;loader().documentLoader(), identifier, error);
+    loader.didFail(identifier, error);
+}
+
+void CrossOriginPreflightChecker::validatePreflightResponse(DocumentThreadableLoader&amp; loader, ResourceRequest&amp;&amp; request, unsigned long identifier, const ResourceResponse&amp; response)
+{
+    Frame* frame = loader.document().frame();
+    ASSERT(frame);
+    auto cookie = InspectorInstrumentation::willReceiveResourceResponse(frame);
+    InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, frame-&gt;loader().documentLoader(), response, 0);
+
+    String description;
+    if (!passesAccessControlCheck(response, loader.options().allowCredentials(), loader.securityOrigin(), description)) {
+        loader.preflightFailure(identifier, ResourceError(errorDomainWebKitInternal, 0, response.url(), description));
+        return;
+    }
+
+    auto result = std::make_unique&lt;CrossOriginPreflightResultCacheItem&gt;(loader.options().allowCredentials());
+    if (!result-&gt;parse(response, description)
+        || !result-&gt;allowsCrossOriginMethod(request.httpMethod(), description)
+        || !result-&gt;allowsCrossOriginHeaders(request.httpHeaderFields(), description)) {
+        loader.preflightFailure(identifier, ResourceError(errorDomainWebKitInternal, 0, response.url(), description));
+        return;
+    }
+
+    CrossOriginPreflightResultCache::singleton().appendEntry(loader.securityOrigin()-&gt;toString(), request.url(), WTFMove(result));
+    loader.preflightSuccess(WTFMove(request));
+}
+
+void CrossOriginPreflightChecker::notifyFinished(CachedResource* resource)
+{
+    ASSERT_UNUSED(resource, resource == m_resource);
+    if (m_resource-&gt;loadFailedOrCanceled()) {
+        handleLoadingFailure(m_loader, m_resource-&gt;identifier(), m_resource-&gt;resourceError());
+        return;
+    }
+    validatePreflightResponse(m_loader, WTFMove(m_request), m_resource-&gt;identifier(), m_resource-&gt;response());
+}
+
+void CrossOriginPreflightChecker::startPreflight()
+{
+    auto options = m_loader.options();
+    options.setClientCredentialPolicy(DoNotAskClientForCrossOriginCredentials);
+    options.setSecurityCheck(DoSecurityCheck);
+    // Don't sniff content or send load callbacks for the preflight request.
+    options.setSendLoadCallbacks(DoNotSendCallbacks);
+    options.setSniffContent(DoNotSniffContent);
+    // Keep buffering the data for the preflight request.
+    options.setDataBufferingPolicy(BufferData);
+
+    CachedResourceRequest preflightRequest(createAccessControlPreflightRequest(m_request, m_loader.securityOrigin()), options);
+    if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled())
+        preflightRequest.setInitiator(m_loader.options().initiator);
+
+    ASSERT(!m_resource);
+    m_resource = m_loader.document().cachedResourceLoader().requestRawResource(preflightRequest);
+    if (m_resource)
+        m_resource-&gt;addClient(this);
+}
+
+void CrossOriginPreflightChecker::doPreflight(DocumentThreadableLoader&amp; loader, ResourceRequest&amp;&amp; request)
+{
+    if (!loader.document().frame())
+        return;
+
+    ResourceRequest preflightRequest = createAccessControlPreflightRequest(request, loader.securityOrigin());
+    ResourceError error;
+    ResourceResponse response;
+    RefPtr&lt;SharedBuffer&gt; data;
+    unsigned identifier = loader.document().frame()-&gt;loader().loadResourceSynchronously(preflightRequest, loader.options().allowCredentials(), loader.options().clientCredentialPolicy(), error, response, data);
+
+    if (!error.isNull() &amp;&amp; response.httpStatusCode() &lt;= 0) {
+        handleLoadingFailure(loader, identifier, error);
+        return;
+    }
+    validatePreflightResponse(loader, WTFMove(request), identifier, response);
+}
+
+void CrossOriginPreflightChecker::redirectReceived(CachedResource*, ResourceRequest&amp;, const ResourceResponse&amp;)
+{
+    // FIXME: We should call preflightFailure or set redirect mode to error.
+    ASSERT(m_loader.m_client);
+    m_loader.m_client-&gt;didFailRedirectCheck();
+}
+
+void CrossOriginPreflightChecker::setDefersLoading(bool value)
+{
+    if (m_resource)
+        m_resource-&gt;setDefersLoading(value);
+}
+
+bool CrossOriginPreflightChecker::isXMLHttpRequest() const
+{
+    return m_loader.isXMLHttpRequest();
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreloaderCrossOriginPreflightCheckerh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/loader/CrossOriginPreflightChecker.h (0 => 201924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/CrossOriginPreflightChecker.h                                (rev 0)
+++ trunk/Source/WebCore/loader/CrossOriginPreflightChecker.h        2016-06-10 13:26:30 UTC (rev 201924)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+/*
+ * Copyright (C) 2016, Canon Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT
+ * OWNER OR 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
+
+#include &quot;CachedRawResourceClient.h&quot;
+#include &quot;CachedResourceHandle.h&quot;
+#include &quot;ResourceRequest.h&quot;
+
+namespace WebCore {
+
+class CachedRawResource;
+class Document;
+class DocumentThreadableLoader;
+class ResourceError;
+
+class CrossOriginPreflightChecker final : private CachedRawResourceClient {
+public:
+    static void doPreflight(DocumentThreadableLoader&amp;, ResourceRequest&amp;&amp;);
+
+    CrossOriginPreflightChecker(DocumentThreadableLoader&amp;, ResourceRequest&amp;&amp;);
+    ~CrossOriginPreflightChecker();
+
+    void startPreflight();
+
+    void setDefersLoading(bool);
+
+private:
+    void notifyFinished(CachedResource*) final;
+    void redirectReceived(CachedResource*, ResourceRequest&amp;, const ResourceResponse&amp;) final;
+
+    static void handleLoadingFailure(DocumentThreadableLoader&amp;, unsigned long, const ResourceError&amp;);
+    static void validatePreflightResponse(DocumentThreadableLoader&amp;, ResourceRequest&amp;&amp;, unsigned long, const ResourceResponse&amp;);
+
+    bool isXMLHttpRequest() const final;
+
+    DocumentThreadableLoader&amp; m_loader;
+    CachedResourceHandle&lt;CachedRawResource&gt; m_resource;
+    ResourceRequest m_request;
+};
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentThreadableLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (201923 => 201924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp        2016-06-10 12:58:12 UTC (rev 201923)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp        2016-06-10 13:26:30 UTC (rev 201924)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #include &quot;CachedResourceRequestInitiators.h&quot;
</span><span class="cx"> #include &quot;ContentSecurityPolicy.h&quot;
</span><span class="cx"> #include &quot;CrossOriginAccessControl.h&quot;
</span><ins>+#include &quot;CrossOriginPreflightChecker.h&quot;
</ins><span class="cx"> #include &quot;CrossOriginPreflightResultCache.h&quot;
</span><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="lines">@@ -70,7 +71,7 @@
</span><span class="cx"> RefPtr&lt;DocumentThreadableLoader&gt; DocumentThreadableLoader::create(Document&amp; document, ThreadableLoaderClient&amp; client, const ResourceRequest&amp; request, const ThreadableLoaderOptions&amp; options, std::unique_ptr&lt;ContentSecurityPolicy&gt;&amp;&amp; contentSecurityPolicy)
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;DocumentThreadableLoader&gt; loader = adoptRef(new DocumentThreadableLoader(document, client, LoadAsynchronously, request, options, WTFMove(contentSecurityPolicy)));
</span><del>-    if (!loader-&gt;m_resource)
</del><ins>+    if (!loader-&gt;isLoading())
</ins><span class="cx">         loader = nullptr;
</span><span class="cx">     return loader;
</span><span class="cx"> }
</span><span class="lines">@@ -111,19 +112,17 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl);
</span><span class="cx"> 
</span><del>-    auto crossOriginRequest = std::make_unique&lt;ResourceRequest&gt;(request);
-    updateRequestForAccessControl(*crossOriginRequest, securityOrigin(), m_options.allowCredentials());
</del><ins>+    auto crossOriginRequest = request;
+    updateRequestForAccessControl(crossOriginRequest, securityOrigin(), m_options.allowCredentials());
</ins><span class="cx"> 
</span><del>-    if ((m_options.preflightPolicy == ConsiderPreflight &amp;&amp; isSimpleCrossOriginAccessRequest(crossOriginRequest-&gt;httpMethod(), crossOriginRequest-&gt;httpHeaderFields())) || m_options.preflightPolicy == PreventPreflight)
-        makeSimpleCrossOriginAccessRequest(*crossOriginRequest);
</del><ins>+    if ((m_options.preflightPolicy == ConsiderPreflight &amp;&amp; isSimpleCrossOriginAccessRequest(crossOriginRequest.httpMethod(), crossOriginRequest.httpHeaderFields())) || m_options.preflightPolicy == PreventPreflight)
+        makeSimpleCrossOriginAccessRequest(crossOriginRequest);
</ins><span class="cx">     else {
</span><span class="cx">         m_simpleRequest = false;
</span><del>-        m_actualRequest = WTFMove(crossOriginRequest);
-
-        if (CrossOriginPreflightResultCache::singleton().canSkipPreflight(securityOrigin()-&gt;toString(), m_actualRequest-&gt;url(), m_options.allowCredentials(), m_actualRequest-&gt;httpMethod(), m_actualRequest-&gt;httpHeaderFields()))
-            preflightSuccess();
</del><ins>+        if (CrossOriginPreflightResultCache::singleton().canSkipPreflight(securityOrigin()-&gt;toString(), crossOriginRequest.url(), m_options.allowCredentials(), crossOriginRequest.httpMethod(), crossOriginRequest.httpHeaderFields()))
+            preflightSuccess(WTFMove(crossOriginRequest));
</ins><span class="cx">         else
</span><del>-            makeCrossOriginAccessRequestWithPreflight(*m_actualRequest);
</del><ins>+            makeCrossOriginAccessRequestWithPreflight(WTFMove(crossOriginRequest));
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -141,10 +140,14 @@
</span><span class="cx">     loadRequest(request, DoSecurityCheck);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void DocumentThreadableLoader::makeCrossOriginAccessRequestWithPreflight(const ResourceRequest&amp; request)
</del><ins>+void DocumentThreadableLoader::makeCrossOriginAccessRequestWithPreflight(ResourceRequest&amp;&amp; request)
</ins><span class="cx"> {
</span><del>-    ResourceRequest preflightRequest = createAccessControlPreflightRequest(request, securityOrigin());
-    loadRequest(preflightRequest, DoSecurityCheck);
</del><ins>+    if (m_async) {
+        m_preflightChecker = CrossOriginPreflightChecker(*this, WTFMove(request));
+        m_preflightChecker-&gt;startPreflight();
+        return;
+    }
+    CrossOriginPreflightChecker::doPreflight(*this, WTFMove(request));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> DocumentThreadableLoader::~DocumentThreadableLoader()
</span><span class="lines">@@ -171,6 +174,8 @@
</span><span class="cx"> {
</span><span class="cx">     if (m_resource)
</span><span class="cx">         m_resource-&gt;setDefersLoading(value);
</span><ins>+    if (m_preflightChecker)
+        m_preflightChecker-&gt;setDefersLoading(value);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DocumentThreadableLoader::clearResource()
</span><span class="lines">@@ -183,6 +188,8 @@
</span><span class="cx">         m_resource = nullptr;
</span><span class="cx">         resource-&gt;removeClient(this);
</span><span class="cx">     }
</span><ins>+    if (m_preflightChecker)
+        m_preflightChecker = Nullopt;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DocumentThreadableLoader::redirectReceived(CachedResource* resource, ResourceRequest&amp; request, const ResourceResponse&amp; redirectResponse)
</span><span class="lines">@@ -260,36 +267,14 @@
</span><span class="cx">     ASSERT(m_client);
</span><span class="cx"> 
</span><span class="cx">     String accessControlErrorDescription;
</span><del>-    if (m_actualRequest) {
-        DocumentLoader* loader = m_document.frame()-&gt;loader().documentLoader();
-        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_document.frame());
-        InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, response, 0);
-
</del><ins>+    if (!m_sameOriginRequest &amp;&amp; m_options.crossOriginRequestPolicy == UseAccessControl) {
</ins><span class="cx">         if (!passesAccessControlCheck(response, m_options.allowCredentials(), securityOrigin(), accessControlErrorDescription)) {
</span><del>-            preflightFailure(identifier, response.url(), accessControlErrorDescription);
</del><ins>+            m_client-&gt;didFailAccessControlCheck(ResourceError(errorDomainWebKitInternal, 0, response.url(), accessControlErrorDescription));
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><del>-
-        StoredCredentials allowCredentials = m_options.allowCredentials();
-        auto preflightResult = std::make_unique&lt;CrossOriginPreflightResultCacheItem&gt;(allowCredentials);
-        if (!preflightResult-&gt;parse(response, accessControlErrorDescription)
-            || !preflightResult-&gt;allowsCrossOriginMethod(m_actualRequest-&gt;httpMethod(), accessControlErrorDescription)
-            || !preflightResult-&gt;allowsCrossOriginHeaders(m_actualRequest-&gt;httpHeaderFields(), accessControlErrorDescription)) {
-            preflightFailure(identifier, response.url(), accessControlErrorDescription);
-            return;
-        }
-
-        CrossOriginPreflightResultCache::singleton().appendEntry(securityOrigin()-&gt;toString(), m_actualRequest-&gt;url(), WTFMove(preflightResult));
-    } else {
-        if (!m_sameOriginRequest &amp;&amp; m_options.crossOriginRequestPolicy == UseAccessControl) {
-            if (!passesAccessControlCheck(response, m_options.allowCredentials(), securityOrigin(), accessControlErrorDescription)) {
-                m_client-&gt;didFailAccessControlCheck(ResourceError(errorDomainWebKitInternal, 0, response.url(), accessControlErrorDescription));
-                return;
-            }
-        }
-
-        m_client-&gt;didReceiveResponse(identifier, response);
</del><span class="cx">     }
</span><ins>+
+    m_client-&gt;didReceiveResponse(identifier, response);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void DocumentThreadableLoader::dataReceived(CachedResource* resource, const char* data, int dataLength)
</span><span class="lines">@@ -298,16 +283,10 @@
</span><span class="cx">     didReceiveData(m_resource-&gt;identifier(), data, dataLength);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void DocumentThreadableLoader::didReceiveData(unsigned long identifier, const char* data, int dataLength)
</del><ins>+void DocumentThreadableLoader::didReceiveData(unsigned long, const char* data, int dataLength)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(m_client);
</span><span class="cx"> 
</span><del>-    // Preflight data should be invisible to clients.
-    if (m_actualRequest) {
-        InspectorInstrumentation::didReceiveData(m_document.frame(), identifier, 0, 0, dataLength);
-        return;
-    }
-
</del><span class="cx">     m_client-&gt;didReceiveData(data, dataLength);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -315,7 +294,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_client);
</span><span class="cx">     ASSERT_UNUSED(resource, resource == m_resource);
</span><del>-        
</del><ins>+
</ins><span class="cx">     if (m_resource-&gt;errorOccurred())
</span><span class="cx">         didFail(m_resource-&gt;identifier(), m_resource-&gt;resourceError());
</span><span class="cx">     else
</span><span class="lines">@@ -324,44 +303,34 @@
</span><span class="cx"> 
</span><span class="cx"> void DocumentThreadableLoader::didFinishLoading(unsigned long identifier, double finishTime)
</span><span class="cx"> {
</span><del>-    if (m_actualRequest) {
-        InspectorInstrumentation::didFinishLoading(m_document.frame(), m_document.frame()-&gt;loader().documentLoader(), identifier, finishTime);
-
-        ASSERT(!m_sameOriginRequest);
-        ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl);
-        preflightSuccess();
-    } else
-        m_client-&gt;didFinishLoading(identifier, finishTime);
</del><ins>+    ASSERT(m_client);
+    m_client-&gt;didFinishLoading(identifier, finishTime);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void DocumentThreadableLoader::didFail(unsigned long identifier, const ResourceError&amp; error)
</del><ins>+void DocumentThreadableLoader::didFail(unsigned long, const ResourceError&amp; error)
</ins><span class="cx"> {
</span><del>-    if (m_actualRequest)
-        InspectorInstrumentation::didFailLoading(m_document.frame(), m_document.frame()-&gt;loader().documentLoader(), identifier, error);
-
</del><ins>+    ASSERT(m_client);
</ins><span class="cx">     m_client-&gt;didFail(error);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void DocumentThreadableLoader::preflightSuccess()
</del><ins>+void DocumentThreadableLoader::preflightSuccess(ResourceRequest&amp;&amp; request)
</ins><span class="cx"> {
</span><del>-    std::unique_ptr&lt;ResourceRequest&gt; actualRequest;
-    actualRequest.swap(m_actualRequest);
</del><ins>+    ResourceRequest actualRequest(WTFMove(request));
+    actualRequest.setHTTPOrigin(securityOrigin()-&gt;toString());
</ins><span class="cx"> 
</span><del>-    actualRequest-&gt;setHTTPOrigin(securityOrigin()-&gt;toString());
</del><ins>+    m_preflightChecker = Nullopt;
</ins><span class="cx"> 
</span><del>-    clearResource();
-
</del><span class="cx">     // It should be ok to skip the security check since we already asked about the preflight request.
</span><del>-    loadRequest(*actualRequest, SkipSecurityCheck);
</del><ins>+    loadRequest(actualRequest, SkipSecurityCheck);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void DocumentThreadableLoader::preflightFailure(unsigned long identifier, const URL&amp; url, const String&amp; errorDescription)
</del><ins>+void DocumentThreadableLoader::preflightFailure(unsigned long identifier, const ResourceError&amp; error)
</ins><span class="cx"> {
</span><del>-    ResourceError error(errorDomainWebKitInternal, 0, url, errorDescription);
-    if (m_actualRequest)
-        InspectorInstrumentation::didFailLoading(m_document.frame(), m_document.frame()-&gt;loader().documentLoader(), identifier, error);
</del><ins>+    m_preflightChecker = Nullopt;
</ins><span class="cx"> 
</span><del>-    m_actualRequest = nullptr; // Prevent didFinishLoading() from bypassing access check.
</del><ins>+    InspectorInstrumentation::didFailLoading(m_document.frame(), m_document.frame()-&gt;loader().documentLoader(), identifier, error);
+
+    ASSERT(m_client);
</ins><span class="cx">     m_client-&gt;didFailAccessControlCheck(error);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -376,13 +345,6 @@
</span><span class="cx">     if (m_async) {
</span><span class="cx">         ThreadableLoaderOptions options = m_options;
</span><span class="cx">         options.setClientCredentialPolicy(DoNotAskClientForCrossOriginCredentials);
</span><del>-        if (m_actualRequest) {
-            // Don't sniff content or send load callbacks for the preflight request.
-            options.setSendLoadCallbacks(DoNotSendCallbacks);
-            options.setSniffContent(DoNotSniffContent);
-            // Keep buffering the data for the preflight request.
-            options.setDataBufferingPolicy(BufferData);
-        }
</del><span class="cx"> 
</span><span class="cx">         CachedResourceRequest newRequest(request, options);
</span><span class="cx">         if (RuntimeEnabledFeatures::sharedFeatures().resourceTimingEnabled())
</span><span class="lines">@@ -394,7 +356,7 @@
</span><span class="cx"> 
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     // FIXME: ThreadableLoaderOptions.sniffContent is not supported for synchronous requests.
</span><span class="cx">     RefPtr&lt;SharedBuffer&gt; data;
</span><span class="cx">     ResourceError error;
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentThreadableLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.h (201923 => 201924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentThreadableLoader.h        2016-06-10 12:58:12 UTC (rev 201923)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.h        2016-06-10 13:26:30 UTC (rev 201924)
</span><span class="lines">@@ -31,16 +31,13 @@
</span><span class="cx"> #ifndef DocumentThreadableLoader_h
</span><span class="cx"> #define DocumentThreadableLoader_h
</span><span class="cx"> 
</span><del>-#include &quot;CachedRawResourceClient.h&quot;
-#include &quot;CachedResourceHandle.h&quot;
</del><ins>+#include &quot;CrossOriginPreflightChecker.h&quot;
</ins><span class="cx"> #include &quot;ThreadableLoader.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx">     class CachedRawResource;
</span><span class="cx">     class ContentSecurityPolicy;
</span><span class="cx">     class Document;
</span><del>-    class URL;
-    class ResourceRequest;
</del><span class="cx">     class SecurityOrigin;
</span><span class="cx">     class ThreadableLoaderClient;
</span><span class="cx"> 
</span><span class="lines">@@ -58,6 +55,8 @@
</span><span class="cx">         void cancel() override;
</span><span class="cx">         virtual void setDefersLoading(bool);
</span><span class="cx"> 
</span><ins>+        friend CrossOriginPreflightChecker;
+
</ins><span class="cx">         using RefCounted&lt;DocumentThreadableLoader&gt;::ref;
</span><span class="cx">         using RefCounted&lt;DocumentThreadableLoader&gt;::deref;
</span><span class="cx"> 
</span><span class="lines">@@ -87,10 +86,10 @@
</span><span class="cx">         void didFinishLoading(unsigned long identifier, double finishTime);
</span><span class="cx">         void didFail(unsigned long identifier, const ResourceError&amp;);
</span><span class="cx">         void makeCrossOriginAccessRequest(const ResourceRequest&amp;);
</span><del>-        void makeSimpleCrossOriginAccessRequest(const ResourceRequest&amp; request);
-        void makeCrossOriginAccessRequestWithPreflight(const ResourceRequest&amp; request);
-        void preflightSuccess();
-        void preflightFailure(unsigned long identifier, const URL&amp;, const String&amp; errorDescription);
</del><ins>+        void makeSimpleCrossOriginAccessRequest(const ResourceRequest&amp;);
+        void makeCrossOriginAccessRequestWithPreflight(ResourceRequest&amp;&amp;);
+        void preflightSuccess(ResourceRequest&amp;&amp;);
+        void preflightFailure(unsigned long identifier, const ResourceError&amp;);
</ins><span class="cx"> 
</span><span class="cx">         void loadRequest(const ResourceRequest&amp;, SecurityCheckPolicy);
</span><span class="cx">         bool isAllowedRedirect(const URL&amp;);
</span><span class="lines">@@ -101,6 +100,10 @@
</span><span class="cx">         SecurityOrigin* securityOrigin() const;
</span><span class="cx">         const ContentSecurityPolicy&amp; contentSecurityPolicy() const;
</span><span class="cx"> 
</span><ins>+        Document&amp; document() { return m_document; }
+        const ThreadableLoaderOptions&amp; options() const { return m_options; }
+        bool isLoading() { return m_resource || m_preflightChecker; }
+
</ins><span class="cx">         CachedResourceHandle&lt;CachedRawResource&gt; m_resource;
</span><span class="cx">         ThreadableLoaderClient* m_client;
</span><span class="cx">         Document&amp; m_document;
</span><span class="lines">@@ -108,8 +111,8 @@
</span><span class="cx">         bool m_sameOriginRequest;
</span><span class="cx">         bool m_simpleRequest;
</span><span class="cx">         bool m_async;
</span><del>-        std::unique_ptr&lt;ResourceRequest&gt; m_actualRequest; // non-null during Access Control preflight checks
</del><span class="cx">         std::unique_ptr&lt;ContentSecurityPolicy&gt; m_contentSecurityPolicy;
</span><ins>+        Optional&lt;CrossOriginPreflightChecker&gt; m_preflightChecker;
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre>
</div>
</div>

</body>
</html>