Use DiagnosticLoggingClient to log page cache failures
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jan 2015 10:07:21 +0000 (10:07 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jan 2015 10:07:21 +0000 (10:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140650

Reviewed by Andreas Kling.

Use DiagnosticLoggingClient to log page cache failures instead of the
legacy FeatureCounter.

* history/PageCache.cpp:
(WebCore::logPageCacheFailureDiagnosticMessage):
(WebCore::logCanCacheFrameDecision):
(WebCore::logCanCachePageDecision):
(WebCore::PageCache::canCache):
(WebCore::pruningReasonToDiagnosticLoggingKey):
(WebCore::PageCache::take):
(WebCore::PageCache::get):
(WebCore::pruningReasonToFeatureCounterKey): Deleted.
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::successKey):
(WebCore::DiagnosticLoggingKeys::failureKey):
(WebCore::DiagnosticLoggingKeys::pageLoadedKey):
(WebCore::DiagnosticLoggingKeys::engineFailedToLoadKey):
(WebCore::DiagnosticLoggingKeys::navigationKey):
(WebCore::DiagnosticLoggingKeys::pageCacheKey):
(WebCore::DiagnosticLoggingKeys::noDocumentLoaderKey):
(WebCore::DiagnosticLoggingKeys::mainDocumentErrorKey):
(WebCore::DiagnosticLoggingKeys::isErrorPageKey):
(WebCore::DiagnosticLoggingKeys::hasPluginsKey):
(WebCore::DiagnosticLoggingKeys::httpsNoStoreKey):
(WebCore::DiagnosticLoggingKeys::hasOpenDatabasesKey):
(WebCore::DiagnosticLoggingKeys::noCurrentHistoryItemKey):
(WebCore::DiagnosticLoggingKeys::quirkRedirectComingKey):
(WebCore::DiagnosticLoggingKeys::loadingAPISenseKey):
(WebCore::DiagnosticLoggingKeys::documentLoaderStoppingKey):
(WebCore::DiagnosticLoggingKeys::cannotSuspendActiveDOMObjectsKey):
(WebCore::DiagnosticLoggingKeys::applicationCacheKey):
(WebCore::DiagnosticLoggingKeys::deniedByClientKey):
(WebCore::DiagnosticLoggingKeys::deviceMotionKey):
(WebCore::DiagnosticLoggingKeys::deviceOrientationKey):
(WebCore::DiagnosticLoggingKeys::deviceProximityKey):
(WebCore::DiagnosticLoggingKeys::reloadKey):
(WebCore::DiagnosticLoggingKeys::reloadFromOriginKey):
(WebCore::DiagnosticLoggingKeys::sameLoadKey):
(WebCore::DiagnosticLoggingKeys::expiredKey):
(WebCore::DiagnosticLoggingKeys::prunedDueToMemoryPressureKey):
(WebCore::DiagnosticLoggingKeys::prunedDueToCapacityReached):
(WebCore::DiagnosticLoggingKeys::prunedDueToProcessSuspended):
(WebCore::DiagnosticLoggingKeys::passKey): Deleted.
(WebCore::DiagnosticLoggingKeys::failKey): Deleted.
(WebCore::DiagnosticLoggingKeys::noopKey): Deleted.
* page/DiagnosticLoggingKeys.h:
* platform/FeatureCounterKeys.h:

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

Source/WebCore/ChangeLog
Source/WebCore/history/PageCache.cpp
Source/WebCore/page/DiagnosticLoggingKeys.cpp
Source/WebCore/page/DiagnosticLoggingKeys.h
Source/WebCore/platform/FeatureCounterKeys.h

index 05c11a8..1302ed0 100644 (file)
@@ -1,3 +1,58 @@
+2015-01-20  Chris Dumez  <cdumez@apple.com>
+
+        Use DiagnosticLoggingClient to log page cache failures
+        https://bugs.webkit.org/show_bug.cgi?id=140650
+
+        Reviewed by Andreas Kling.
+
+        Use DiagnosticLoggingClient to log page cache failures instead of the
+        legacy FeatureCounter.
+
+        * history/PageCache.cpp:
+        (WebCore::logPageCacheFailureDiagnosticMessage):
+        (WebCore::logCanCacheFrameDecision):
+        (WebCore::logCanCachePageDecision):
+        (WebCore::PageCache::canCache):
+        (WebCore::pruningReasonToDiagnosticLoggingKey):
+        (WebCore::PageCache::take):
+        (WebCore::PageCache::get):
+        (WebCore::pruningReasonToFeatureCounterKey): Deleted.
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::successKey):
+        (WebCore::DiagnosticLoggingKeys::failureKey):
+        (WebCore::DiagnosticLoggingKeys::pageLoadedKey):
+        (WebCore::DiagnosticLoggingKeys::engineFailedToLoadKey):
+        (WebCore::DiagnosticLoggingKeys::navigationKey):
+        (WebCore::DiagnosticLoggingKeys::pageCacheKey):
+        (WebCore::DiagnosticLoggingKeys::noDocumentLoaderKey):
+        (WebCore::DiagnosticLoggingKeys::mainDocumentErrorKey):
+        (WebCore::DiagnosticLoggingKeys::isErrorPageKey):
+        (WebCore::DiagnosticLoggingKeys::hasPluginsKey):
+        (WebCore::DiagnosticLoggingKeys::httpsNoStoreKey):
+        (WebCore::DiagnosticLoggingKeys::hasOpenDatabasesKey):
+        (WebCore::DiagnosticLoggingKeys::noCurrentHistoryItemKey):
+        (WebCore::DiagnosticLoggingKeys::quirkRedirectComingKey):
+        (WebCore::DiagnosticLoggingKeys::loadingAPISenseKey):
+        (WebCore::DiagnosticLoggingKeys::documentLoaderStoppingKey):
+        (WebCore::DiagnosticLoggingKeys::cannotSuspendActiveDOMObjectsKey):
+        (WebCore::DiagnosticLoggingKeys::applicationCacheKey):
+        (WebCore::DiagnosticLoggingKeys::deniedByClientKey):
+        (WebCore::DiagnosticLoggingKeys::deviceMotionKey):
+        (WebCore::DiagnosticLoggingKeys::deviceOrientationKey):
+        (WebCore::DiagnosticLoggingKeys::deviceProximityKey):
+        (WebCore::DiagnosticLoggingKeys::reloadKey):
+        (WebCore::DiagnosticLoggingKeys::reloadFromOriginKey):
+        (WebCore::DiagnosticLoggingKeys::sameLoadKey):
+        (WebCore::DiagnosticLoggingKeys::expiredKey):
+        (WebCore::DiagnosticLoggingKeys::prunedDueToMemoryPressureKey):
+        (WebCore::DiagnosticLoggingKeys::prunedDueToCapacityReached):
+        (WebCore::DiagnosticLoggingKeys::prunedDueToProcessSuspended):
+        (WebCore::DiagnosticLoggingKeys::passKey): Deleted.
+        (WebCore::DiagnosticLoggingKeys::failKey): Deleted.
+        (WebCore::DiagnosticLoggingKeys::noopKey): Deleted.
+        * page/DiagnosticLoggingKeys.h:
+        * platform/FeatureCounterKeys.h:
+
 2015-01-19  Sergio Villar Senin  <svillar@igalia.com>
 
         [CSS Grid Layout] Wrong arguments passed to computeNormalizedFractionBreadth
