Clean up PageCache classes
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jan 2014 01:47:19 +0000 (01:47 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 18 Jan 2014 01:47:19 +0000 (01:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127202

Reviewed by Andreas Kling.

Source/WebCore:

* WebCore.exp.in:
* history/CachedFrame.cpp:
(WebCore::CachedFrameBase::~CachedFrameBase):
(WebCore::CachedFrame::CachedFrame):
(WebCore::CachedFrame::clear):
(WebCore::CachedFrame::setCachedFramePlatformData):
* history/CachedFrame.h:
* history/CachedPage.cpp:
(WebCore::CachedPage::CachedPage):
* history/CachedPage.h:
* history/HistoryItem.h:
(WebCore::HistoryItem::isInPageCache):
* history/PageCache.cpp:
(WebCore::PageCache::add):
(WebCore::PageCache::take):
(WebCore::PageCache::remove):
* history/PageCache.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::commitProvisionalLoad):
* loader/HistoryController.cpp:
(WebCore::HistoryController::invalidateCurrentItemCachedPage):

Source/WebKit/mac:

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::savePlatformDataToCachedFrame):
(WebFrameLoaderClient::transitionToCommittedFromCachedFrame):

Source/WebKit/win:

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::savePlatformDataToCachedFrame):

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

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/history/CachedFrame.cpp
Source/WebCore/history/CachedFrame.h
Source/WebCore/history/CachedPage.cpp
Source/WebCore/history/CachedPage.h
Source/WebCore/history/HistoryItem.h
Source/WebCore/history/PageCache.cpp
Source/WebCore/history/PageCache.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/HistoryController.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp

index effc54e..e766c92 100644 (file)
@@ -1,3 +1,32 @@
+2014-01-17  Anders Carlsson  <andersca@apple.com>
+
+        Clean up PageCache classes
+        https://bugs.webkit.org/show_bug.cgi?id=127202
+
+        Reviewed by Andreas Kling.
+
+        * WebCore.exp.in:
+        * history/CachedFrame.cpp:
+        (WebCore::CachedFrameBase::~CachedFrameBase):
+        (WebCore::CachedFrame::CachedFrame):
+        (WebCore::CachedFrame::clear):
+        (WebCore::CachedFrame::setCachedFramePlatformData):
+        * history/CachedFrame.h:
+        * history/CachedPage.cpp:
+        (WebCore::CachedPage::CachedPage):
+        * history/CachedPage.h:
+        * history/HistoryItem.h:
+        (WebCore::HistoryItem::isInPageCache):
+        * history/PageCache.cpp:
+        (WebCore::PageCache::add):
+        (WebCore::PageCache::take):
+        (WebCore::PageCache::remove):
+        * history/PageCache.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::commitProvisionalLoad):
+        * loader/HistoryController.cpp:
+        (WebCore::HistoryController::invalidateCurrentItemCachedPage):
+
 2014-01-17  Andy Estes  <aestes@apple.com>
 
         Work around a preprocessor warning in mediaControlsApple.js
index c7cc610..8a2d607 100644 (file)
@@ -121,7 +121,7 @@ __ZN7WebCore11BitmapImage13getCGImageRefEv
 __ZN7WebCore11BitmapImageC1EP7CGImagePNS_13ImageObserverE
 __ZN7WebCore11BitmapImageC1EPNS_13ImageObserverE
 __ZN7WebCore11CachedFrame23cachedFramePlatformDataEv
-__ZN7WebCore11CachedFrame26setCachedFramePlatformDataEN3WTF10PassOwnPtrINS_23CachedFramePlatformDataEEE
+__ZN7WebCore11CachedFrame26setCachedFramePlatformDataENSt3__110unique_ptrINS_23CachedFramePlatformDataENS1_14default_deleteIS3_EEEE
 __ZN7WebCore11FileChooser10chooseFileERKN3WTF6StringE
 __ZN7WebCore11FileChooser11chooseFilesERKN3WTF6VectorINS1_6StringELm0ENS1_15CrashOnOverflowEEE
 __ZN7WebCore11FileChooserD1Ev
index d4a4023..1f61671 100644 (file)
 
 namespace WebCore {
 
-#ifndef NDEBUG
-static WTF::RefCountedLeakCounter& cachedFrameCounter()
-{
-    DEFINE_STATIC_LOCAL(WTF::RefCountedLeakCounter, counter, ("CachedFrame"));
-    return counter;
-}
-#endif
+DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, cachedFrameCounter, ("CachedFrame"));
 
 CachedFrameBase::CachedFrameBase(Frame& frame)
     : m_document(frame.document())
