<!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>[182601] 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/182601">182601</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2015-04-09 09:13:06 -0700 (Thu, 09 Apr 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Give each cache group a storage and use it in place of the singleton
https://bugs.webkit.org/show_bug.cgi?id=143540
Reviewed by Sam Weinig.
This is another step towards making the cache storage be per page.
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::ApplicationCacheGroup):
(WebCore::ApplicationCacheGroup::~ApplicationCacheGroup):
(WebCore::ApplicationCacheGroup::cacheForMainRequest):
(WebCore::ApplicationCacheGroup::fallbackCacheForMainRequest):
(WebCore::ApplicationCacheGroup::selectCache):
(WebCore::ApplicationCacheGroup::makeObsolete):
(WebCore::ApplicationCacheGroup::didReachMaxAppCacheSize):
(WebCore::ApplicationCacheGroup::recalculateAvailableSpaceInQuota):
(WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
* loader/appcache/ApplicationCacheGroup.h:
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::loadCacheGroup):
(WebCore::ApplicationCacheStorage::findOrCreateCacheGroup):
(WebCore::ApplicationCacheStorage::cacheGroupForURL):
(WebCore::ApplicationCacheStorage::fallbackCacheGroupForURL):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderappcacheApplicationCacheGroupcpp">trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderappcacheApplicationCacheGrouph">trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h</a></li>
<li><a href="#trunkSourceWebCoreloaderappcacheApplicationCacheStoragecpp">trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (182600 => 182601)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-04-09 15:42:52 UTC (rev 182600)
+++ trunk/Source/WebCore/ChangeLog        2015-04-09 16:13:06 UTC (rev 182601)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2015-04-08 Anders Carlsson <andersca@apple.com>
+
+ Give each cache group a storage and use it in place of the singleton
+ https://bugs.webkit.org/show_bug.cgi?id=143540
+
+ Reviewed by Sam Weinig.
+
+ This is another step towards making the cache storage be per page.
+
+ * loader/appcache/ApplicationCacheGroup.cpp:
+ (WebCore::ApplicationCacheGroup::ApplicationCacheGroup):
+ (WebCore::ApplicationCacheGroup::~ApplicationCacheGroup):
+ (WebCore::ApplicationCacheGroup::cacheForMainRequest):
+ (WebCore::ApplicationCacheGroup::fallbackCacheForMainRequest):
+ (WebCore::ApplicationCacheGroup::selectCache):
+ (WebCore::ApplicationCacheGroup::makeObsolete):
+ (WebCore::ApplicationCacheGroup::didReachMaxAppCacheSize):
+ (WebCore::ApplicationCacheGroup::recalculateAvailableSpaceInQuota):
+ (WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
+ * loader/appcache/ApplicationCacheGroup.h:
+ * loader/appcache/ApplicationCacheStorage.cpp:
+ (WebCore::ApplicationCacheStorage::loadCacheGroup):
+ (WebCore::ApplicationCacheStorage::findOrCreateCacheGroup):
+ (WebCore::ApplicationCacheStorage::cacheGroupForURL):
+ (WebCore::ApplicationCacheStorage::fallbackCacheGroupForURL):
+
</ins><span class="cx"> 2015-04-09 Andy Estes <aestes@apple.com>
</span><span class="cx">
</span><span class="cx"> Try to fix the Mac build after r182596.
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderappcacheApplicationCacheGroupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp (182600 => 182601)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp        2015-04-09 15:42:52 UTC (rev 182600)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp        2015-04-09 16:13:06 UTC (rev 182601)
</span><span class="lines">@@ -50,8 +50,9 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-ApplicationCacheGroup::ApplicationCacheGroup(const URL& manifestURL)
- : m_manifestURL(manifestURL)
</del><ins>+ApplicationCacheGroup::ApplicationCacheGroup(Ref<ApplicationCacheStorage>&& storage, const URL& manifestURL)
+ : m_storage(WTF::move(storage))
+ , m_manifestURL(manifestURL)
</ins><span class="cx"> , m_origin(SecurityOrigin::create(manifestURL))
</span><span class="cx"> , m_updateStatus(Idle)
</span><span class="cx"> , m_downloadingPendingMasterResourceLoadersCount(0)
</span><span class="lines">@@ -73,33 +74,34 @@
</span><span class="cx"> ASSERT(m_caches.isEmpty());
</span><span class="cx">
</span><span class="cx"> stopLoading();
</span><del>-
- ApplicationCacheStorage::singleton().cacheGroupDestroyed(this);
</del><ins>+
+ m_storage->cacheGroupDestroyed(this);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ApplicationCache* ApplicationCacheGroup::cacheForMainRequest(const ResourceRequest& request, DocumentLoader* documentLoader)
</span><span class="cx"> {
</span><span class="cx"> if (!ApplicationCache::requestIsHTTPOrHTTPSGet(request))
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx">
</span><span class="cx"> URL url(request.url());
</span><span class="cx"> if (url.hasFragmentIdentifier())
</span><span class="cx"> url.removeFragmentIdentifier();
</span><span class="cx">
</span><del>- if (documentLoader->frame() && documentLoader->frame()->page()->usesEphemeralSession())
- return 0;
</del><ins>+ auto* page = documentLoader->frame() ? documentLoader->frame()->page() : nullptr;
+ if (!page || page->usesEphemeralSession())
+ return nullptr;
</ins><span class="cx">
</span><del>- if (ApplicationCacheGroup* group = ApplicationCacheStorage::singleton().cacheGroupForURL(url)) {
</del><ins>+ if (ApplicationCacheGroup* group = page->applicationCacheStorage().cacheGroupForURL(url)) {
</ins><span class="cx"> ASSERT(group->newestCache());
</span><span class="cx"> ASSERT(!group->isObsolete());
</span><span class="cx">
</span><span class="cx"> return group->newestCache();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-ApplicationCache* ApplicationCacheGroup::fallbackCacheForMainRequest(const ResourceRequest& request, DocumentLoader*)
</del><ins>+ApplicationCache* ApplicationCacheGroup::fallbackCacheForMainRequest(const ResourceRequest& request, DocumentLoader* documentLoader)
</ins><span class="cx"> {
</span><span class="cx"> if (!ApplicationCache::requestIsHTTPOrHTTPSGet(request))
</span><span class="cx"> return 0;
</span><span class="lines">@@ -108,7 +110,11 @@
</span><span class="cx"> if (url.hasFragmentIdentifier())
</span><span class="cx"> url.removeFragmentIdentifier();
</span><span class="cx">
</span><del>- if (ApplicationCacheGroup* group = ApplicationCacheStorage::singleton().fallbackCacheGroupForURL(url)) {
</del><ins>+ auto* page = documentLoader->frame() ? documentLoader->frame()->page() : nullptr;
+ if (!page)
+ return nullptr;
+
+ if (ApplicationCacheGroup* group = page->applicationCacheStorage().fallbackCacheGroupForURL(url)) {
</ins><span class="cx"> ASSERT(group->newestCache());
</span><span class="cx"> ASSERT(!group->isObsolete());
</span><span class="cx">
</span><span class="lines">@@ -162,7 +168,7 @@
</span><span class="cx"> bool inStorage = resource->storageID();
</span><span class="cx"> resource->addType(ApplicationCacheResource::Foreign);
</span><span class="cx"> if (inStorage)
</span><del>- ApplicationCacheStorage::singleton().storeUpdatedType(resource, mainResourceCache);
</del><ins>+ frame->page()->applicationCacheStorage().storeUpdatedType(resource, mainResourceCache);
</ins><span class="cx">
</span><span class="cx"> // Restart the current navigation from the top of the navigation algorithm, undoing any changes that were made
</span><span class="cx"> // as part of the initial load.
</span><span class="lines">@@ -183,7 +189,7 @@
</span><span class="cx"> if (!protocolHostAndPortAreEqual(manifestURL, request.url()))
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- ApplicationCacheGroup* group = ApplicationCacheStorage::singleton().findOrCreateCacheGroup(manifestURL);
</del><ins>+ ApplicationCacheGroup* group = frame->page()->applicationCacheStorage().findOrCreateCacheGroup(manifestURL);
</ins><span class="cx">
</span><span class="cx"> documentLoader->applicationCacheHost()->setCandidateApplicationCacheGroup(group);
</span><span class="cx"> group->m_pendingMasterResourceLoaders.add(documentLoader);
</span><span class="lines">@@ -396,7 +402,7 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> m_isObsolete = true;
</span><del>- ApplicationCacheStorage::singleton().cacheGroupMadeObsolete(this);
</del><ins>+ m_storage->cacheGroupMadeObsolete(this);
</ins><span class="cx"> ASSERT(!m_storageID);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -760,7 +766,7 @@
</span><span class="cx"> {
</span><span class="cx"> ASSERT(m_frame);
</span><span class="cx"> ASSERT(m_cacheBeingUpdated);
</span><del>- m_frame->page()->chrome().client().reachedMaxAppCacheSize(ApplicationCacheStorage::singleton().spaceNeeded(m_cacheBeingUpdated->estimatedSizeInStorage()));
</del><ins>+ m_frame->page()->chrome().client().reachedMaxAppCacheSize(m_frame->page()->applicationCacheStorage().spaceNeeded(m_cacheBeingUpdated->estimatedSizeInStorage()));
</ins><span class="cx"> m_calledReachedMaxAppCacheSize = true;
</span><span class="cx"> checkIfLoadIsComplete();
</span><span class="cx"> }
</span><span class="lines">@@ -784,7 +790,7 @@
</span><span class="cx">
</span><span class="cx"> void ApplicationCacheGroup::recalculateAvailableSpaceInQuota()
</span><span class="cx"> {
</span><del>- if (!ApplicationCacheStorage::singleton().calculateRemainingSizeForOriginExcludingCache(m_origin.get(), m_newestCache.get(), m_availableSpaceInQuota)) {
</del><ins>+ if (!m_frame->page()->applicationCacheStorage().calculateRemainingSizeForOriginExcludingCache(m_origin.get(), m_newestCache.get(), m_availableSpaceInQuota)) {
</ins><span class="cx"> // Failed to determine what is left in the quota. Fallback to allowing anything.
</span><span class="cx"> m_availableSpaceInQuota = ApplicationCacheStorage::noQuota();
</span><span class="cx"> }
</span><span class="lines">@@ -841,7 +847,7 @@
</span><span class="cx">
</span><span class="cx"> // The storage could have been manually emptied by the user.
</span><span class="cx"> if (!m_storageID)
</span><del>- ApplicationCacheStorage::singleton().storeNewestCache(this);
</del><ins>+ m_storage->storeNewestCache(this);
</ins><span class="cx">
</span><span class="cx"> postListenerTask(ApplicationCacheHost::NOUPDATE_EVENT, m_associatedDocumentLoaders);
</span><span class="cx"> break;
</span><span class="lines">@@ -866,7 +872,7 @@
</span><span class="cx"> // the maximum size. In such a case, m_manifestResource may be 0, as
</span><span class="cx"> // the manifest was already set on the newest cache object.
</span><span class="cx"> ASSERT(m_cacheBeingUpdated->manifestResource());
</span><del>- ASSERT(ApplicationCacheStorage::singleton().isMaximumSizeReached());
</del><ins>+ ASSERT(m_storage->isMaximumSizeReached());
</ins><span class="cx"> ASSERT(m_calledReachedMaxAppCacheSize);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -875,16 +881,15 @@
</span><span class="cx"> // If we exceeded the origin quota while downloading we can request a quota
</span><span class="cx"> // increase now, before we attempt to store the cache.
</span><span class="cx"> int64_t totalSpaceNeeded;
</span><del>- auto& cacheStorage = ApplicationCacheStorage::singleton();
- if (!cacheStorage.checkOriginQuota(this, oldNewestCache.get(), m_cacheBeingUpdated.get(), totalSpaceNeeded))
</del><ins>+ if (!m_storage->checkOriginQuota(this, oldNewestCache.get(), m_cacheBeingUpdated.get(), totalSpaceNeeded))
</ins><span class="cx"> didReachOriginQuota(totalSpaceNeeded);
</span><span class="cx">
</span><span class="cx"> ApplicationCacheStorage::FailureReason failureReason;
</span><span class="cx"> setNewestCache(m_cacheBeingUpdated.release());
</span><del>- if (cacheStorage.storeNewestCache(this, oldNewestCache.get(), failureReason)) {
</del><ins>+ if (m_storage->storeNewestCache(this, oldNewestCache.get(), failureReason)) {
</ins><span class="cx"> // New cache stored, now remove the old cache.
</span><span class="cx"> if (oldNewestCache)
</span><del>- cacheStorage.remove(oldNewestCache.get());
</del><ins>+ m_storage->remove(oldNewestCache.get());
</ins><span class="cx">
</span><span class="cx"> // Fire the final progress event.
</span><span class="cx"> ASSERT(m_progressDone == m_progressTotal);
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderappcacheApplicationCacheGrouph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h (182600 => 182601)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h        2015-04-09 15:42:52 UTC (rev 182600)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h        2015-04-09 16:13:06 UTC (rev 182601)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx">
</span><span class="cx"> class ApplicationCache;
</span><span class="cx"> class ApplicationCacheResource;
</span><ins>+class ApplicationCacheStorage;
</ins><span class="cx"> class Document;
</span><span class="cx"> class DocumentLoader;
</span><span class="cx"> class Frame;
</span><span class="lines">@@ -52,7 +53,7 @@
</span><span class="cx"> class ApplicationCacheGroup : ResourceHandleClient {
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(ApplicationCacheGroup); WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>- explicit ApplicationCacheGroup(const URL& manifestURL);
</del><ins>+ explicit ApplicationCacheGroup(Ref<ApplicationCacheStorage>&&, const URL& manifestURL);
</ins><span class="cx"> virtual ~ApplicationCacheGroup();
</span><span class="cx">
</span><span class="cx"> enum UpdateStatus { Idle, Checking, Downloading };
</span><span class="lines">@@ -129,7 +130,9 @@
</span><span class="cx"> void associateDocumentLoaderWithCache(DocumentLoader*, ApplicationCache*);
</span><span class="cx">
</span><span class="cx"> void stopLoading();
</span><del>-
</del><ins>+
+ Ref<ApplicationCacheStorage> m_storage;
+
</ins><span class="cx"> URL m_manifestURL;
</span><span class="cx"> RefPtr<SecurityOrigin> m_origin;
</span><span class="cx"> UpdateStatus m_updateStatus;
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderappcacheApplicationCacheStoragecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp (182600 => 182601)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp        2015-04-09 15:42:52 UTC (rev 182600)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp        2015-04-09 16:13:06 UTC (rev 182601)
</span><span class="lines">@@ -128,7 +128,7 @@
</span><span class="cx"> if (!cache)
</span><span class="cx"> return 0;
</span><span class="cx">
</span><del>- ApplicationCacheGroup* group = new ApplicationCacheGroup(manifestURL);
</del><ins>+ ApplicationCacheGroup* group = new ApplicationCacheGroup(*this, manifestURL);
</ins><span class="cx">
</span><span class="cx"> group->setStorageID(static_cast<unsigned>(statement.getColumnInt64(0)));
</span><span class="cx"> group->setNewestCache(cache.release());
</span><span class="lines">@@ -152,7 +152,7 @@
</span><span class="cx">
</span><span class="cx"> // If the group was not found we need to create it
</span><span class="cx"> if (!group) {
</span><del>- group = new ApplicationCacheGroup(manifestURL);
</del><ins>+ group = new ApplicationCacheGroup(*this, manifestURL);
</ins><span class="cx"> m_cacheHostSet.add(urlHostHash(manifestURL));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -252,7 +252,7 @@
</span><span class="cx"> if (resource->type() & ApplicationCacheResource::Foreign)
</span><span class="cx"> continue;
</span><span class="cx">
</span><del>- ApplicationCacheGroup* group = new ApplicationCacheGroup(manifestURL);
</del><ins>+ ApplicationCacheGroup* group = new ApplicationCacheGroup(*this, manifestURL);
</ins><span class="cx">
</span><span class="cx"> group->setStorageID(static_cast<unsigned>(statement.getColumnInt64(0)));
</span><span class="cx"> group->setNewestCache(cache.release());
</span><span class="lines">@@ -322,7 +322,7 @@
</span><span class="cx"> if (cache->resourceForURL(fallbackURL)->type() & ApplicationCacheResource::Foreign)
</span><span class="cx"> continue;
</span><span class="cx">
</span><del>- ApplicationCacheGroup* group = new ApplicationCacheGroup(manifestURL);
</del><ins>+ ApplicationCacheGroup* group = new ApplicationCacheGroup(*this, manifestURL);
</ins><span class="cx">
</span><span class="cx"> group->setStorageID(static_cast<unsigned>(statement.getColumnInt64(0)));
</span><span class="cx"> group->setNewestCache(cache.release());
</span></span></pre>
</div>
</div>
</body>
</html>