Rename pageCache() to PageCache::shared() and return a reference
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jan 2015 09:33:54 +0000 (09:33 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Jan 2015 09:33:54 +0000 (09:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140983

Reviewed by Andreas Kling.

Rename pageCache() to PageCache::shared() as this is a singleton class
and have it return a reference instead of a pointer.

Source/WebCore:

* history/BackForwardList.cpp:
(WebCore::BackForwardList::addItem):
(WebCore::BackForwardList::setCapacity):
(WebCore::BackForwardList::clearAllPageCaches):
(WebCore::BackForwardList::close):
* history/CachedFrame.cpp:
(WebCore::CachedFrame::CachedFrame):
* history/HistoryItem.cpp:
(WebCore::HistoryItem::setURL):
* history/PageCache.cpp:
(WebCore::PageCache::shared):
(WebCore::PageCache::get):
(WebCore::pageCache): Deleted.
* history/PageCache.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::commitProvisionalLoad):
(WebCore::FrameLoader::loadDifferentDocumentItem):
* loader/HistoryController.cpp:
(WebCore::HistoryController::invalidateCurrentItemCachedPage):
(WebCore::HistoryController::updateForReload):
* page/Frame.cpp:
(WebCore::Frame::setPageAndTextZoomFactors):
* page/Page.cpp:
(WebCore::Page::setDeviceScaleFactor):
(WebCore::Page::setPagination):
(WebCore::Page::setVisitedLinkStore):
* page/PageGroup.cpp:
(WebCore::PageGroup::captionPreferencesChanged):
* page/Settings.cpp:
(WebCore::Settings::setUsesPageCache):
* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::releaseCriticalMemory):

Source/WebKit/mac:

* History/WebBackForwardList.mm:
(-[WebBackForwardList pageCacheSize]):
* Misc/WebCoreStatistics.mm:
(+[WebCoreStatistics cachedPageCount]):
(+[WebCoreStatistics cachedFrameCount]):
* WebCoreSupport/WebVisitedLinkStore.mm:
(WebVisitedLinkStore::removeAllVisitedLinks):
(WebVisitedLinkStore::removeVisitedLink):
(WebVisitedLinkStore::addVisitedLinkHash):
* WebView/WebView.mm:
(+[WebView _setCacheModel:]):

Source/WebKit/win:

* WebCoreStatistics.cpp:
(WebCoreStatistics::cachedPageCount):
(WebCoreStatistics::cachedFrameCount):
* WebCoreSupport/WebVisitedLinkStore.cpp:
(WebVisitedLinkStore::removeAllVisitedLinks):
(WebVisitedLinkStore::addVisitedLinkHash):
* WebView.cpp:
(WebView::setCacheModel):

Source/WebKit2:

* WebProcess/WebPage/VisitedLinkTableController.cpp:
(WebKit::VisitedLinkTableController::setVisitedLinkTable):
(WebKit::VisitedLinkTableController::visitedLinkStateChanged):
(WebKit::VisitedLinkTableController::allVisitedLinkStateChanged):
(WebKit::VisitedLinkTableController::removeAllVisitedLinks):
* WebProcess/WebPage/WebBackForwardListProxy.cpp:
(WebKit::WebBackForwardListProxy::removeItem):
(WebKit::WebBackForwardListProxy::close):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::releasePageCache):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformSetCacheModel):
* WebProcess/soup/WebProcessSoup.cpp:
(WebKit::WebProcess::platformSetCacheModel):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179247 268f45cc-cd09-0410-ab3c-d52691b4dbfc

29 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/history/BackForwardList.cpp
Source/WebCore/history/CachedFrame.cpp
Source/WebCore/history/HistoryItem.cpp
Source/WebCore/history/PageCache.cpp
Source/WebCore/history/PageCache.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/HistoryController.cpp
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/page/PageGroup.cpp
Source/WebCore/page/Settings.cpp
Source/WebCore/platform/MemoryPressureHandler.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/History/WebBackForwardList.mm
Source/WebKit/mac/Misc/WebCoreStatistics.mm
Source/WebKit/mac/WebCoreSupport/WebVisitedLinkStore.mm
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreStatistics.cpp
Source/WebKit/win/WebCoreSupport/WebVisitedLinkStore.cpp
Source/WebKit/win/WebView.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/VisitedLinkTableController.cpp
Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm
Source/WebKit2/WebProcess/soup/WebProcessSoup.cpp