@@ -88,7 +82,7 @@ CachedFrameBase::CachedFrameBase(Frame& frame)
 CachedFrameBase::~CachedFrameBase()
 {
 #ifndef NDEBUG
-    cachedFrameCounter().decrement();
+    cachedFrameCounter.decrement();
 #endif
     // CachedFrames should always have had destroy() called by their parent CachedPage
     ASSERT(!m_document);
@@ -162,7 +156,7 @@ CachedFrame::CachedFrame(Frame& frame)
     : CachedFrameBase(frame)
 {
 #ifndef NDEBUG
-    cachedFrameCounter().increment();
+    cachedFrameCounter.increment();
 #endif
     ASSERT(m_document);
     ASSERT(m_documentLoader);
@@ -179,7 +173,7 @@ CachedFrame::CachedFrame(Frame& frame)
 
     // Create the CachedFrames for all Frames in the FrameTree.
     for (Frame* child = frame.tree().firstChild(); child; child = child->tree().nextSibling())
-        m_childFrames.append(CachedFrame::create(*child));
+        m_childFrames.append(std::make_unique<CachedFrame>(*child));
 
     // Active DOM objects must be suspended before we cache the frame script data,
     // but after we've fired the pagehide event, in case that creates more objects.
@@ -188,7 +182,7 @@ CachedFrame::CachedFrame(Frame& frame)
     m_document->documentWillSuspendForPageCache();
     m_document->suspendScriptedAnimationControllerCallbacks();
     m_document->suspendActiveDOMObjects(ActiveDOMObject::DocumentWillBecomeInactive);
-    m_cachedFrameScriptData = adoptPtr(new ScriptCachedFrameData(frame));
+    m_cachedFrameScriptData = std::make_unique<ScriptCachedFrameData>(frame);
 
     m_document->domWindow()->suspendForPageCache();
 
@@ -256,13 +250,13 @@ void CachedFrame::clear()
     for (int i = m_childFrames.size() - 1; i >= 0; --i)
         m_childFrames[i]->clear();
 
-    m_document = 0;
-    m_view = 0;
-    m_mousePressNode = 0;
+    m_document = nullptr;
+    m_view = nullptr;
+    m_mousePressNode = nullptr;
     m_url = URL();
 
-    m_cachedFramePlatformData.clear();
-    m_cachedFrameScriptData.clear();
+    m_cachedFramePlatformData = nullptr;
+    m_cachedFrameScriptData = nullptr;
 }
 
 void CachedFrame::destroy()
@@ -300,9 +294,9 @@ void CachedFrame::destroy()
     clear();
 }
 
-void CachedFrame::setCachedFramePlatformData(PassOwnPtr<CachedFramePlatformData> data)
+void CachedFrame::setCachedFramePlatformData(std::unique_ptr<CachedFramePlatformData> data)
 {
-    m_cachedFramePlatformData = data;
+    m_cachedFramePlatformData = std::move(data);
 }
 
 CachedFramePlatformData* CachedFrame::cachedFramePlatformData()
index 3864ca4..e9f367b 100644 (file)
@@ -29,7 +29,6 @@
 #include "DOMWindow.h"
 #include "URL.h"
 #include "ScriptCachedFrameData.h"
-#include <wtf/PassOwnPtr.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
@@ -59,25 +58,25 @@ protected:
     RefPtr<FrameView> m_view;
     RefPtr<Node> m_mousePressNode;
     URL m_url;
-    OwnPtr<ScriptCachedFrameData> m_cachedFrameScriptData;
-    OwnPtr<CachedFramePlatformData> m_cachedFramePlatformData;
+    std::unique_ptr<ScriptCachedFrameData> m_cachedFrameScriptData;
+    std::unique_ptr<CachedFramePlatformData> m_cachedFramePlatformData;
     bool m_isMainFrame;
 #if USE(ACCELERATED_COMPOSITING)
     bool m_isComposited;
 #endif
     