index 9dba497..cf65c0f 100644 (file)
 #include "DatabaseManager.h"
 #include "DeviceMotionController.h"
 #include "DeviceOrientationController.h"
+#include "DiagnosticLoggingClient.h"
+#include "DiagnosticLoggingKeys.h"
 #include "Document.h"
 #include "DocumentLoader.h"
-#include "FeatureCounter.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
 #include "FrameLoaderStateMachine.h"
@@ -95,99 +96,115 @@ enum ReasonFrameCannotBeInPageCache {
 };
 COMPILE_ASSERT(NumberOfReasonsFramesCannotBeInPageCache <= sizeof(unsigned)*8, ReasonFrameCannotBeInPageCacheDoesNotFitInBitmap);
 
-static unsigned logCanCacheFrameDecision(Frame* frame, int indentLevel)
+static inline void logPageCacheFailureDiagnosticMessage(DiagnosticLoggingClient* client, const String& reason)
+{
+    if (client)
+        client->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::pageCacheKey(), DiagnosticLoggingKeys::failureKey(), reason);
+}
+
+static inline void logPageCacheFailureDiagnosticMessage(Page* page, const String& reason)
+{
+    if (!page)
+        return;
+
+    MainFrame& mainFrame = page->mainFrame();
+    if (mainFrame.settings().diagnosticLoggingEnabled())
+        logPageCacheFailureDiagnosticMessage(mainFrame.diagnosticLoggingClient(), reason);
+}
+
+static unsigned logCanCacheFrameDecision(Frame& frame, DiagnosticLoggingClient* diagnosticLoggingClient, int indentLevel)
 {
     PCLOG("+---");
-    if (!frame->loader().documentLoader()) {
+    if (!frame.loader().documentLoader()) {
         PCLOG("   -There is no DocumentLoader object");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureNoDocumentLoaderKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::noDocumentLoaderKey());
         return 1 << NoDocumentLoader;
     }
 
-    URL currentURL = frame->loader().documentLoader()->url();
-    URL newURL = frame->loader().provisionalDocumentLoader() ? frame->loader().provisionalDocumentLoader()->url() : URL();
+    URL currentURL = frame.loader().documentLoader()->url();
+    URL newURL = frame.loader().provisionalDocumentLoader() ? frame.loader().provisionalDocumentLoader()->url() : URL();
     if (!newURL.isEmpty())
         PCLOG(" Determining if frame can be cached navigating from (", currentURL.string(), ") to (", newURL.string(), "):");
     else
         PCLOG(" Determining if subframe with URL (", currentURL.string(), ") can be cached:");
      
     unsigned rejectReasons = 0;
-    if (!frame->loader().documentLoader()->mainDocumentError().isNull()) {
+    if (!frame.loader().documentLoader()->mainDocumentError().isNull()) {
         PCLOG("   -Main document has an error");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureMainDocumentErrorKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::mainDocumentErrorKey());
 #if !PLATFORM(IOS)
         rejectReasons |= 1 << MainDocumentError;
 #else
-        if (frame->loader().documentLoader()->mainDocumentError().isCancellation() && frame->loader().documentLoader()->subresourceLoadersArePageCacheAcceptable())
+        if (frame.loader().documentLoader()->mainDocumentError().isCancellation() && frame.loader().documentLoader()->subresourceLoadersArePageCacheAcceptable())
             PCLOG("    -But, it was a cancellation and all loaders during the cancel were loading images.");
         else
             rejectReasons |= 1 << MainDocumentError;
 #endif
     }
-    if (frame->loader().documentLoader()->substituteData().isValid() && frame->loader().documentLoader()->substituteData().failingURL().isEmpty()) {
+    if (frame.loader().documentLoader()->substituteData().isValid() && frame.loader().documentLoader()->substituteData().failingURL().isEmpty()) {
         PCLOG("   -Frame is an error page");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureIsErrorPageKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::isErrorPageKey());
         rejectReasons |= 1 << IsErrorPage;
     }
-    if (frame->loader().subframeLoader().containsPlugins() && !frame->page()->settings().pageCacheSupportsPlugins()) {
+    if (frame.loader().subframeLoader().containsPlugins() && !frame.page()->settings().pageCacheSupportsPlugins()) {
         PCLOG("   -Frame contains plugins");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureHasPlugins);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::hasPluginsKey());
         rejectReasons |= 1 << HasPlugins;
     }
