<!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>[195770] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/195770">195770</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2016-01-28 11:52:57 -0800 (Thu, 28 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allow CachedResourceLoader clients to opt out of the MemoryCache.
https://bugs.webkit.org/show_bug.cgi?id=153549

Reviewed by Darin Adler.

Add a flag to ResourceLoaderOptions which allow loader clients to opt out of having
resources stored in the MemoryCache.

* loader/ResourceLoaderOptions.h:
(WebCore::ResourceLoaderOptions::ResourceLoaderOptions):
(WebCore::ResourceLoaderOptions::cachingPolicy):

Existing clients will have to add the (default) AllowCaching flag when they create a
ResourceLoaderOptions object.

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::startLoadingMainResource):
* loader/MediaResourceLoader.cpp:
(WebCore::MediaResourceLoader::start):
* loader/NetscapePlugInStreamLoader.cpp:
(WebCore::NetscapePlugInStreamLoader::NetscapePlugInStreamLoader):
(WebCore::ResourceLoaderOptions::setCachingPolicy):
* loader/icon/IconLoader.cpp:
(WebCore::IconLoader::startLoading):
* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
(WebCore::WebCoreAVFResourceLoader::startLoading):

Every time the CachedResource or CachedResourceLoader accesses the MemoryCache, check
to see whether the resource or the request have allowed caching before adding resources
to, removing resources from, or sourcing resource data from the MemoryCache.

* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::~CachedResource):
(WebCore::CachedResource::failBeforeStarting):
(WebCore::CachedResource::addClientToSet):
(WebCore::CachedResource::removeClient):
(WebCore::CachedResource::setDecodedSize):
(WebCore::CachedResource::setEncodedSize):
(WebCore::CachedResource::didAccessDecodedData):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::allowsCaching):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestUserCSSStyleSheet):
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::revalidateResource):
(WebCore::CachedResourceLoader::loadResource):
(WebCore::CachedResourceLoader::printPreloadStats):
(WebCore::CachedResourceLoader::defaultCachedResourceOptions):
* loader/cache/CachedResourceRequest.h:
(WebCore::CachedResourceRequest::allowsCaching):</pre>