-    Vector<OwnPtr<CachedFrame>> m_childFrames;
+    Vector<std::unique_ptr<CachedFrame>> m_childFrames;
 };
 
 class CachedFrame : private CachedFrameBase {
 public:
-    static PassOwnPtr<CachedFrame> create(Frame& frame) { return adoptPtr(new CachedFrame(frame)); }
+    explicit CachedFrame(Frame&);
 
     void open();
     void clear();
     void destroy();
 
-    void setCachedFramePlatformData(PassOwnPtr<CachedFramePlatformData>);
+    void setCachedFramePlatformData(std::unique_ptr<CachedFramePlatformData>);
     CachedFramePlatformData* cachedFramePlatformData();
 
     using CachedFrameBase::document;
@@ -87,9 +86,6 @@ public:
     Node* mousePressNode() const { return m_mousePressNode.get(); }
 
     int descendantFrameCount() const;
-
-private:
-    explicit CachedFrame(Frame&);
 };
 
 } // namespace WebCore
index 410b91b..cad1849 100644 (file)
@@ -49,15 +49,10 @@ namespace WebCore {
 
 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, cachedPageCounter, ("CachedPage"));
 
-PassOwnPtr<CachedPage> CachedPage::create(Page& page)
-{
-    return adoptPtr(new CachedPage(page));
-}
-
 CachedPage::CachedPage(Page& page)
     : m_timeStamp(monotonicallyIncreasingTime())
     , m_expirationTime(m_timeStamp + page.settings().backForwardCacheExpirationInterval())
-    , m_cachedMainFrame(CachedFrame::create(page.mainFrame()))
+    , m_cachedMainFrame(std::make_unique<CachedFrame>(page.mainFrame()))
     , m_needStyleRecalcForVisitedLinks(false)
     , m_needsFullStyleRecalc(false)
     , m_needsCaptionPreferencesChanged(false)
index d8fb3e0..bb83e0f 100644 (file)
@@ -36,7 +36,7 @@ class Page;
 
 class CachedPage {
 public:
-    static PassOwnPtr<CachedPage> create(Page&);
+    explicit CachedPage(Page&);
     ~CachedPage();
 
     void restore(Page&);
@@ -61,12 +61,11 @@ public:
 #endif
 
 private:
-    explicit CachedPage(Page&);
     void destroy();
 
     double m_timeStamp;
     double m_expirationTime;
-    OwnPtr<CachedFrame> m_cachedMainFrame;
+    std::unique_ptr<CachedFrame> m_cachedMainFrame;
     bool m_needStyleRecalcForVisitedLinks;
     bool m_needsFullStyleRecalc;
     bool m_needsCaptionPreferencesChanged;
index 8edb671..51fc0d1 100644 (file)
@@ -98,7 +98,7 @@ public:
     const String& urlString() const;
     const String& title() const;
     
-    bool isInPageCache() const { return m_cachedPage; }
+    bool isInPageCache() const { return m_cachedPage.get(); }
     bool hasCachedPageExpired() const;
     
     double lastVisitedTime() const;
@@ -287,7 +287,7 @@ private:
     // PageCache controls these fields.
     HistoryItem* m_next;
     HistoryItem* m_prev;
-    OwnPtr<CachedPage> m_cachedPage;
+    std::unique_ptr<CachedPage> m_cachedPage;
 
 #if PLATFORM(IOS)
     float m_scale;
index 7c65587..1e8f208 100644 (file)
@@ -472,19 +472,19 @@ void PageCache::add(PassRefPtr<HistoryItem> prpItem, Page& page)
     if (item->m_cachedPage)
         remove(item);
 
-    item->m_cachedPage = CachedPage::create(page);
+    item->m_cachedPage = std::make_unique<CachedPage>(page);
     addToLRUList(item);
     ++m_size;
     
     prune();
 }
 
-PassOwnPtr<CachedPage> PageCache::take(HistoryItem* item)
+std::unique_ptr<CachedPage> PageCache::take(HistoryItem* item)
 {
     if (!item)
         return nullptr;
 
-    OwnPtr<CachedPage> cachedPage = item->m_cachedPage.release();
+    std::unique_ptr<CachedPage> cachedPage = std::move(item->m_cachedPage);
 
     removeFromLRUList(item);
     --m_size;
@@ -499,7 +499,7 @@ PassOwnPtr<CachedPage> PageCache::take(HistoryItem* item)
         return nullptr;
     }
 
-    return cachedPage.release();
+    return cachedPage;
 }
 
 CachedPage* PageCache::get(HistoryItem* item)
@@ -523,7 +523,7 @@ void PageCache::remove(HistoryItem* item)
     if (!item || !item->m_cachedPage)
         return;
 
-    item->m_cachedPage.clear();
+    item->m_cachedPage = nullptr;
     removeFromLRUList(item);
     --m_size;
 
