Log types of resources being loaded using DiagnosticLoggingClient
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jan 2015 20:37:20 +0000 (20:37 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jan 2015 20:37:20 +0000 (20:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140682

Reviewed by Andreas Kling.

Log types of resources being loaded using DiagnosticLoggingClient
instead of the legacy FeatureCounter.

* loader/SubresourceLoader.cpp:
(WebCore::logResourceLoaded):
(WebCore::SubresourceLoader::didFinishLoading):
(WebCore::logResourceLoadedUsingFeatureCounter): Deleted.
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::otherKey):
(WebCore::DiagnosticLoggingKeys::mainResourceKey):
(WebCore::DiagnosticLoggingKeys::loadedKey):
(WebCore::DiagnosticLoggingKeys::imageKey):
(WebCore::DiagnosticLoggingKeys::rawKey):
(WebCore::DiagnosticLoggingKeys::resourceKey):
(WebCore::DiagnosticLoggingKeys::scriptKey):
(WebCore::DiagnosticLoggingKeys::styleSheetKey):
(WebCore::DiagnosticLoggingKeys::svgDocumentKey):
(WebCore::DiagnosticLoggingKeys::fontKey):
* page/DiagnosticLoggingKeys.h:
* platform/FeatureCounterKeys.h:

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

Source/WebCore/ChangeLog
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/page/DiagnosticLoggingKeys.cpp
Source/WebCore/page/DiagnosticLoggingKeys.h
Source/WebCore/platform/FeatureCounterKeys.h

index a36eba3..e88093f 100644 (file)
@@ -1,3 +1,31 @@
+2015-01-20  Chris Dumez  <cdumez@apple.com>
+
+        Log types of resources being loaded using DiagnosticLoggingClient
+        https://bugs.webkit.org/show_bug.cgi?id=140682
+
+        Reviewed by Andreas Kling.
+
+        Log types of resources being loaded using DiagnosticLoggingClient
+        instead of the legacy FeatureCounter.
+
+        * loader/SubresourceLoader.cpp:
+        (WebCore::logResourceLoaded):
+        (WebCore::SubresourceLoader::didFinishLoading):
+        (WebCore::logResourceLoadedUsingFeatureCounter): Deleted.
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::otherKey):
+        (WebCore::DiagnosticLoggingKeys::mainResourceKey):
+        (WebCore::DiagnosticLoggingKeys::loadedKey):
+        (WebCore::DiagnosticLoggingKeys::imageKey):
+        (WebCore::DiagnosticLoggingKeys::rawKey):
+        (WebCore::DiagnosticLoggingKeys::resourceKey):
+        (WebCore::DiagnosticLoggingKeys::scriptKey):
+        (WebCore::DiagnosticLoggingKeys::styleSheetKey):
+        (WebCore::DiagnosticLoggingKeys::svgDocumentKey):
+        (WebCore::DiagnosticLoggingKeys::fontKey):
+        * page/DiagnosticLoggingKeys.h:
+        * platform/FeatureCounterKeys.h:
+
 2015-01-20  Zalan Bujtas  <zalan@apple.com>
 
         Simple line layout: Remove redundant style.preserveNewline check when collapsing trailing whitespace.
index a896975..ad4a524 100644 (file)
 #include "SubresourceLoader.h"
 
 #include "CachedResourceLoader.h"
+#include "DiagnosticLoggingClient.h"
+#include "DiagnosticLoggingKeys.h"
 #include "Document.h"
 #include "DocumentLoader.h"
 #include "FeatureCounter.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "Logging.h"
+#include "MainFrame.h"
 #include "MemoryCache.h"
 #include "Page.h"
+#include "Settings.h"
 #include <wtf/Ref.h>
 #include <wtf/RefCountedLeakCounter.h>
 #include <wtf/StdLibExtras.h>
@@ -292,36 +296,39 @@ bool SubresourceLoader::checkForHTTPStatusCodeError()
     return true;
 }
 