-    if (frame->isMainFrame() && frame->document()->url().protocolIs("https") && frame->loader().documentLoader()->response().cacheControlContainsNoStore()) {
+    if (frame.isMainFrame() && frame.document()->url().protocolIs("https") && frame.loader().documentLoader()->response().cacheControlContainsNoStore()) {
         PCLOG("   -Frame is HTTPS, and cache control prohibits storing");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureHTTPSNoStoreKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::httpsNoStoreKey());
         rejectReasons |= 1 << IsHttpsAndCacheControlled;
     }
-    if (DatabaseManager::manager().hasOpenDatabases(frame->document())) {
+    if (DatabaseManager::manager().hasOpenDatabases(frame.document())) {
         PCLOG("   -Frame has open database handles");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureHasOpenDatabasesKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::hasOpenDatabasesKey());
         rejectReasons |= 1 << HasDatabaseHandles;
     }
-    if (!frame->loader().history().currentItem()) {
+    if (!frame.loader().history().currentItem()) {
         PCLOG("   -No current history item");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureNoCurrentHistoryItemKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::noCurrentHistoryItemKey());
         rejectReasons |= 1 << NoHistoryItem;
     }
-    if (frame->loader().quickRedirectComing()) {
+    if (frame.loader().quickRedirectComing()) {
         PCLOG("   -Quick redirect is coming");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureQuirkRedirectComingKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::quirkRedirectComingKey());
         rejectReasons |= 1 << QuickRedirectComing;
     }