index 9de5cc9..92cdc0a 100644 (file)
@@ -1,3 +1,46 @@
+2015-01-28  Chris Dumez  <cdumez@apple.com>
+
+        Rename pageCache() to PageCache::shared() and return a reference
+        https://bugs.webkit.org/show_bug.cgi?id=140983
+
+        Reviewed by Andreas Kling.
+
+        Rename pageCache() to PageCache::shared() as this is a singleton class
+        and have it return a reference instead of a pointer.
+
+        * history/BackForwardList.cpp:
+        (WebCore::BackForwardList::addItem):
+        (WebCore::BackForwardList::setCapacity):
+        (WebCore::BackForwardList::clearAllPageCaches):
+        (WebCore::BackForwardList::close):
+        * history/CachedFrame.cpp:
+        (WebCore::CachedFrame::CachedFrame):
+        * history/HistoryItem.cpp:
+        (WebCore::HistoryItem::setURL):
+        * history/PageCache.cpp:
+        (WebCore::PageCache::shared):
+        (WebCore::PageCache::get):
+        (WebCore::pageCache): Deleted.
+        * history/PageCache.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::commitProvisionalLoad):
+        (WebCore::FrameLoader::loadDifferentDocumentItem):
+        * loader/HistoryController.cpp:
+        (WebCore::HistoryController::invalidateCurrentItemCachedPage):
+        (WebCore::HistoryController::updateForReload):
+        * page/Frame.cpp:
+        (WebCore::Frame::setPageAndTextZoomFactors):
+        * page/Page.cpp:
+        (WebCore::Page::setDeviceScaleFactor):
+        (WebCore::Page::setPagination):
+        (WebCore::Page::setVisitedLinkStore):
+        * page/PageGroup.cpp:
+        (WebCore::PageGroup::captionPreferencesChanged):
+        * page/Settings.cpp:
+        (WebCore::Settings::setUsesPageCache):
+        * platform/MemoryPressureHandler.cpp:
+        (WebCore::MemoryPressureHandler::releaseCriticalMemory):
+
 2015-01-28  Darin Adler  <darin@apple.com>
 
         Fix MediaPlayerEngine leaks
index 0d0c3c6..6d0104b 100644 (file)
@@ -1611,6 +1611,7 @@ __ZN7WebCore9PageCache11setCapacityEi
 __ZN7WebCore9PageCache18pruneToCapacityNowEiNS_13PruningReasonE
 __ZN7WebCore9PageCache33markPagesForVistedLinkStyleRecalcEv
 __ZN7WebCore9PageCache6removeEPNS_11HistoryItemE
+__ZN7WebCore9PageCache6sharedEv
 __ZN7WebCore9PageGroup9pageGroupERKN3WTF6StringE
 __ZN7WebCore9Scrollbar11mouseExitedEv
 __ZN7WebCore9Scrollbar12mouseEnteredEv
@@ -1629,7 +1630,6 @@ __ZN7WebCore9endOfLineERKNS_15VisiblePositionE
 __ZN7WebCore9endOfWordERKNS_15VisiblePositionENS_9EWordSideE
 __ZN7WebCore9fontCacheEv
 __ZN7WebCore9makeRangeERKNS_15VisiblePositionES2_
-__ZN7WebCore9pageCacheEv
 __ZN7WebCore9plainTextEPKNS_5RangeEtb
 __ZN7WebCore9unionRectERKN3WTF6VectorINS_9FloatRectELm0ENS0_15CrashOnOverflowEEE
 __ZNK3JSC8Bindings10RootObject12globalObjectEv
index 1e5e774..cce07f4 100644 (file)
@@ -68,7 +68,7 @@ void BackForwardList::addItem(PassRefPtr<HistoryItem> prpItem)
             RefPtr<HistoryItem> item = m_entries.last();
             m_entries.removeLast();
             m_entryHash.remove(item);
-            pageCache()->remove(item.get());
+            PageCache::shared().remove(item.get());
         }
     }
 
@@ -78,7 +78,7 @@ void BackForwardList::addItem(PassRefPtr<HistoryItem> prpItem)
         RefPtr<HistoryItem> item = m_entries[0];
         m_entries.remove(0);
         m_entryHash.remove(item);
