Title: [110998] trunk/Source/WebCore
Revision
110998
Author
[email protected]
Date
2012-03-16 06:25:31 -0700 (Fri, 16 Mar 2012)

Log Message

Add asserts and improve logging in PageCache.
https://bugs.webkit.org/show_bug.cgi?id=81179

Reviewed by Brady Eidson.

The early exits from logCanCacheFrameDecision had the potential to skew histogram data.  Moving
the DocumentLoader check to the top, but eliminating the early exits is a compromise that keeps
the logged data mostly accurate.

* history/PageCache.cpp:
(WebCore::logCanCacheFrameDecision):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110997 => 110998)


--- trunk/Source/WebCore/ChangeLog	2012-03-16 13:13:14 UTC (rev 110997)
+++ trunk/Source/WebCore/ChangeLog	2012-03-16 13:25:31 UTC (rev 110998)
@@ -1,3 +1,17 @@
+2012-03-16  Gavin Peters  <[email protected]>
+
+        Add asserts and improve logging in PageCache.
+        https://bugs.webkit.org/show_bug.cgi?id=81179
+
+        Reviewed by Brady Eidson.
+
+        The early exits from logCanCacheFrameDecision had the potential to skew histogram data.  Moving
+        the DocumentLoader check to the top, but eliminating the early exits is a compromise that keeps
+        the logged data mostly accurate.
+
+        * history/PageCache.cpp:
+        (WebCore::logCanCacheFrameDecision):
+
 2012-03-16  Yoshifumi Inoue  <[email protected]>
 
         [Forms] label.form attribute doesn't work

Modified: trunk/Source/WebCore/history/PageCache.cpp (110997 => 110998)


--- trunk/Source/WebCore/history/PageCache.cpp	2012-03-16 13:13:14 UTC (rev 110997)
+++ trunk/Source/WebCore/history/PageCache.cpp	2012-03-16 13:25:31 UTC (rev 110998)
@@ -81,20 +81,20 @@
     ClientDeniesCaching,
     NumberOfReasonsFramesCannotBeInPageCache,
 };