<h3>Modified Paths</h3>
<ul>
<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="#trunkSourceWebCoreloaderMediaResourceLoadercpp">trunk/Source/WebCore/loader/MediaResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderNetscapePlugInStreamLoadercpp">trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoaderOptionsh">trunk/Source/WebCore/loader/ResourceLoaderOptions.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourcecpp">trunk/Source/WebCore/loader/cache/CachedResource.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceh">trunk/Source/WebCore/loader/cache/CachedResource.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceLoadercpp">trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceRequesth">trunk/Source/WebCore/loader/cache/CachedResourceRequest.h</a></li>
<li><a href="#trunkSourceWebCoreloadericonIconLoadercpp">trunk/Source/WebCore/loader/icon/IconLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcWebCoreAVFResourceLoadermm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (195769 => 195770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-28 19:40:36 UTC (rev 195769)
+++ trunk/Source/WebCore/ChangeLog        2016-01-28 19:52:57 UTC (rev 195770)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2016-01-27  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        Allow CachedResourceLoader clients to opt out of the MemoryCache.
+        https://bugs.webkit.org/show_bug.cgi?id=153549
+
+        Reviewed by Darin Adler.
+
+        Add a flag to ResourceLoaderOptions which allow loader clients to opt out of having
+        resources stored in the MemoryCache. 
+
+        * loader/ResourceLoaderOptions.h:
+        (WebCore::ResourceLoaderOptions::ResourceLoaderOptions):
+        (WebCore::ResourceLoaderOptions::cachingPolicy):
+
+        Existing clients will have to add the (default) AllowCaching flag when they create a
+        ResourceLoaderOptions object.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::startLoadingMainResource):
+        * loader/MediaResourceLoader.cpp:
+        (WebCore::MediaResourceLoader::start):
+        * loader/NetscapePlugInStreamLoader.cpp:
+        (WebCore::NetscapePlugInStreamLoader::NetscapePlugInStreamLoader):
+        (WebCore::ResourceLoaderOptions::setCachingPolicy):
+        * loader/icon/IconLoader.cpp:
+        (WebCore::IconLoader::startLoading):
+        * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
+        (WebCore::WebCoreAVFResourceLoader::startLoading):
+
+        Every time the CachedResource or CachedResourceLoader accesses the MemoryCache, check
+        to see whether the resource or the request have allowed caching before adding resources
+        to, removing resources from, or sourcing resource data from the MemoryCache.
+
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::~CachedResource):
+        (WebCore::CachedResource::failBeforeStarting):
+        (WebCore::CachedResource::addClientToSet):
+        (WebCore::CachedResource::removeClient):
+        (WebCore::CachedResource::setDecodedSize):
+        (WebCore::CachedResource::setEncodedSize):
+        (WebCore::CachedResource::didAccessDecodedData):
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource::allowsCaching):
+        * loader/cache/CachedResourceLoader.cpp:
+        (WebCore::CachedResourceLoader::requestUserCSSStyleSheet):
+        (WebCore::CachedResourceLoader::requestResource):
+        (WebCore::CachedResourceLoader::revalidateResource):
+        (WebCore::CachedResourceLoader::loadResource):
+        (WebCore::CachedResourceLoader::printPreloadStats):
+        (WebCore::CachedResourceLoader::defaultCachedResourceOptions):
+        * loader/cache/CachedResourceRequest.h:
+        (WebCore::CachedResourceRequest::allowsCaching):
+
</ins><span class="cx"> 2016-01-28  Enrica Casucci  &lt;enrica@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Should avoid navigation for some data detector urls.
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (195769 => 195770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentLoader.cpp        2016-01-28 19:40:36 UTC (rev 195769)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp        2016-01-28 19:52:57 UTC (rev 195770)
</span><span class="lines">@@ -1475,7 +1475,7 @@
</span><span class="cx">     // If this is a reload the cache layer might have made the previous request conditional. DocumentLoader can't handle 304 responses itself.
</span><span class="cx">     request.makeUnconditional();
</span><span class="cx"> 
</span><del>-    static NeverDestroyed&lt;ResourceLoaderOptions&gt; mainResourceLoadOptions(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForAllCredentials, ClientRequestedCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType, IncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading);
</del><ins>+    static NeverDestroyed&lt;ResourceLoaderOptions&gt; mainResourceLoadOptions(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForAllCredentials, ClientRequestedCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType, IncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::AllowCaching);
</ins><span class="cx">     CachedResourceRequest cachedResourceRequest(request, mainResourceLoadOptions);
</span><span class="cx">     cachedResourceRequest.setInitiator(*this);
</span><span class="cx">     m_mainResource = m_cachedResourceLoader-&gt;requestMainResource(cachedResourceRequest);
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderMediaResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/MediaResourceLoader.cpp (195769 => 195770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/MediaResourceLoader.cpp        2016-01-28 19:40:36 UTC (rev 195769)
+++ trunk/Source/WebCore/loader/MediaResourceLoader.cpp        2016-01-28 19:52:57 UTC (rev 195770)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx">     StoredCredentials allowCredentials = m_crossOriginMode.isNull() || equalLettersIgnoringASCIICase(m_crossOriginMode, &quot;use-credentials&quot;) ? AllowStoredCredentials : DoNotAllowStoredCredentials;
</span><span class="cx"> 
</span><span class="cx">     // ContentSecurityPolicyImposition::DoPolicyCheck is a placeholder value. It does not affect the request since Content Security Policy does not apply to raw resources.
</span><del>-    CachedResourceRequest cacheRequest(request, ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, bufferingPolicy, allowCredentials, DoNotAskClientForCrossOriginCredentials, ClientDidNotRequestCredentials, DoSecurityCheck, corsPolicy, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading));
</del><ins>+    CachedResourceRequest cacheRequest(request, ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, bufferingPolicy, allowCredentials, DoNotAskClientForCrossOriginCredentials, ClientDidNotRequestCredentials, DoSecurityCheck, corsPolicy, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::AllowCaching));
</ins><span class="cx"> 
</span><span class="cx">     if (!m_crossOriginMode.isNull())
</span><span class="cx">         updateRequestForAccessControl(cacheRequest.mutableResourceRequest(), m_document.securityOrigin(), allowCredentials);
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderNetscapePlugInStreamLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp (195769 => 195770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp        2016-01-28 19:40:36 UTC (rev 195769)
+++ trunk/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp        2016-01-28 19:52:57 UTC (rev 195770)
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx"> // FIXME: Skip Content Security Policy check when associated plugin element is in a user agent shadow tree.
</span><span class="cx"> // See &lt;https://bugs.webkit.org/show_bug.cgi?id=146663&gt;.
</span><span class="cx"> NetscapePlugInStreamLoader::NetscapePlugInStreamLoader(Frame* frame, NetscapePlugInStreamLoaderClient* client)
</span><del>-    : ResourceLoader(frame, ResourceLoaderOptions(SendCallbacks, SniffContent, DoNotBufferData, AllowStoredCredentials, AskClientForAllCredentials, ClientRequestedCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading))
</del><ins>+    : ResourceLoader(frame, ResourceLoaderOptions(SendCallbacks, SniffContent, DoNotBufferData, AllowStoredCredentials, AskClientForAllCredentials, ClientRequestedCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::AllowCaching))
</ins><span class="cx">     , m_client(client)
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(CONTENT_EXTENSIONS)
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoaderOptionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoaderOptions.h (195769 => 195770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoaderOptions.h        2016-01-28 19:40:36 UTC (rev 195769)
+++ trunk/Source/WebCore/loader/ResourceLoaderOptions.h        2016-01-28 19:52:57 UTC (rev 195770)
</span><span class="lines">@@ -76,6 +76,11 @@
</span><span class="cx">     DisallowDefersLoading
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+enum class CachingPolicy : uint8_t {
+    AllowCaching,
+    DisallowCaching
+};
+
</ins><span class="cx"> struct ResourceLoaderOptions {
</span><span class="cx">     ResourceLoaderOptions()
</span><span class="cx">         : m_sendLoadCallbacks(DoNotSendCallbacks)
</span><span class="lines">@@ -90,7 +95,7 @@
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    ResourceLoaderOptions(SendCallbackPolicy sendLoadCallbacks, ContentSniffingPolicy sniffContent, DataBufferingPolicy dataBufferingPolicy, StoredCredentials allowCredentials, ClientCredentialPolicy credentialPolicy, CredentialRequest credentialRequest, SecurityCheckPolicy securityCheck, RequestOriginPolicy requestOriginPolicy, CertificateInfoPolicy certificateInfoPolicy, ContentSecurityPolicyImposition contentSecurityPolicyImposition, DefersLoadingPolicy defersLoadingPolicy)
</del><ins>+    ResourceLoaderOptions(SendCallbackPolicy sendLoadCallbacks, ContentSniffingPolicy sniffContent, DataBufferingPolicy dataBufferingPolicy, StoredCredentials allowCredentials, ClientCredentialPolicy credentialPolicy, CredentialRequest credentialRequest, SecurityCheckPolicy securityCheck, RequestOriginPolicy requestOriginPolicy, CertificateInfoPolicy certificateInfoPolicy, ContentSecurityPolicyImposition contentSecurityPolicyImposition, DefersLoadingPolicy defersLoadingPolicy, CachingPolicy cachingPolicy)
</ins><span class="cx">         : m_sendLoadCallbacks(sendLoadCallbacks)
</span><span class="cx">         , m_sniffContent(sniffContent)
</span><span class="cx">         , m_dataBufferingPolicy(dataBufferingPolicy)
</span><span class="lines">@@ -102,6 +107,7 @@
</span><span class="cx">         , m_certificateInfoPolicy(certificateInfoPolicy)
</span><span class="cx">         , m_contentSecurityPolicyImposition(contentSecurityPolicyImposition)
</span><span class="cx">         , m_defersLoadingPolicy(defersLoadingPolicy)
</span><ins>+        , m_cachingPolicy(cachingPolicy)
</ins><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -127,6 +133,8 @@
</span><span class="cx">     void setContentSecurityPolicyImposition(ContentSecurityPolicyImposition imposition) { m_contentSecurityPolicyImposition = imposition; }
</span><span class="cx">     DefersLoadingPolicy defersLoadingPolicy() const { return m_defersLoadingPolicy; }
</span><span class="cx">     void setDefersLoadingPolicy(DefersLoadingPolicy defersLoadingPolicy) { m_defersLoadingPolicy = defersLoadingPolicy; }
</span><ins>+    CachingPolicy cachingPolicy() const { return m_cachingPolicy; }
+    void setCachingPolicy(CachingPolicy cachingPolicy) { m_cachingPolicy = cachingPolicy; }
</ins><span class="cx"> 
</span><span class="cx">     unsigned m_sendLoadCallbacks : 1;
</span><span class="cx">     unsigned m_sniffContent : 1;
</span><span class="lines">@@ -139,6 +147,7 @@
</span><span class="cx">     unsigned m_certificateInfoPolicy : 1; // Whether the response should include certificate info.
</span><span class="cx">     ContentSecurityPolicyImposition m_contentSecurityPolicyImposition { ContentSecurityPolicyImposition::DoPolicyCheck };
</span><span class="cx">     DefersLoadingPolicy m_defersLoadingPolicy { DefersLoadingPolicy::AllowDefersLoading };
</span><ins>+    CachingPolicy m_cachingPolicy { CachingPolicy::AllowCaching };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore    
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (195769 => 195770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResource.cpp        2016-01-28 19:40:36 UTC (rev 195769)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp        2016-01-28 19:52:57 UTC (rev 195770)
</span><span class="lines">@@ -159,7 +159,7 @@
</span><span class="cx">     ASSERT(canDelete());
</span><span class="cx">     ASSERT(!inCache());
</span><span class="cx">     ASSERT(!m_deleted);
</span><del>-    ASSERT(url().isNull() || MemoryCache::singleton().resourceForRequest(resourceRequest(), sessionID()) != this);
</del><ins>+    ASSERT(url().isNull() || !allowsCaching() || MemoryCache::singleton().resourceForRequest(resourceRequest(), sessionID()) != this);
</ins><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span><span class="cx">     m_deleted = true;
</span><span class="lines">@@ -174,7 +174,7 @@
</span><span class="cx"> {
</span><span class="cx">     // FIXME: What if resources in other frames were waiting for this revalidation?
</span><span class="cx">     LOG(ResourceLoading, &quot;Cannot start loading '%s'&quot;, url().string().latin1().data());
</span><del>-    if (m_resourceToRevalidate) 
</del><ins>+    if (allowsCaching() &amp;&amp; m_resourceToRevalidate)
</ins><span class="cx">         MemoryCache::singleton().revalidationFailed(*this);
</span><span class="cx">     error(CachedResource::LoadError);
</span><span class="cx"> }
</span><span class="lines">@@ -452,7 +452,7 @@
</span><span class="cx">         else
</span><span class="cx">             m_preloadResult = PreloadReferenced;
</span><span class="cx">     }
</span><del>-    if (!hasClients() &amp;&amp; inCache())
</del><ins>+    if (allowsCaching() &amp;&amp; !hasClients() &amp;&amp; inCache())
</ins><span class="cx">         MemoryCache::singleton().addToLiveResourcesSize(*this);
</span><span class="cx"> 
</span><span class="cx">     if ((m_type == RawResource || m_type == MainResource) &amp;&amp; !m_response.isNull() &amp;&amp; !m_proxyResource) {
</span><span class="lines">@@ -483,7 +483,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     bool deleted = deleteIfPossible();
</span><del>-    if (!deleted &amp;&amp; !hasClients()) {
</del><ins>+    if (allowsCaching() &amp;&amp; !deleted &amp;&amp; !hasClients()) {
</ins><span class="cx">         auto&amp; memoryCache = MemoryCache::singleton();
</span><span class="cx">         if (inCache()) {
</span><span class="cx">             memoryCache.removeFromLiveResourcesSize(*this);
</span><span class="lines">@@ -541,12 +541,12 @@
</span><span class="cx"> 
</span><span class="cx">     // The object must be moved to a different queue, since its size has been changed.
</span><span class="cx">     // Remove before updating m_decodedSize, so we find the resource in the correct LRU list.
</span><del>-    if (inCache())
</del><ins>+    if (allowsCaching() &amp;&amp; inCache())
</ins><span class="cx">         MemoryCache::singleton().removeFromLRUList(*this);
</span><span class="cx">     
</span><span class="cx">     m_decodedSize = size;
</span><span class="cx">    
</span><del>-    if (inCache()) {
</del><ins>+    if (allowsCaching() &amp;&amp; inCache()) {
</ins><span class="cx">         auto&amp; memoryCache = MemoryCache::singleton();
</span><span class="cx">         // Now insert into the new LRU list.
</span><span class="cx">         memoryCache.insertInLRUList(*this);
</span><span class="lines">@@ -578,12 +578,12 @@
</span><span class="cx"> 
</span><span class="cx">     // The object must be moved to a different queue, since its size has been changed.
</span><span class="cx">     // Remove before updating m_encodedSize, so we find the resource in the correct LRU list.
</span><del>-    if (inCache())
</del><ins>+    if (allowsCaching() &amp;&amp; inCache())
</ins><span class="cx">         MemoryCache::singleton().removeFromLRUList(*this);
</span><span class="cx"> 
</span><span class="cx">     m_encodedSize = size;
</span><span class="cx"> 
</span><del>-    if (inCache()) {
</del><ins>+    if (allowsCaching() &amp;&amp; inCache()) {
</ins><span class="cx">         auto&amp; memoryCache = MemoryCache::singleton();
</span><span class="cx">         memoryCache.insertInLRUList(*this);
</span><span class="cx">         memoryCache.adjustSize(hasClients(), delta);
</span><span class="lines">@@ -594,7 +594,7 @@
</span><span class="cx"> {
</span><span class="cx">     m_lastDecodedAccessTime = timeStamp;
</span><span class="cx">     
</span><del>-    if (inCache()) {
</del><ins>+    if (allowsCaching() &amp;&amp; inCache()) {
</ins><span class="cx">         auto&amp; memoryCache = MemoryCache::singleton();
</span><span class="cx">         if (memoryCache.inLiveDecodedResourcesList(*this)) {
</span><span class="cx">             memoryCache.removeFromLiveDecodedResourcesList(*this);
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (195769 => 195770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResource.h        2016-01-28 19:40:36 UTC (rev 195769)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h        2016-01-28 19:52:57 UTC (rev 195770)
</span><span class="lines">@@ -218,6 +218,8 @@
</span><span class="cx"> 
</span><span class="cx">     bool shouldSendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks() == SendCallbacks; }
</span><span class="cx">     DataBufferingPolicy dataBufferingPolicy() const { return m_options.dataBufferingPolicy(); }
</span><ins>+
+    bool allowsCaching() const { return m_options.cachingPolicy() == CachingPolicy::AllowCaching; }
</ins><span class="cx">     
</span><span class="cx">     virtual void destroyDecodedData() { }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (195769 => 195770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2016-01-28 19:40:36 UTC (rev 195769)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2016-01-28 19:52:57 UTC (rev 195770)
</span><span class="lines">@@ -221,20 +221,24 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     auto&amp; memoryCache = MemoryCache::singleton();
</span><del>-    if (CachedResource* existing = memoryCache.resourceForRequest(request.resourceRequest(), sessionID())) {
-        if (is&lt;CachedCSSStyleSheet&gt;(*existing))
-            return downcast&lt;CachedCSSStyleSheet&gt;(existing);
-        memoryCache.remove(*existing);
</del><ins>+    if (request.allowsCaching()) {
+        if (CachedResource* existing = memoryCache.resourceForRequest(request.resourceRequest(), sessionID())) {
+            if (is&lt;CachedCSSStyleSheet&gt;(*existing))
+                return downcast&lt;CachedCSSStyleSheet&gt;(existing);
+            memoryCache.remove(*existing);
+        }
</ins><span class="cx">     }
</span><ins>+
</ins><span class="cx">     if (url.string() != request.resourceRequest().url())
</span><span class="cx">         request.mutableResourceRequest().setURL(url);
</span><span class="cx"> 
</span><span class="cx">     CachedResourceHandle&lt;CachedCSSStyleSheet&gt; userSheet = new CachedCSSStyleSheet(request.resourceRequest(), request.charset(), sessionID());
</span><span class="cx"> 
</span><del>-    memoryCache.add(*userSheet);
</del><ins>+    if (request.allowsCaching())
+        memoryCache.add(*userSheet);
</ins><span class="cx">     // FIXME: loadResource calls setOwningCachedResourceLoader() if the resource couldn't be added to cache. Does this function need to call it, too?
</span><span class="cx"> 
</span><del>-    userSheet-&gt;load(*this, ResourceLoaderOptions(DoNotSendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForAllCredentials, ClientRequestedCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::SkipPolicyCheck, DefersLoadingPolicy::AllowDefersLoading));
</del><ins>+    userSheet-&gt;load(*this, ResourceLoaderOptions(DoNotSendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForAllCredentials, ClientRequestedCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::SkipPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::AllowCaching));
</ins><span class="cx">     
</span><span class="cx">     return userSheet;
</span><span class="cx"> }
</span><span class="lines">@@ -555,7 +559,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     auto&amp; memoryCache = MemoryCache::singleton();
</span><del>-    if (memoryCache.disabled()) {
</del><ins>+    if (request.allowsCaching() &amp;&amp; memoryCache.disabled()) {
</ins><span class="cx">         DocumentResourceMap::iterator it = m_documentResources.find(url.string());
</span><span class="cx">         if (it != m_documentResources.end()) {
</span><span class="cx">             it-&gt;value-&gt;setOwningCachedResourceLoader(nullptr);
</span><span class="lines">@@ -570,7 +574,8 @@
</span><span class="cx">         request.mutableResourceRequest().setDomainForCachePartition(document()-&gt;topOrigin()-&gt;domainForCachePartition());
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    resource = memoryCache.resourceForRequest(request.resourceRequest(), sessionID());
</del><ins>+    if (request.allowsCaching())
+        resource = memoryCache.resourceForRequest(request.resourceRequest(), sessionID());
</ins><span class="cx"> 
</span><span class="cx">     logMemoryCacheResourceRequest(frame(), resource ? DiagnosticLoggingKeys::inMemoryCacheKey() : DiagnosticLoggingKeys::notInMemoryCacheKey());
</span><span class="cx"> 
</span><span class="lines">@@ -608,7 +613,7 @@
</span><span class="cx"> 
</span><span class="cx">         // We don't support immediate loads, but we do support immediate failure.
</span><span class="cx">         if (resource-&gt;errorOccurred()) {
</span><del>-            if (resource-&gt;inCache())
</del><ins>+            if (resource-&gt;allowsCaching() &amp;&amp; resource-&gt;inCache())
</ins><span class="cx">                 memoryCache.remove(*resource);
</span><span class="cx">             return nullptr;
</span><span class="cx">         }
</span><span class="lines">@@ -636,6 +641,7 @@
</span><span class="cx">     ASSERT(resource-&gt;canUseCacheValidator());
</span><span class="cx">     ASSERT(!resource-&gt;resourceToRevalidate());
</span><span class="cx">     ASSERT(resource-&gt;sessionID() == sessionID());
</span><ins>+    ASSERT(resource-&gt;allowsCaching());
</ins><span class="cx"> 
</span><span class="cx">     CachedResourceHandle&lt;CachedResource&gt; newResource = createResource(resource-&gt;type(), resource-&gt;resourceRequest(), resource-&gt;encoding(), resource-&gt;sessionID());
</span><span class="cx"> 
</span><span class="lines">@@ -661,7 +667,7 @@
</span><span class="cx"> 
</span><span class="cx">     CachedResourceHandle&lt;CachedResource&gt; resource = createResource(type, request.mutableResourceRequest(), request.charset(), sessionID());
</span><span class="cx"> 
</span><del>-    if (!memoryCache.add(*resource))
</del><ins>+    if (request.allowsCaching() &amp;&amp; !memoryCache.add(*resource))
</ins><span class="cx">         resource-&gt;setOwningCachedResourceLoader(this);
</span><span class="cx"> #if ENABLE(RESOURCE_TIMING)
</span><span class="cx">     storeResourceTimingInitiatorInformation(resource, request);
</span><span class="lines">@@ -1151,7 +1157,7 @@
</span><span class="cx">                 imageMisses++;
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        if (resource-&gt;errorOccurred())
</del><ins>+        if (resource-&gt;errorOccurred() &amp;&amp; resource-&gt;preloadResult() == CachedResource::PreloadNotReferenced)
</ins><span class="cx">             MemoryCache::singleton().remove(resource);
</span><span class="cx">         
</span><span class="cx">         resource-&gt;decreasePreloadCount();
</span><span class="lines">@@ -1169,7 +1175,7 @@
</span><span class="cx"> 
</span><span class="cx"> const ResourceLoaderOptions&amp; CachedResourceLoader::defaultCachedResourceOptions()
</span><span class="cx"> {
</span><del>-    static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForAllCredentials, ClientRequestedCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading);
</del><ins>+    static ResourceLoaderOptions options(SendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForAllCredentials, ClientRequestedCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::AllowCaching);
</ins><span class="cx">     return options;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceRequesth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequest.h (195769 => 195770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceRequest.h        2016-01-28 19:40:36 UTC (rev 195769)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequest.h        2016-01-28 19:52:57 UTC (rev 195770)
</span><span class="lines">@@ -60,6 +60,7 @@
</span><span class="cx">     void setInitiator(PassRefPtr&lt;Element&gt;);
</span><span class="cx">     void setInitiator(const AtomicString&amp; name);
</span><span class="cx">     const AtomicString&amp; initiatorName() const;
</span><ins>+    bool allowsCaching() const { return m_options.cachingPolicy() == CachingPolicy::AllowCaching; }
</ins><span class="cx"> 
</span><span class="cx">     void setInitiator(DocumentLoader&amp;);
</span><span class="cx">     DocumentLoader* initiatingDocumentLoader() const { return m_initiatingDocumentLoader.get(); }
</span></span></pre></div>
<a id="trunkSourceWebCoreloadericonIconLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/icon/IconLoader.cpp (195769 => 195770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/icon/IconLoader.cpp        2016-01-28 19:40:36 UTC (rev 195769)
+++ trunk/Source/WebCore/loader/icon/IconLoader.cpp        2016-01-28 19:52:57 UTC (rev 195770)
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     // ContentSecurityPolicyImposition::DoPolicyCheck is a placeholder value. It does not affect the request since Content Security Policy does not apply to raw resources.
</span><del>-    CachedResourceRequest request(ResourceRequest(m_frame.loader().icon().url()), ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForAnyCredentials, ClientDidNotRequestCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading));
</del><ins>+    CachedResourceRequest request(ResourceRequest(m_frame.loader().icon().url()), ResourceLoaderOptions(SendCallbacks, SniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForAnyCredentials, ClientDidNotRequestCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::AllowCaching));
</ins><span class="cx"> 
</span><span class="cx">     request.mutableResourceRequest().setPriority(ResourceLoadPriority::Low);
</span><span class="cx">     request.setInitiator(cachedResourceRequestInitiators().icon);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcWebCoreAVFResourceLoadermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm (195769 => 195770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm        2016-01-28 19:40:36 UTC (rev 195769)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm        2016-01-28 19:52:57 UTC (rev 195770)
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx">     NSURLRequest *nsRequest = [m_avRequest.get() request];
</span><span class="cx"> 
</span><span class="cx">     // ContentSecurityPolicyImposition::DoPolicyCheck is a placeholder value. It does not affect the request since Content Security Policy does not apply to raw resources.
</span><del>-    CachedResourceRequest request(nsRequest, ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, ClientDidNotRequestCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading));
</del><ins>+    CachedResourceRequest request(nsRequest, ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, ClientDidNotRequestCredentials, DoSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::DisallowCaching));
</ins><span class="cx"> 
</span><span class="cx">     request.mutableResourceRequest().setPriority(ResourceLoadPriority::Low);
</span><span class="cx">     CachedResourceLoader* loader = m_parent-&gt;player()-&gt;cachedResourceLoader();
</span></span></pre>
</div>
</div>

</body>
</html>