-        pageCache()->remove(item.get());
+        PageCache::shared().remove(item.get());
         m_current--;
     }
 
@@ -175,7 +175,7 @@ void BackForwardList::setCapacity(int size)
         RefPtr<HistoryItem> item = m_entries.last();
         m_entries.removeLast();
         m_entryHash.remove(item);
-        pageCache()->remove(item.get());
+        PageCache::shared().remove(item.get());
     }
 
     if (!size)
@@ -247,7 +247,7 @@ bool BackForwardList::clearAllPageCaches()
         HistoryItem* item = m_entries[i].get();
         if (item->isInPageCache()) {
             didRemoveAtLeastOneItem = true;
-            pageCache()->remove(item);
+            PageCache::shared().remove(item);
         }
     }
     return didRemoveAtLeastOneItem;
@@ -258,7 +258,7 @@ void BackForwardList::close()
 {
     int size = m_entries.size();
     for (int i = 0; i < size; ++i)
-        pageCache()->remove(m_entries[i].get());
+        PageCache::shared().remove(m_entries[i].get());
     m_entries.clear();
     m_entryHash.clear();
     m_page = 0;
index 50e6596..ecf4ea8 100644 (file)
@@ -173,7 +173,7 @@ CachedFrame::CachedFrame(Frame& frame)
 
     frame.loader().client().savePlatformDataToCachedFrame(this);
 
-    if (m_isComposited && pageCache()->shouldClearBackingStores())
+    if (m_isComposited && PageCache::shared().shouldClearBackingStores())
         frame.view()->clearBackingStores();
 
     // documentWillSuspendForPageCache() can set up a layout timer on the FrameView, so clear timers after that.
index f55fa34..0c473c0 100644 (file)
@@ -286,7 +286,7 @@ void HistoryItem::setURLString(const String& urlString)
 
 void HistoryItem::setURL(const URL& url)
 {
-    pageCache()->remove(this);
+    PageCache::shared().remove(this);
     setURLString(url.string());
     clearDocumentState();
 }
index fd9df52..c1be392 100644 (file)
@@ -51,6 +51,7 @@
 #include "Settings.h"
 #include "SubframeLoader.h"
 #include <wtf/CurrentTime.h>
+#include <wtf/NeverDestroyed.h>
 #include <wtf/TemporaryChange.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringConcatenate.h>
@@ -291,10 +292,10 @@ static void logCanCachePageDecision(Page& page)
     diagnosticLoggingClient.logDiagnosticMessageWithResult(DiagnosticLoggingKeys::pageCacheKey(), emptyString(), rejectReasons ? DiagnosticLoggingResultFail : DiagnosticLoggingResultPass);
 }
 
-PageCache* pageCache()
+PageCache& PageCache::shared()
 {
-    static PageCache* staticPageCache = new PageCache;
-    return staticPageCache;
+    static NeverDestroyed<PageCache> globalPageCache;
+    return globalPageCache;
 }
 
 PageCache::PageCache()
@@ -507,7 +508,7 @@ CachedPage* PageCache::get(HistoryItem* item, Page* page)
         
         LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", item->url().string().ascii().data());
         logPageCacheFailureDiagnosticMessage(page, DiagnosticLoggingKeys::expiredKey());
-        pageCache()->remove(item);
+        PageCache::shared().remove(item);
     } else if (item->m_pruningReason != PruningReason::None)
         logPageCacheFailureDiagnosticMessage(page, pruningReasonToDiagnosticLoggingKey(item->m_pruningReason));
 