+COMPILE_ASSERT(NumberOfReasonsFramesCannotBeInPageCache <= sizeof(unsigned)*8, ReasonFrameCannotBeInPageCacheDoesNotFitInBitmap);
 
 static unsigned logCanCacheFrameDecision(Frame* frame, int indentLevel)
 {
 #ifdef NDEBUG
     UNUSED_PARAM(indentLevel);
 #endif
-    // Only bother logging for frames that have actually loaded and have content.
-    if (frame->loader()->stateMachine()->creatingInitialEmptyDocument())
-        return false;
-    KURL currentURL = frame->loader()->documentLoader() ? frame->loader()->documentLoader()->url() : KURL();
-    if (currentURL.isEmpty())
-        return false;
-    
     PCLOG("+---");
+    if (!frame->loader()->documentLoader()) {
+        PCLOG("   -There is no DocumentLoader object");
+        return 1 << NoDocumentLoader;
+    }
+
+    KURL currentURL = frame->loader()->documentLoader()->url();
     KURL newURL = frame->loader()->provisionalDocumentLoader() ? frame->loader()->provisionalDocumentLoader()->url() : KURL();
     if (!newURL.isEmpty())
         PCLOG(" Determining if frame can be cached navigating from (", currentURL.string(), ") to (", newURL.string(), "):");
@@ -102,74 +102,68 @@
         PCLOG(" Determining if subframe with URL (", currentURL.string(), ") can be cached:");
      
     unsigned rejectReasons = 0;
-    
-    if (!frame->loader()->documentLoader()) {
-        PCLOG("   -There is no DocumentLoader object");
-        rejectReasons |= 1 << NoDocumentLoader;
-    } else {
-        if (!frame->loader()->documentLoader()->mainDocumentError().isNull()) {
-            PCLOG("   -Main document has an error");
-            rejectReasons |= 1 << MainDocumentError;
-        }
-        if (frame->loader()->documentLoader()->substituteData().isValid() && frame->loader()->documentLoader()->substituteData().failingURL().isEmpty()) {
-            PCLOG("   -Frame is an error page");
-            rejectReasons |= 1 << IsErrorPage;
-        }
-        if (frame->loader()->subframeLoader()->containsPlugins() && !frame->page()->settings()->pageCacheSupportsPlugins()) {
-            PCLOG("   -Frame contains plugins");
-            rejectReasons |= 1 << HasPlugins;
-        }
-        if (frame->document()->url().protocolIs("https")
-            && (frame->loader()->documentLoader()->response().cacheControlContainsNoCache()
-                || frame->loader()->documentLoader()->response().cacheControlContainsNoStore())) {
-            PCLOG("   -Frame is HTTPS, and cache control prohibits caching or storing");
-            rejectReasons |= 1 << IsHttpsAndCacheControlled;
-        }
-        if (frame->domWindow() && frame->domWindow()->hasEventListeners(eventNames().unloadEvent)) {
-            PCLOG("   -Frame has an unload event listener");
-            rejectReasons |= 1 << HasUnloadListener;
-        }
+    if (!frame->loader()->documentLoader()->mainDocumentError().isNull()) {
+        PCLOG("   -Main document has an error");
+        rejectReasons |= 1 << MainDocumentError;
+    }
+    if (frame->loader()->documentLoader()->substituteData().isValid() && frame->loader()->documentLoader()->substituteData().failingURL().isEmpty()) {
+        PCLOG("   -Frame is an error page");
+        rejectReasons |= 1 << IsErrorPage;
+    }
+    if (frame->loader()->subframeLoader()->containsPlugins() && !frame->page()->settings()->pageCacheSupportsPlugins()) {
+        PCLOG("   -Frame contains plugins");
+        rejectReasons |= 1 << HasPlugins;
+    }
+    if (frame->document()->url().protocolIs("https")
+        && (frame->loader()->documentLoader()->response().cacheControlContainsNoCache()
+            || frame->loader()->documentLoader()->response().cacheControlContainsNoStore())) {
+        PCLOG("   -Frame is HTTPS, and cache control prohibits caching or storing");
+        rejectReasons |= 1 << IsHttpsAndCacheControlled;
+    }
+    if (frame->domWindow() && frame->domWindow()->hasEventListeners(eventNames().unloadEvent)) {
+        PCLOG("   -Frame has an unload event listener");
+        rejectReasons |= 1 << HasUnloadListener;
+    }
 #if ENABLE(SQL_DATABASE)
-        if (DatabaseContext::hasOpenDatabases(frame->document())) {
-            PCLOG("   -Frame has open database handles");
-            rejectReasons |= 1 << HasDatabaseHandles;
-        }
+    if (DatabaseContext::hasOpenDatabases(frame->document())) {
+        PCLOG("   -Frame has open database handles");
+        rejectReasons |= 1 << HasDatabaseHandles;
+    }
 #endif
 #if ENABLE(SHARED_WORKERS)
-        if (SharedWorkerRepository::hasSharedWorkers(frame->document())) {
-            PCLOG("   -Frame has associated SharedWorkers");
-            rejectReasons |= 1 << HasSharedWorkers;
-        }
+    if (SharedWorkerRepository::hasSharedWorkers(frame->document())) {
+        PCLOG("   -Frame has associated SharedWorkers");
+        rejectReasons |= 1 << HasSharedWorkers;
+    }
 #endif
-        if (!frame->loader()->history()->currentItem()) {
-            PCLOG("   -No current history item");
-            rejectReasons |= 1 << NoHistoryItem;
-        }
-        if (frame->loader()->quickRedirectComing()) {
-            PCLOG("   -Quick redirect is coming");
-            rejectReasons |= 1 << QuickRedirectComing;
-        }
-        if (frame->loader()->documentLoader()->isLoadingInAPISense()) {
-            PCLOG("   -DocumentLoader is still loading in API sense");
-            rejectReasons |= 1 << IsLoadingInAPISense;
-        }
-        if (frame->loader()->documentLoader()->isStopping()) {
-            PCLOG("   -DocumentLoader is in the middle of stopping");
-            rejectReasons |= 1 << IsStopping;
-        }
-        if (!frame->document()->canSuspendActiveDOMObjects()) {
-            PCLOG("   -The document cannot suspect its active DOM Objects");
-            rejectReasons |= 1 << CannotSuspendActiveDOMObjects;
-        }
-        if (!frame->loader()->documentLoader()->applicationCacheHost()->canCacheInPageCache()) {
-            PCLOG("   -The DocumentLoader uses an application cache");
-            rejectReasons |= 1 << DocumentLoaderUsesApplicationCache;
-        }
-        if (!frame->loader()->client()->canCachePage()) {
-            PCLOG("   -The client says this frame cannot be cached");
-            rejectReasons |= 1 << ClientDeniesCaching;
-        }
+    if (!frame->loader()->history()->currentItem()) {
+        PCLOG("   -No current history item");
+        rejectReasons |= 1 << NoHistoryItem;
     }
+    if (frame->loader()->quickRedirectComing()) {
+        PCLOG("   -Quick redirect is coming");
+        rejectReasons |= 1 << QuickRedirectComing;
+    }
+    if (frame->loader()->documentLoader()->isLoadingInAPISense()) {
+        PCLOG("   -DocumentLoader is still loading in API sense");
+        rejectReasons |= 1 << IsLoadingInAPISense;
+    }
+    if (frame->loader()->documentLoader()->isStopping()) {
+        PCLOG("   -DocumentLoader is in the middle of stopping");
+        rejectReasons |= 1 << IsStopping;
+    }
+    if (!frame->document()->canSuspendActiveDOMObjects()) {
+        PCLOG("   -The document cannot suspect its active DOM Objects");
+        rejectReasons |= 1 << CannotSuspendActiveDOMObjects;
+    }
+    if (!frame->loader()->documentLoader()->applicationCacheHost()->canCacheInPageCache()) {
+        PCLOG("   -The DocumentLoader uses an application cache");
+        rejectReasons |= 1 << DocumentLoaderUsesApplicationCache;
+    }
+    if (!frame->loader()->client()->canCachePage()) {
+        PCLOG("   -The client says this frame cannot be cached");
+        rejectReasons |= 1 << ClientDeniesCaching;
+    }
 
     HistogramSupport::histogramEnumeration("PageCache.FrameCacheable", !rejectReasons, 2);
     int reasonCount = 0;
@@ -203,6 +197,7 @@
     IsSameLoad,
     NumberOfReasonsPagesCannotBeInPageCache,
 };
+COMPILE_ASSERT(NumberOfReasonsPagesCannotBeInPageCache <= sizeof(unsigned)*8, ReasonPageCannotBeInPageCacheDoesNotFitInBitmap);
 
 static void logCanCachePageDecision(Page* page)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to