index 347772d..ebab10c 100644 (file)
@@ -51,7 +51,7 @@ namespace WebCore {
         void add(PassRefPtr<HistoryItem>, Page&); // Prunes if capacity() is exceeded.
         void remove(HistoryItem*);
         CachedPage* get(HistoryItem* item);
-        PassOwnPtr<CachedPage> take(HistoryItem*);
+        std::unique_ptr<CachedPage> take(HistoryItem*);
 
         int pageCount() const { return m_size; }
         int frameCount() const;
index ec28d87..2bd20b9 100644 (file)
@@ -1772,7 +1772,7 @@ void FrameLoader::commitProvisionalLoad()
     RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
     Ref<Frame> protect(m_frame);
 
-    OwnPtr<CachedPage> cachedPage;
+    std::unique_ptr<CachedPage> cachedPage;
     if (m_loadingFromCachedPage)
         cachedPage = pageCache()->take(history().provisionalItem());
 
index af864fe..2d69c0c 100644 (file)
@@ -231,7 +231,7 @@ void HistoryController::invalidateCurrentItemCachedPage()
     if (!pageCache()->get(currentItem()))
         return;
 
-    OwnPtr<CachedPage> cachedPage = pageCache()->take(currentItem());
+    std::unique_ptr<CachedPage> cachedPage = pageCache()->take(currentItem());
 
     // 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.
index 0aedd1e..8d51ee0 100644 (file)
@@ -1,5 +1,16 @@
 2014-01-17  Anders Carlsson  <andersca@apple.com>
 
+        Clean up PageCache classes
+        https://bugs.webkit.org/show_bug.cgi?id=127202
+
+        Reviewed by Andreas Kling.
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::savePlatformDataToCachedFrame):
+        (WebFrameLoaderClient::transitionToCommittedFromCachedFrame):
+
+2014-01-17  Anders Carlsson  <andersca@apple.com>
+
         Remove another unused FrameLoaderClient callback
         https://bugs.webkit.org/show_bug.cgi?id=127192
 
index 087f6a3..e19d802 100644 (file)
@@ -1410,8 +1410,7 @@ void WebFrameLoaderClient::setTitle(const StringWithDirection& title, const URL&
 
 void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame* cachedFrame)
 {
-    OwnPtr<WebCachedFramePlatformData> webPlatformData = adoptPtr(new WebCachedFramePlatformData([m_webFrame->_private->webFrameView documentView]));
-    cachedFrame->setCachedFramePlatformData(webPlatformData.release());
+    cachedFrame->setCachedFramePlatformData(std::make_unique<WebCachedFramePlatformData>(m_webFrame->_private->webFrameView.documentView));
 
 #if PLATFORM(IOS)
     // At this point we know this frame is going to be cached. Stop all plugins.
@@ -1422,7 +1421,7 @@ void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame* cachedFram
 
 void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame* cachedFrame)
 {
-    WebCachedFramePlatformData* platformData = reinterpret_cast<WebCachedFramePlatformData*>(cachedFrame->cachedFramePlatformData());
+    WebCachedFramePlatformData* platformData = static_cast<WebCachedFramePlatformData*>(cachedFrame->cachedFramePlatformData());
     NSView <WebDocumentView> *cachedView = platformData->webDocumentView();
     ASSERT(cachedView != nil);
     ASSERT(cachedFrame->documentLoader());
index 74086fe..f9d04e0 100644 (file)
@@ -1,5 +1,15 @@
 2014-01-17  Anders Carlsson  <andersca@apple.com>
 
+        Clean up PageCache classes
+        https://bugs.webkit.org/show_bug.cgi?id=127202
+
+        Reviewed by Andreas Kling.
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::savePlatformDataToCachedFrame):
+
+2014-01-17  Anders Carlsson  <andersca@apple.com>
+
         Remove another unused FrameLoaderClient callback
         https://bugs.webkit.org/show_bug.cgi?id=127192
 
index 5eba8fb..0e3ecef 100644 (file)
@@ -1024,7 +1024,7 @@ void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame* cachedFram
 
     ASSERT(coreFrame->loader().documentLoader() == cachedFrame->documentLoader());
 
-    cachedFrame->setCachedFramePlatformData(adoptPtr(new WebCachedFramePlatformData(static_cast<IWebDataSource*>(getWebDataSource(coreFrame->loader().documentLoader())))));
+    cachedFrame->setCachedFramePlatformData(std::make_unique<WebCachedFramePlatformData>(static_cast<IWebDataSource*>(getWebDataSource(coreFrame->loader().documentLoader()))));
 #else
     notImplemented();
 #endif