<!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>[175050] 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/175050">175050</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-10-22 08:12:08 -0700 (Wed, 22 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GStreamer] Do not use CachedResourceLoader, SecurityOrigin, ResourceBuffer and other WebCore types
https://bugs.webkit.org/show_bug.cgi?id=137064

Reviewed by Philippe Normand.

Source/WebCore:

Move the media resource loader to a new class in WebCore/loader
that inherits from a PlatformMediaResourceLoader class defined in
the platform layer. The platform specific behaviour is implemented
using a client also defined in the platform layer, implemented by
every media backend, and used by the WebCore MediaResourceLoader.

* CMakeLists.txt: Add new files to compilation.
* WebCore.vcxproj/WebCore.vcxproj: Ditto.
* WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerCreateResourceLoader):
Create a MediaResourceLoader.
(WebCore::HTMLMediaElement::mediaPlayerCORSMode): Deleted. This is
no longer used.
* html/HTMLMediaElement.h:
* loader/MediaResourceLoader.cpp: Added.
(WebCore::MediaResourceLoader::MediaResourceLoader):
(WebCore::MediaResourceLoader::~MediaResourceLoader):
(WebCore::MediaResourceLoader::start): Start a new load for the
given request and load options.
(WebCore::MediaResourceLoader::stop): Stop the load if needed.
(WebCore::MediaResourceLoader::setDefersLoading):
(WebCore::MediaResourceLoader::responseReceived): Handle CORS
access check and notify the client about the response.
(WebCore::MediaResourceLoader::dataReceived): Notify the client.
(WebCore::MediaResourceLoader::notifyFinished): Ditto.
(WebCore::MediaResourceLoader::getOrCreateReadBuffer): Ask the
client to create the read buffer.
* loader/MediaResourceLoader.h: Added.
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::createResourceLoader): Call
mediaPlayerCreateResourceLoader() if there's a client.
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerCreateResourceLoader):
(WebCore::MediaPlayerClient::mediaPlayerCORSMode): Deleted.
* platform/graphics/PlatformMediaResourceLoader.h: Added.
(WebCore::PlatformMediaResourceLoaderClient::responseReceived):
(WebCore::PlatformMediaResourceLoaderClient::dataReceived):
(WebCore::PlatformMediaResourceLoaderClient::bufferReceived):
(WebCore::PlatformMediaResourceLoaderClient::accessControlCheckFailed):
(WebCore::PlatformMediaResourceLoaderClient::loadFailed):
(WebCore::PlatformMediaResourceLoaderClient::loadFinished):
(WebCore::PlatformMediaResourceLoaderClient::getOrCreateReadBuffer):
(WebCore::PlatformMediaResourceLoader::~PlatformMediaResourceLoader):
(WebCore::PlatformMediaResourceLoader::stop):
(WebCore::PlatformMediaResourceLoader::setDefersLoading):
(WebCore::PlatformMediaResourceLoader::didPassAccessControlCheck):
(WebCore::PlatformMediaResourceLoader::PlatformMediaResourceLoader):
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(webKitWebSrcStop): Also delete the PlatformMediaResourceLoader.
(webKitWebSrcStart): Create a new resource loader using
MediaPlayer::createResourceLoader() with a new
CachedResourceStreamingClient as client.
(webKitWebSrcNeedDataMainCb): Call setDefersLoading() for the
resource loader if there's one.
(webKitWebSrcEnoughDataMainCb): Ditto.
(webKitSrcPassedCORSAccessCheck): Return didPassAccessControlCheck.
(StreamingClient::handleResponseReceived): Remove the CORS check
result parameter since that's now handled by MediaResourceLoader.
(CachedResourceStreamingClient::CachedResourceStreamingClient):
(CachedResourceStreamingClient::~CachedResourceStreamingClient):
(CachedResourceStreamingClient::getOrCreateReadBuffer):
(CachedResourceStreamingClient::responseReceived): Update didPassAccessControlCheck.
(CachedResourceStreamingClient::dataReceived):
(CachedResourceStreamingClient::accessControlCheckFailed): Log the
error and stop the load.
(CachedResourceStreamingClient::loadFailed): Log the error if it
was not a cancellation.
(CachedResourceStreamingClient::loadFinished):
(ResourceHandleStreamingClient::didReceiveResponse):
(CachedResourceStreamingClient::setDefersLoading): Deleted.
(CachedResourceStreamingClient::notifyFinished): Deleted.

LayoutTests:

Update expected results of http/tests/security/video-cross-origin-accessfailure.html, since
now the error is also logged in the console.