-static void logResourceLoadedUsingFeatureCounter(Page* page, CachedResource::Type type)
+static void logResourceLoaded(Frame* frame, CachedResource::Type type)
 {
-    const char* key;
+    if (!frame || !frame->settings().diagnosticLoggingEnabled())
+        return;
+
+    String resourceType;
     switch (type) {
     case CachedResource::MainResource:
-        key = FeatureCounterResourceLoadedMainResourceKey;
+        resourceType = DiagnosticLoggingKeys::mainResourceKey();
         break;
     case CachedResource::ImageResource:
-        key = FeatureCounterResourceLoadedImageKey;
+        resourceType = DiagnosticLoggingKeys::imageKey();
         break;
 #if ENABLE(XSLT)
     case CachedResource::XSLStyleSheet:
 #endif
     case CachedResource::CSSStyleSheet:
-        key = FeatureCounterResourceLoadedStyleSheetKey;
+        resourceType = DiagnosticLoggingKeys::styleSheetKey();
         break;
     case CachedResource::Script:
-        key = FeatureCounterResourceLoadedScriptKey;
+        resourceType = DiagnosticLoggingKeys::scriptKey();
         break;
     case CachedResource::FontResource:
 #if ENABLE(SVG_FONTS)
     case CachedResource::SVGFontResource:
 #endif
-        key = FeatureCounterResourceLoadedFontKey;
+        resourceType = DiagnosticLoggingKeys::fontKey();
         break;
     case CachedResource::RawResource:
-        key = FeatureCounterResourceLoadedRawKey;
+        resourceType = DiagnosticLoggingKeys::rawKey();
         break;
     case CachedResource::SVGDocumentResource:
-        key = FeatureCounterResourceLoadedSVGDocumentKey;
+        resourceType = DiagnosticLoggingKeys::svgDocumentKey();
         break;
 #if ENABLE(LINK_PREFETCH)
     case CachedResource::LinkPrefetch:
@@ -330,10 +337,11 @@ static void logResourceLoadedUsingFeatureCounter(Page* page, CachedResource::Typ
 #if ENABLE(VIDEO_TRACK)
     case CachedResource::TextTrackResource:
 #endif
-        key = FeatureCounterResourceLoadedOtherKey;
+        resourceType = DiagnosticLoggingKeys::otherKey();
         break;
     }
-    FEATURE_COUNTER_INCREMENT_KEY(page, key);
+    if (auto* client = frame->mainFrame().diagnosticLoggingClient())
+        client->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceKey(), DiagnosticLoggingKeys::loadedKey(), resourceType);
 }
 
 void SubresourceLoader::didFinishLoading(double finishTime)
@@ -345,7 +353,7 @@ void SubresourceLoader::didFinishLoading(double finishTime)
     // FIXME (129394): We should cancel the load when a decode error occurs instead of continuing the load to completion.
     ASSERT(!m_resource->errorOccurred() || m_resource->status() == CachedResource::DecodeError);
     LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1().data());
-    logResourceLoadedUsingFeatureCounter(m_frame ? m_frame->page() : nullptr, m_resource->type());
+    logResourceLoaded(m_frame.get(), m_resource->type());
 
     Ref<SubresourceLoader> protect(*this);
     CachedResourceHandle<CachedResource> protectResource(m_resource);
index 0d7cacd..02b2c6e 100644 (file)
@@ -103,16 +103,31 @@ String DiagnosticLoggingKeys::noDocumentLoaderKey()
     return ASCIILiteral("noDocumentLoader");
 }
 
+String DiagnosticLoggingKeys::otherKey()
+{
+    return ASCIILiteral("other");
+}
+
 String DiagnosticLoggingKeys::mainDocumentErrorKey()
 {
     return ASCIILiteral("mainDocumentError");
 }
 
+String DiagnosticLoggingKeys::mainResourceKey()
+{
+    return ASCIILiteral("mainResource");
+}
+
 String DiagnosticLoggingKeys::isErrorPageKey()
 {
     return ASCIILiteral("isErrorPage");
 }
 
+String DiagnosticLoggingKeys::loadedKey()
+{
+    return ASCIILiteral("loaded");
+}
+
 String DiagnosticLoggingKeys::hasPluginsKey()
 {
     return ASCIILiteral("hasPlugins");
@@ -123,6 +138,11 @@ String DiagnosticLoggingKeys::httpsNoStoreKey()
     return ASCIILiteral("httpsNoStore");
 }
 
+String DiagnosticLoggingKeys::imageKey()
+{
+    return ASCIILiteral("image");
+}
+
 String DiagnosticLoggingKeys::hasOpenDatabasesKey()
 {
     return ASCIILiteral("hasOpenDatabases");
@@ -138,6 +158,11 @@ String DiagnosticLoggingKeys::quirkRedirectComingKey()
     return ASCIILiteral("quirkRedirectComing");
 }
 
+String DiagnosticLoggingKeys::rawKey()
+{
+    return ASCIILiteral("raw");
+}
+
 String DiagnosticLoggingKeys::loadingAPISenseKey()
 {
     return ASCIILiteral("loadingAPISense");
@@ -183,6 +208,11 @@ String DiagnosticLoggingKeys::reloadKey()
     return ASCIILiteral("reload");
 }
 