-    if (frame->loader().documentLoader()->isLoadingInAPISense()) {
+    if (frame.loader().documentLoader()->isLoadingInAPISense()) {
         PCLOG("   -DocumentLoader is still loading in API sense");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureLoadingAPISenseKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::loadingAPISenseKey());
         rejectReasons |= 1 << IsLoadingInAPISense;
     }
-    if (frame->loader().documentLoader()->isStopping()) {
+    if (frame.loader().documentLoader()->isStopping()) {
         PCLOG("   -DocumentLoader is in the middle of stopping");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureDocumentLoaderStoppingKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::documentLoaderStoppingKey());
         rejectReasons |= 1 << IsStopping;
     }
 
     Vector<ActiveDOMObject*> unsuspendableObjects;
-    if (!frame->document()->canSuspendActiveDOMObjects(&unsuspendableObjects)) {
+    if (!frame.document()->canSuspendActiveDOMObjects(&unsuspendableObjects)) {
         PCLOG("   -The document cannot suspend its active DOM Objects");
         for (auto* activeDOMObject : unsuspendableObjects) {
             PCLOG("    - Unsuspendable: ", activeDOMObject->activeDOMObjectName());
             UNUSED_PARAM(activeDOMObject);
         }
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureCannotSuspendActiveDOMObjectsKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::cannotSuspendActiveDOMObjectsKey());
         rejectReasons |= 1 << CannotSuspendActiveDOMObjects;
     }
-    if (!frame->loader().documentLoader()->applicationCacheHost()->canCacheInPageCache()) {
+    if (!frame.loader().documentLoader()->applicationCacheHost()->canCacheInPageCache()) {
         PCLOG("   -The DocumentLoader uses an application cache");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureApplicationCacheKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::applicationCacheKey());
         rejectReasons |= 1 << DocumentLoaderUsesApplicationCache;
     }
-    if (!frame->loader().client().canCachePage()) {
+    if (!frame.loader().client().canCachePage()) {
         PCLOG("   -The client says this frame cannot be cached");
-        FEATURE_COUNTER_INCREMENT_KEY(frame->page(), FeatureCounterPageCacheFailureDeniedByClientKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::deniedByClientKey());
         rejectReasons |= 1 << ClientDeniesCaching;
     }
 
-    for (Frame* child = frame->tree().firstChild(); child; child = child->tree().nextSibling())
-        rejectReasons |= logCanCacheFrameDecision(child, indentLevel + 1);
+    for (Frame* child = frame.tree().firstChild(); child; child = child->tree().nextSibling())
+        rejectReasons |= logCanCacheFrameDecision(*child, diagnosticLoggingClient, indentLevel + 1);
     
     PCLOG(rejectReasons ? " Frame CANNOT be cached" : " Frame CAN be cached");
     PCLOG("+---");
@@ -210,12 +227,12 @@ enum ReasonPageCannotBeInPageCache {
 };
 COMPILE_ASSERT(NumberOfReasonsPagesCannotBeInPageCache <= sizeof(unsigned)*8, ReasonPageCannotBeInPageCacheDoesNotFitInBitmap);
 
-static void logCanCachePageDecision(Page* page)
+static void logCanCachePageDecision(Page& page)
 {
     // Only bother logging for main frames that have actually loaded and have content.
-    if (page->mainFrame().loader().stateMachine().creatingInitialEmptyDocument())
+    if (page.mainFrame().loader().stateMachine().creatingInitialEmptyDocument())
         return;
-    URL currentURL = page->mainFrame().loader().documentLoader() ? page->mainFrame().loader().documentLoader()->url() : URL();
+    URL currentURL = page.mainFrame().loader().documentLoader() ? page.mainFrame().loader().documentLoader()->url() : URL();
     if (currentURL.isEmpty())
         return;
     
@@ -223,57 +240,59 @@ static void logCanCachePageDecision(Page* page)
     PCLOG("--------\n Determining if page can be cached:");
     
     unsigned rejectReasons = 0;
-    unsigned frameRejectReasons = logCanCacheFrameDecision(&page->mainFrame(), indentLevel+1);
+    MainFrame& mainFrame = page.mainFrame();
+    DiagnosticLoggingClient* diagnosticLoggingClient = mainFrame.settings().diagnosticLoggingEnabled() ? mainFrame.diagnosticLoggingClient() : nullptr;
+    unsigned frameRejectReasons = logCanCacheFrameDecision(mainFrame, diagnosticLoggingClient, indentLevel + 1);
     if (frameRejectReasons)
         rejectReasons |= 1 << FrameCannotBeInPageCache;
     
-    if (!page->settings().usesPageCache()) {
+    if (!page.settings().usesPageCache()) {
         PCLOG("   -Page settings says b/f cache disabled");
         rejectReasons |= 1 << DisabledPageCache;
     }
 #if ENABLE(DEVICE_ORIENTATION) && !PLATFORM(IOS)
     if (DeviceMotionController::isActiveAt(page)) {
         PCLOG("   -Page is using DeviceMotion");
-        FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterPageCacheFailureDeviceMotionKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::deviceMotionKey());
         rejectReasons |= 1 << UsesDeviceMotion;
     }
     if (DeviceOrientationController::isActiveAt(page)) {
         PCLOG("   -Page is using DeviceOrientation");
-        FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterPageCacheFailureDeviceOrientationKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::deviceOrientationKey());
         rejectReasons |= 1 << UsesDeviceOrientation;
     }
 #endif
 #if ENABLE(PROXIMITY_EVENTS)
     if (DeviceProximityController::isActiveAt(page)) {
         PCLOG("   -Page is using DeviceProximity");
-        FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterPageCacheFailureDeviceProximityKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, deviceProximityKey);
         rejectReasons |= 1 << UsesDeviceMotion;
     }
 #endif