index f0d095e..64c0bba 100644 (file)
@@ -43,7 +43,10 @@ namespace WebCore {
     class PageCache {
         WTF_MAKE_NONCOPYABLE(PageCache); WTF_MAKE_FAST_ALLOCATED;
     public:
-        friend PageCache* pageCache();
+        friend class NeverDestroyed<PageCache>;
+
+        // Function to obtain the global page cache.
+        WEBCORE_EXPORT static PageCache& shared();
         
         bool canCache(Page*) const;
 
@@ -75,7 +78,7 @@ namespace WebCore {
         void markPagesForDeviceScaleChanged(Page*);
 
     private:
-        PageCache(); // Use pageCache() instead.
+        PageCache(); // Use shared() instead.
         ~PageCache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons.
         
         static bool canCachePageContainingThisFrame(Frame*);
@@ -95,9 +98,6 @@ namespace WebCore {
         bool m_shouldClearBackingStores;
      };
 
-    // Function to obtain the global page cache.
-    WEBCORE_EXPORT PageCache* pageCache();
-
 } // namespace WebCore
 
 #endif // PageCache_h
index a95969f..90b5a0a 100644 (file)
@@ -1741,7 +1741,7 @@ void FrameLoader::commitProvisionalLoad()
 
     std::unique_ptr<CachedPage> cachedPage;
     if (m_loadingFromCachedPage)
-        cachedPage = pageCache()->take(history().provisionalItem(), m_frame.page());
+        cachedPage = PageCache::shared().take(history().provisionalItem(), m_frame.page());
 
     LOG(PageCache, "WebCoreLoading %s: About to commit provisional load from previous URL '%s' to new URL '%s'", m_frame.tree().uniqueName().string().utf8().data(),
         m_frame.document() ? m_frame.document()->url().stringCenterEllipsizedToLength().utf8().data() : "",
@@ -1758,11 +1758,11 @@ void FrameLoader::commitProvisionalLoad()
             LOG(MemoryPressure, "Pruning page cache because under memory pressure at: %s", __PRETTY_FUNCTION__);
             LOG(PageCache, "Pruning page cache to 0 due to memory pressure");
             // Don't cache any page if we are under memory pressure.
-            pageCache()->pruneToCapacityNow(0, PruningReason::MemoryPressure);
+            PageCache::shared().pruneToCapacityNow(0, PruningReason::MemoryPressure);
         } else if (systemMemoryLevel() <= memoryLevelThresholdToPrunePageCache) {
             LOG(MemoryPressure, "Pruning page cache because system memory level is %d at: %s", systemMemoryLevel(), __PRETTY_FUNCTION__);
-            LOG(PageCache, "Pruning page cache to %d due to low memory (level %d less or equal to %d threshold)", pageCache()->capacity() / 2, systemMemoryLevel(), memoryLevelThresholdToPrunePageCache);
-            pageCache()->pruneToCapacityNow(pageCache()->capacity() / 2, PruningReason::MemoryPressure);
+            LOG(PageCache, "Pruning page cache to %d due to low memory (level %d less or equal to %d threshold)", PageCache::shared().capacity() / 2, systemMemoryLevel(), memoryLevelThresholdToPrunePageCache);
+            PageCache::shared().pruneToCapacityNow(PageCache::shared().capacity() / 2, PruningReason::MemoryPressure);
         }
     }
 #endif
@@ -1772,8 +1772,8 @@ void FrameLoader::commitProvisionalLoad()
     // Check to see if we need to cache the page we are navigating away from into the back/forward cache.
     // We are doing this here because we know for sure that a new page is about to be loaded.
     HistoryItem* item = history().currentItem();
-    if (!m_frame.tree().parent() && pageCache()->canCache(m_frame.page()) && !item->isInPageCache())
-        pageCache()->add(item, *m_frame.page());
+    if (!m_frame.tree().parent() && PageCache::shared().canCache(m_frame.page()) && !item->isInPageCache())
+        PageCache::shared().add(item, *m_frame.page());
 
     if (m_loadType != FrameLoadType::Replace)
         closeOldDataSources();
@@ -3159,7 +3159,7 @@ void FrameLoader::loadDifferentDocumentItem(HistoryItem* item, FrameLoadType loa
     // Remember this item so we can traverse any child items as child frames load
     history().setProvisionalItem(item);
 
-    if (CachedPage* cachedPage = pageCache()->get(item, m_frame.page())) {
+    if (CachedPage* cachedPage = PageCache::shared().get(item, m_frame.page())) {
         auto documentLoader = cachedPage->documentLoader();
         documentLoader->setTriggeringAction(NavigationAction(documentLoader->request(), loadType, false));
         documentLoader->setLastCheckedRequest(ResourceRequest());
index b71c5b5..9b83a84 100644 (file)
@@ -235,10 +235,10 @@ void HistoryController::restoreDocumentState()
 void HistoryController::invalidateCurrentItemCachedPage()
 {
     // When we are pre-commit, the currentItem is where any page cache data resides.
-    if (!pageCache()->get(currentItem(), m_frame.page()))
+    if (!PageCache::shared().get(currentItem(), m_frame.page()))
         return;
 
-    std::unique_ptr<CachedPage> cachedPage = pageCache()->take(currentItem(), m_frame.page());
+    std::unique_ptr<CachedPage> cachedPage = PageCache::shared().take(currentItem(), m_frame.page());
 
     // FIXME: This is a grotesque hack to fix <rdar://problem/4059059> Crash in RenderFlow::detach
     // Somehow the PageState object is not properly updated, and is holding onto a stale document.
@@ -334,7 +334,7 @@ void HistoryController::updateForReload()
 #endif
 
     if (m_currentItem) {
-        pageCache()->remove(m_currentItem.get());
+        PageCache::shared().remove(m_currentItem.get());
     
         if (m_frame.loader().loadType() == FrameLoadType::Reload || m_frame.loader().loadType() == FrameLoadType::ReloadFromOrigin)
             saveScrollPositionAndViewStateToItem(m_currentItem.get());
index 8edafbf..8314c9a 100644 (file)
@@ -989,7 +989,7 @@ void Frame::setPageAndTextZoomFactors(float pageZoomFactor, float textZoomFactor
     }
 
     if (isMainFrame())
-        pageCache()->markPagesForFullStyleRecalc(page);
+        PageCache::shared().markPagesForFullStyleRecalc(page);
 }
 
 float Frame::frameScaleFactor() const
index 8c318b2..7c535d0 100644 (file)
@@ -839,9 +839,9 @@ void Page::setDeviceScaleFactor(float scaleFactor)
     setNeedsRecalcStyleInAllFrames();
 
     mainFrame().deviceOrPageScaleFactorChanged();
-    pageCache()->markPagesForDeviceScaleChanged(this);
+    PageCache::shared().markPagesForDeviceScaleChanged(this);
 
-    pageCache()->markPagesForFullStyleRecalc(this);
+    PageCache::shared().markPagesForFullStyleRecalc(this);
     GraphicsContext::updateDocumentMarkerResources();
 
     mainFrame().pageOverlayController().didChangeDeviceScaleFactor();
@@ -921,7 +921,7 @@ void Page::setPagination(const Pagination& pagination)
     m_pagination = pagination;
 
     setNeedsRecalcStyleInAllFrames();
-    pageCache()->markPagesForFullStyleRecalc(this);
+    PageCache::shared().markPagesForFullStyleRecalc(this);
 }
 
 unsigned Page::pageCount() const
@@ -1661,7 +1661,7 @@ void Page::setVisitedLinkStore(Ref<VisitedLinkStore>&& visitedLinkStore)
     m_visitedLinkStore->addPage(*this);
 
     invalidateStylesForAllLinks();
-    pageCache()->markPagesForFullStyleRecalc(this);
+    PageCache::shared().markPagesForFullStyleRecalc(this);
 }
 
 SessionID Page::sessionID() const
index e9665a4..dac26f2 100644 (file)
@@ -111,7 +111,7 @@ void PageGroup::captionPreferencesChanged()
 {
     for (auto it = m_pages.begin(), end = m_pages.end(); it != end; ++it)
         (*it)->captionPreferencesChanged();
-    pageCache()->markPagesForCaptionPreferencesChanged();
+    PageCache::shared().markPagesForCaptionPreferencesChanged();
 }
 
 CaptionUserPreferences* PageGroup::captionPreferences()
index 6b9d23c..d7739d1 100644 (file)
@@ -523,7 +523,7 @@ void Settings::setUsesPageCache(bool usesPageCache)
         int first = -m_page->backForward().backCount();
         int last = m_page->backForward().forwardCount();
         for (int i = first; i <= last; i++)
-            pageCache()->remove(m_page->backForward().itemAtIndex(i));
+            PageCache::shared().remove(m_page->backForward().itemAtIndex(i));
     }
 }
 
index 7d7022d..5cd2105 100644 (file)
@@ -102,7 +102,7 @@ void MemoryPressureHandler::releaseCriticalMemory()
         ReliefLogger log("Empty the PageCache");
         // Right now, the only reason we call release critical memory while not under memory pressure is if the process is about to be suspended.
         PruningReason pruningReason = memoryPressureHandler().isUnderMemoryPressure() ? PruningReason::MemoryPressure : PruningReason::ProcessSuspended;
-        pageCache()->pruneToCapacityNow(0, pruningReason);
+        PageCache::shared().pruneToCapacityNow(0, pruningReason);
     }
 
     {
index 7cf6391..d923646 100644 (file)
@@ -1,3 +1,25 @@
+2015-01-28  Chris Dumez  <cdumez@apple.com>
+
+        Rename pageCache() to PageCache::shared() and return a reference
+        https://bugs.webkit.org/show_bug.cgi?id=140983
+
+        Reviewed by Andreas Kling.
+
+        Rename pageCache() to PageCache::shared() as this is a singleton class
+        and have it return a reference instead of a pointer.
+
+        * History/WebBackForwardList.mm:
+        (-[WebBackForwardList pageCacheSize]):
+        * Misc/WebCoreStatistics.mm:
+        (+[WebCoreStatistics cachedPageCount]):
+        (+[WebCoreStatistics cachedFrameCount]):
+        * WebCoreSupport/WebVisitedLinkStore.mm:
+        (WebVisitedLinkStore::removeAllVisitedLinks):
+        (WebVisitedLinkStore::removeVisitedLink):
+        (WebVisitedLinkStore::addVisitedLinkHash):
+        * WebView/WebView.mm:
+        (+[WebView _setCacheModel:]):
+
 2015-01-27  Alexey Proskuryakov  <ap@apple.com>
 
         More build fixes for newer clang.
index 077c903..8757c8c 100644 (file)
@@ -355,7 +355,7 @@ static bool bumperCarBackForwardHackNeeded()
 
 - (NSUInteger)pageCacheSize
 {
-    return [kit(core(self)->page()) usesPageCache] ? pageCache()->capacity() : 0;
+    return [kit(core(self)->page()) usesPageCache] ? PageCache::shared().capacity() : 0;
 }
 
 - (int)backListCount
index f4ab16e..563ec8e 100644 (file)
@@ -224,12 +224,12 @@ using namespace WebCore;
 
 + (int)cachedPageCount
 {
-    return pageCache()->pageCount();
+    return PageCache::shared().pageCount();
 }
 
 + (int)cachedFrameCount
 {
-    return pageCache()->frameCount();
+    return PageCache::shared().frameCount();
 }
 
 // Deprecated
index a00fc06..864dd4e 100644 (file)
@@ -74,7 +74,7 @@ void WebVisitedLinkStore::removeAllVisitedLinks()
 {
     for (auto& visitedLinkStore : visitedLinkStores())
         visitedLinkStore->removeVisitedLinkHashes();
-    pageCache()->markPagesForVistedLinkStyleRecalc();
+    PageCache::shared().markPagesForVistedLinkStyleRecalc();
 }
 
 void WebVisitedLinkStore::addVisitedLink(NSString *urlString)
@@ -103,7 +103,7 @@ void WebVisitedLinkStore::removeVisitedLink(NSString *urlString)
     m_visitedLinkHashes.remove(linkHash);
 
     invalidateStylesForLink(linkHash);
-    pageCache()->markPagesForVistedLinkStyleRecalc();
+    PageCache::shared().markPagesForVistedLinkStyleRecalc();
 }
 
 bool WebVisitedLinkStore::isLinkVisited(Page& page, LinkHash linkHash, const URL& baseURL, const AtomicString& attributeURL)