+String DiagnosticLoggingKeys::resourceKey()
+{
+    return ASCIILiteral("resource");
+}
+
 String DiagnosticLoggingKeys::reloadFromOriginKey()
 {
     return ASCIILiteral("reloadFromOrigin");
@@ -193,11 +223,31 @@ String DiagnosticLoggingKeys::sameLoadKey()
     return ASCIILiteral("sameLoad");
 }
 
+String DiagnosticLoggingKeys::scriptKey()
+{
+    return ASCIILiteral("script");
+}
+
+String DiagnosticLoggingKeys::styleSheetKey()
+{
+    return ASCIILiteral("styleSheet");
+}
+
+String DiagnosticLoggingKeys::svgDocumentKey()
+{
+    return ASCIILiteral("svgDocument");
+}
+
 String DiagnosticLoggingKeys::expiredKey()
 {
     return ASCIILiteral("expired");
 }
 
+String DiagnosticLoggingKeys::fontKey()
+{
+    return ASCIILiteral("font");
+}
+
 String DiagnosticLoggingKeys::prunedDueToMemoryPressureKey()
 {
     return ASCIILiteral("pruned.memoryPressure");
index a2634ed..d3da3f7 100644 (file)
@@ -41,17 +41,22 @@ public:
     static String documentLoaderStoppingKey();
     static String engineFailedToLoadKey();
     static String expiredKey();
+    static String fontKey();
     static String hasOpenDatabasesKey();
     static String hasPluginsKey();
     static String httpsNoStoreKey();
+    static String imageKey();
     static String isErrorPageKey();
+    static String loadedKey();
     static String loadingAPISenseKey();
     static String mainDocumentErrorKey();
+    static String mainResourceKey();
     static String mediaLoadedKey();
     static String mediaLoadingFailedKey();
     static String navigationKey();
     static String noCurrentHistoryItemKey();
     static String noDocumentLoaderKey();
+    static String otherKey();
     static String pageCacheKey();
     static String pageContainsAtLeastOneMediaEngineKey();
     static String pageContainsAtLeastOnePluginKey();
@@ -64,9 +69,14 @@ public:
     static String prunedDueToMemoryPressureKey();
     static String prunedDueToProcessSuspended();
     static String quirkRedirectComingKey();
+    static String rawKey();
     static String reloadFromOriginKey();
     static String reloadKey();
+    static String resourceKey();
     static String sameLoadKey();
+    static String scriptKey();
+    static String styleSheetKey();
+    static String svgDocumentKey();
 
     // Success / Failure keys.
     static String successKey();
index 379ffd1..e4fdfc7 100644 (file)
@@ -43,16 +43,6 @@ static const char FeatureCounterMediaAudioElementLoadingKey[] = "com.apple.WebKi
 static const char FeatureCounterMediaVideoElementPlayedKey[] = "com.apple.WebKit.media.video.played";
 static const char FeatureCounterMediaAudioElementPlayedKey[] = "com.apple.WebKit.media.audio.played";
 
-// Resource types.
-static const char FeatureCounterResourceLoadedFontKey[] = "com.apple.WebKit.resource.loaded.font";
-static const char FeatureCounterResourceLoadedImageKey[] = "com.apple.WebKit.resource.loaded.image";
-static const char FeatureCounterResourceLoadedMainResourceKey[] = "com.apple.WebKit.resource.loaded.mainResource";
-static const char FeatureCounterResourceLoadedRawKey[] = "com.apple.WebKit.resource.loaded.raw";
-static const char FeatureCounterResourceLoadedSVGDocumentKey[] = "com.apple.WebKit.resource.loaded.svgDocument";
-static const char FeatureCounterResourceLoadedScriptKey[] = "com.apple.WebKit.resource.loaded.script";
-static const char FeatureCounterResourceLoadedStyleSheetKey[] = "com.apple.WebKit.resource.loaded.styleSheet";
-static const char FeatureCounterResourceLoadedOtherKey[] = "com.apple.WebKit.resource.loaded.other";
-
 // Memory cache.
 static const char FeatureCounterResourceRequestInMemoryCacheKey[] = "com.apple.WebKit.resourceRequest.inMemoryCache";
 static const char FeatureCounterResourceRequestNotInMemoryCacheKey[] = "com.apple.WebKit.resourceRequest.notInMemoryCache";