-    FrameLoadType loadType = page->mainFrame().loader().loadType();
+    FrameLoadType loadType = page.mainFrame().loader().loadType();
     if (loadType == FrameLoadType::Reload) {
         PCLOG("   -Load type is: Reload");
-        FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterPageCacheFailureReloadKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::reloadKey());
         rejectReasons |= 1 << IsReload;
     }
     if (loadType == FrameLoadType::ReloadFromOrigin) {
         PCLOG("   -Load type is: Reload from origin");
-        FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterPageCacheFailureReloadFromOriginKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::reloadFromOriginKey());
         rejectReasons |= 1 << IsReloadFromOrigin;
     }
     if (loadType == FrameLoadType::Same) {
         PCLOG("   -Load type is: Same");
-        FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterPageCacheFailureSameLoadKey);
+        logPageCacheFailureDiagnosticMessage(diagnosticLoggingClient, DiagnosticLoggingKeys::sameLoadKey());
         rejectReasons |= 1 << IsSameLoad;
     }
     
-    if (rejectReasons) {
+    if (rejectReasons)
         PCLOG(" Page CANNOT be cached\n--------");
-        FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterPageCacheFailureKey);
-    } else {
+    else
         PCLOG(" Page CAN be cached\n--------");
-        FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterPageCacheSuccessKey);
-    }
+
+    if (diagnosticLoggingClient)
+        diagnosticLoggingClient->logDiagnosticMessageWithResult(DiagnosticLoggingKeys::pageCacheKey(), emptyString(), rejectReasons ? DiagnosticLoggingResultFail : DiagnosticLoggingResultPass);
 }
 
 PageCache* pageCache()
@@ -329,7 +348,7 @@ bool PageCache::canCache(Page* page) const
     if (!page)
         return false;
     
-    logCanCachePageDecision(page);
+    logCanCachePageDecision(*page);
 
     if (memoryPressureHandler().isUnderMemoryPressure())
         return false;
@@ -419,21 +438,20 @@ void PageCache::markPagesForCaptionPreferencesChanged()
 }
 #endif
 
