Reverting "Cached Page and Frame don't need to be ref-counted.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Sep 2013 15:17:33 +0000 (15:17 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Sep 2013 15:17:33 +0000 (15:17 +0000)
<https://webkit.org/b/120758>

This didn't work so well on Qt bots. Will have to take bigger steps
here instead of iterating.

* history/CachedFrame.h:
(WebCore::CachedFrame::create):
* history/CachedPage.cpp:
(WebCore::CachedPage::create):
* history/CachedPage.h:
* history/HistoryItem.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::commitProvisionalLoad):
(WebCore::FrameLoader::transitionToCommitted):
* loader/FrameLoader.h:

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

Source/WebCore/ChangeLog
Source/WebCore/history/CachedFrame.h
Source/WebCore/history/CachedPage.cpp
Source/WebCore/history/CachedPage.h
Source/WebCore/history/HistoryItem.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoader.h

index a11c727..8fd24ad 100644 (file)
@@ -1,3 +1,22 @@
+2013-09-05  Andreas Kling  <akling@apple.com>
+
+        Reverting "Cached Page and Frame don't need to be ref-counted.
+        <https://webkit.org/b/120758>
+
+        This didn't work so well on Qt bots. Will have to take bigger steps
+        here instead of iterating.
+
+        * history/CachedFrame.h:
+        (WebCore::CachedFrame::create):
+        * history/CachedPage.cpp:
+        (WebCore::CachedPage::create):
+        * history/CachedPage.h:
+        * history/HistoryItem.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::commitProvisionalLoad):
+        (WebCore::FrameLoader::transitionToCommitted):
+        * loader/FrameLoader.h:
+
 2013-09-04  Anders Carlsson  <andersca@apple.com>
 
         Animations in an AnimationList are never null
index 9838f73..c23266f 100644 (file)
@@ -30,6 +30,7 @@
 #include "KURL.h"
 #include "ScriptCachedFrameData.h"
 #include <wtf/PassOwnPtr.h>
+#include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
@@ -66,12 +67,12 @@ protected:
     bool m_isComposited;
 #endif
     
-    Vector<OwnPtr<CachedFrame>> m_childFrames;
+    Vector<RefPtr<CachedFrame>> m_childFrames;
 };
 
-class CachedFrame : private CachedFrameBase {
+class CachedFrame : public RefCounted<CachedFrame>, private CachedFrameBase {
 public:
-    static PassOwnPtr<CachedFrame> create(Frame& frame) { return adoptPtr(new CachedFrame(frame)); }
+    static PassRefPtr<CachedFrame> create(Frame& frame) { return adoptRef(new CachedFrame(frame)); }
 
     void open();
     void clear();
index 8ddd331..4192e60 100644 (file)
@@ -45,9 +45,9 @@ namespace WebCore {
 
 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, cachedPageCounter, ("CachedPage"));
 
-PassOwnPtr<CachedPage> CachedPage::create(Page& page)
+PassRefPtr<CachedPage> CachedPage::create(Page& page)
 {
-    return adoptPtr(new CachedPage(page));
+    return adoptRef(new CachedPage(page));
 }
 
 CachedPage::CachedPage(Page& page)
index d8fb3e0..0d40382 100644 (file)
@@ -27,6 +27,7 @@
 #define CachedPage_h
 
 #include "CachedFrame.h"
+#include <wtf/RefCounted.h>
 
 namespace WebCore {
     
@@ -34,9 +35,9 @@ class Document;
 class DocumentLoader;
 class Page;
 
-class CachedPage {
+class CachedPage : public RefCounted<CachedPage> {
 public:
-    static PassOwnPtr<CachedPage> create(Page&);
+    static PassRefPtr<CachedPage> create(Page&);
     ~CachedPage();
 
     void restore(Page&);
@@ -66,7 +67,7 @@ private:
 
     double m_timeStamp;
     double m_expirationTime;
-    OwnPtr<CachedFrame> m_cachedMainFrame;
+    RefPtr<CachedFrame> m_cachedMainFrame;
     bool m_needStyleRecalcForVisitedLinks;
     bool m_needsFullStyleRecalc;
     bool m_needsCaptionPreferencesChanged;
index 573c1b1..7fe4511 100644 (file)
@@ -286,7 +286,7 @@ private:
     // PageCache controls these fields.
     HistoryItem* m_next;
     HistoryItem* m_prev;
-    OwnPtr<CachedPage> m_cachedPage;
+    RefPtr<CachedPage> m_cachedPage;
     
 #if PLATFORM(MAC)
     RetainPtr<id> m_viewState;
index ec368f3..1d02225 100644 (file)
@@ -1699,7 +1699,7 @@ void FrameLoader::clearProvisionalLoad()
 
 void FrameLoader::commitProvisionalLoad()
 {
-    CachedPage* cachedPage = m_loadingFromCachedPage ? pageCache()->get(history().provisionalItem()) : 0;
+    RefPtr<CachedPage> cachedPage = m_loadingFromCachedPage ? pageCache()->get(history().provisionalItem()) : 0;
     RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
     Ref<Frame> protect(m_frame);
 
@@ -1743,9 +1743,6 @@ void FrameLoader::commitProvisionalLoad()
         // The page should be removed from the cache immediately after a restoration in order for the PageCache to be consistent.
         pageCache()->remove(history().currentItem());
 
-        // Clear out 'cachedPage' right away since it now points to a deleted object.
-        cachedPage = nullptr;
-
         dispatchDidCommitLoad();
 
         // If we have a title let the WebView know about it. 
@@ -1755,12 +1752,8 @@ void FrameLoader::commitProvisionalLoad()
 
         checkCompleted();
     } else {
-        if (cachedPage) {
+        if (cachedPage)
             pageCache()->remove(history().currentItem());
-
-            // Clear out 'cachedPage' right away since it now points to a deleted object.
-            cachedPage = nullptr;
-        }
         didOpenURL();
     }
 
@@ -1796,7 +1789,7 @@ void FrameLoader::commitProvisionalLoad()
     }
 }
 
-void FrameLoader::transitionToCommitted(CachedPage* cachedPage)
+void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
 {
     ASSERT(m_client.hasWebView());
     ASSERT(m_state == FrameStateProvisional);
index fab57a3..803eac1 100644 (file)
@@ -308,7 +308,7 @@ private:
     void addExtraFieldsToRequest(ResourceRequest&, FrameLoadType, bool isMainResource);
 
     void clearProvisionalLoad();
-    void transitionToCommitted(CachedPage*);
+    void transitionToCommitted(PassRefPtr<CachedPage>);
     void frameLoadCompleted();
 
     SubstituteData defaultSubstituteDataForURL(const KURL&);