[iOS] Log which type of resources are commonly loaded using FeatureCounter
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Dec 2014 07:28:53 +0000 (07:28 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 23 Dec 2014 07:28:53 +0000 (07:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=139890

Reviewed by Darin Adler.

Log which type of resources are commonly loaded using FeatureCounter
(e.g. stylesheets, scripts, fonts, images, ...).

* loader/SubresourceLoader.cpp:
(WebCore::logResourceLoadedUsingFeatureCounter):
(WebCore::SubresourceLoader::didFinishLoading):
* platform/FeatureCounterKeys.h:

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

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

index 75c6385..9dd302c 100644 (file)
@@ -1,5 +1,20 @@
 2014-12-22  Chris Dumez  <cdumez@apple.com>
 
+        [iOS] Log which type of resources are commonly loaded using FeatureCounter
+        https://bugs.webkit.org/show_bug.cgi?id=139890
+
+        Reviewed by Darin Adler.
+
+        Log which type of resources are commonly loaded using FeatureCounter
+        (e.g. stylesheets, scripts, fonts, images, ...).
+
+        * loader/SubresourceLoader.cpp:
+        (WebCore::logResourceLoadedUsingFeatureCounter):
+        (WebCore::SubresourceLoader::didFinishLoading):
+        * platform/FeatureCounterKeys.h:
+
+2014-12-22  Chris Dumez  <cdumez@apple.com>
+
         [iOS] Log using FeatureCounter when a PacheCache fails due to memory pressure
         https://bugs.webkit.org/show_bug.cgi?id=139874
         <rdar://problem/19255690>
index 4c6db7f..a896975 100644 (file)
@@ -292,6 +292,50 @@ bool SubresourceLoader::checkForHTTPStatusCodeError()
     return true;
 }
 
+static void logResourceLoadedUsingFeatureCounter(Page* page, CachedResource::Type type)
+{
+    const char* key;
+    switch (type) {
+    case CachedResource::MainResource:
+        key = FeatureCounterResourceLoadedMainResourceKey;
+        break;
+    case CachedResource::ImageResource:
+        key = FeatureCounterResourceLoadedImageKey;
+        break;
+#if ENABLE(XSLT)
+    case CachedResource::XSLStyleSheet:
+#endif
+    case CachedResource::CSSStyleSheet:
+        key = FeatureCounterResourceLoadedStyleSheetKey;
+        break;
+    case CachedResource::Script:
+        key = FeatureCounterResourceLoadedScriptKey;
+        break;
+    case CachedResource::FontResource:
+#if ENABLE(SVG_FONTS)
+    case CachedResource::SVGFontResource:
+#endif
+        key = FeatureCounterResourceLoadedFontKey;
+        break;
+    case CachedResource::RawResource:
+        key = FeatureCounterResourceLoadedRawKey;
+        break;
+    case CachedResource::SVGDocumentResource:
+        key = FeatureCounterResourceLoadedSVGDocumentKey;
+        break;
+#if ENABLE(LINK_PREFETCH)
+    case CachedResource::LinkPrefetch:
+    case CachedResource::LinkSubresource:
+#endif
+#if ENABLE(VIDEO_TRACK)
+    case CachedResource::TextTrackResource:
+#endif
+        key = FeatureCounterResourceLoadedOtherKey;
+        break;
+    }
+    FEATURE_COUNTER_INCREMENT_KEY(page, key);
+}
+
 void SubresourceLoader::didFinishLoading(double finishTime)
 {
     if (m_state != Initialized)
@@ -301,6 +345,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());
 
     Ref<SubresourceLoader> protect(*this);
     CachedResourceHandle<CachedResource> protectResource(m_resource);
index 6f5e022..3edf532 100644 (file)
@@ -87,6 +87,16 @@ static const char FeatureCounterNavigationReloadKey[] = "com.apple.WebKit.naviga
 static const char FeatureCounterNavigationSameKey[] = "com.apple.WebKit.navigation.same";
 static const char FeatureCounterNavigationReloadFromOriginKey[] = "com.apple.WebKit.navigation.reloadFromOrigin";
 
+// 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";