@@ -152,7 +152,7 @@ void WebVisitedLinkStore::addVisitedLinkHash(LinkHash linkHash)
     m_visitedLinkHashes.add(linkHash);
 
     invalidateStylesForLink(linkHash);
-    pageCache()->markPagesForVistedLinkStyleRecalc();
+    PageCache::shared().markPagesForVistedLinkStyleRecalc();
 }
 
 void WebVisitedLinkStore::removeVisitedLinkHashes()
index 0cc1bd4..90bf06e 100644 (file)
@@ -7935,9 +7935,9 @@ static inline uint64_t roundUpToPowerOf2(uint64_t num)
 
     memoryCache().setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
     memoryCache().setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
-    pageCache()->setCapacity(pageCacheCapacity);
+    PageCache::shared().setCapacity(pageCacheCapacity);
 #if PLATFORM(IOS)
-    pageCache()->setShouldClearBackingStores(true);
+    PageCache::shared().setShouldClearBackingStores(true);
     nsurlCacheMemoryCapacity = std::max(nsurlCacheMemoryCapacity, [nsurlCache memoryCapacity]);
     CFURLCacheRef cfCache;
     if ([nsurlCache respondsToSelector:@selector(_CFURLCache)] && (cfCache = [nsurlCache _CFURLCache]))