* http/tests/security/video-cross-origin-accessfailure-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityvideocrossoriginaccessfailureexpectedtxt">trunk/LayoutTests/http/tests/security/video-cross-origin-accessfailure-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="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementh">trunk/Source/WebCore/html/HTMLMediaElement.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMediaPlayercpp">trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMediaPlayerh">trunk/Source/WebCore/platform/graphics/MediaPlayer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerWebKitWebSourceGStreamercpp">trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreloaderMediaResourceLoadercpp">trunk/Source/WebCore/loader/MediaResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderMediaResourceLoaderh">trunk/Source/WebCore/loader/MediaResourceLoader.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsPlatformMediaResourceLoaderh">trunk/Source/WebCore/platform/graphics/PlatformMediaResourceLoader.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/LayoutTests/ChangeLog        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-10-22  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GStreamer] Do not use CachedResourceLoader, SecurityOrigin, ResourceBuffer and other WebCore types
+        https://bugs.webkit.org/show_bug.cgi?id=137064
+
+        Reviewed by Philippe Normand.
+
+        Update expected results of http/tests/security/video-cross-origin-accessfailure.html, since
+        now the error is also logged in the console.
+
+        * http/tests/security/video-cross-origin-accessfailure-expected.txt:
+
</ins><span class="cx"> 2014-10-22  Tibor Meszaros  &lt;tmeszaros.u-szeged@partner.samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Match spec for font-weight: bolder|lighter
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityvideocrossoriginaccessfailureexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/video-cross-origin-accessfailure-expected.txt (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/video-cross-origin-accessfailure-expected.txt        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/LayoutTests/http/tests/security/video-cross-origin-accessfailure-expected.txt        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><ins>+CONSOLE MESSAGE: Cross-origin media resource load denied by Cross-Origin Resource Sharing policy.
</ins><span class="cx"> EVENT(error)
</span><span class="cx"> END OF TEST
</span><span class="cx">  
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/Source/WebCore/CMakeLists.txt        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -1807,6 +1807,7 @@
</span><span class="cx">     loader/ImageLoader.cpp
</span><span class="cx">     loader/LinkLoader.cpp
</span><span class="cx">     loader/LoaderStrategy.cpp
</span><ins>+    loader/MediaResourceLoader.cpp
</ins><span class="cx">     loader/MixedContentChecker.cpp
</span><span class="cx">     loader/NavigationAction.cpp
</span><span class="cx">     loader/NavigationScheduler.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/Source/WebCore/ChangeLog        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -1,5 +1,86 @@
</span><span class="cx"> 2014-10-22  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><ins>+        [GStreamer] Do not use CachedResourceLoader, SecurityOrigin, ResourceBuffer and other WebCore types
+        https://bugs.webkit.org/show_bug.cgi?id=137064
+
+        Reviewed by Philippe Normand.
+
+        Move the media resource loader to a new class in WebCore/loader
+        that inherits from a PlatformMediaResourceLoader class defined in
+        the platform layer. The platform specific behaviour is implemented
+        using a client also defined in the platform layer, implemented by
+        every media backend, and used by the WebCore MediaResourceLoader.
+
+        * CMakeLists.txt: Add new files to compilation.
+        * WebCore.vcxproj/WebCore.vcxproj: Ditto.
+        * WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaPlayerCreateResourceLoader):
+        Create a MediaResourceLoader.
+        (WebCore::HTMLMediaElement::mediaPlayerCORSMode): Deleted. This is
+        no longer used.
+        * html/HTMLMediaElement.h:
+        * loader/MediaResourceLoader.cpp: Added.
+        (WebCore::MediaResourceLoader::MediaResourceLoader):
+        (WebCore::MediaResourceLoader::~MediaResourceLoader):
+        (WebCore::MediaResourceLoader::start): Start a new load for the
+        given request and load options.
+        (WebCore::MediaResourceLoader::stop): Stop the load if needed.
+        (WebCore::MediaResourceLoader::setDefersLoading):
+        (WebCore::MediaResourceLoader::responseReceived): Handle CORS
+        access check and notify the client about the response.
+        (WebCore::MediaResourceLoader::dataReceived): Notify the client.
+        (WebCore::MediaResourceLoader::notifyFinished): Ditto.
+        (WebCore::MediaResourceLoader::getOrCreateReadBuffer): Ask the
+        client to create the read buffer.
+        * loader/MediaResourceLoader.h: Added.
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::createResourceLoader): Call
+        mediaPlayerCreateResourceLoader() if there's a client.
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::mediaPlayerCreateResourceLoader):
+        (WebCore::MediaPlayerClient::mediaPlayerCORSMode): Deleted.
+        * platform/graphics/PlatformMediaResourceLoader.h: Added.
+        (WebCore::PlatformMediaResourceLoaderClient::responseReceived):
+        (WebCore::PlatformMediaResourceLoaderClient::dataReceived):
+        (WebCore::PlatformMediaResourceLoaderClient::bufferReceived):
+        (WebCore::PlatformMediaResourceLoaderClient::accessControlCheckFailed):
+        (WebCore::PlatformMediaResourceLoaderClient::loadFailed):
+        (WebCore::PlatformMediaResourceLoaderClient::loadFinished):
+        (WebCore::PlatformMediaResourceLoaderClient::getOrCreateReadBuffer):
+        (WebCore::PlatformMediaResourceLoader::~PlatformMediaResourceLoader):
+        (WebCore::PlatformMediaResourceLoader::stop):
+        (WebCore::PlatformMediaResourceLoader::setDefersLoading):
+        (WebCore::PlatformMediaResourceLoader::didPassAccessControlCheck):
+        (WebCore::PlatformMediaResourceLoader::PlatformMediaResourceLoader):
+        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+        (webKitWebSrcStop): Also delete the PlatformMediaResourceLoader.
+        (webKitWebSrcStart): Create a new resource loader using
+        MediaPlayer::createResourceLoader() with a new
+        CachedResourceStreamingClient as client.
+        (webKitWebSrcNeedDataMainCb): Call setDefersLoading() for the
+        resource loader if there's one.
+        (webKitWebSrcEnoughDataMainCb): Ditto.
+        (webKitSrcPassedCORSAccessCheck): Return didPassAccessControlCheck.
+        (StreamingClient::handleResponseReceived): Remove the CORS check
+        result parameter since that's now handled by MediaResourceLoader.
+        (CachedResourceStreamingClient::CachedResourceStreamingClient):
+        (CachedResourceStreamingClient::~CachedResourceStreamingClient):
+        (CachedResourceStreamingClient::getOrCreateReadBuffer):
+        (CachedResourceStreamingClient::responseReceived): Update didPassAccessControlCheck.
+        (CachedResourceStreamingClient::dataReceived):
+        (CachedResourceStreamingClient::accessControlCheckFailed): Log the
+        error and stop the load.
+        (CachedResourceStreamingClient::loadFailed): Log the error if it
+        was not a cancellation.
+        (CachedResourceStreamingClient::loadFinished):
+        (ResourceHandleStreamingClient::didReceiveResponse):
+        (CachedResourceStreamingClient::setDefersLoading): Deleted.
+        (CachedResourceStreamingClient::notifyFinished): Deleted.
+
+2014-10-22  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
</ins><span class="cx">         [GTK] Move GtkInputMethodFilter from Platform to WebKit2
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=137884
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -7241,6 +7241,7 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\loader\ImageLoader.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\loader\LinkLoader.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\loader\LoaderStrategy.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\loader\MediaResourceLoader.cpp&quot; /&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\loader\MixedContentChecker.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\loader\NavigationAction.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\loader\NavigationScheduler.cpp&quot; /&gt;
</span><span class="lines">@@ -19241,6 +19242,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\loader\LinkLoader.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\loader\LinkLoaderClient.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\loader\LoaderStrategy.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\loader\MediaResourceLoader.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\loader\MixedContentChecker.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\loader\NavigationAction.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\loader\NavigationScheduler.h&quot; /&gt;
</span><span class="lines">@@ -19585,6 +19587,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\PathTraversalState.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\Pattern.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\PlatformLayer.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\platform\graphics\PlatformMediaResourceLoader.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\PlatformTimeRanges.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\Region.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\RoundedRect.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -900,6 +900,9 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\loader\LoaderStrategy.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;loader&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\loader\MediaResourceLoader.cpp&quot;&gt;
+      &lt;Filter&gt;loader&lt;/Filter&gt;
+    &lt;/ClCompile&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\loader\MixedContentChecker.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;loader&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><span class="lines">@@ -7914,6 +7917,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\loader\LoaderStrategy.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;loader&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\loader\MediaResourceLoader.h&quot;&gt;
+      &lt;Filter&gt;loader&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\loader\MixedContentChecker.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;loader&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><span class="lines">@@ -8526,6 +8532,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\PlatformLayer.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;platform\graphics&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\platform\graphics\PlatformMediaResourceLoader.h&quot;&gt;
+      &lt;Filter&gt;platform\graphics&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\platform\graphics\PlatformTimeRanges.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;platform\graphics&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -5759,6 +5759,9 @@
</span><span class="cx">                 CECADFCE1537791D00E37068 /* TextInsertionBaseCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = CECADFCC1537791D00E37068 /* TextInsertionBaseCommand.h */; };
</span><span class="cx">                 CECCFC3B141973D5002A0AC1 /* DecodeEscapeSequences.h in Headers */ = {isa = PBXBuildFile; fileRef = CECCFC3A141973D5002A0AC1 /* DecodeEscapeSequences.h */; };
</span><span class="cx">                 CEDA12D7152CA1CB00D9E08D /* AlternativeTextClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CEDA12D6152CA1CB00D9E08D /* AlternativeTextClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                CEEFCD7919DB31F7003876D7 /* MediaResourceLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEEFCD7719DB31F7003876D7 /* MediaResourceLoader.cpp */; };
+                CEEFCD7A19DB31F7003876D7 /* MediaResourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = CEEFCD7819DB31F7003876D7 /* MediaResourceLoader.h */; };
+                CEEFCD7C19DB33DC003876D7 /* PlatformMediaResourceLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = CEEFCD7B19DB33DC003876D7 /* PlatformMediaResourceLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 CEF418CE1179678C009D112C /* ViewportArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEF418CC1179678C009D112C /* ViewportArguments.cpp */; };
</span><span class="cx">                 CEF418CF1179678C009D112C /* ViewportArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = CEF418CD1179678C009D112C /* ViewportArguments.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 D000EBA211BDAFD400C47726 /* FrameLoaderStateMachine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D000EBA011BDAFD400C47726 /* FrameLoaderStateMachine.cpp */; };
</span><span class="lines">@@ -13234,6 +13237,9 @@
</span><span class="cx">                 CECCFC3A141973D5002A0AC1 /* DecodeEscapeSequences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecodeEscapeSequences.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CEDA12D6152CA1CB00D9E08D /* AlternativeTextClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlternativeTextClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CEEC6034187DD962003E43BB /* TextTrackRepresentationIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextTrackRepresentationIOS.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                CEEFCD7719DB31F7003876D7 /* MediaResourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaResourceLoader.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CEEFCD7819DB31F7003876D7 /* MediaResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaResourceLoader.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CEEFCD7B19DB33DC003876D7 /* PlatformMediaResourceLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformMediaResourceLoader.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 CEF418CC1179678C009D112C /* ViewportArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ViewportArguments.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CEF418CD1179678C009D112C /* ViewportArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewportArguments.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 D000EBA011BDAFD400C47726 /* FrameLoaderStateMachine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameLoaderStateMachine.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -20494,6 +20500,7 @@
</span><span class="cx">                                 A8FA6E5C0E4CFDED00D5CF49 /* Pattern.cpp */,
</span><span class="cx">                                 A8FA6E5B0E4CFDED00D5CF49 /* Pattern.h */,
</span><span class="cx">                                 0562F9601573F88F0031CA16 /* PlatformLayer.h */,
</span><ins>+                                CEEFCD7B19DB33DC003876D7 /* PlatformMediaResourceLoader.h */,
</ins><span class="cx">                                 072847E216EBC5B00043CFA4 /* PlatformTextTrack.h */,
</span><span class="cx">                                 072847E316EBC5B00043CFA4 /* PlatformTextTrackMenu.h */,
</span><span class="cx">                                 074E82B818A69F0E007EF54C /* PlatformTimeRanges.cpp */,
</span><span class="lines">@@ -21179,6 +21186,8 @@
</span><span class="cx">                                 984264EF12D5280A000D88A4 /* LinkLoaderClient.h */,
</span><span class="cx">                                 51ABF64C16392E2800132A7A /* LoaderStrategy.cpp */,
</span><span class="cx">                                 51E6820F16387302003BBF3C /* LoaderStrategy.h */,
</span><ins>+                                CEEFCD7719DB31F7003876D7 /* MediaResourceLoader.cpp */,
+                                CEEFCD7819DB31F7003876D7 /* MediaResourceLoader.h */,
</ins><span class="cx">                                 52F10862162B6D82009AC81E /* MixedContentChecker.cpp */,
</span><span class="cx">                                 52F10863162B6D82009AC81E /* MixedContentChecker.h */,
</span><span class="cx">                                 93CCF05F0AF6CA7600018E89 /* NavigationAction.cpp */,
</span><span class="lines">@@ -25307,6 +25316,7 @@
</span><span class="cx">                                 D3A94A39122DABAC00A37BBC /* MediaQueryList.h in Headers */,
</span><span class="cx">                                 D3A94A3B122DABAC00A37BBC /* MediaQueryListListener.h in Headers */,
</span><span class="cx">                                 D3AA10F4123A98AA0092152B /* MediaQueryMatcher.h in Headers */,
</span><ins>+                                CEEFCD7A19DB31F7003876D7 /* MediaResourceLoader.h in Headers */,
</ins><span class="cx">                                 070E09191875EEFC003A1D3C /* MediaSession.h in Headers */,
</span><span class="cx">                                 07F944161864D046005D31CB /* MediaSessionManager.h in Headers */,
</span><span class="cx">                                 07638A991884487200E15A1B /* MediaSessionManagerIOS.h in Headers */,
</span><span class="lines">@@ -25506,6 +25516,7 @@
</span><span class="cx">                                 935C476809AC4D4300A6AAB4 /* PlatformKeyboardEvent.h in Headers */,
</span><span class="cx">                                 0562F9611573F88F0031CA16 /* PlatformLayer.h in Headers */,
</span><span class="cx">                                 F544F78915CFB2A800AF33A8 /* PlatformLocale.h in Headers */,
</span><ins>+                                CEEFCD7C19DB33DC003876D7 /* PlatformMediaResourceLoader.h in Headers */,
</ins><span class="cx">                                 932871C00B20DEB70049035A /* PlatformMenuDescription.h in Headers */,
</span><span class="cx">                                 41BF70100FE86F61005E8DEC /* PlatformMessagePortChannel.h in Headers */,
</span><span class="cx">                                 935C476909AC4D4300A6AAB4 /* PlatformMouseEvent.h in Headers */,
</span><span class="lines">@@ -28855,6 +28866,7 @@
</span><span class="cx">                                 4E19592D0A39DACC00220FE5 /* MediaQueryExp.cpp in Sources */,
</span><span class="cx">                                 D3A94A38122DABAC00A37BBC /* MediaQueryList.cpp in Sources */,
</span><span class="cx">                                 D3AA10F3123A98AA0092152B /* MediaQueryMatcher.cpp in Sources */,
</span><ins>+                                CEEFCD7919DB31F7003876D7 /* MediaResourceLoader.cpp in Sources */,
</ins><span class="cx">                                 070E091B1875EF71003A1D3C /* MediaSession.cpp in Sources */,
</span><span class="cx">                                 CDAE8C091746B95700532D78 /* MediaSessionManager.cpp in Sources */,
</span><span class="cx">                                 07638A9A1884487200E15A1B /* MediaSessionManagerIOS.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -62,6 +62,7 @@
</span><span class="cx"> #include &quot;MediaKeyEvent.h&quot;
</span><span class="cx"> #include &quot;MediaList.h&quot;
</span><span class="cx"> #include &quot;MediaQueryEvaluator.h&quot;
</span><ins>+#include &quot;MediaResourceLoader.h&quot;
</ins><span class="cx"> #include &quot;MediaSessionManager.h&quot;
</span><span class="cx"> #include &quot;NetworkingContext.h&quot;
</span><span class="cx"> #include &quot;PageActivityAssertionToken.h&quot;
</span><span class="lines">@@ -5585,15 +5586,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-MediaPlayerClient::CORSMode HTMLMediaElement::mediaPlayerCORSMode() const
-{
-    if (!fastHasAttribute(HTMLNames::crossoriginAttr))
-        return Unspecified;
-    if (equalIgnoringCase(fastGetAttribute(HTMLNames::crossoriginAttr), &quot;use-credentials&quot;))
-        return UseCredentials;
-    return Anonymous;
-}
-
</del><span class="cx"> bool HTMLMediaElement::mediaPlayerNeedsSiteSpecificHacks() const
</span><span class="cx"> {
</span><span class="cx">     Settings* settings = document().settings();
</span><span class="lines">@@ -5673,6 +5665,11 @@
</span><span class="cx">     return document().cachedResourceLoader();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+PassRefPtr&lt;PlatformMediaResourceLoader&gt; HTMLMediaElement::mediaPlayerCreateResourceLoader(std::unique_ptr&lt;PlatformMediaResourceLoaderClient&gt; client)
+{
+    return adoptRef(new MediaResourceLoader(document(), fastGetAttribute(HTMLNames::crossoriginAttr), WTF::move(client)));
+}
+
</ins><span class="cx"> bool HTMLMediaElement::mediaPlayerShouldWaitForResponseToAuthenticationChallenge(const AuthenticationChallenge&amp; challenge)
</span><span class="cx"> {
</span><span class="cx">     Frame* frame = document().frame();
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.h        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -552,7 +552,6 @@
</span><span class="cx"> 
</span><span class="cx">     virtual String mediaPlayerReferrer() const override;
</span><span class="cx">     virtual String mediaPlayerUserAgent() const override;
</span><del>-    virtual CORSMode mediaPlayerCORSMode() const override;
</del><span class="cx"> 
</span><span class="cx">     virtual bool mediaPlayerNeedsSiteSpecificHacks() const override;
</span><span class="cx">     virtual String mediaPlayerDocumentHost() const override;
</span><span class="lines">@@ -570,6 +569,7 @@
</span><span class="cx">     virtual bool mediaPlayerIsPaused() const override;
</span><span class="cx">     virtual bool mediaPlayerIsLooping() const override;
</span><span class="cx">     virtual CachedResourceLoader* mediaPlayerCachedResourceLoader() override;
</span><ins>+    virtual PassRefPtr&lt;PlatformMediaResourceLoader&gt; mediaPlayerCreateResourceLoader(std::unique_ptr&lt;PlatformMediaResourceLoaderClient&gt;);
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(WIN) &amp;&amp; USE(AVFOUNDATION)
</span><span class="cx">     virtual GraphicsDeviceAdapter* mediaPlayerGraphicsDeviceAdapter(const MediaPlayer*) const override;
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderMediaResourceLoadercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/loader/MediaResourceLoader.cpp (0 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/MediaResourceLoader.cpp                                (rev 0)
+++ trunk/Source/WebCore/loader/MediaResourceLoader.cpp        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -0,0 +1,146 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;MediaResourceLoader.h&quot;
+
+#if ENABLE(VIDEO)
+#include &quot;CachedRawResource.h&quot;
+#include &quot;CachedResourceLoader.h&quot;
+#include &quot;CachedResourceRequest.h&quot;
+#include &quot;CrossOriginAccessControl.h&quot;
+#include &quot;Document.h&quot;
+#include &quot;ResourceBuffer.h&quot;
+#include &quot;SecurityOrigin.h&quot;
+#include &lt;wtf/NeverDestroyed.h&gt;
+
+namespace WebCore {
+
+MediaResourceLoader::MediaResourceLoader(Document&amp; document, const String&amp; crossOriginMode, std::unique_ptr&lt;PlatformMediaResourceLoaderClient&gt; client)
+    : PlatformMediaResourceLoader(WTF::move(client))
+    , m_document(document)
+    , m_crossOriginMode(crossOriginMode)
+    , m_didPassAccessControlCheck(false)
+{
+}
+
+MediaResourceLoader::~MediaResourceLoader()
+{
+    stop();
+}
+
+bool MediaResourceLoader::start(const ResourceRequest&amp; request, LoadOptions options)
+{
+    if (m_resource)
+        return false;
+
+    DataBufferingPolicy bufferingPolicy = options &amp; LoadOption::BufferData ? WebCore::BufferData : WebCore::DoNotBufferData;
+    RequestOriginPolicy corsPolicy = !m_crossOriginMode.isNull() ? PotentiallyCrossOriginEnabled : UseDefaultOriginRestrictionsForType;
+    StoredCredentials allowCredentials = m_crossOriginMode.isNull() || equalIgnoringCase(m_crossOriginMode, &quot;use-credentials&quot;) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
+    CachedResourceRequest cacheRequest(request, ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, bufferingPolicy, allowCredentials, DoNotAskClientForCrossOriginCredentials, DoSecurityCheck, corsPolicy, DoNotIncludeCertificateInfo));
+
+    if (!m_crossOriginMode.isNull())
+        updateRequestForAccessControl(cacheRequest.mutableResourceRequest(), m_document.securityOrigin(), allowCredentials);
+
+    m_didPassAccessControlCheck = false;
+
+    CachedResourceLoader* loader = m_document.cachedResourceLoader();
+    m_resource = loader ? loader-&gt;requestRawResource(cacheRequest) : nullptr;
+    if (!m_resource)
+        return false;
+
+    m_resource-&gt;addClient(this);
+    return true;
+}
+
+void MediaResourceLoader::stop()
+{
+    if (!m_resource)
+        return;
+
+    m_resource-&gt;removeClient(this);
+    m_resource = nullptr;
+}
+
+void MediaResourceLoader::setDefersLoading(bool defersLoading)
+{
+    if (m_resource)
+        m_resource-&gt;setDefersLoading(defersLoading);
+}
+
+void MediaResourceLoader::responseReceived(CachedResource* resource, const ResourceResponse&amp; response)
+{
+    ASSERT_UNUSED(resource, resource == m_resource);
+
+    RefPtr&lt;MediaResourceLoader&gt; protect(this);
+    if (!m_crossOriginMode.isNull()
+        &amp;&amp; !m_document.securityOrigin()-&gt;canRequest(resource-&gt;response().url())
+        &amp;&amp; !resource-&gt;passesAccessControlCheck(m_document.securityOrigin())) {
+        static NeverDestroyed&lt;const String&gt; consoleMessage(&quot;Cross-origin media resource load denied by Cross-Origin Resource Sharing policy.&quot;);
+        m_document.addConsoleMessage(MessageSource::Security, MessageLevel::Error, consoleMessage.get());
+        m_didPassAccessControlCheck = false;
+        m_client-&gt;accessControlCheckFailed(ResourceError(errorDomainWebKitInternal, 0, response.url().string(), consoleMessage.get()));
+        stop();
+        return;
+    }
+
+    m_didPassAccessControlCheck = !m_crossOriginMode.isNull();
+    m_client-&gt;responseReceived(response);
+}
+
+void MediaResourceLoader::dataReceived(CachedResource* resource, const char* data, int dataLength)
+{
+    ASSERT(resource == m_resource);
+
+    RefPtr&lt;MediaResourceLoader&gt; protect(this);
+    m_client-&gt;dataReceived(data, dataLength);
+
+    if (SharedBuffer* buffer = resource-&gt;resourceBuffer() ? resource-&gt;resourceBuffer()-&gt;sharedBuffer() : nullptr)
+        m_client-&gt;bufferReceived(buffer);
+}
+
+void MediaResourceLoader::notifyFinished(CachedResource* resource)
+{
+    ASSERT(resource == m_resource);
+
+    RefPtr&lt;MediaResourceLoader&gt; protect(this);
+    if (resource-&gt;loadFailedOrCanceled())
+        m_client-&gt;loadFailed(resource-&gt;resourceError());
+    else
+        m_client-&gt;loadFinished(resource-&gt;resourceBuffer() ? resource-&gt;resourceBuffer()-&gt;sharedBuffer() : nullptr);
+    stop();
+}
+
+#if USE(SOUP)
+char* MediaResourceLoader::getOrCreateReadBuffer(CachedResource* resource, size_t requestedSize, size_t&amp; actualSize)
+{
+    ASSERT_UNUSED(resource, resource == m_resource);
+    return m_client-&gt;getOrCreateReadBuffer(requestedSize, actualSize);
+}
+#endif
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreloaderMediaResourceLoaderh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/loader/MediaResourceLoader.h (0 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/MediaResourceLoader.h                                (rev 0)
+++ trunk/Source/WebCore/loader/MediaResourceLoader.h        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE 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 APPLE INC. OR 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 MediaResourceLoader_h
+#define MediaResourceLoader_h
+
+#if ENABLE(VIDEO)
+#include &quot;CachedRawResourceClient.h&quot;
+#include &quot;CachedResourceHandle.h&quot;
+#include &quot;PlatformMediaResourceLoader.h&quot;
+#include &lt;wtf/text/WTFString.h&gt;
+
+namespace WebCore {
+
+class CachedRawResource;
+class Document;
+
+class MediaResourceLoader final : public PlatformMediaResourceLoader, CachedRawResourceClient {
+public:
+    MediaResourceLoader(Document&amp;, const String&amp; crossOriginMode, std::unique_ptr&lt;PlatformMediaResourceLoaderClient&gt;);
+    virtual ~MediaResourceLoader();
+
+    virtual bool start(const ResourceRequest&amp;, LoadOptions) override;
+    virtual void stop() override;
+    virtual void setDefersLoading(bool) override;
+    virtual bool didPassAccessControlCheck() const override { return m_didPassAccessControlCheck; }
+
+    // CachedResourceClient
+    virtual void responseReceived(CachedResource*, const ResourceResponse&amp;) override;
+    virtual void dataReceived(CachedResource*, const char*, int) override;
+    virtual void notifyFinished(CachedResource*) override;
+#if USE(SOUP)
+    virtual char* getOrCreateReadBuffer(CachedResource*, size_t /*requestedSize*/, size_t&amp; /*actualSize*/) override;
+#endif
+
+private:
+    Document&amp; m_document;
+    String m_crossOriginMode;
+    bool m_didPassAccessControlCheck;
+    CachedResourceHandle&lt;CachedRawResource&gt; m_resource;
+};
+
+
+} // namespace WebCore
+
+#endif
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMediaPlayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -1153,6 +1153,11 @@
</span><span class="cx">     return m_client.mediaPlayerCachedResourceLoader();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+PassRefPtr&lt;PlatformMediaResourceLoader&gt; MediaPlayer::createResourceLoader(std::unique_ptr&lt;PlatformMediaResourceLoaderClient&gt; client)
+{
+    return m_client.mediaPlayerCreateResourceLoader(WTF::move(client));
+}
+
</ins><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx"> void MediaPlayer::addAudioTrack(PassRefPtr&lt;AudioTrackPrivate&gt; track)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMediaPlayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> #include &quot;MediaSession.h&quot;
</span><span class="cx"> #include &quot;NativeImagePtr.h&quot;
</span><span class="cx"> #include &quot;PlatformLayer.h&quot;
</span><ins>+#include &quot;PlatformMediaResourceLoader.h&quot;
</ins><span class="cx"> #include &quot;Timer.h&quot;
</span><span class="cx"> #include &quot;VideoTrackPrivate.h&quot;
</span><span class="cx"> #include &lt;runtime/Uint8Array.h&gt;
</span><span class="lines">@@ -143,8 +144,6 @@
</span><span class="cx"> 
</span><span class="cx"> class MediaPlayerClient {
</span><span class="cx"> public:
</span><del>-    enum CORSMode { Unspecified, Anonymous, UseCredentials };
-
</del><span class="cx">     virtual ~MediaPlayerClient() { }
</span><span class="cx"> 
</span><span class="cx">     // the network state has changed
</span><span class="lines">@@ -224,7 +223,6 @@
</span><span class="cx"> 
</span><span class="cx">     virtual String mediaPlayerReferrer() const { return String(); }
</span><span class="cx">     virtual String mediaPlayerUserAgent() const { return String(); }
</span><del>-    virtual CORSMode mediaPlayerCORSMode() const { return Unspecified; }
</del><span class="cx">     virtual void mediaPlayerEnterFullscreen() { }
</span><span class="cx">     virtual void mediaPlayerExitFullscreen() { }
</span><span class="cx">     virtual bool mediaPlayerIsFullscreen() const { return false; }
</span><span class="lines">@@ -238,6 +236,7 @@
</span><span class="cx">     virtual bool mediaPlayerIsPaused() const { return true; }
</span><span class="cx">     virtual bool mediaPlayerIsLooping() const { return false; }
</span><span class="cx">     virtual CachedResourceLoader* mediaPlayerCachedResourceLoader() { return 0; }
</span><ins>+    virtual PassRefPtr&lt;PlatformMediaResourceLoader&gt; mediaPlayerCreateResourceLoader(std::unique_ptr&lt;PlatformMediaResourceLoaderClient&gt;) { return nullptr; }
</ins><span class="cx">     virtual bool doesHaveAttribute(const AtomicString&amp;, AtomicString* = 0) const { return false; }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="lines">@@ -525,6 +524,7 @@
</span><span class="cx">     String engineDescription() const;
</span><span class="cx"> 
</span><span class="cx">     CachedResourceLoader* cachedResourceLoader();
</span><ins>+    PassRefPtr&lt;PlatformMediaResourceLoader&gt; createResourceLoader(std::unique_ptr&lt;PlatformMediaResourceLoaderClient&gt;);
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     void addAudioTrack(PassRefPtr&lt;AudioTrackPrivate&gt;);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsPlatformMediaResourceLoaderh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/PlatformMediaResourceLoader.h (0 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/PlatformMediaResourceLoader.h                                (rev 0)
+++ trunk/Source/WebCore/platform/graphics/PlatformMediaResourceLoader.h        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -0,0 +1,82 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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.
+ */
+
+#ifndef PlatformMediaResourceLoader_h
+#define PlatformMediaResourceLoader_h
+
+#if ENABLE(VIDEO)
+#include &lt;wtf/Noncopyable.h&gt;
+#include &lt;wtf/RefCounted.h&gt;
+
+namespace WebCore {
+
+class ResourceError;
+class ResourceRequest;
+class ResourceResponse;
+class SharedBuffer;
+
+class PlatformMediaResourceLoaderClient {
+public:
+    virtual ~PlatformMediaResourceLoaderClient() { }
+
+    virtual void responseReceived(const ResourceResponse&amp;) { }
+    virtual void dataReceived(const char*, int) { }
+    virtual void bufferReceived(SharedBuffer*) { }
+    virtual void accessControlCheckFailed(const ResourceError&amp;) { }
+    virtual void loadFailed(const ResourceError&amp;) { }
+    virtual void loadFinished(SharedBuffer*) { }
+#if USE(SOUP)
+    virtual char* getOrCreateReadBuffer(size_t /*requestedSize*/, size_t&amp; /*actualSize*/) { return nullptr; };
+#endif
+};
+
+class PlatformMediaResourceLoader : public RefCounted&lt;PlatformMediaResourceLoader&gt; {
+    WTF_MAKE_NONCOPYABLE(PlatformMediaResourceLoader); WTF_MAKE_FAST_ALLOCATED;
+public:
+    enum LoadOption {
+        BufferData = 1 &lt;&lt; 0,
+    };
+    typedef unsigned LoadOptions;
+
+    virtual ~PlatformMediaResourceLoader() { }
+
+    virtual bool start(const ResourceRequest&amp;, LoadOptions) = 0;
+    virtual void stop() { }
+    virtual void setDefersLoading(bool) { }
+    virtual bool didPassAccessControlCheck() const { return false; }
+
+protected:
+    PlatformMediaResourceLoader(std::unique_ptr&lt;PlatformMediaResourceLoaderClient&gt; client)
+        : m_client(WTF::move(client))
+    {
+    }
+
+    std::unique_ptr&lt;PlatformMediaResourceLoaderClient&gt; m_client;
+};
+
+} // namespace WebCore
+
+#endif
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerWebKitWebSourceGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp (175049 => 175050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp        2014-10-22 15:09:43 UTC (rev 175049)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp        2014-10-22 15:12:08 UTC (rev 175050)
</span><span class="lines">@@ -22,22 +22,17 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIDEO) &amp;&amp; USE(GSTREAMER)
</span><span class="cx"> 
</span><del>-#include &quot;CachedRawResource.h&quot;
-#include &quot;CachedRawResourceClient.h&quot;
-#include &quot;CachedResourceHandle.h&quot;
-#include &quot;CachedResourceLoader.h&quot;
-#include &quot;CachedResourceRequest.h&quot;
-#include &quot;CrossOriginAccessControl.h&quot;
</del><span class="cx"> #include &quot;GRefPtrGStreamer.h&quot;
</span><span class="cx"> #include &quot;GStreamerUtilities.h&quot;
</span><span class="cx"> #include &quot;HTTPHeaderNames.h&quot;
</span><span class="cx"> #include &quot;MediaPlayer.h&quot;
</span><span class="cx"> #include &quot;NotImplemented.h&quot;
</span><ins>+#include &quot;PlatformMediaResourceLoader.h&quot;
+#include &quot;ResourceError.h&quot;
</ins><span class="cx"> #include &quot;ResourceHandle.h&quot;
</span><span class="cx"> #include &quot;ResourceHandleClient.h&quot;
</span><span class="cx"> #include &quot;ResourceRequest.h&quot;
</span><span class="cx"> #include &quot;ResourceResponse.h&quot;
</span><del>-#include &quot;SecurityOrigin.h&quot;
</del><span class="cx"> #include &quot;SharedBuffer.h&quot;
</span><span class="cx"> #include &lt;gst/app/gstappsrc.h&gt;
</span><span class="cx"> #include &lt;gst/gst.h&gt;
</span><span class="lines">@@ -51,48 +46,34 @@
</span><span class="cx"> 
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><del>-enum CORSAccessCheckResult {
-    CORSNoCheck,
-    CORSSuccess,
-    CORSFailure
-};
-
</del><span class="cx"> class StreamingClient {
</span><span class="cx">     public:
</span><span class="cx">         StreamingClient(WebKitWebSrc*);
</span><span class="cx">         virtual ~StreamingClient();
</span><span class="cx"> 
</span><del>-        virtual bool loadFailed() const = 0;
-        virtual void setDefersLoading(bool) = 0;
-
</del><span class="cx">     protected:
</span><span class="cx">         char* createReadBuffer(size_t requestedSize, size_t&amp; actualSize);
</span><del>-        void handleResponseReceived(const ResourceResponse&amp;, CORSAccessCheckResult);
</del><ins>+        void handleResponseReceived(const ResourceResponse&amp;);
</ins><span class="cx">         void handleDataReceived(const char*, int);
</span><span class="cx">         void handleNotifyFinished();
</span><span class="cx"> 
</span><span class="cx">         GstElement* m_src;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-class CachedResourceStreamingClient : public CachedRawResourceClient, public StreamingClient {
-    WTF_MAKE_NONCOPYABLE(CachedResourceStreamingClient); WTF_MAKE_FAST_ALLOCATED;
</del><ins>+class CachedResourceStreamingClient final : public PlatformMediaResourceLoaderClient, public StreamingClient {
+    WTF_MAKE_NONCOPYABLE(CachedResourceStreamingClient);
</ins><span class="cx">     public:
</span><del>-        CachedResourceStreamingClient(WebKitWebSrc*, CachedResourceLoader*, const ResourceRequest&amp;, MediaPlayerClient::CORSMode);
</del><ins>+        CachedResourceStreamingClient(WebKitWebSrc*);
</ins><span class="cx">         virtual ~CachedResourceStreamingClient();
</span><span class="cx"> 
</span><del>-        // StreamingClient virtual methods.
-        virtual bool loadFailed() const;
-        virtual void setDefersLoading(bool);
-
</del><span class="cx">     private:
</span><del>-        // CachedResourceClient virtual methods.
-        virtual char* getOrCreateReadBuffer(CachedResource*, size_t requestedSize, size_t&amp; actualSize);
-        virtual void responseReceived(CachedResource*, const ResourceResponse&amp;);
-        virtual void dataReceived(CachedResource*, const char*, int);
-        virtual void notifyFinished(CachedResource*);
-
-        CachedResourceHandle&lt;CachedRawResource&gt; m_resource;
-        RefPtr&lt;SecurityOrigin&gt; m_origin;
</del><ins>+        // PlatformMediaResourceLoaderClient virtual methods.
+        virtual char* getOrCreateReadBuffer(size_t requestedSize, size_t&amp; actualSize) override;
+        virtual void responseReceived(const ResourceResponse&amp;) override;
+        virtual void dataReceived(const char*, int) override;
+        virtual void accessControlCheckFailed(const ResourceError&amp;) override;
+        virtual void loadFailed(const ResourceError&amp;) override;
+        virtual void loadFinished(SharedBuffer*) override;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class ResourceHandleStreamingClient : public ResourceHandleClient, public StreamingClient {
</span><span class="lines">@@ -102,8 +83,8 @@
</span><span class="cx">         virtual ~ResourceHandleStreamingClient();
</span><span class="cx"> 
</span><span class="cx">         // StreamingClient virtual methods.
</span><del>-        virtual bool loadFailed() const;
-        virtual void setDefersLoading(bool);
</del><ins>+        bool loadFailed() const;
+        void setDefersLoading(bool);
</ins><span class="cx"> 
</span><span class="cx">     private:
</span><span class="cx">         // ResourceHandleClient virtual methods.
</span><span class="lines">@@ -128,9 +109,10 @@
</span><span class="cx"> 
</span><span class="cx">     WebCore::MediaPlayer* player;
</span><span class="cx"> 
</span><del>-    StreamingClient* client;
</del><ins>+    RefPtr&lt;PlatformMediaResourceLoader&gt; loader;
+    ResourceHandleStreamingClient* client;
</ins><span class="cx"> 
</span><del>-    CORSAccessCheckResult corsAccessCheck;
</del><ins>+    bool didPassAccessControlCheck;
</ins><span class="cx"> 
</span><span class="cx">     guint64 offset;
</span><span class="cx">     guint64 size;
</span><span class="lines">@@ -402,6 +384,8 @@
</span><span class="cx">         priv-&gt;client = 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    priv-&gt;loader = nullptr;
+
</ins><span class="cx">     if (priv-&gt;buffer) {
</span><span class="cx">         unmapGstBuffer(priv-&gt;buffer.get());
</span><span class="cx">         priv-&gt;buffer.clear();
</span><span class="lines">@@ -449,7 +433,7 @@
</span><span class="cx"> 
</span><span class="cx">     GMutexLocker&lt;GMutex&gt; locker(*GST_OBJECT_GET_LOCK(src));
</span><span class="cx"> 
</span><del>-    priv-&gt;corsAccessCheck = CORSNoCheck;
</del><ins>+    priv-&gt;didPassAccessControlCheck = false;
</ins><span class="cx"> 
</span><span class="cx">     if (!priv-&gt;uri) {
</span><span class="cx">         GST_ERROR_OBJECT(src, &quot;No URI provided&quot;);
</span><span class="lines">@@ -459,6 +443,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT(!priv-&gt;client);
</span><ins>+    ASSERT(!priv-&gt;loader);
</ins><span class="cx"> 
</span><span class="cx">     URL url = URL(URL(), priv-&gt;uri);
</span><span class="cx"> 
</span><span class="lines">@@ -493,20 +478,29 @@
</span><span class="cx">     // We always request Icecast/Shoutcast metadata, just in case ...
</span><span class="cx">     request.setHTTPHeaderField(HTTPHeaderName::IcyMetadata, &quot;1&quot;);
</span><span class="cx"> 
</span><ins>+    bool loadFailed = true;
</ins><span class="cx">     if (priv-&gt;player) {
</span><del>-        if (CachedResourceLoader* loader = priv-&gt;player-&gt;cachedResourceLoader())
-            priv-&gt;client = new CachedResourceStreamingClient(src, loader, request, priv-&gt;player-&gt;client().mediaPlayerCORSMode());
</del><ins>+        priv-&gt;loader = priv-&gt;player-&gt;createResourceLoader(std::make_unique&lt;CachedResourceStreamingClient&gt;(src));
+        if (priv-&gt;loader) {
+            PlatformMediaResourceLoader::LoadOptions loadOptions = 0;
+            if (request.url().protocolIs(&quot;blob&quot;))
+                loadOptions |= PlatformMediaResourceLoader::LoadOption::BufferData;
+            loadFailed = !priv-&gt;loader-&gt;start(request, loadOptions);
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!priv-&gt;client)
</del><ins>+    if (!priv-&gt;loader) {
</ins><span class="cx">         priv-&gt;client = new ResourceHandleStreamingClient(src, request);
</span><ins>+        loadFailed = priv-&gt;client-&gt;loadFailed();
+    }
</ins><span class="cx"> 
</span><del>-    if (!priv-&gt;client || priv-&gt;client-&gt;loadFailed()) {
</del><ins>+    if (loadFailed) {
</ins><span class="cx">         GST_ERROR_OBJECT(src, &quot;Failed to setup streaming client&quot;);
</span><span class="cx">         if (priv-&gt;client) {
</span><span class="cx">             delete priv-&gt;client;
</span><del>-            priv-&gt;client = 0;
</del><ins>+            priv-&gt;client = nullptr;
</ins><span class="cx">         }
</span><ins>+        priv-&gt;loader = nullptr;
</ins><span class="cx">         locker.unlock();
</span><span class="cx">         webKitWebSrcStop(src);
</span><span class="cx">         return;
</span><span class="lines">@@ -680,6 +674,8 @@
</span><span class="cx"> 
</span><span class="cx">     if (priv-&gt;client)
</span><span class="cx">         priv-&gt;client-&gt;setDefersLoading(false);
</span><ins>+    if (priv-&gt;loader)
+        priv-&gt;loader-&gt;setDefersLoading(false);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void webKitWebSrcNeedDataCb(GstAppSrc*, guint length, gpointer userData)
</span><span class="lines">@@ -710,6 +706,8 @@
</span><span class="cx"> 
</span><span class="cx">     if (priv-&gt;client)
</span><span class="cx">         priv-&gt;client-&gt;setDefersLoading(true);
</span><ins>+    if (priv-&gt;loader)
+        priv-&gt;loader-&gt;setDefersLoading(true);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void webKitWebSrcEnoughDataCb(GstAppSrc*, gpointer userData)
</span><span class="lines">@@ -767,7 +765,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool webKitSrcPassedCORSAccessCheck(WebKitWebSrc* src)
</span><span class="cx"> {
</span><del>-    return src-&gt;priv-&gt;corsAccessCheck == CORSSuccess;
</del><ins>+    return src-&gt;priv-&gt;didPassAccessControlCheck;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> StreamingClient::StreamingClient(WebKitWebSrc* src)
</span><span class="lines">@@ -799,19 +797,15 @@
</span><span class="cx">     return getGstBufferDataPointer(buffer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void StreamingClient::handleResponseReceived(const ResourceResponse&amp; response, CORSAccessCheckResult corsAccessCheck)
</del><ins>+void StreamingClient::handleResponseReceived(const ResourceResponse&amp; response)
</ins><span class="cx"> {
</span><span class="cx">     WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src);
</span><span class="cx">     WebKitWebSrcPrivate* priv = src-&gt;priv;
</span><span class="cx"> 
</span><span class="cx">     GST_DEBUG_OBJECT(src, &quot;Received response: %d&quot;, response.httpStatusCode());
</span><span class="cx"> 
</span><del>-    if (response.httpStatusCode() &gt;= 400 || corsAccessCheck == CORSFailure) {
-        // Received error code or CORS check failed
-        if (corsAccessCheck == CORSFailure)
-            GST_ELEMENT_ERROR(src, RESOURCE, READ, (&quot;Cross-origin stream load denied by Cross-Origin Resource Sharing policy.&quot;), (nullptr));
-        else
-            GST_ELEMENT_ERROR(src, RESOURCE, READ, (&quot;Received %d HTTP error code&quot;, response.httpStatusCode()), (nullptr));
</del><ins>+    if (response.httpStatusCode() &gt;= 400) {
+        GST_ELEMENT_ERROR(src, RESOURCE, READ, (&quot;Received %d HTTP error code&quot;, response.httpStatusCode()), (nullptr));
</ins><span class="cx">         gst_app_src_end_of_stream(priv-&gt;appsrc);
</span><span class="cx">         webKitWebSrcStop(src);
</span><span class="cx">         return;
</span><span class="lines">@@ -819,8 +813,6 @@
</span><span class="cx"> 
</span><span class="cx">     GMutexLocker&lt;GMutex&gt; locker(*GST_OBJECT_GET_LOCK(src));
</span><span class="cx"> 
</span><del>-    priv-&gt;corsAccessCheck = corsAccessCheck;
-
</del><span class="cx">     if (priv-&gt;seekSource.isActive()) {
</span><span class="cx">         GST_DEBUG_OBJECT(src, &quot;Seek in progress, ignoring response&quot;);
</span><span class="cx">         return;
</span><span class="lines">@@ -992,78 +984,54 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-CachedResourceStreamingClient::CachedResourceStreamingClient(WebKitWebSrc* src, CachedResourceLoader* resourceLoader, const ResourceRequest&amp; request, MediaPlayerClient::CORSMode corsMode)
</del><ins>+CachedResourceStreamingClient::CachedResourceStreamingClient(WebKitWebSrc* src)
</ins><span class="cx">     : StreamingClient(src)
</span><span class="cx"> {
</span><del>-    DataBufferingPolicy bufferingPolicy = request.url().protocolIs(&quot;blob&quot;) ? BufferData : DoNotBufferData;
-    RequestOriginPolicy corsPolicy = corsMode != MediaPlayerClient::Unspecified ? PotentiallyCrossOriginEnabled : UseDefaultOriginRestrictionsForType;
-    StoredCredentials allowCredentials = corsMode == MediaPlayerClient::Anonymous ? DoNotAllowStoredCredentials : AllowStoredCredentials;
-    ResourceLoaderOptions options(SendCallbacks, DoNotSniffContent, bufferingPolicy, allowCredentials, DoNotAskClientForCrossOriginCredentials, DoSecurityCheck, corsPolicy, DoNotIncludeCertificateInfo);
-
-    CachedResourceRequest cacheRequest(request, options);
-
-    if (corsMode != MediaPlayerClient::Unspecified) {
-        m_origin = resourceLoader-&gt;document() ? resourceLoader-&gt;document()-&gt;securityOrigin() : nullptr;
-        updateRequestForAccessControl(cacheRequest.mutableResourceRequest(), m_origin.get(), allowCredentials);
-    }
-
-    // TODO: Decide whether to use preflight mode for cross-origin requests (see http://wkbug.com/131484).
-    m_resource = resourceLoader-&gt;requestRawResource(cacheRequest);
-    if (m_resource)
-        m_resource-&gt;addClient(this);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CachedResourceStreamingClient::~CachedResourceStreamingClient()
</span><span class="cx"> {
</span><del>-    if (m_resource) {
-        m_resource-&gt;removeClient(this);
-        m_resource = 0;
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool CachedResourceStreamingClient::loadFailed() const
</del><ins>+char* CachedResourceStreamingClient::getOrCreateReadBuffer(size_t requestedSize, size_t&amp; actualSize)
</ins><span class="cx"> {
</span><del>-    return !m_resource;
</del><ins>+    return createReadBuffer(requestedSize, actualSize);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CachedResourceStreamingClient::setDefersLoading(bool defers)
</del><ins>+void CachedResourceStreamingClient::responseReceived(const ResourceResponse&amp; response)
</ins><span class="cx"> {
</span><del>-    if (m_resource)
-        m_resource-&gt;setDefersLoading(defers);
</del><ins>+    WebKitWebSrcPrivate* priv = WEBKIT_WEB_SRC(m_src)-&gt;priv;
+    priv-&gt;didPassAccessControlCheck = priv-&gt;loader-&gt;didPassAccessControlCheck();
+    handleResponseReceived(response);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-char* CachedResourceStreamingClient::getOrCreateReadBuffer(CachedResource*, size_t requestedSize, size_t&amp; actualSize)
</del><ins>+void CachedResourceStreamingClient::dataReceived(const char* data, int length)
</ins><span class="cx"> {
</span><del>-    return createReadBuffer(requestedSize, actualSize);
</del><ins>+    handleDataReceived(data, length);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CachedResourceStreamingClient::responseReceived(CachedResource* resource, const ResourceResponse&amp; response)
</del><ins>+void CachedResourceStreamingClient::accessControlCheckFailed(const ResourceError&amp; error)
</ins><span class="cx"> {
</span><del>-    CORSAccessCheckResult corsAccessCheck = CORSNoCheck;
-    if (m_origin)
-        corsAccessCheck = (m_origin-&gt;canRequest(response.url()) || resource-&gt;passesAccessControlCheck(m_origin.get())) ? CORSSuccess : CORSFailure;
-    handleResponseReceived(response, corsAccessCheck);
</del><ins>+    WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src);
+    GST_ELEMENT_ERROR(src, RESOURCE, READ, (&quot;%s&quot;, error.localizedDescription().utf8().data()), (nullptr));
+    gst_app_src_end_of_stream(src-&gt;priv-&gt;appsrc);
+    webKitWebSrcStop(src);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CachedResourceStreamingClient::dataReceived(CachedResource*, const char* data, int length)
</del><ins>+void CachedResourceStreamingClient::loadFailed(const ResourceError&amp; error)
</ins><span class="cx"> {
</span><del>-    handleDataReceived(data, length);
-}
</del><ins>+    WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src);
</ins><span class="cx"> 
</span><del>-void CachedResourceStreamingClient::notifyFinished(CachedResource* resource)
-{
-    if (resource-&gt;loadFailedOrCanceled()) {
-        WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src);
-
-        if (!resource-&gt;wasCanceled()) {
-            const ResourceError&amp; error = resource-&gt;resourceError();
-            GST_ERROR_OBJECT(src, &quot;Have failure: %s&quot;, error.localizedDescription().utf8().data());
-            GST_ELEMENT_ERROR(src, RESOURCE, FAILED, (&quot;%s&quot;, error.localizedDescription().utf8().data()), (0));
-        }
-        gst_app_src_end_of_stream(src-&gt;priv-&gt;appsrc);
-        return;
</del><ins>+    if (!error.isCancellation()) {
+        GST_ERROR_OBJECT(src, &quot;Have failure: %s&quot;, error.localizedDescription().utf8().data());
+        GST_ELEMENT_ERROR(src, RESOURCE, FAILED, (&quot;%s&quot;, error.localizedDescription().utf8().data()), (nullptr));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    gst_app_src_end_of_stream(src-&gt;priv-&gt;appsrc);
+}
+
+void CachedResourceStreamingClient::loadFinished(SharedBuffer*)
+{
</ins><span class="cx">     handleNotifyFinished();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -1104,7 +1072,7 @@
</span><span class="cx"> 
</span><span class="cx"> void ResourceHandleStreamingClient::didReceiveResponse(ResourceHandle*, const ResourceResponse&amp; response)
</span><span class="cx"> {
</span><del>-    handleResponseReceived(response, CORSNoCheck);
</del><ins>+    handleResponseReceived(response);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ResourceHandleStreamingClient::didReceiveData(ResourceHandle*, const char* /* data */, unsigned /* length */, int)
</span></span></pre>
</div>
</div>

</body>
</html>