<!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>[179421] trunk/Source</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/179421">179421</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2015-01-30 16:04:36 -0800 (Fri, 30 Jan 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update MemoryCache code to use more references instead of pointers
https://bugs.webkit.org/show_bug.cgi?id=141099
Reviewed by Andreas Kling.
Source/WebKit2:
* WebProcess/ResourceCache/WebResourceCacheManager.cpp:
(WebKit::WebResourceCacheManager::clearCacheForOrigin):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCorehtmlDOMURLcpp">trunk/Source/WebCore/html/DOMURL.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorResourceAgentcpp">trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentLoadercpp">trunk/Source/WebCore/loader/DocumentLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderSubresourceLoadercpp">trunk/Source/WebCore/loader/SubresourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedImagecpp">trunk/Source/WebCore/loader/cache/CachedImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourcecpp">trunk/Source/WebCore/loader/cache/CachedResource.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceHandleh">trunk/Source/WebCore/loader/cache/CachedResourceHandle.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceLoadercpp">trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceLoaderh">trunk/Source/WebCore/loader/cache/CachedResourceLoader.h</a></li>
<li><a href="#trunkSourceWebCoreloadercacheMemoryCachecpp">trunk/Source/WebCore/loader/cache/MemoryCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheMemoryCacheh">trunk/Source/WebCore/loader/cache/MemoryCache.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsMaskImageOperationcpp">trunk/Source/WebCore/platform/graphics/MaskImageOperation.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessResourceCacheWebResourceCacheManagercpp">trunk/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/ChangeLog        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -1,3 +1,10 @@
</span><ins>+2015-01-30 Chris Dumez <cdumez@apple.com>
+
+ Update MemoryCache code to use more references instead of pointers
+ https://bugs.webkit.org/show_bug.cgi?id=141099
+
+ Reviewed by Andreas Kling.
+
</ins><span class="cx"> 2015-01-30 Brian J. Burg <burg@cs.washington.edu>
</span><span class="cx">
</span><span class="cx"> Web Inspector: ASSERT in InspectorTimelineAgent::internalStop
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/WebCore.exp.in        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -196,7 +196,7 @@
</span><span class="cx"> __ZN7WebCore11MemoryCache18resourceForRequestERKNS_15ResourceRequestENS_9SessionIDE
</span><span class="cx"> __ZN7WebCore11MemoryCache19getOriginsWithCacheERN3WTF7HashSetINS1_6RefPtrINS_14SecurityOriginEEENS_18SecurityOriginHashENS1_10HashTraitsIS5_EEEE
</span><span class="cx"> __ZN7WebCore11MemoryCache20removeImageFromCacheERKNS_3URLERKN3WTF6StringE
</span><del>-__ZN7WebCore11MemoryCache25removeResourcesWithOriginEPNS_14SecurityOriginE
</del><ins>+__ZN7WebCore11MemoryCache25removeResourcesWithOriginERNS_14SecurityOriginE
</ins><span class="cx"> __ZN7WebCore11PageOverlay15setNeedsDisplayERKNS_7IntRectE
</span><span class="cx"> __ZN7WebCore11PageOverlay15setNeedsDisplayEv
</span><span class="cx"> __ZN7WebCore11PageOverlay20stopFadeOutAnimationEv
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlDOMURLcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/DOMURL.cpp (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/DOMURL.cpp        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/html/DOMURL.cpp        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -118,7 +118,7 @@
</span><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> request.setDomainForCachePartition(scriptExecutionContext->topOrigin()->domainForCachePartition());
</span><span class="cx"> #endif
</span><del>- MemoryCache::removeRequestFromSessionCaches(scriptExecutionContext, request);
</del><ins>+ MemoryCache::removeRequestFromSessionCaches(*scriptExecutionContext, request);
</ins><span class="cx">
</span><span class="cx"> scriptExecutionContext->publicURLManager().revoke(url);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorResourceAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -710,7 +710,7 @@
</span><span class="cx">
</span><span class="cx"> CachedResource* cachedResource = memoryCache().resourceForRequest(request, m_pageAgent->page()->sessionID());
</span><span class="cx"> if (cachedResource)
</span><del>- memoryCache().remove(cachedResource);
</del><ins>+ memoryCache().remove(*cachedResource);
</ins><span class="cx">
</span><span class="cx"> xhr->open(xhrReplayData->method(), xhrReplayData->url(), xhrReplayData->async(), IGNORE_EXCEPTION);
</span><span class="cx"> for (const auto& header : xhrReplayData->headers())
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentLoader.cpp        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -448,7 +448,7 @@
</span><span class="cx"> // and deny the appcache the chance to intercept it in the future, so remove from the memory cache.
</span><span class="cx"> if (m_frame) {
</span><span class="cx"> if (m_mainResource && m_frame->document()->hasManifest())
</span><del>- memoryCache().remove(m_mainResource.get());
</del><ins>+ memoryCache().remove(*m_mainResource);
</ins><span class="cx"> }
</span><span class="cx"> m_applicationCacheHost->finishedLoadingMainResource();
</span><span class="cx"> }
</span><span class="lines">@@ -599,7 +599,7 @@
</span><span class="cx"> // The memory cache doesn't understand the application cache or its caching rules. So if a main resource is served
</span><span class="cx"> // from the application cache, ensure we don't save the result for future use.
</span><span class="cx"> if (willLoadFallback)
</span><del>- memoryCache().remove(m_mainResource.get());
</del><ins>+ memoryCache().remove(*m_mainResource);
</ins><span class="cx">
</span><span class="cx"> if (willLoadFallback)
</span><span class="cx"> return;
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderSubresourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/SubresourceLoader.cpp        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -159,7 +159,7 @@
</span><span class="cx"> // Doing so would have us reusing the resource from the first request if the second request's revalidation succeeds.
</span><span class="cx"> if (newRequest.isConditional() && m_resource->resourceToRevalidate() && newRequest.url() != m_resource->resourceToRevalidate()->response().url()) {
</span><span class="cx"> newRequest.makeUnconditional();
</span><del>- memoryCache().revalidationFailed(m_resource);
</del><ins>+ memoryCache().revalidationFailed(*m_resource);
</ins><span class="cx"> if (m_frame)
</span><span class="cx"> m_frame->mainFrame().diagnosticLoggingClient().logDiagnosticMessageWithResult(DiagnosticLoggingKeys::cachedResourceRevalidationKey(), emptyString(), DiagnosticLoggingResultFail);
</span><span class="cx"> }
</span><span class="lines">@@ -207,7 +207,7 @@
</span><span class="cx"> // 304 Not modified / Use local copy
</span><span class="cx"> // Existing resource is ok, just use it updating the expiration time.
</span><span class="cx"> m_resource->setResponse(response);
</span><del>- memoryCache().revalidationSucceeded(m_resource, response);
</del><ins>+ memoryCache().revalidationSucceeded(*m_resource, response);
</ins><span class="cx"> if (m_frame)
</span><span class="cx"> m_frame->mainFrame().diagnosticLoggingClient().logDiagnosticMessageWithResult(DiagnosticLoggingKeys::cachedResourceRevalidationKey(), emptyString(), DiagnosticLoggingResultPass);
</span><span class="cx"> if (!reachedTerminalState())
</span><span class="lines">@@ -215,7 +215,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx"> // Did not get 304 response, continue as a regular resource load.
</span><del>- memoryCache().revalidationFailed(m_resource);
</del><ins>+ memoryCache().revalidationFailed(*m_resource);
</ins><span class="cx"> if (m_frame)
</span><span class="cx"> m_frame->mainFrame().diagnosticLoggingClient().logDiagnosticMessageWithResult(DiagnosticLoggingKeys::cachedResourceRevalidationKey(), emptyString(), DiagnosticLoggingResultFail);
</span><span class="cx"> }
</span><span class="lines">@@ -385,10 +385,10 @@
</span><span class="cx"> CachedResourceHandle<CachedResource> protectResource(m_resource);
</span><span class="cx"> m_state = Finishing;
</span><span class="cx"> if (m_resource->resourceToRevalidate())
</span><del>- memoryCache().revalidationFailed(m_resource);
</del><ins>+ memoryCache().revalidationFailed(*m_resource);
</ins><span class="cx"> m_resource->setResourceError(error);
</span><span class="cx"> if (!m_resource->isPreloaded())
</span><del>- memoryCache().remove(m_resource);
</del><ins>+ memoryCache().remove(*m_resource);
</ins><span class="cx"> m_resource->error(CachedResource::LoadError);
</span><span class="cx"> cleanupForError(error);
</span><span class="cx"> notifyDone();
</span><span class="lines">@@ -418,9 +418,9 @@
</span><span class="cx"> m_state = Finishing;
</span><span class="cx"> #endif
</span><span class="cx"> if (m_resource->resourceToRevalidate())
</span><del>- memoryCache().revalidationFailed(m_resource);
</del><ins>+ memoryCache().revalidationFailed(*m_resource);
</ins><span class="cx"> m_resource->setResourceError(error);
</span><del>- memoryCache().remove(m_resource);
</del><ins>+ memoryCache().remove(*m_resource);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void SubresourceLoader::didCancel(const ResourceError&)
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedImage.cpp (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedImage.cpp        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/loader/cache/CachedImage.cpp        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -381,7 +381,7 @@
</span><span class="cx"> // Image decoding failed. Either we need more image data or the image data is malformed.
</span><span class="cx"> error(errorOccurred() ? status() : DecodeError);
</span><span class="cx"> if (inCache())
</span><del>- memoryCache().remove(this);
</del><ins>+ memoryCache().remove(*this);
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -422,7 +422,7 @@
</span><span class="cx"> // Image decoding failed; the image data is malformed.
</span><span class="cx"> error(errorOccurred() ? status() : DecodeError);
</span><span class="cx"> if (inCache())
</span><del>- memoryCache().remove(this);
</del><ins>+ memoryCache().remove(*this);
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResource.cpp        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -170,7 +170,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> if (m_owningCachedResourceLoader)
</span><del>- m_owningCachedResourceLoader->removeCachedResource(this);
</del><ins>+ m_owningCachedResourceLoader->removeCachedResource(*this);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void CachedResource::failBeforeStarting()
</span><span class="lines">@@ -178,7 +178,7 @@
</span><span class="cx"> // FIXME: What if resources in other frames were waiting for this revalidation?
</span><span class="cx"> LOG(ResourceLoading, "Cannot start loading '%s'", url().string().latin1().data());
</span><span class="cx"> if (m_resourceToRevalidate)
</span><del>- memoryCache().revalidationFailed(this);
</del><ins>+ memoryCache().revalidationFailed(*this);
</ins><span class="cx"> error(CachedResource::LoadError);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -415,7 +415,7 @@
</span><span class="cx"> m_preloadResult = PreloadReferenced;
</span><span class="cx"> }
</span><span class="cx"> if (!hasClients() && inCache())
</span><del>- memoryCache().addToLiveResourcesSize(this);
</del><ins>+ memoryCache().addToLiveResourcesSize(*this);
</ins><span class="cx">
</span><span class="cx"> if ((m_type == RawResource || m_type == MainResource) && !m_response.isNull() && !m_proxyResource) {
</span><span class="cx"> // Certain resources (especially XHRs and main resources) do crazy things if an asynchronous load returns
</span><span class="lines">@@ -447,8 +447,8 @@
</span><span class="cx"> bool deleted = deleteIfPossible();
</span><span class="cx"> if (!deleted && !hasClients()) {
</span><span class="cx"> if (inCache()) {
</span><del>- memoryCache().removeFromLiveResourcesSize(this);
- memoryCache().removeFromLiveDecodedResourcesList(this);
</del><ins>+ memoryCache().removeFromLiveResourcesSize(*this);
+ memoryCache().removeFromLiveDecodedResourcesList(*this);
</ins><span class="cx"> }
</span><span class="cx"> if (!m_switchingClientsToRevalidatedResource)
</span><span class="cx"> allClientsRemoved();
</span><span class="lines">@@ -458,7 +458,7 @@
</span><span class="cx"> // "no-store: ... MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible"
</span><span class="cx"> // "... History buffers MAY store such responses as part of their normal operation."
</span><span class="cx"> // We allow non-secure content to be reused in history, but we do not allow secure content to be reused.
</span><del>- memoryCache().remove(this);
</del><ins>+ memoryCache().remove(*this);
</ins><span class="cx"> }
</span><span class="cx"> memoryCache().prune();
</span><span class="cx"> }
</span><span class="lines">@@ -499,13 +499,13 @@
</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><span class="cx"> if (inCache())
</span><del>- memoryCache().removeFromLRUList(this);
</del><ins>+ memoryCache().removeFromLRUList(*this);
</ins><span class="cx">
</span><span class="cx"> m_decodedSize = size;
</span><span class="cx">
</span><span class="cx"> if (inCache()) {
</span><span class="cx"> // Now insert into the new LRU list.
</span><del>- memoryCache().insertInLRUList(this);
</del><ins>+ memoryCache().insertInLRUList(*this);
</ins><span class="cx">
</span><span class="cx"> // Insert into or remove from the live decoded list if necessary.
</span><span class="cx"> // When inserting into the LiveDecodedResourcesList it is possible
</span><span class="lines">@@ -516,9 +516,9 @@
</span><span class="cx"> // a problem. For more details please see: https://bugs.webkit.org/show_bug.cgi?id=30209
</span><span class="cx"> bool inLiveDecodedResourcesList = memoryCache().inLiveDecodedResourcesList(*this);
</span><span class="cx"> if (m_decodedSize && !inLiveDecodedResourcesList && hasClients())
</span><del>- memoryCache().insertInLiveDecodedResourcesList(this);
</del><ins>+ memoryCache().insertInLiveDecodedResourcesList(*this);
</ins><span class="cx"> else if (!m_decodedSize && inLiveDecodedResourcesList)
</span><del>- memoryCache().removeFromLiveDecodedResourcesList(this);
</del><ins>+ memoryCache().removeFromLiveDecodedResourcesList(*this);
</ins><span class="cx">
</span><span class="cx"> // Update the cache's size totals.
</span><span class="cx"> memoryCache().adjustSize(hasClients(), delta);
</span><span class="lines">@@ -535,12 +535,12 @@
</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><span class="cx"> if (inCache())
</span><del>- memoryCache().removeFromLRUList(this);
</del><ins>+ memoryCache().removeFromLRUList(*this);
</ins><span class="cx">
</span><span class="cx"> m_encodedSize = size;
</span><span class="cx">
</span><span class="cx"> if (inCache()) {
</span><del>- memoryCache().insertInLRUList(this);
</del><ins>+ memoryCache().insertInLRUList(*this);
</ins><span class="cx"> memoryCache().adjustSize(hasClients(), delta);
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -551,8 +551,8 @@
</span><span class="cx">
</span><span class="cx"> if (inCache()) {
</span><span class="cx"> if (memoryCache().inLiveDecodedResourcesList(*this)) {
</span><del>- memoryCache().removeFromLiveDecodedResourcesList(this);
- memoryCache().insertInLiveDecodedResourcesList(this);
</del><ins>+ memoryCache().removeFromLiveDecodedResourcesList(*this);
+ memoryCache().insertInLiveDecodedResourcesList(*this);
</ins><span class="cx"> }
</span><span class="cx"> memoryCache().prune();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceHandleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceHandle.h (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceHandle.h        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/loader/cache/CachedResourceHandle.h        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -68,6 +68,7 @@
</span><span class="cx">
</span><span class="cx"> R* get() const { return reinterpret_cast<R*>(CachedResourceHandleBase::get()); }
</span><span class="cx"> R* operator->() const { return get(); }
</span><ins>+ R& operator*() const { ASSERT(get()); return *get(); }
</ins><span class="cx">
</span><span class="cx"> CachedResourceHandle& operator=(R* res) { setResource(res); return *this; }
</span><span class="cx"> CachedResourceHandle& operator=(const CachedResourceHandle& o) { setResource(o.get()); return *this; }
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -218,14 +218,14 @@
</span><span class="cx"> if (CachedResource* existing = memoryCache().resourceForRequest(request.resourceRequest(), sessionID())) {
</span><span class="cx"> if (is<CachedCSSStyleSheet>(*existing))
</span><span class="cx"> return downcast<CachedCSSStyleSheet>(existing);
</span><del>- memoryCache().remove(existing);
</del><ins>+ memoryCache().remove(*existing);
</ins><span class="cx"> }
</span><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<CachedCSSStyleSheet> userSheet = new CachedCSSStyleSheet(request.resourceRequest(), request.charset(), sessionID());
</span><span class="cx">
</span><del>- memoryCache().add(userSheet.get());
</del><ins>+ 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><span class="cx"> userSheet->load(*this, ResourceLoaderOptions(DoNotSendCallbacks, SniffContent, BufferData, AllowStoredCredentials, AskClientForAllCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType, DoNotIncludeCertificateInfo));
</span><span class="lines">@@ -489,7 +489,7 @@
</span><span class="cx"> const RevalidationPolicy policy = determineRevalidationPolicy(type, request.mutableResourceRequest(), request.forPreload(), resource.get(), request.defer());
</span><span class="cx"> switch (policy) {
</span><span class="cx"> case Reload:
</span><del>- memoryCache().remove(resource.get());
</del><ins>+ memoryCache().remove(*resource);
</ins><span class="cx"> FALLTHROUGH;
</span><span class="cx"> case Load:
</span><span class="cx"> if (resource)
</span><span class="lines">@@ -505,7 +505,7 @@
</span><span class="cx"> if (!shouldContinueAfterNotifyingLoadedFromMemoryCache(request, resource.get()))
</span><span class="cx"> return nullptr;
</span><span class="cx"> logMemoryCacheResourceRequest(frame(), DiagnosticLoggingKeys::inMemoryCacheKey(), DiagnosticLoggingKeys::usedKey());
</span><del>- memoryCache().resourceAccessed(resource.get());
</del><ins>+ memoryCache().resourceAccessed(*resource);
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -521,7 +521,7 @@
</span><span class="cx"> // We don't support immediate loads, but we do support immediate failure.
</span><span class="cx"> if (resource->errorOccurred()) {
</span><span class="cx"> if (resource->inCache())
</span><del>- memoryCache().remove(resource.get());
</del><ins>+ memoryCache().remove(*resource);
</ins><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -555,8 +555,8 @@
</span><span class="cx"> LOG(ResourceLoading, "Resource %p created to revalidate %p", newResource.get(), resource);
</span><span class="cx"> newResource->setResourceToRevalidate(resource);
</span><span class="cx">
</span><del>- memoryCache().remove(resource);
- memoryCache().add(newResource.get());
</del><ins>+ memoryCache().remove(*resource);
+ memoryCache().add(*newResource);
</ins><span class="cx"> #if ENABLE(RESOURCE_TIMING)
</span><span class="cx"> storeResourceTimingInitiatorInformation(resource, request);
</span><span class="cx"> #else
</span><span class="lines">@@ -573,7 +573,7 @@
</span><span class="cx">
</span><span class="cx"> CachedResourceHandle<CachedResource> resource = createResource(type, request.mutableResourceRequest(), request.charset(), sessionID());
</span><span class="cx">
</span><del>- if (!memoryCache().add(resource.get()))
</del><ins>+ if (!memoryCache().add(*resource))
</ins><span class="cx"> resource->setOwningCachedResourceLoader(this);
</span><span class="cx"> #if ENABLE(RESOURCE_TIMING)
</span><span class="cx"> storeResourceTimingInitiatorInformation(resource, request);
</span><span class="lines">@@ -789,22 +789,22 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void CachedResourceLoader::removeCachedResource(CachedResource* resource) const
</del><ins>+void CachedResourceLoader::removeCachedResource(CachedResource& resource)
</ins><span class="cx"> {
</span><span class="cx"> #ifndef NDEBUG
</span><del>- DocumentResourceMap::iterator it = m_documentResources.find(resource->url());
</del><ins>+ DocumentResourceMap::iterator it = m_documentResources.find(resource.url());
</ins><span class="cx"> if (it != m_documentResources.end())
</span><del>- ASSERT(it->value.get() == resource);
</del><ins>+ ASSERT(it->value.get() == &resource);
</ins><span class="cx"> #endif
</span><del>- m_documentResources.remove(resource->url());
</del><ins>+ m_documentResources.remove(resource.url());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void CachedResourceLoader::addCachedResource(CachedResource* resource)
</del><ins>+void CachedResourceLoader::addCachedResource(CachedResource& resource)
</ins><span class="cx"> {
</span><del>- m_documentResources.set(resource->url(), resource);
</del><ins>+ m_documentResources.set(resource.url(), &resource);
</ins><span class="cx">
</span><span class="cx"> if (!memoryCache().add(resource))
</span><del>- resource->setOwningCachedResourceLoader(this);
</del><ins>+ resource.setOwningCachedResourceLoader(this);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void CachedResourceLoader::loadDone(CachedResource* resource, bool shouldPerformPostLoadActions)
</span><span class="lines">@@ -985,13 +985,11 @@
</span><span class="cx"> if (!m_preloads)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- ListHashSet<CachedResource*>::iterator end = m_preloads->end();
- for (ListHashSet<CachedResource*>::iterator it = m_preloads->begin(); it != end; ++it) {
- CachedResource* res = *it;
- res->decreasePreloadCount();
- bool deleted = res->deleteIfPossible();
- if (!deleted && res->preloadResult() == CachedResource::PreloadNotReferenced)
- memoryCache().remove(res);
</del><ins>+ for (auto* resource : *m_preloads) {
+ resource->decreasePreloadCount();
+ bool deleted = resource->deleteIfPossible();
+ if (!deleted && resource->preloadResult() == CachedResource::PreloadNotReferenced)
+ memoryCache().remove(*resource);
</ins><span class="cx"> }
</span><span class="cx"> m_preloads = nullptr;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -113,8 +113,8 @@
</span><span class="cx"> void clearDocumentLoader() { m_documentLoader = 0; }
</span><span class="cx"> SessionID sessionID() const;
</span><span class="cx">
</span><del>- void removeCachedResource(CachedResource*) const;
- void addCachedResource(CachedResource*);
</del><ins>+ void removeCachedResource(CachedResource&);
+ void addCachedResource(CachedResource&);
</ins><span class="cx">
</span><span class="cx"> void loadDone(CachedResource*, bool shouldPerformPostLoadActions = true);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheMemoryCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/MemoryCache.cpp (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/MemoryCache.cpp        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.cpp        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -99,81 +99,82 @@
</span><span class="cx"> return url;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool MemoryCache::add(CachedResource* resource)
</del><ins>+bool MemoryCache::add(CachedResource& resource)
</ins><span class="cx"> {
</span><span class="cx"> if (disabled())
</span><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> ASSERT(WTF::isMainThread());
</span><span class="cx">
</span><del>- CachedResourceMap& resources = getSessionMap(resource->sessionID());
</del><ins>+ CachedResourceMap& resources = getSessionMap(resource.sessionID());
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><del>- CachedResourceItem* originMap = resources.get(resource->url());
</del><ins>+ CachedResourceItem* originMap = resources.get(resource.url());
</ins><span class="cx"> if (!originMap) {
</span><span class="cx"> originMap = new CachedResourceItem;
</span><del>- resources.set(resource->url(), adoptPtr(originMap));
</del><ins>+ resources.set(resource.url(), adoptPtr(originMap));
</ins><span class="cx"> }
</span><del>- originMap->set(resource->cachePartition(), resource);
</del><ins>+ originMap->set(resource.cachePartition(), &resource);
</ins><span class="cx"> #else
</span><del>- resources.set(resource->url(), resource);
</del><ins>+ resources.set(resource.url(), &resource);
</ins><span class="cx"> #endif
</span><del>- resource->setInCache(true);
</del><ins>+ resource.setInCache(true);
</ins><span class="cx">
</span><span class="cx"> resourceAccessed(resource);
</span><span class="cx">
</span><del>- LOG(ResourceLoading, "MemoryCache::add Added '%s', resource %p\n", resource->url().string().latin1().data(), resource);
</del><ins>+ LOG(ResourceLoading, "MemoryCache::add Added '%s', resource %p\n", resource.url().string().latin1().data(), &resource);
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::revalidationSucceeded(CachedResource* revalidatingResource, const ResourceResponse& response)
</del><ins>+// FIXME: This should take a reference.
+void MemoryCache::revalidationSucceeded(CachedResource& revalidatingResource, const ResourceResponse& response)
</ins><span class="cx"> {
</span><del>- CachedResource* resource = revalidatingResource->resourceToRevalidate();
- ASSERT(resource);
- ASSERT(!resource->inCache());
- ASSERT(resource->isLoaded());
- ASSERT(revalidatingResource->inCache());
</del><ins>+ ASSERT(revalidatingResource.resourceToRevalidate());
+ CachedResource& resource = *revalidatingResource.resourceToRevalidate();
+ ASSERT(!resource.inCache());
+ ASSERT(resource.isLoaded());
+ ASSERT(revalidatingResource.inCache());
</ins><span class="cx">
</span><span class="cx"> // Calling remove() can potentially delete revalidatingResource, which we use
</span><span class="cx"> // below. This mustn't be the case since revalidation means it is loaded
</span><span class="cx"> // and so canDelete() is false.
</span><del>- ASSERT(!revalidatingResource->canDelete());
</del><ins>+ ASSERT(!revalidatingResource.canDelete());
</ins><span class="cx">
</span><span class="cx"> remove(revalidatingResource);
</span><span class="cx">
</span><del>- CachedResourceMap& resources = getSessionMap(resource->sessionID());
</del><ins>+ CachedResourceMap& resources = getSessionMap(resource.sessionID());
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><del>- ASSERT(!resources.get(resource->url()) || !resources.get(resource->url())->get(resource->cachePartition()));
- CachedResourceItem* originMap = resources.get(resource->url());
</del><ins>+ ASSERT(!resources.get(resource.url()) || !resources.get(resource.url())->get(resource.cachePartition()));
+ CachedResourceItem* originMap = resources.get(resource.url());
</ins><span class="cx"> if (!originMap) {
</span><span class="cx"> originMap = new CachedResourceItem;
</span><del>- resources.set(resource->url(), adoptPtr(originMap));
</del><ins>+ resources.set(resource.url(), adoptPtr(originMap));
</ins><span class="cx"> }
</span><del>- originMap->set(resource->cachePartition(), resource);
</del><ins>+ originMap->set(resource.cachePartition(), &resource);
</ins><span class="cx"> #else
</span><del>- ASSERT(!resources.get(resource->url()));
- resources.set(resource->url(), resource);
</del><ins>+ ASSERT(!resources.get(resource.url()));
+ resources.set(resource.url(), &resource);
</ins><span class="cx"> #endif
</span><del>- resource->setInCache(true);
- resource->updateResponseAfterRevalidation(response);
</del><ins>+ resource.setInCache(true);
+ resource.updateResponseAfterRevalidation(response);
</ins><span class="cx"> insertInLRUList(resource);
</span><del>- int delta = resource->size();
- if (resource->decodedSize() && resource->hasClients())
</del><ins>+ int delta = resource.size();
+ if (resource.decodedSize() && resource.hasClients())
</ins><span class="cx"> insertInLiveDecodedResourcesList(resource);
</span><span class="cx"> if (delta)
</span><del>- adjustSize(resource->hasClients(), delta);
</del><ins>+ adjustSize(resource.hasClients(), delta);
</ins><span class="cx">
</span><del>- revalidatingResource->switchClientsToRevalidatedResource();
- ASSERT(!revalidatingResource->m_deleted);
</del><ins>+ revalidatingResource.switchClientsToRevalidatedResource();
+ ASSERT(!revalidatingResource.m_deleted);
</ins><span class="cx"> // this deletes the revalidating resource
</span><del>- revalidatingResource->clearResourceToRevalidate();
</del><ins>+ revalidatingResource.clearResourceToRevalidate();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::revalidationFailed(CachedResource* revalidatingResource)
</del><ins>+void MemoryCache::revalidationFailed(CachedResource& revalidatingResource)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(WTF::isMainThread());
</span><del>- LOG(ResourceLoading, "Revalidation failed for %p", revalidatingResource);
- ASSERT(revalidatingResource->resourceToRevalidate());
- revalidatingResource->clearResourceToRevalidate();
</del><ins>+ LOG(ResourceLoading, "Revalidation failed for %p", &revalidatingResource);
+ ASSERT(revalidatingResource.resourceToRevalidate());
+ revalidatingResource.clearResourceToRevalidate();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> CachedResource* MemoryCache::resourceForURL(const URL& resourceURL, SessionID sessionID)
</span><span class="lines">@@ -193,7 +194,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> CachedResourceItem* item = resources.get(url);
</span><del>- CachedResource* resource = 0;
</del><ins>+ CachedResource* resource = nullptr;
</ins><span class="cx"> if (item)
</span><span class="cx"> resource = item->get(request.cachePartition());
</span><span class="cx"> #else
</span><span class="lines">@@ -245,7 +246,7 @@
</span><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> cachedImage->resourceRequest().setDomainForCachePartition(domainForCachePartition);
</span><span class="cx"> #endif
</span><del>- return add(cachedImage.release());
</del><ins>+ return add(*cachedImage.release());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void MemoryCache::removeImageFromCache(const URL& url, const String& domainForCachePartition)
</span><span class="lines">@@ -266,7 +267,7 @@
</span><span class="cx">
</span><span class="cx"> // A resource exists and is not a manually cached image, so just remove it.
</span><span class="cx"> if (!is<CachedImage>(*resource) || !downcast<CachedImage>(*resource).isManuallyCached()) {
</span><del>- remove(resource);
</del><ins>+ remove(*resource);
</ins><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -383,7 +384,7 @@
</span><span class="cx"> CachedResourceHandle<CachedResource> previous = current->m_prevInAllResourcesList;
</span><span class="cx"> ASSERT(!previous || previous->inCache());
</span><span class="cx"> if (!current->hasClients() && !current->isPreloaded() && !current->isCacheValidator()) {
</span><del>- remove(current);
</del><ins>+ remove(*current);
</ins><span class="cx"> if (targetSize && m_deadSize <= targetSize)
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -411,73 +412,73 @@
</span><span class="cx"> prune();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::remove(CachedResource* resource)
</del><ins>+void MemoryCache::remove(CachedResource& resource)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(WTF::isMainThread());
</span><del>- LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", resource, resource->url().string().latin1().data());
</del><ins>+ LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", &resource, resource.url().string().latin1().data());
</ins><span class="cx"> // The resource may have already been removed by someone other than our caller,
</span><span class="cx"> // who needed a fresh copy for a reload. See <http://bugs.webkit.org/show_bug.cgi?id=12479#c6>.
</span><del>- CachedResourceMap& resources = getSessionMap(resource->sessionID());
- if (resource->inCache()) {
</del><ins>+ CachedResourceMap& resources = getSessionMap(resource.sessionID());
+ if (resource.inCache()) {
</ins><span class="cx"> // Remove from the resource map.
</span><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><del>- CachedResourceItem* item = resources.get(resource->url());
</del><ins>+ CachedResourceItem* item = resources.get(resource.url());
</ins><span class="cx"> if (item) {
</span><del>- item->remove(resource->cachePartition());
</del><ins>+ item->remove(resource.cachePartition());
</ins><span class="cx"> if (!item->size())
</span><del>- resources.remove(resource->url());
</del><ins>+ resources.remove(resource.url());
</ins><span class="cx"> }
</span><span class="cx"> #else
</span><del>- resources.remove(resource->url());
</del><ins>+ resources.remove(resource.url());
</ins><span class="cx"> #endif
</span><del>- resource->setInCache(false);
</del><ins>+ resource.setInCache(false);
</ins><span class="cx">
</span><span class="cx"> // Remove from the appropriate LRU list.
</span><span class="cx"> removeFromLRUList(resource);
</span><span class="cx"> removeFromLiveDecodedResourcesList(resource);
</span><del>- adjustSize(resource->hasClients(), -static_cast<int>(resource->size()));
</del><ins>+ adjustSize(resource.hasClients(), -static_cast<int>(resource.size()));
</ins><span class="cx"> } else
</span><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><del>- ASSERT(!resources.get(resource->url()) || resources.get(resource->url())->get(resource->cachePartition()) != resource);
</del><ins>+ ASSERT(!resources.get(resource.url()) || resources.get(resource.url())->get(resource.cachePartition()) != &resource);
</ins><span class="cx"> #else
</span><del>- ASSERT(resources.get(resource->url()) != resource);
</del><ins>+ ASSERT(resources.get(resource.url()) != &resource);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- resource->deleteIfPossible();
</del><ins>+ resource.deleteIfPossible();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-MemoryCache::LRUList* MemoryCache::lruListFor(CachedResource* resource)
</del><ins>+MemoryCache::LRUList* MemoryCache::lruListFor(CachedResource& resource)
</ins><span class="cx"> {
</span><del>- unsigned accessCount = std::max(resource->accessCount(), 1U);
- unsigned queueIndex = WTF::fastLog2(resource->size() / accessCount);
</del><ins>+ unsigned accessCount = std::max(resource.accessCount(), 1U);
+ unsigned queueIndex = WTF::fastLog2(resource.size() / accessCount);
</ins><span class="cx"> #ifndef NDEBUG
</span><del>- resource->m_lruIndex = queueIndex;
</del><ins>+ resource.m_lruIndex = queueIndex;
</ins><span class="cx"> #endif
</span><span class="cx"> if (m_allResources.size() <= queueIndex)
</span><span class="cx"> m_allResources.grow(queueIndex + 1);
</span><span class="cx"> return &m_allResources[queueIndex];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::removeFromLRUList(CachedResource* resource)
</del><ins>+void MemoryCache::removeFromLRUList(CachedResource& resource)
</ins><span class="cx"> {
</span><span class="cx"> // If we've never been accessed, then we're brand new and not in any list.
</span><del>- if (resource->accessCount() == 0)
</del><ins>+ if (!resource.accessCount())
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> #if !ASSERT_DISABLED
</span><del>- unsigned oldListIndex = resource->m_lruIndex;
</del><ins>+ unsigned oldListIndex = resource.m_lruIndex;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> LRUList* list = lruListFor(resource);
</span><span class="cx">
</span><span class="cx"> #if !ASSERT_DISABLED
</span><span class="cx"> // Verify that the list we got is the list we want.
</span><del>- ASSERT(resource->m_lruIndex == oldListIndex);
</del><ins>+ ASSERT(resource.m_lruIndex == oldListIndex);
</ins><span class="cx">
</span><span class="cx"> // Verify that we are in fact in this list.
</span><span class="cx"> bool found = false;
</span><span class="cx"> for (CachedResource* current = list->m_head; current; current = current->m_nextInAllResourcesList) {
</span><del>- if (current == resource) {
</del><ins>+ if (current == &resource) {
</ins><span class="cx"> found = true;
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="lines">@@ -485,49 +486,49 @@
</span><span class="cx"> ASSERT(found);
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- CachedResource* next = resource->m_nextInAllResourcesList;
- CachedResource* prev = resource->m_prevInAllResourcesList;
</del><ins>+ CachedResource* next = resource.m_nextInAllResourcesList;
+ CachedResource* prev = resource.m_prevInAllResourcesList;
</ins><span class="cx">
</span><del>- if (next == 0 && prev == 0 && list->m_head != resource)
</del><ins>+ if (!next && !prev && list->m_head != &resource)
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- resource->m_nextInAllResourcesList = 0;
- resource->m_prevInAllResourcesList = 0;
</del><ins>+ resource.m_nextInAllResourcesList = nullptr;
+ resource.m_prevInAllResourcesList = nullptr;
</ins><span class="cx">
</span><span class="cx"> if (next)
</span><span class="cx"> next->m_prevInAllResourcesList = prev;
</span><del>- else if (list->m_tail == resource)
</del><ins>+ else if (list->m_tail == &resource)
</ins><span class="cx"> list->m_tail = prev;
</span><span class="cx">
</span><span class="cx"> if (prev)
</span><span class="cx"> prev->m_nextInAllResourcesList = next;
</span><del>- else if (list->m_head == resource)
</del><ins>+ else if (list->m_head == &resource)
</ins><span class="cx"> list->m_head = next;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::insertInLRUList(CachedResource* resource)
</del><ins>+void MemoryCache::insertInLRUList(CachedResource& resource)
</ins><span class="cx"> {
</span><span class="cx"> // Make sure we aren't in some list already.
</span><del>- ASSERT(!resource->m_nextInAllResourcesList && !resource->m_prevInAllResourcesList);
- ASSERT(resource->inCache());
- ASSERT(resource->accessCount() > 0);
</del><ins>+ ASSERT(!resource.m_nextInAllResourcesList && !resource.m_prevInAllResourcesList);
+ ASSERT(resource.inCache());
+ ASSERT(resource.accessCount() > 0);
</ins><span class="cx">
</span><span class="cx"> LRUList* list = lruListFor(resource);
</span><span class="cx">
</span><del>- resource->m_nextInAllResourcesList = list->m_head;
</del><ins>+ resource.m_nextInAllResourcesList = list->m_head;
</ins><span class="cx"> if (list->m_head)
</span><del>- list->m_head->m_prevInAllResourcesList = resource;
- list->m_head = resource;
</del><ins>+ list->m_head->m_prevInAllResourcesList = &resource;
+ list->m_head = &resource;
</ins><span class="cx">
</span><del>- if (!resource->m_nextInAllResourcesList)
- list->m_tail = resource;
</del><ins>+ if (!resource.m_nextInAllResourcesList)
+ list->m_tail = &resource;
</ins><span class="cx">
</span><span class="cx"> #if !ASSERT_DISABLED
</span><span class="cx"> // Verify that we are in now in the list like we should be.
</span><span class="cx"> list = lruListFor(resource);
</span><span class="cx"> bool found = false;
</span><span class="cx"> for (CachedResource* current = list->m_head; current; current = current->m_nextInAllResourcesList) {
</span><del>- if (current == resource) {
</del><ins>+ if (current == &resource) {
</ins><span class="cx"> found = true;
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="lines">@@ -537,33 +538,33 @@
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::resourceAccessed(CachedResource* resource)
</del><ins>+void MemoryCache::resourceAccessed(CachedResource& resource)
</ins><span class="cx"> {
</span><del>- ASSERT(resource->inCache());
</del><ins>+ ASSERT(resource.inCache());
</ins><span class="cx">
</span><span class="cx"> // Need to make sure to remove before we increase the access count, since
</span><span class="cx"> // the queue will possibly change.
</span><span class="cx"> removeFromLRUList(resource);
</span><span class="cx">
</span><span class="cx"> // If this is the first time the resource has been accessed, adjust the size of the cache to account for its initial size.
</span><del>- if (!resource->accessCount())
- adjustSize(resource->hasClients(), resource->size());
</del><ins>+ if (!resource.accessCount())
+ adjustSize(resource.hasClients(), resource.size());
</ins><span class="cx">
</span><span class="cx"> // Add to our access count.
</span><del>- resource->increaseAccessCount();
</del><ins>+ resource.increaseAccessCount();
</ins><span class="cx">
</span><span class="cx"> // Now insert into the new queue.
</span><span class="cx"> insertInLRUList(resource);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::removeResourcesWithOrigin(SecurityOrigin* origin)
</del><ins>+void MemoryCache::removeResourcesWithOrigin(SecurityOrigin& origin)
</ins><span class="cx"> {
</span><span class="cx"> Vector<CachedResource*> resourcesWithOrigin;
</span><span class="cx">
</span><span class="cx"> for (auto& resources : m_sessionResources) {
</span><span class="cx"> CachedResourceMap::iterator e = resources.value->end();
</span><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><del>- String originPartition = ResourceRequest::partitionName(origin->host());
</del><ins>+ String originPartition = ResourceRequest::partitionName(origin.host());
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> for (CachedResourceMap::iterator it = resources.value->begin(); it != e; ++it) {
</span><span class="lines">@@ -581,7 +582,7 @@
</span><span class="cx"> RefPtr<SecurityOrigin> resourceOrigin = SecurityOrigin::createFromString(resource->url());
</span><span class="cx"> if (!resourceOrigin)
</span><span class="cx"> continue;
</span><del>- if (resourceOrigin->equal(origin))
</del><ins>+ if (resourceOrigin->equal(&origin))
</ins><span class="cx"> resourcesWithOrigin.append(resource);
</span><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> }
</span><span class="lines">@@ -589,8 +590,8 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- for (size_t i = 0; i < resourcesWithOrigin.size(); ++i)
- remove(resourcesWithOrigin[i]);
</del><ins>+ for (auto* resource : resourcesWithOrigin)
+ remove(*resource);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void MemoryCache::getOriginsWithCache(SecurityOriginSet& origins)
</span><span class="lines">@@ -613,28 +614,28 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::removeFromLiveDecodedResourcesList(CachedResource* resource)
</del><ins>+void MemoryCache::removeFromLiveDecodedResourcesList(CachedResource& resource)
</ins><span class="cx"> {
</span><del>- m_liveDecodedResources.remove(resource);
</del><ins>+ m_liveDecodedResources.remove(&resource);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::insertInLiveDecodedResourcesList(CachedResource* resource)
</del><ins>+void MemoryCache::insertInLiveDecodedResourcesList(CachedResource& resource)
</ins><span class="cx"> {
</span><span class="cx"> // Make sure we aren't in the list already.
</span><del>- ASSERT(!m_liveDecodedResources.contains(resource));
- m_liveDecodedResources.add(resource);
</del><ins>+ ASSERT(!m_liveDecodedResources.contains(&resource));
+ m_liveDecodedResources.add(&resource);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::addToLiveResourcesSize(CachedResource* resource)
</del><ins>+void MemoryCache::addToLiveResourcesSize(CachedResource& resource)
</ins><span class="cx"> {
</span><del>- m_liveSize += resource->size();
- m_deadSize -= resource->size();
</del><ins>+ m_liveSize += resource.size();
+ m_deadSize -= resource.size();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::removeFromLiveResourcesSize(CachedResource* resource)
</del><ins>+void MemoryCache::removeFromLiveResourcesSize(CachedResource& resource)
</ins><span class="cx"> {
</span><del>- m_liveSize -= resource->size();
- m_deadSize += resource->size();
</del><ins>+ m_liveSize -= resource.size();
+ m_deadSize += resource.size();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void MemoryCache::adjustSize(bool live, int delta)
</span><span class="lines">@@ -648,30 +649,29 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::removeRequestFromSessionCaches(ScriptExecutionContext* context, const ResourceRequest& request)
</del><ins>+void MemoryCache::removeRequestFromSessionCaches(ScriptExecutionContext& context, const ResourceRequest& request)
</ins><span class="cx"> {
</span><del>- ASSERT(context);
- if (is<WorkerGlobalScope>(*context)) {
</del><ins>+ if (is<WorkerGlobalScope>(context)) {
</ins><span class="cx"> CrossThreadResourceRequestData* requestData = request.copyData().leakPtr();
</span><del>- downcast<WorkerGlobalScope>(*context).thread().workerLoaderProxy().postTaskToLoader([requestData] (ScriptExecutionContext& context) {
</del><ins>+ downcast<WorkerGlobalScope>(context).thread().workerLoaderProxy().postTaskToLoader([requestData] (ScriptExecutionContext& context) {
</ins><span class="cx"> OwnPtr<ResourceRequest> request(ResourceRequest::adopt(adoptPtr(requestData)));
</span><del>- MemoryCache::removeRequestFromSessionCaches(&context, *request);
</del><ins>+ MemoryCache::removeRequestFromSessionCaches(context, *request);
</ins><span class="cx"> });
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> for (auto& resources : memoryCache().m_sessionResources) {
</span><span class="cx"> if (CachedResource* resource = memoryCache().resourceForRequestImpl(request, *resources.value))
</span><del>- memoryCache().remove(resource);
</del><ins>+ memoryCache().remove(*resource);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void MemoryCache::TypeStatistic::addResource(CachedResource* o)
</del><ins>+void MemoryCache::TypeStatistic::addResource(CachedResource& resource)
</ins><span class="cx"> {
</span><span class="cx"> count++;
</span><del>- size += o->size();
- liveSize += o->hasClients() ? o->size() : 0;
- decodedSize += o->decodedSize();
</del><ins>+ size += resource.size();
+ liveSize += resource.hasClients() ? resource.size() : 0;
+ decodedSize += resource.decodedSize();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> MemoryCache::Statistics MemoryCache::getStatistics()
</span><span class="lines">@@ -683,11 +683,11 @@
</span><span class="cx"> for (CachedResourceMap::iterator i = resources.value->begin(); i != e; ++i) {
</span><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> for (CachedResourceItem::iterator itemIterator = i->value->begin(); itemIterator != i->value->end(); ++itemIterator) {
</span><del>- CachedResource* resource = itemIterator->value;
</del><ins>+ CachedResource& resource = *itemIterator->value;
</ins><span class="cx"> #else
</span><del>- CachedResource* resource = i->value;
</del><ins>+ CachedResource& resource = *i->value;
</ins><span class="cx"> #endif
</span><del>- switch (resource->type()) {
</del><ins>+ switch (resource.type()) {
</ins><span class="cx"> case CachedResource::ImageResource:
</span><span class="cx"> stats.images.addResource(resource);
</span><span class="cx"> break;
</span><span class="lines">@@ -726,17 +726,17 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> for (;;) {
</span><del>- SessionCachedResourceMap::iterator sessionIterator = m_sessionResources.begin();
</del><ins>+ auto sessionIterator = m_sessionResources.begin();
</ins><span class="cx"> if (sessionIterator == m_sessionResources.end())
</span><span class="cx"> break;
</span><del>- CachedResourceMap::iterator outerIterator = sessionIterator->value->begin();
</del><ins>+ auto outerIterator = sessionIterator->value->begin();
</ins><span class="cx"> if (outerIterator == sessionIterator->value->end())
</span><span class="cx"> break;
</span><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><del>- CachedResourceItem::iterator innerIterator = outerIterator->value->begin();
- remove(innerIterator->value);
</del><ins>+ auto innerIterator = outerIterator->value->begin();
+ remove(*innerIterator->value);
</ins><span class="cx"> #else
</span><del>- remove(outerIterator->value);
</del><ins>+ remove(*outerIterator->value);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheMemoryCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/MemoryCache.h (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/MemoryCache.h        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/loader/cache/MemoryCache.h        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -78,7 +78,7 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>- void addResource(CachedResource*);
</del><ins>+ void addResource(CachedResource&);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct Statistics {
</span><span class="lines">@@ -92,13 +92,13 @@
</span><span class="cx"> WEBCORE_EXPORT CachedResource* resourceForURL(const URL&, SessionID = SessionID::defaultSessionID());
</span><span class="cx"> WEBCORE_EXPORT CachedResource* resourceForRequest(const ResourceRequest&, SessionID);
</span><span class="cx">
</span><del>- bool add(CachedResource*);
- void remove(CachedResource*);
</del><ins>+ bool add(CachedResource&);
+ void remove(CachedResource&);
</ins><span class="cx">
</span><span class="cx"> static URL removeFragmentIdentifierIfNeeded(const URL& originalURL);
</span><span class="cx">
</span><del>- void revalidationSucceeded(CachedResource* revalidatingResource, const ResourceResponse&);
- void revalidationFailed(CachedResource* revalidatingResource);
</del><ins>+ void revalidationSucceeded(CachedResource& revalidatingResource, const ResourceResponse&);
+ void revalidationFailed(CachedResource& revalidatingResource);
</ins><span class="cx">
</span><span class="cx"> // Sets the cache's memory capacities, in bytes. These will hold only approximately,
</span><span class="cx"> // since the decoded cost of resources like scripts and stylesheets is not known.
</span><span class="lines">@@ -120,29 +120,29 @@
</span><span class="cx"> std::chrono::milliseconds deadDecodedDataDeletionInterval() const { return m_deadDecodedDataDeletionInterval; }
</span><span class="cx">
</span><span class="cx"> // Calls to put the cached resource into and out of LRU lists.
</span><del>- void insertInLRUList(CachedResource*);
- void removeFromLRUList(CachedResource*);
</del><ins>+ void insertInLRUList(CachedResource&);
+ void removeFromLRUList(CachedResource&);
</ins><span class="cx">
</span><span class="cx"> // Called to adjust the cache totals when a resource changes size.
</span><span class="cx"> void adjustSize(bool live, int delta);
</span><span class="cx">
</span><span class="cx"> // Track decoded resources that are in the cache and referenced by a Web page.
</span><del>- void insertInLiveDecodedResourcesList(CachedResource*);
- void removeFromLiveDecodedResourcesList(CachedResource*);
</del><ins>+ void insertInLiveDecodedResourcesList(CachedResource&);
+ void removeFromLiveDecodedResourcesList(CachedResource&);
</ins><span class="cx">
</span><del>- void addToLiveResourcesSize(CachedResource*);
- void removeFromLiveResourcesSize(CachedResource*);
</del><ins>+ void addToLiveResourcesSize(CachedResource&);
+ void removeFromLiveResourcesSize(CachedResource&);
</ins><span class="cx">
</span><del>- static void removeRequestFromSessionCaches(ScriptExecutionContext*, const ResourceRequest&);
</del><ins>+ static void removeRequestFromSessionCaches(ScriptExecutionContext&, const ResourceRequest&);
</ins><span class="cx">
</span><span class="cx"> // Function to collect cache statistics for the caches window in the Safari Debug menu.
</span><span class="cx"> WEBCORE_EXPORT Statistics getStatistics();
</span><span class="cx">
</span><del>- void resourceAccessed(CachedResource*);
</del><ins>+ void resourceAccessed(CachedResource&);
</ins><span class="cx"> bool inLiveDecodedResourcesList(CachedResource& resource) const { return m_liveDecodedResources.contains(&resource); }
</span><span class="cx">
</span><span class="cx"> typedef HashSet<RefPtr<SecurityOrigin>> SecurityOriginSet;
</span><del>- WEBCORE_EXPORT void removeResourcesWithOrigin(SecurityOrigin*);
</del><ins>+ WEBCORE_EXPORT void removeResourcesWithOrigin(SecurityOrigin&);
</ins><span class="cx"> WEBCORE_EXPORT void getOriginsWithCache(SecurityOriginSet& origins);
</span><span class="cx">
</span><span class="cx"> #if USE(CG)
</span><span class="lines">@@ -176,7 +176,7 @@
</span><span class="cx"> MemoryCache();
</span><span class="cx"> ~MemoryCache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons.
</span><span class="cx">
</span><del>- LRUList* lruListFor(CachedResource*);
</del><ins>+ LRUList* lruListFor(CachedResource&);
</ins><span class="cx"> #ifndef NDEBUG
</span><span class="cx"> void dumpStats();
</span><span class="cx"> void dumpLRULists(bool includeLive) const;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsMaskImageOperationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/MaskImageOperation.cpp (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/MaskImageOperation.cpp        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebCore/platform/graphics/MaskImageOperation.cpp        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -218,7 +218,7 @@
</span><span class="cx"> // Let the cached resource loader of the document which requested this mask keep a handle to this
</span><span class="cx"> // cached image to ensure it only gets deleted when it should.
</span><span class="cx"> if (m_cachedResourceLoader.get())
</span><del>- m_cachedResourceLoader->addCachedResource(m_styleImage->cachedImage());
</del><ins>+ m_cachedResourceLoader->addCachedResource(*m_styleImage->cachedImage());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Destroy the current SVG document as its no longer needed
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebKit2/ChangeLog        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -1,5 +1,15 @@
</span><span class="cx"> 2015-01-30 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><ins>+ Update MemoryCache code to use more references instead of pointers
+ https://bugs.webkit.org/show_bug.cgi?id=141099
+
+ Reviewed by Andreas Kling.
+
+ * WebProcess/ResourceCache/WebResourceCacheManager.cpp:
+ (WebKit::WebResourceCacheManager::clearCacheForOrigin):
+
+2015-01-30 Chris Dumez <cdumez@apple.com>
+
</ins><span class="cx"> Rename shared() static member functions to singleton() for singleton classes.
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=141088
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessResourceCacheWebResourceCacheManagercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp (179420 => 179421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp        2015-01-30 23:58:20 UTC (rev 179420)
+++ trunk/Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp        2015-01-31 00:04:36 UTC (rev 179421)
</span><span class="lines">@@ -114,7 +114,7 @@
</span><span class="cx"> if (!origin)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- memoryCache().removeResourcesWithOrigin(origin.get());
</del><ins>+ memoryCache().removeResourcesWithOrigin(*origin);
</ins><span class="cx">
</span><span class="cx"> #if USE(CFURLCACHE)
</span><span class="cx"> if (resourceCachesToClear != InMemoryResourceCachesOnly) {
</span></span></pre>
</div>
</div>
</body>
</html>