-static const char* pruningReasonToFeatureCounterKey(PruningReason pruningReason)
+static String pruningReasonToDiagnosticLoggingKey(PruningReason pruningReason)
 {
     switch (pruningReason) {
     case PruningReason::MemoryPressure:
-        return FeatureCounterPageCacheFailurePrunedMemoryPressureKey;
+        return DiagnosticLoggingKeys::prunedDueToMemoryPressureKey();
     case PruningReason::ProcessSuspended:
-        return FeatureCounterPageCacheFailurePrunedProcessedSuspendedKey;
+        return DiagnosticLoggingKeys::prunedDueToProcessSuspended();
     case PruningReason::ReachedCapacity:
-        return FeatureCounterPageCacheFailurePrunedCapacityReachedKey;
+        return DiagnosticLoggingKeys::prunedDueToCapacityReached();
     case PruningReason::None:
-        ASSERT_NOT_REACHED();
-        return nullptr;
+        break;
     }
     ASSERT_NOT_REACHED();
-    return nullptr;
+    return emptyString();
 }
 
 void PageCache::add(PassRefPtr<HistoryItem> prpItem, Page& page)
@@ -469,13 +487,13 @@ std::unique_ptr<CachedPage> PageCache::take(HistoryItem* item, Page* page)
 
     if (!cachedPage) {
         if (item->m_pruningReason != PruningReason::None)
-            FEATURE_COUNTER_INCREMENT_KEY(page, pruningReasonToFeatureCounterKey(item->m_pruningReason));
+            logPageCacheFailureDiagnosticMessage(page, pruningReasonToDiagnosticLoggingKey(item->m_pruningReason));
         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());
-        FEATURE_COUNTER_INCREMENT_KEY(page, FeatureCounterPageCacheFailureExpiredKey);
+        logPageCacheFailureDiagnosticMessage(page, DiagnosticLoggingKeys::expiredKey());
         return nullptr;
     }
 
@@ -492,10 +510,10 @@ CachedPage* PageCache::get(HistoryItem* item, Page* page)
             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);
+        logPageCacheFailureDiagnosticMessage(page, DiagnosticLoggingKeys::expiredKey());
         pageCache()->remove(item);
     } else if (item->m_pruningReason != PruningReason::None)
-        FEATURE_COUNTER_INCREMENT_KEY(page, pruningReasonToFeatureCounterKey(item->m_pruningReason));
+        logPageCacheFailureDiagnosticMessage(page, pruningReasonToDiagnosticLoggingKey(item->m_pruningReason));
 
     return nullptr;
 }
index 66eb27d..0d7cacd 100644 (file)
@@ -68,35 +68,150 @@ String DiagnosticLoggingKeys::pageContainsAtLeastOneMediaEngineKey()
     return ASCIILiteral("pageContainsAtLeastOneMediaEngine");
 }
 
-String DiagnosticLoggingKeys::passKey()
+String DiagnosticLoggingKeys::successKey()
 {
-    return ASCIILiteral("pass");
+    return ASCIILiteral("success");
 }
 
-String DiagnosticLoggingKeys::failKey()
+String DiagnosticLoggingKeys::failureKey()
 {
-    return ASCIILiteral("fail");
+    return ASCIILiteral("failure");
 }
 
-String DiagnosticLoggingKeys::noopKey()
+String DiagnosticLoggingKeys::pageLoadedKey()
 {
-    return ASCIILiteral("noop");
+    return ASCIILiteral("pageLoaded");
 }
 
-String DiagnosticLoggingKeys::pageLoadedKey()
+String DiagnosticLoggingKeys::engineFailedToLoadKey()
 {
-    return WTF::ASCIILiteral("pageLoaded");
+    return ASCIILiteral("engineFailedToLoad");
 }
 