index 71362cc..d443be6 100644 (file)
@@ -1,3 +1,22 @@
+2015-01-28  Chris Dumez  <cdumez@apple.com>
+
+        Rename pageCache() to PageCache::shared() and return a reference
+        https://bugs.webkit.org/show_bug.cgi?id=140983
+
+        Reviewed by Andreas Kling.
+
+        Rename pageCache() to PageCache::shared() as this is a singleton class
+        and have it return a reference instead of a pointer.
+
+        * WebCoreStatistics.cpp:
+        (WebCoreStatistics::cachedPageCount):
+        (WebCoreStatistics::cachedFrameCount):
+        * WebCoreSupport/WebVisitedLinkStore.cpp:
+        (WebVisitedLinkStore::removeAllVisitedLinks):
+        (WebVisitedLinkStore::addVisitedLinkHash):
+        * WebView.cpp:
+        (WebView::setCacheModel):
+
 2015-01-27  Chris Dumez  <cdumez@apple.com>
 
         Use a Ref<CachedResourceLoader> in Document instead of a RefPtr
index 32271f9..b43071c 100644 (file)
@@ -327,7 +327,7 @@ HRESULT WebCoreStatistics::cachedPageCount(INT* count)
     if (!count)
         return E_POINTER;
 
-    *count = pageCache()->pageCount();
+    *count = PageCache::shared().pageCount();
     return S_OK;
 }
 
