[iOS] Log using FeatureCounter when a PacheCache entry is not reused because it expired
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Dec 2014 20:13:07 +0000 (20:13 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Dec 2014 20:13:07 +0000 (20:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=139869
<rdar://problem/19255690>

Reviewed by Darin Adler.

Log using FeatureCounter when a PacheCache entry is not reused because
it expired.

* history/PageCache.cpp:
(WebCore::PageCache::take):
(WebCore::PageCache::get):
* history/PageCache.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::commitProvisionalLoad):
(WebCore::FrameLoader::loadDifferentDocumentItem):
* loader/HistoryController.cpp:
(WebCore::HistoryController::invalidateCurrentItemCachedPage):
* platform/FeatureCounterKeys.h:

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

Source/WebCore/ChangeLog
Source/WebCore/history/PageCache.cpp
Source/WebCore/history/PageCache.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/HistoryController.cpp
Source/WebCore/platform/FeatureCounterKeys.h

index c429340..e81f011 100644 (file)
@@ -1,3 +1,25 @@
+2014-12-22  Chris Dumez  <cdumez@apple.com>
+
+        [iOS] Log using FeatureCounter when a PacheCache entry is not reused because it expired
+        https://bugs.webkit.org/show_bug.cgi?id=139869
+        <rdar://problem/19255690>
+
+        Reviewed by Darin Adler.
+
+        Log using FeatureCounter when a PacheCache entry is not reused because
+        it expired.
+
+        * history/PageCache.cpp:
+        (WebCore::PageCache::take):
+        (WebCore::PageCache::get):
+        * history/PageCache.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::commitProvisionalLoad):
+        (WebCore::FrameLoader::loadDifferentDocumentItem):
+        * loader/HistoryController.cpp:
+        (WebCore::HistoryController::invalidateCurrentItemCachedPage):
+        * platform/FeatureCounterKeys.h:
+
 2014-12-22  Antti Koivisto  <antti@apple.com>
 
         Try to fix the windows build.
index 8058833..311ea14 100644 (file)
@@ -451,7 +451,7 @@ void PageCache::add(PassRefPtr<HistoryItem> prpItem, Page& page)
     prune();
 }
 
-std::unique_ptr<CachedPage> PageCache::take(HistoryItem* item)
+std::unique_ptr<CachedPage> PageCache::take(HistoryItem* item, Page* page)
 {
     if (!item)
         return nullptr;
@@ -468,25 +468,27 @@ std::unique_ptr<CachedPage> PageCache::take(HistoryItem* item)
 
     if (cachedPage->hasExpired()) {
         LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", item->url().string().ascii().data());
+        FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterPageCacheFailureExpiredKey);
         return nullptr;
     }
 
     return cachedPage;
 }
 
-CachedPage* PageCache::get(HistoryItem* item)
+CachedPage* PageCache::get(HistoryItem* item, Page* page)
 {
     if (!item)
-        return 0;
+        return nullptr;
 
     if (CachedPage* cachedPage = item->m_cachedPage.get()) {
         if (!cachedPage->hasExpired())
             return cachedPage;
         
         LOG(PageCache, "Not restoring page for %s from back/forward cache because cache entry has expired", item->url().string().ascii().data());
+        FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterPageCacheFailureExpiredKey);
         pageCache()->remove(item);
     }
-    return 0;
+    return nullptr;
 }
 
 void PageCache::remove(HistoryItem* item)
index ced4d62..c96f47a 100644 (file)
@@ -50,8 +50,8 @@ namespace WebCore {
         
         void add(PassRefPtr<HistoryItem>, Page&); // Prunes if capacity() is exceeded.
         WEBCORE_EXPORT void remove(HistoryItem*);
-        CachedPage* get(HistoryItem* item);
-        std::unique_ptr<CachedPage> take(HistoryItem*);
+        CachedPage* get(HistoryItem*, Page*);
+        std::unique_ptr<CachedPage> take(HistoryItem*, Page*);
 
         int pageCount() const { return m_size; }
         WEBCORE_EXPORT int frameCount() const;
index 7f262fb..30ac20f 100644 (file)
@@ -1749,7 +1749,7 @@ void FrameLoader::commitProvisionalLoad()
 
     std::unique_ptr<CachedPage> cachedPage;
     if (m_loadingFromCachedPage)
-        cachedPage = pageCache()->take(history().provisionalItem());
+        cachedPage = pageCache()->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() : "",
@@ -3175,7 +3175,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)) {
+    if (CachedPage* cachedPage = pageCache()->get(item, m_frame.page())) {
         auto documentLoader = cachedPage->documentLoader();
         documentLoader->setTriggeringAction(NavigationAction(documentLoader->request(), loadType, false));
         documentLoader->setLastCheckedRequest(ResourceRequest());
index 96df50a..b71c5b5 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()))
+    if (!pageCache()->get(currentItem(), m_frame.page()))
         return;
 
-    std::unique_ptr<CachedPage> cachedPage = pageCache()->take(currentItem());
+    std::unique_ptr<CachedPage> cachedPage = pageCache()->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.
index 7ee223c..4dd7ccc 100644 (file)
@@ -58,6 +58,7 @@ static const char FeatureCounterPageCacheFailureDeviceProximityKey[] = "com.appl
 static const char FeatureCounterPageCacheFailureReloadKey[] = "com.apple.WebKit.pageCache.failure.reload";
 static const char FeatureCounterPageCacheFailureReloadFromOriginKey[] = "com.apple.WebKit.pageCache.failure.reloadFromOrigin";
 static const char FeatureCounterPageCacheFailureSameLoadKey[] = "com.apple.WebKit.pageCache.failure.sameLoad";
+static const char FeatureCounterPageCacheFailureExpiredKey[] = "com.apple.WebKit.pageCache.failure.expired";
 static const char FeatureCounterPageCacheFailureKey[] = "com.apple.WebKit.pageCache.failure";
 static const char FeatureCounterPageCacheSuccessKey[] = "com.apple.WebKit.pageCache.success";