-String DiagnosticLoggingKeys::engineFailedToLoadKey()
+String DiagnosticLoggingKeys::navigationKey()
+{
+    return ASCIILiteral("navigation");
+}
+
+String DiagnosticLoggingKeys::pageCacheKey()
+{
+    return ASCIILiteral("pageCache");
+}
+
+String DiagnosticLoggingKeys::noDocumentLoaderKey()
+{
+    return ASCIILiteral("noDocumentLoader");
+}
+
+String DiagnosticLoggingKeys::mainDocumentErrorKey()
+{
+    return ASCIILiteral("mainDocumentError");
+}
+
+String DiagnosticLoggingKeys::isErrorPageKey()
+{
+    return ASCIILiteral("isErrorPage");
+}
+
+String DiagnosticLoggingKeys::hasPluginsKey()
+{
+    return ASCIILiteral("hasPlugins");
+}
+
+String DiagnosticLoggingKeys::httpsNoStoreKey()
+{
+    return ASCIILiteral("httpsNoStore");
+}
+
+String DiagnosticLoggingKeys::hasOpenDatabasesKey()
+{
+    return ASCIILiteral("hasOpenDatabases");
+}
+
+String DiagnosticLoggingKeys::noCurrentHistoryItemKey()
+{
+    return ASCIILiteral("noCurrentHistoryItem");
+}
+
+String DiagnosticLoggingKeys::quirkRedirectComingKey()
+{
+    return ASCIILiteral("quirkRedirectComing");
+}
+
+String DiagnosticLoggingKeys::loadingAPISenseKey()
+{
+    return ASCIILiteral("loadingAPISense");
+}
+
+String DiagnosticLoggingKeys::documentLoaderStoppingKey()
+{
+    return ASCIILiteral("documentLoaderStopping");
+}
+
+String DiagnosticLoggingKeys::cannotSuspendActiveDOMObjectsKey()
+{
+    return ASCIILiteral("cannotSuspendActiveDOMObjects");
+}
+
+String DiagnosticLoggingKeys::applicationCacheKey()
+{
+    return ASCIILiteral("applicationCache");
+}
+
+String DiagnosticLoggingKeys::deniedByClientKey()
+{
+    return ASCIILiteral("deniedByClient");
+}
+
+String DiagnosticLoggingKeys::deviceMotionKey()
+{
+    return ASCIILiteral("deviceMotion");
+}
+
+String DiagnosticLoggingKeys::deviceOrientationKey()
+{
+    return ASCIILiteral("deviceOrientation");
+}
+
+String DiagnosticLoggingKeys::deviceProximityKey()
+{
+    return ASCIILiteral("deviceProximity");
+}
+
+String DiagnosticLoggingKeys::reloadKey()
+{
+    return ASCIILiteral("reload");
+}
+
+String DiagnosticLoggingKeys::reloadFromOriginKey()
+{
+    return ASCIILiteral("reloadFromOrigin");
+}
+
+String DiagnosticLoggingKeys::sameLoadKey()
 {
-    return WTF::ASCIILiteral("engineFailedToLoad");
+    return ASCIILiteral("sameLoad");
 }
 
-WTF::String DiagnosticLoggingKeys::navigationKey()
+String DiagnosticLoggingKeys::expiredKey()
 {
-    return WTF::ASCIILiteral("navigation");
+    return ASCIILiteral("expired");
 }
 
+String DiagnosticLoggingKeys::prunedDueToMemoryPressureKey()
+{
+    return ASCIILiteral("pruned.memoryPressure");
+}
+
+String DiagnosticLoggingKeys::prunedDueToCapacityReached()
+{
+    return ASCIILiteral("pruned.capacityReached");
 }
 
+String DiagnosticLoggingKeys::prunedDueToProcessSuspended()
+{
+    return ASCIILiteral("pruned.processSuspended");
+}
+
+} // namespace WebCore
+
index 1df4020..a2634ed 100644 (file)
@@ -32,23 +32,45 @@ namespace WebCore {
 
 class DiagnosticLoggingKeys {
 public:
-    // Message keys.
+    static String applicationCacheKey();
+    static String cannotSuspendActiveDOMObjectsKey();
+    static String deniedByClientKey();
+    static String deviceMotionKey();
+    static String deviceOrientationKey();
+    static String deviceProximityKey();
+    static String documentLoaderStoppingKey();
+    static String engineFailedToLoadKey();
+    static String expiredKey();
+    static String hasOpenDatabasesKey();
+    static String hasPluginsKey();
+    static String httpsNoStoreKey();
+    static String isErrorPageKey();
+    static String loadingAPISenseKey();
+    static String mainDocumentErrorKey();
     static String mediaLoadedKey();
     static String mediaLoadingFailedKey();
-    static String pluginLoadedKey();
-    static String pluginLoadingFailedKey();
-    static String pageContainsPluginKey();
+    static String navigationKey();
+    static String noCurrentHistoryItemKey();
+    static String noDocumentLoaderKey();
+    static String pageCacheKey();
+    static String pageContainsAtLeastOneMediaEngineKey();
     static String pageContainsAtLeastOnePluginKey();
     static String pageContainsMediaEngineKey();
-    static String pageContainsAtLeastOneMediaEngineKey();
+    static String pageContainsPluginKey();
     static String pageLoadedKey();
-    static String engineFailedToLoadKey();
-    static String navigationKey();
+    static String pluginLoadedKey();
+    static String pluginLoadingFailedKey();
+    static String prunedDueToCapacityReached();
+    static String prunedDueToMemoryPressureKey();
+    static String prunedDueToProcessSuspended();
+    static String quirkRedirectComingKey();
+    static String reloadFromOriginKey();
+    static String reloadKey();
+    static String sameLoadKey();
 
-    // Success keys.
-    static String passKey();
-    static String failKey();
-    static String noopKey();
+    // Success / Failure keys.
+    static String successKey();
+    static String failureKey();
 };
 
 }
