<!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>[183467] 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/183467">183467</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2015-04-28 05:49:30 -0700 (Tue, 28 Apr 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Network Cache: Disk cache getting filled by YouTube video data
https://bugs.webkit.org/show_bug.cgi?id=144259

Reviewed by Darin Adler.

Source/WebCore:

MSE media is loaded via XHR and tends to eventually fill the cache.

YouTube serves the media chunks cacheable, however they are rarely (if ever) reused.
We can reduce disk writes and keep more useful resources around by not caching them

Test: http/tests/cache/disk-cache/disk-cache-media.html

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::startLoadingMainResource):

    Set the requester.

* loader/cache/CachedRawResource.cpp:
(WebCore::CachedRawResource::CachedRawResource):
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::streamingMedia):
* page/DiagnosticLoggingKeys.h:
* platform/network/ResourceRequestBase.cpp:
(WebCore::ResourceRequestBase::adopt):
(WebCore::ResourceRequestBase::copyData):
(WebCore::equalIgnoringHeaderFields):
* platform/network/ResourceRequestBase.h:
(WebCore::ResourceRequestBase::requester):
(WebCore::ResourceRequestBase::setRequester):

    Add requester type to the request object. Currently this is main resource, xhr or unspecified.

(WebCore::ResourceRequestBase::encodeWithoutPlatformData):
(WebCore::ResourceRequestBase::decodeWithoutPlatformData):
* platform/network/cf/ResourceRequest.h:
(WebCore::ResourceRequest::deprecatedSetMainResourceRequest): Deleted.
(WebCore::ResourceRequest::deprecatedIsMainResourceRequest): Deleted.

    Replace this iOS only field with shared mechanism.

* platform/network/ios/QuickLook.mm:
(WebCore::QuickLookHandle::create):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createRequest):

    Set the requester.

Source/WebKit2:

MSE media is loaded via XHR and tends to eventually fill the cache.

YouTube serves the media chunks cacheable, however they are rarely (if ever) reused.
We can reduce disk writes and keep more useful resources around by not caching them

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::didReceiveResponseAsync):
(WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::makeStoreDecision):

    Don't store if the requester is XHR and response has video or audio content type.

* NetworkProcess/cache/NetworkCache.h:
* NetworkProcess/cache/NetworkCacheStatistics.cpp:
(WebKit::NetworkCache::storeDecisionToDiagnosticKey):
* Shared/Network/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
(WebKit::NetworkResourceLoadParameters::encode):
(WebKit::NetworkResourceLoadParameters::decode):
* Shared/Network/NetworkResourceLoadParameters.h:

    The requester type is now part of the ResourceRequest, no need for separate parameter.

* Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::ArgumentCoder&lt;ResourceRequest&gt;::encodePlatformData):
(IPC::ArgumentCoder&lt;ResourceRequest&gt;::decodePlatformData):
* WebProcess/Network/WebResourceLoadScheduler.cpp:
(WebKit::WebResourceLoadScheduler::scheduleLoad):

LayoutTests:

* http/tests/cache/disk-cache/disk-cache-media-expected.txt: Added.
* http/tests/cache/disk-cache/disk-cache-media.html: Added.
* http/tests/cache/disk-cache/resources/cache-test.js:
(generateTestURL):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcacheresourcescachetestjs">trunk/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentLoadercpp">trunk/Source/WebCore/loader/DocumentLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedRawResourcecpp">trunk/Source/WebCore/loader/cache/CachedRawResource.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDiagnosticLoggingKeyscpp">trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp</a></li>
<li><a href="#trunkSourceWebCorepageDiagnosticLoggingKeysh">trunk/Source/WebCore/page/DiagnosticLoggingKeys.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkResourceRequestBasecpp">trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkResourceRequestBaseh">trunk/Source/WebCore/platform/network/ResourceRequestBase.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcfResourceRequesth">trunk/Source/WebCore/platform/network/cf/ResourceRequest.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkiosQuickLookmm">trunk/Source/WebCore/platform/network/ios/QuickLook.mm</a></li>
<li><a href="#trunkSourceWebCorexmlXMLHttpRequestcpp">trunk/Source/WebCore/xml/XMLHttpRequest.cpp</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebFrameLoaderClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessNetworkResourceLoadercpp">trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCachecpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheh">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheStatisticscpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedNetworkNetworkResourceLoadParameterscpp">trunk/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedNetworkNetworkResourceLoadParametersh">trunk/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h</a></li>
<li><a href="#trunkSourceWebKit2SharedmacWebCoreArgumentCodersMacmm">trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebResourceLoadSchedulercpp">trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestscachediskcachediskcachemediaexpectedtxt">trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestscachediskcachediskcachemediahtml">trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/LayoutTests/ChangeLog        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2015-04-28  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Network Cache: Disk cache getting filled by YouTube video data
+        https://bugs.webkit.org/show_bug.cgi?id=144259
+
+        Reviewed by Darin Adler.
+
+        * http/tests/cache/disk-cache/disk-cache-media-expected.txt: Added.
+        * http/tests/cache/disk-cache/disk-cache-media.html: Added.
+        * http/tests/cache/disk-cache/resources/cache-test.js:
+        (generateTestURL):
+
</ins><span class="cx"> 2015-04-25  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Eliminate styleDidChange with StyleDifferenceEqual when updates are actually necessary
</span></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachediskcachemediaexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media-expected.txt (0 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media-expected.txt                                (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media-expected.txt        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+Tests that media resources loaded via XHR is not cached.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+running 6 tests
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Content-Type&quot;:&quot;text/plain&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;Content-Type&quot;:&quot;text/plain&quot;}
+response source: Disk cache
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Content-Type&quot;:&quot;video/mp4&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;Content-Type&quot;:&quot;video/mp4&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=0&quot;,&quot;Content-Type&quot;:&quot;audio/mp4&quot;}
+response source: Network
+
+response headers: {&quot;Cache-control&quot;:&quot;max-age=100&quot;,&quot;Content-Type&quot;:&quot;audio/mp4&quot;}
+response source: Network
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcachediskcachemediahtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media.html (0 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/disk-cache-media.html        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+&lt;script src=&quot;/js-test-resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/cache-test.js&quot;&gt;&lt;/script&gt;
+&lt;body&gt;
+&lt;script&gt;
+
+var testMatrix =
+[
+ [
+  { responseHeaders: {'Cache-control': 'max-age=0' } },
+  { responseHeaders: {'Cache-control': 'max-age=100' } },
+  ],
+ [
+  { responseHeaders: {'Content-Type': 'text/plain' } },
+  { responseHeaders: {'Content-Type': 'video/mp4' } },
+  { responseHeaders: {'Content-Type': 'audio/mp4' } },
+  ],
+ ];
+
+description(&quot;Tests that media resources loaded via XHR is not cached.&quot;);
+
+var tests = generateTests(testMatrix);
+
+debug(&quot;running &quot; + tests.length + &quot; tests&quot;);
+debug(&quot;&quot;);
+
+runTests(tests);
+
+&lt;/script&gt;
+&lt;script src=&quot;/js-test-resources/js-test-post.js&quot;&gt;&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestscachediskcacheresourcescachetestjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -46,7 +46,9 @@
</span><span class="cx">     var testURL = &quot;resources/generate-response.cgi?include-body=&quot; + (includeBody ? &quot;1&quot; : &quot;0&quot;);
</span><span class="cx">     if (expiresInFutureIn304)
</span><span class="cx">         testURL += &quot;&amp;expires-in-future-in-304=1&quot;;
</span><del>-    testURL += &quot;&amp;uniqueId=&quot; + uniqueTestId++ + &quot;&amp;Content-type=text/plain&quot;;
</del><ins>+    testURL += &quot;&amp;uniqueId=&quot; + uniqueTestId++;
+    if (!test.responseHeaders || !test.responseHeaders[&quot;Content-Type&quot;])
+        testURL += &quot;&amp;Content-Type=text/plain&quot;;
</ins><span class="cx">     for (var header in test.responseHeaders)
</span><span class="cx">         testURL += '&amp;' + header + '=' + makeHeaderValue(test.responseHeaders[header]);
</span><span class="cx">     return testURL;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebCore/ChangeLog        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -1,3 +1,52 @@
</span><ins>+2015-04-28  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Network Cache: Disk cache getting filled by YouTube video data
+        https://bugs.webkit.org/show_bug.cgi?id=144259
+
+        Reviewed by Darin Adler.
+
+        MSE media is loaded via XHR and tends to eventually fill the cache.
+
+        YouTube serves the media chunks cacheable, however they are rarely (if ever) reused.
+        We can reduce disk writes and keep more useful resources around by not caching them
+
+        Test: http/tests/cache/disk-cache/disk-cache-media.html
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::startLoadingMainResource):
+
+            Set the requester.
+
+        * loader/cache/CachedRawResource.cpp:
+        (WebCore::CachedRawResource::CachedRawResource):
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::streamingMedia):
+        * page/DiagnosticLoggingKeys.h:
+        * platform/network/ResourceRequestBase.cpp:
+        (WebCore::ResourceRequestBase::adopt):
+        (WebCore::ResourceRequestBase::copyData):
+        (WebCore::equalIgnoringHeaderFields):
+        * platform/network/ResourceRequestBase.h:
+        (WebCore::ResourceRequestBase::requester):
+        (WebCore::ResourceRequestBase::setRequester):
+
+            Add requester type to the request object. Currently this is main resource, xhr or unspecified.
+
+        (WebCore::ResourceRequestBase::encodeWithoutPlatformData):
+        (WebCore::ResourceRequestBase::decodeWithoutPlatformData):
+        * platform/network/cf/ResourceRequest.h:
+        (WebCore::ResourceRequest::deprecatedSetMainResourceRequest): Deleted.
+        (WebCore::ResourceRequest::deprecatedIsMainResourceRequest): Deleted.
+
+            Replace this iOS only field with shared mechanism.
+
+        * platform/network/ios/QuickLook.mm:
+        (WebCore::QuickLookHandle::create):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::createRequest):
+
+            Set the requester.
+
</ins><span class="cx"> 2015-04-28  Namhoon Kim  &lt;nakim@ea.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix windows build error in WebCore related to bulk build.
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentLoader.cpp        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -934,11 +934,6 @@
</span><span class="cx"> {
</span><span class="cx">     m_loadingMainResource = false;
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
-    // FIXME: Remove PLATFORM(IOS)-guard once we upstream the iOS changes to ResourceRequest.h.
-    m_request.deprecatedSetMainResourceRequest(false);
-#endif
-
</del><span class="cx">     if (this == frameLoader()-&gt;activeDocumentLoader())
</span><span class="cx">         checkLoadComplete();
</span><span class="cx"> }
</span><span class="lines">@@ -1403,12 +1398,9 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
-    // FIXME: Remove PLATFORM(IOS)-guard once we upstream the iOS changes to ResourceRequest.h.
-    m_request.deprecatedSetMainResourceRequest(true);
-#endif
-
</del><span class="cx">     ResourceRequest request(m_request);
</span><ins>+    request.setRequester(ResourceRequest::Requester::Main);
+    
</ins><span class="cx">     static NeverDestroyed&lt;ResourceLoaderOptions&gt; mainResourceLoadOptions(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForAllCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType, IncludeCertificateInfo);
</span><span class="cx">     CachedResourceRequest cachedResourceRequest(request, mainResourceLoadOptions);
</span><span class="cx">     cachedResourceRequest.setInitiator(*this);
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedRawResourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedRawResource.cpp (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedRawResource.cpp        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebCore/loader/cache/CachedRawResource.cpp        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -42,7 +42,6 @@
</span><span class="cx">     , m_identifier(0)
</span><span class="cx">     , m_allowEncodedDataReplacement(true)
</span><span class="cx"> {
</span><del>-    // FIXME: The wrong CachedResource::Type here may cause a bad cast elsewhere.
</del><span class="cx">     ASSERT(isMainOrRawResource());
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageDiagnosticLoggingKeyscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -373,6 +373,11 @@
</span><span class="cx">     return ASCIILiteral(&quot;sourceKey&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+String DiagnosticLoggingKeys::streamingMedia()
+{
+    return ASCIILiteral(&quot;streamingMedia&quot;);
+}
+
</ins><span class="cx"> String DiagnosticLoggingKeys::styleSheetKey()
</span><span class="cx"> {
</span><span class="cx">     return ASCIILiteral(&quot;styleSheet&quot;);
</span></span></pre></div>
<a id="trunkSourceWebCorepageDiagnosticLoggingKeysh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.h (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.h        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.h        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -106,6 +106,7 @@
</span><span class="cx">     static String sameLoadKey();
</span><span class="cx">     static String scriptKey();
</span><span class="cx">     static String sourceKey();
</span><ins>+    WEBCORE_EXPORT static String streamingMedia();
</ins><span class="cx">     static String styleSheetKey();
</span><span class="cx">     static String svgDocumentKey();
</span><span class="cx">     WEBCORE_EXPORT static String uncacheableStatusCodeKey();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkResourceRequestBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.cpp        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx">     request-&gt;setFirstPartyForCookies(data-&gt;m_firstPartyForCookies);
</span><span class="cx">     request-&gt;setHTTPMethod(data-&gt;m_httpMethod);
</span><span class="cx">     request-&gt;setPriority(data-&gt;m_priority);
</span><ins>+    request-&gt;setRequester(data-&gt;m_requester);
</ins><span class="cx"> 
</span><span class="cx">     request-&gt;updateResourceRequest();
</span><span class="cx">     request-&gt;m_httpHeaderFields.adopt(WTF::move(data-&gt;m_httpHeaders));
</span><span class="lines">@@ -90,6 +91,7 @@
</span><span class="cx">     data-&gt;m_httpMethod = httpMethod().isolatedCopy();
</span><span class="cx">     data-&gt;m_httpHeaders = httpHeaderFields().copyData();
</span><span class="cx">     data-&gt;m_priority = priority();
</span><ins>+    data-&gt;m_requester = m_requester;
</ins><span class="cx"> 
</span><span class="cx">     data-&gt;m_responseContentDispositionEncodingFallbackArray.reserveInitialCapacity(m_responseContentDispositionEncodingFallbackArray.size());
</span><span class="cx">     size_t encodingArraySize = m_responseContentDispositionEncodingFallbackArray.size();
</span><span class="lines">@@ -496,6 +498,9 @@
</span><span class="cx">     if (a.priority() != b.priority())
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if (a.requester() != b.requester())
+        return false;
+
</ins><span class="cx">     FormData* formDataA = a.httpBody();
</span><span class="cx">     FormData* formDataB = b.httpBody();
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkResourceRequestBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ResourceRequestBase.h        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.h        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -147,6 +147,10 @@
</span><span class="cx">         bool hiddenFromInspector() const { return m_hiddenFromInspector; }
</span><span class="cx">         void setHiddenFromInspector(bool hiddenFromInspector) { m_hiddenFromInspector = hiddenFromInspector; }
</span><span class="cx"> 
</span><ins>+        enum class Requester { Unspecified, Main, XHR };
+        WEBCORE_EXPORT Requester requester() const { return m_requester; }
+        WEBCORE_EXPORT void setRequester(Requester requester) { m_requester = requester; }
+
</ins><span class="cx"> #if !PLATFORM(COCOA)
</span><span class="cx">         bool encodingRequiresPlatformData() const { return true; }
</span><span class="cx"> #endif
</span><span class="lines">@@ -224,6 +228,7 @@
</span><span class="cx">         unsigned m_reportRawHeaders : 1;
</span><span class="cx">         unsigned m_hiddenFromInspector : 1;
</span><span class="cx">         unsigned m_priority : 4;
</span><ins>+        Requester m_requester { Requester::Unspecified };
</ins><span class="cx"> 
</span><span class="cx">     private:
</span><span class="cx">         const ResourceRequest&amp; asResourceRequest() const;
</span><span class="lines">@@ -255,6 +260,7 @@
</span><span class="cx">         RefPtr&lt;FormData&gt; m_httpBody;
</span><span class="cx">         bool m_allowCookies;
</span><span class="cx">         ResourceLoadPriority m_priority;
</span><ins>+        ResourceRequestBase::Requester m_requester;
</ins><span class="cx">     };
</span><span class="cx">     
</span><span class="cx">     unsigned initializeMaximumHTTPConnectionCountPerHost();
</span><span class="lines">@@ -276,6 +282,7 @@
</span><span class="cx">     encoder.encodeEnum(m_cachePolicy);
</span><span class="cx">     encoder &lt;&lt; m_allowCookies;
</span><span class="cx">     encoder.encodeEnum(m_priority);
</span><ins>+    encoder.encodeEnum(m_requester);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;class Decoder&gt;
</span><span class="lines">@@ -318,6 +325,9 @@
</span><span class="cx">         return false;
</span><span class="cx">     m_priority = priority;
</span><span class="cx"> 
</span><ins>+    if (!decoder.decodeEnum(m_requester))
+        return false;
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcfResourceRequesth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cf/ResourceRequest.h (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/cf/ResourceRequest.h        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebCore/platform/network/cf/ResourceRequest.h        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -118,18 +118,7 @@
</span><span class="cx"> 
</span><span class="cx">         static bool resourcePrioritiesEnabled();
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
-        // FIXME: deprecatedIsMainResourceRequest() does not return the correct value if the ResourceRequest has been
-        // deserialized from an IPC message. As a result this function can only be relied on when networking is not in a
-        // separate process.
-        void deprecatedSetMainResourceRequest(bool isMainResourceRequest) const { m_mainResourceRequest = isMainResourceRequest; }
-        bool deprecatedIsMainResourceRequest() const { return m_mainResourceRequest; }
-
</del><span class="cx">     private:
</span><del>-        mutable bool m_mainResourceRequest = false;
-#endif
-
-    private:
</del><span class="cx">         friend class ResourceRequestBase;
</span><span class="cx"> 
</span><span class="cx">         void doUpdatePlatformRequest();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkiosQuickLookmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ios/QuickLook.mm (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ios/QuickLook.mm        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebCore/platform/network/ios/QuickLook.mm        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -459,7 +459,7 @@
</span><span class="cx"> std::unique_ptr&lt;QuickLookHandle&gt; QuickLookHandle::create(ResourceHandle* handle, NSURLConnection *connection, NSURLResponse *nsResponse, id delegate)
</span><span class="cx"> {
</span><span class="cx">     ASSERT_ARG(handle, handle);
</span><del>-    if (!handle-&gt;firstRequest().deprecatedIsMainResourceRequest() || ![WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:[nsResponse MIMEType]])
</del><ins>+    if (handle-&gt;firstRequest().requester() != ResourceRequest::Requester::Main || ![WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:[nsResponse MIMEType]])
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;QuickLookHandle&gt; quickLookHandle(new QuickLookHandle([handle-&gt;firstRequest().nsURLRequest(DoNotUpdateHTTPBody) URL], connection, nsResponse, delegate));
</span><span class="lines">@@ -471,7 +471,7 @@
</span><span class="cx"> std::unique_ptr&lt;QuickLookHandle&gt; QuickLookHandle::create(ResourceHandle* handle, SynchronousResourceHandleCFURLConnectionDelegate* connectionDelegate, CFURLResponseRef cfResponse)
</span><span class="cx"> {
</span><span class="cx">     ASSERT_ARG(handle, handle);
</span><del>-    if (!handle-&gt;firstRequest().deprecatedIsMainResourceRequest() || ![WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:(NSString *)CFURLResponseGetMIMEType(cfResponse)])
</del><ins>+    if (handle-&gt;firstRequest().requester() != ResourceRequest::Requester::Main || ![WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:(NSString *)CFURLResponseGetMIMEType(cfResponse)])
</ins><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><span class="cx">     NSURLResponse *nsResponse = [NSURLResponse _responseWithCFURLResponse:cfResponse];
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXMLHttpRequestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -745,6 +745,7 @@
</span><span class="cx">     m_uploadEventsAllowed = m_sameOriginRequest || uploadEvents || !isSimpleCrossOriginAccessRequest(m_method, m_requestHeaders);
</span><span class="cx"> 
</span><span class="cx">     ResourceRequest request(m_url);
</span><ins>+    request.setRequester(ResourceRequest::Requester::XHR);
</ins><span class="cx">     request.setHTTPMethod(m_method);
</span><span class="cx"> 
</span><span class="cx">     if (m_requestEntityBody) {
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebFrameLoaderClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -363,8 +363,8 @@
</span><span class="cx">     NSURLRequest *newURLRequest = currentURLRequest;
</span><span class="cx">     ResourceLoadPriority priority = request.priority();
</span><span class="cx">     bool isHiddenFromInspector = request.hiddenFromInspector();
</span><ins>+    auto requester = request.requester();
</ins><span class="cx"> #if PLATFORM(IOS)
</span><del>-    bool isMainResourceRequest = request.deprecatedIsMainResourceRequest();
</del><span class="cx">     if (implementations-&gt;webThreadWillSendRequestFunc) {
</span><span class="cx">         newURLRequest = (NSURLRequest *)CallResourceLoadDelegateInWebThread(implementations-&gt;webThreadWillSendRequestFunc, webView, @selector(webThreadWebView:resource:willSendRequest:redirectResponse:fromDataSource:), [webView _objectForIdentifier:identifier], currentURLRequest, redirectResponse.nsURLResponse(), dataSource(loader));
</span><span class="cx">     } else
</span><span class="lines">@@ -375,10 +375,8 @@
</span><span class="cx">     if (newURLRequest != currentURLRequest)
</span><span class="cx">         request = newURLRequest;
</span><span class="cx">     request.setHiddenFromInspector(isHiddenFromInspector);
</span><del>-#if PLATFORM(IOS)
-    request.deprecatedSetMainResourceRequest(isMainResourceRequest);
-#endif
</del><span class="cx">     request.setPriority(priority);
</span><ins>+    request.setRequester(requester);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader* loader, unsigned long identifier)
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebKit2/ChangeLog        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2015-04-28  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Network Cache: Disk cache getting filled by YouTube video data
+        https://bugs.webkit.org/show_bug.cgi?id=144259
+
+        Reviewed by Darin Adler.
+
+        MSE media is loaded via XHR and tends to eventually fill the cache.
+
+        YouTube serves the media chunks cacheable, however they are rarely (if ever) reused.
+        We can reduce disk writes and keep more useful resources around by not caching them
+
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::didReceiveResponseAsync):
+        (WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::makeStoreDecision):
+
+            Don't store if the requester is XHR and response has video or audio content type.
+
+        * NetworkProcess/cache/NetworkCache.h:
+        * NetworkProcess/cache/NetworkCacheStatistics.cpp:
+        (WebKit::NetworkCache::storeDecisionToDiagnosticKey):
+        * Shared/Network/NetworkResourceLoadParameters.cpp:
+        (WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
+        (WebKit::NetworkResourceLoadParameters::encode):
+        (WebKit::NetworkResourceLoadParameters::decode):
+        * Shared/Network/NetworkResourceLoadParameters.h:
+
+            The requester type is now part of the ResourceRequest, no need for separate parameter.
+
+        * Shared/mac/WebCoreArgumentCodersMac.mm:
+        (IPC::ArgumentCoder&lt;ResourceRequest&gt;::encodePlatformData):
+        (IPC::ArgumentCoder&lt;ResourceRequest&gt;::decodePlatformData):
+        * WebProcess/Network/WebResourceLoadScheduler.cpp:
+        (WebKit::WebResourceLoadScheduler::scheduleLoad):
+
</ins><span class="cx"> 2015-04-28  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WK2] API::UserContentURLPattern creation functions should return Ref&lt;&gt;
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessNetworkResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -253,17 +253,18 @@
</span><span class="cx">     shouldSendDidReceiveResponse = !m_cacheEntryForValidation;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    bool shouldWaitContinueDidReceiveResponse = originalRequest().requester() == ResourceRequest::Requester::Main;
</ins><span class="cx">     if (shouldSendDidReceiveResponse) {
</span><span class="cx">         if (isSynchronous())
</span><span class="cx">             m_synchronousLoadData-&gt;response = m_response;
</span><span class="cx">         else {
</span><del>-            if (!sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponse(m_response, m_parameters.isMainResource)))
</del><ins>+            if (!sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponse(m_response, shouldWaitContinueDidReceiveResponse)))
</ins><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // For main resources, the web process is responsible for sending back a NetworkResourceLoader::ContinueDidReceiveResponse message.
</span><del>-    bool shouldContinueDidReceiveResponse = !m_parameters.isMainResource;
</del><ins>+    bool shouldContinueDidReceiveResponse = !shouldWaitContinueDidReceiveResponse;
</ins><span class="cx"> #if ENABLE(NETWORK_CACHE)
</span><span class="cx">     shouldContinueDidReceiveResponse = shouldContinueDidReceiveResponse || m_cacheEntryForValidation;
</span><span class="cx"> #endif
</span><span class="lines">@@ -543,7 +544,8 @@
</span><span class="cx">         m_synchronousLoadData-&gt;response = entry-&gt;response();
</span><span class="cx">         sendReplyToSynchronousRequest(*m_synchronousLoadData, entry-&gt;buffer());
</span><span class="cx">     } else {
</span><del>-        sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponse(entry-&gt;response(), m_parameters.isMainResource));
</del><ins>+        bool needsContinueDidReceiveResponseMessage = originalRequest().requester() == ResourceRequest::Requester::Main;
+        sendAbortingOnFailure(Messages::WebResourceLoader::DidReceiveResponse(entry-&gt;response(), needsContinueDidReceiveResponseMessage));
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(SHAREABLE_RESOURCE)
</span><span class="cx">         if (!entry-&gt;shareableResourceHandle().isNull())
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -267,6 +267,15 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static bool isMediaMIMEType(const String&amp; mimeType)
+{
+    if (mimeType.startsWith(&quot;video/&quot;, /*caseSensitive*/ false))
+        return true;
+    if (mimeType.startsWith(&quot;audio/&quot;, /*caseSensitive*/ false))
+        return true;
+    return false;
+}
+
</ins><span class="cx"> static StoreDecision makeStoreDecision(const WebCore::ResourceRequest&amp; originalRequest, const WebCore::ResourceResponse&amp; response)
</span><span class="cx"> {
</span><span class="cx">     if (!originalRequest.url().protocolIsInHTTPFamily() || !response.isHTTP())
</span><span class="lines">@@ -290,8 +299,8 @@
</span><span class="cx">             return StoreDecision::NoDueToHTTPStatusCode;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // Main resource has ResourceLoadPriorityVeryHigh.
-    bool storeUnconditionallyForHistoryNavigation = originalRequest.priority() == WebCore::ResourceLoadPriorityVeryHigh;
</del><ins>+    bool isMainResource = originalRequest.requester() == WebCore::ResourceRequest::Requester::Main;
+    bool storeUnconditionallyForHistoryNavigation = isMainResource || originalRequest.priority() == WebCore::ResourceLoadPriorityVeryHigh;
</ins><span class="cx">     if (!storeUnconditionallyForHistoryNavigation) {
</span><span class="cx">         auto now = std::chrono::system_clock::now();
</span><span class="cx">         bool hasNonZeroLifetime = !response.cacheControlContainsNoCache() &amp;&amp; WebCore::computeFreshnessLifetimeForHTTPFamily(response, now) &gt; 0_ms;
</span><span class="lines">@@ -301,6 +310,14 @@
</span><span class="cx">             return StoreDecision::NoDueToUnlikelyToReuse;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // Media loaded via XHR is likely being used for MSE streaming (YouTube and Netflix for example).
+    // Streaming media fills the cache quickly and is unlikely to be reused.
+    // FIXME: We should introduce a separate media cache partition that doesn't affect other resources.
+    // FIXME: We should also make sure make the MSE paths are copy-free so we can use mapped buffers from disk effectively.
+    bool isLikelyStreamingMedia = originalRequest.requester() == WebCore::ResourceRequest::Requester::XHR &amp;&amp; isMediaMIMEType(response.mimeType());
+    if (isLikelyStreamingMedia)
+        return StoreDecision::NoDueToStreamingMedia;
+
</ins><span class="cx">     return StoreDecision::Yes;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -71,7 +71,8 @@
</span><span class="cx">     NoDueToNoStoreResponse,
</span><span class="cx">     NoDueToHTTPStatusCode,
</span><span class="cx">     NoDueToNoStoreRequest,
</span><del>-    NoDueToUnlikelyToReuse
</del><ins>+    NoDueToUnlikelyToReuse,
+    NoDueToStreamingMedia
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> enum class UseDecision {
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheStatisticscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.cpp (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.cpp        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.cpp        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -244,6 +244,8 @@
</span><span class="cx">         return WebCore::DiagnosticLoggingKeys::uncacheableStatusCodeKey();
</span><span class="cx">     case StoreDecision::NoDueToUnlikelyToReuse:
</span><span class="cx">         return WebCore::DiagnosticLoggingKeys::unlikelyToReuseKey();
</span><ins>+    case StoreDecision::NoDueToStreamingMedia:
+        return WebCore::DiagnosticLoggingKeys::streamingMedia();
</ins><span class="cx">     case StoreDecision::Yes:
</span><span class="cx">         // It was stored but could not be retrieved so it must have been pruned from the cache.
</span><span class="cx">         return WebCore::DiagnosticLoggingKeys::noLongerInCacheKey();
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedNetworkNetworkResourceLoadParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -45,7 +45,6 @@
</span><span class="cx">     , allowStoredCredentials(DoNotAllowStoredCredentials)
</span><span class="cx">     , clientCredentialPolicy(DoNotAskClientForAnyCredentials)
</span><span class="cx">     , shouldClearReferrerOnHTTPSToHTTPRedirect(true)
</span><del>-    , isMainResource(false)
</del><span class="cx">     , defersLoading(false)
</span><span class="cx">     , needsCertificateInfo(false)
</span><span class="cx">     , maximumBufferingTime(0_ms)
</span><span class="lines">@@ -94,7 +93,6 @@
</span><span class="cx">     encoder.encodeEnum(allowStoredCredentials);
</span><span class="cx">     encoder.encodeEnum(clientCredentialPolicy);
</span><span class="cx">     encoder &lt;&lt; shouldClearReferrerOnHTTPSToHTTPRedirect;
</span><del>-    encoder &lt;&lt; isMainResource;
</del><span class="cx">     encoder &lt;&lt; defersLoading;
</span><span class="cx">     encoder &lt;&lt; needsCertificateInfo;
</span><span class="cx">     encoder &lt;&lt; maximumBufferingTime;
</span><span class="lines">@@ -151,8 +149,6 @@
</span><span class="cx">         return false;
</span><span class="cx">     if (!decoder.decode(result.shouldClearReferrerOnHTTPSToHTTPRedirect))
</span><span class="cx">         return false;
</span><del>-    if (!decoder.decode(result.isMainResource))
-        return false;
</del><span class="cx">     if (!decoder.decode(result.defersLoading))
</span><span class="cx">         return false;
</span><span class="cx">     if (!decoder.decode(result.needsCertificateInfo))
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedNetworkNetworkResourceLoadParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -61,7 +61,6 @@
</span><span class="cx">     WebCore::StoredCredentials allowStoredCredentials;
</span><span class="cx">     WebCore::ClientCredentialPolicy clientCredentialPolicy;
</span><span class="cx">     bool shouldClearReferrerOnHTTPSToHTTPRedirect;
</span><del>-    bool isMainResource;
</del><span class="cx">     bool defersLoading;
</span><span class="cx">     bool needsCertificateInfo;
</span><span class="cx">     std::chrono::milliseconds maximumBufferingTime;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedmacWebCoreArgumentCodersMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx"> 
</span><span class="cx">     // The fallback array is part of CFURLRequest, but it is not encoded by WKCFURLRequestCreateSerializableRepresentation.
</span><span class="cx">     encoder &lt;&lt; resourceRequest.responseContentDispositionEncodingFallbackArray();
</span><ins>+    encoder.encodeEnum(resourceRequest.requester());
</ins><span class="cx"> }
</span><span class="cx"> #else
</span><span class="cx"> void ArgumentCoder&lt;ResourceRequest&gt;::encodePlatformData(ArgumentEncoder&amp; encoder, const ResourceRequest&amp; resourceRequest)
</span><span class="lines">@@ -109,6 +110,7 @@
</span><span class="cx"> 
</span><span class="cx">     // The fallback array is part of NSURLRequest, but it is not encoded by WKNSURLRequestCreateSerializableRepresentation.
</span><span class="cx">     encoder &lt;&lt; resourceRequest.responseContentDispositionEncodingFallbackArray();
</span><ins>+    encoder.encodeEnum(resourceRequest.requester());
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -151,6 +153,11 @@
</span><span class="cx">         responseContentDispositionEncodingFallbackArray.size() &gt; 2 ? responseContentDispositionEncodingFallbackArray[2] : String()
</span><span class="cx">     );
</span><span class="cx"> 
</span><ins>+    ResourceRequest::Requester requester;
+    if (!decoder.decodeEnum(requester))
+        return false;
+    resourceRequest.setRequester(requester);
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebResourceLoadSchedulercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp (183466 => 183467)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp        2015-04-28 11:36:17 UTC (rev 183466)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp        2015-04-28 12:49:30 UTC (rev 183467)
</span><span class="lines">@@ -173,7 +173,6 @@
</span><span class="cx">     // If there is no WebFrame then this resource cannot be authenticated with the client.
</span><span class="cx">     loadParameters.clientCredentialPolicy = (webFrame &amp;&amp; webPage &amp;&amp; resourceLoader-&gt;isAllowedToAskUserForCredentials()) ? AskClientForAllCredentials : DoNotAskClientForAnyCredentials;
</span><span class="cx">     loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = shouldClearReferrerOnHTTPSToHTTPRedirect;
</span><del>-    loadParameters.isMainResource = resource &amp;&amp; resource-&gt;type() == CachedResource::MainResource;
</del><span class="cx">     loadParameters.defersLoading = resourceLoader-&gt;defersLoading();
</span><span class="cx">     loadParameters.needsCertificateInfo = resourceLoader-&gt;shouldIncludeCertificateInfo();
</span><span class="cx">     loadParameters.maximumBufferingTime = maximumBufferingTime(resource);
</span></span></pre>
</div>
</div>

</body>
</html>