@@ -336,6 +336,6 @@ HRESULT WebCoreStatistics::cachedFrameCount(INT* count)
     if (!count)
         return E_POINTER;
 
-    *count = pageCache()->frameCount();
+    *count = PageCache::shared().frameCount();
     return S_OK;
 }
index 5086ffa..0a195af 100644 (file)
@@ -63,7 +63,7 @@ void WebVisitedLinkStore::setShouldTrackVisitedLinks(bool shouldTrackVisitedLink
 void WebVisitedLinkStore::removeAllVisitedLinks()
 {
     shared().removeVisitedLinkHashes();
-    pageCache()->markPagesForVistedLinkStyleRecalc();
+    PageCache::shared().markPagesForVistedLinkStyleRecalc();
 }
 
 void WebVisitedLinkStore::addVisitedLink(const String& urlString)
@@ -116,7 +116,7 @@ void WebVisitedLinkStore::addVisitedLinkHash(LinkHash linkHash)
     m_visitedLinkHashes.add(linkHash);
 
     invalidateStylesForLink(linkHash);
-    pageCache()->markPagesForVistedLinkStyleRecalc();
+    PageCache::shared().markPagesForVistedLinkStyleRecalc();
 }
 
 void WebVisitedLinkStore::removeVisitedLinkHashes()
index 5764724..0f17eda 100644 (file)
@@ -675,7 +675,7 @@ void WebView::setCacheModel(WebCacheModel cacheModel)
 
     memoryCache().setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
     memoryCache().setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
-    pageCache()->setCapacity(pageCacheCapacity);
+    PageCache::shared().setCapacity(pageCacheCapacity);
 
 #if USE(CFNETWORK)
     // Don't shrink a big disk cache, since that would cause churn.
index 477e627..7c58315 100644 (file)
@@ -1,3 +1,28 @@
+2015-01-28  Chris Dumez  <cdumez@apple.com>
+
+        Rename pageCache() to PageCache::shared() and return a reference
+        https://bugs.webkit.org/show_bug.cgi?id=140983
+
+        Reviewed by Andreas Kling.
+
+        Rename pageCache() to PageCache::shared() as this is a singleton class
+        and have it return a reference instead of a pointer.
+
+        * WebProcess/WebPage/VisitedLinkTableController.cpp:
+        (WebKit::VisitedLinkTableController::setVisitedLinkTable):
+        (WebKit::VisitedLinkTableController::visitedLinkStateChanged):
+        (WebKit::VisitedLinkTableController::allVisitedLinkStateChanged):
+        (WebKit::VisitedLinkTableController::removeAllVisitedLinks):
+        * WebProcess/WebPage/WebBackForwardListProxy.cpp:
+        (WebKit::WebBackForwardListProxy::removeItem):
+        (WebKit::WebBackForwardListProxy::close):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::releasePageCache):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformSetCacheModel):
+        * WebProcess/soup/WebProcessSoup.cpp:
+        (WebKit::WebProcess::platformSetCacheModel):
+
 2015-01-27  Alexey Proskuryakov  <ap@apple.com>
 
         More build fixes for newer clang.