index 6b997ae..379ffd1 100644 (file)
 
 namespace WebCore {
 
-// Page cache.
-static const char FeatureCounterPageCacheFailureNoDocumentLoaderKey[] = "com.apple.WebKit.pageCache.failure.noDocumentLoader";
-static const char FeatureCounterPageCacheFailureMainDocumentErrorKey[] = "com.apple.WebKit.pageCache.failure.mainDocumentError";
-static const char FeatureCounterPageCacheFailureIsErrorPageKey[] = "com.apple.WebKit.pageCache.failure.isErrorPage";
-static const char FeatureCounterPageCacheFailureHasPlugins[] = "com.apple.WebKit.pageCache.failure.hasPlugins";
-static const char FeatureCounterPageCacheFailureHTTPSNoStoreKey[] = "com.apple.WebKit.pageCache.failure.httpsNoStore";
-static const char FeatureCounterPageCacheFailureHasOpenDatabasesKey[] = "com.apple.WebKit.pageCache.failure.hasOpenDatabases";
-static const char FeatureCounterPageCacheFailureNoCurrentHistoryItemKey[] = "com.apple.WebKit.pageCache.failure.noCurrentHistoryItem";
-static const char FeatureCounterPageCacheFailureQuirkRedirectComingKey[] = "com.apple.WebKit.pageCache.failure.quirkRedirectComing";
-static const char FeatureCounterPageCacheFailureLoadingAPISenseKey[] = "com.apple.WebKit.pageCache.failure.loadingAPISense";
-static const char FeatureCounterPageCacheFailureDocumentLoaderStoppingKey[] = "com.apple.WebKit.pageCache.failure.documentLoaderStopping";
-static const char FeatureCounterPageCacheFailureCannotSuspendActiveDOMObjectsKey[] = "com.apple.WebKit.pageCache.failure.cannotSuspendActiveDOMObjects";
-static const char FeatureCounterPageCacheFailureApplicationCacheKey[] = "com.apple.WebKit.pageCache.failure.applicationCache";
-static const char FeatureCounterPageCacheFailureDeniedByClientKey[] = "com.apple.WebKit.pageCache.failure.deniedByClient";
-#if ENABLE(DEVICE_ORIENTATION)
-static const char FeatureCounterPageCacheFailureDeviceMotionKey[] = "com.apple.WebKit.pageCache.failure.deviceMotion";
-static const char FeatureCounterPageCacheFailureDeviceOrientationKey[] = "com.apple.WebKit.pageCache.failure.deviceOrientation";
-#endif
-#if ENABLE(PROXIMITY_EVENTS)
-static const char FeatureCounterPageCacheFailureDeviceProximityKey[] = "com.apple.WebKit.pageCache.failure.deviceProximity";
-#endif
-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 FeatureCounterPageCacheFailurePrunedMemoryPressureKey[] = "com.apple.WebKit.pageCache.failure.pruned.memoryPressure";
-static const char FeatureCounterPageCacheFailurePrunedCapacityReachedKey[] = "com.apple.WebKit.pageCache.failure.pruned.capacityReached";
-static const char FeatureCounterPageCacheFailurePrunedProcessedSuspendedKey[] = "com.apple.WebKit.pageCache.failure.pruned.processSuspended";
-static const char FeatureCounterPageCacheFailureKey[] = "com.apple.WebKit.pageCache.failure";
-static const char FeatureCounterPageCacheSuccessKey[] = "com.apple.WebKit.pageCache.success";
-
 // Cached resources revalidation.
 static const char FeatureCounterCachedResourceRevalidationSuccessKey[] = "com.apple.WebKit.cachedResourceRevalidation.success";
 static const char FeatureCounterCachedResourceRevalidationFailureKey[] = "com.apple.WebKit.cachedResourceRevalidation.failure";