Cached Page and Frame don't need to be ref-counted.
[WebKit-https.git] / Source / WebCore / history / PageCache.cpp
index d18f59e..5551fa4 100644 (file)
@@ -442,6 +442,29 @@ void PageCache::add(PassRefPtr<HistoryItem> prpItem, Page& page)
     prune();
 }
 
+PassOwnPtr<CachedPage> PageCache::take(HistoryItem* item)
+{
+    if (!item)
+        return nullptr;
+
+    OwnPtr<CachedPage> cachedPage = item->m_cachedPage.release();
+
+    removeFromLRUList(item);
+    --m_size;
+
+    item->deref(); // Balanced in add().
+
+    if (!cachedPage)
+        return nullptr;
+
+    if (cachedPage->hasExpired()) {
+        LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", item->url().string().ascii().data());
+        return nullptr;
+    }
+
+    return cachedPage.release();
+}
+
 CachedPage* PageCache::get(HistoryItem* item)
 {
     if (!item)