index 8e37462..9e6adcc 100644 (file)
@@ -97,20 +97,20 @@ void VisitedLinkTableController::setVisitedLinkTable(const SharedMemory::Handle&
     m_visitedLinkTable.setSharedMemory(sharedMemory.release());
 
     invalidateStylesForAllLinks();
-    pageCache()->markPagesForVistedLinkStyleRecalc();
+    PageCache::shared().markPagesForVistedLinkStyleRecalc();
 }
 
 void VisitedLinkTableController::visitedLinkStateChanged(const Vector<WebCore::LinkHash>& linkHashes)
 {
     for (auto linkHash : linkHashes)
         invalidateStylesForLink(linkHash);
-    pageCache()->markPagesForVistedLinkStyleRecalc();
+    PageCache::shared().markPagesForVistedLinkStyleRecalc();
 }
 
 void VisitedLinkTableController::allVisitedLinkStateChanged()
 {
     invalidateStylesForAllLinks();
-    pageCache()->markPagesForVistedLinkStyleRecalc();
+    PageCache::shared().markPagesForVistedLinkStyleRecalc();
 }
 
 void VisitedLinkTableController::removeAllVisitedLinks()
@@ -118,7 +118,7 @@ void VisitedLinkTableController::removeAllVisitedLinks()
     m_visitedLinkTable.clear();
 
     invalidateStylesForAllLinks();
-    pageCache()->markPagesForVistedLinkStyleRecalc();
+    PageCache::shared().markPagesForVistedLinkStyleRecalc();
 }
 
 } // namespace WebKit
index 6520440..a17613b 100644 (file)
@@ -132,7 +132,7 @@ void WebBackForwardListProxy::removeItem(uint64_t itemID)
     if (!item)
         return;
         
-    pageCache()->remove(item.get());
+    PageCache::shared().remove(item.get());
     WebCore::Page::clearPreviousItemFromAllPages(item.get());
     historyItemToIDMap().remove(item);
 }
@@ -218,7 +218,7 @@ void WebBackForwardListProxy::close()
 {
     HashSet<uint64_t>::iterator end = m_associatedItemIDs.end();
     for (HashSet<uint64_t>::iterator i = m_associatedItemIDs.begin(); i != end; ++i)
-        WebCore::pageCache()->remove(itemForID(*i));
+        WebCore::PageCache::shared().remove(itemForID(*i));
 
     m_associatedItemIDs.clear();
 
index c7c187e..8b8b884 100644 (file)
@@ -1116,7 +1116,7 @@ void WebProcess::setTextCheckerState(const TextCheckerState& textCheckerState)
 
 void WebProcess::releasePageCache()
 {
-    pageCache()->pruneToCapacityNow(0, PruningReason::MemoryPressure);
+    PageCache::shared().pruneToCapacityNow(0, PruningReason::MemoryPressure);
 }
 
 #if !PLATFORM(COCOA)
index 113dc9a..88e4d98 100644 (file)
@@ -115,7 +115,7 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel)
 
     memoryCache().setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
     memoryCache().setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
-    pageCache()->setCapacity(pageCacheCapacity);
+    PageCache::shared().setCapacity(pageCacheCapacity);
 
     NSURLCache *nsurlCache = [NSURLCache sharedURLCache];
 
index 7d8a68a..bcc7ad6 100644 (file)
@@ -104,10 +104,10 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel)
     WebCore::memoryCache().setDisabled(cacheModel == CacheModelDocumentViewer);
     WebCore::memoryCache().setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
     WebCore::memoryCache().setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
-    WebCore::pageCache()->setCapacity(pageCacheCapacity);
+    WebCore::PageCache::shared().setCapacity(pageCacheCapacity);
 
 #if PLATFORM(GTK)
-    WebCore::pageCache()->setShouldClearBackingStores(true);
+    WebCore::PageCache::shared().setShouldClearBackingStores(true);
 #endif
 
     if (!usesNetworkProcess()) {