Add diagnostic logging for ResourceResponse's source
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Feb 2015 02:22:51 +0000 (02:22 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Feb 2015 02:22:51 +0000 (02:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141170
<rdar://problem/19632080>

Reviewed by Antti Koivisto.

Add diagnostic logging for ResourceResponse's source (network, disk
cache, disk cache after validation) to give us an idea of our network
cache efficacy.

* loader/ResourceLoader.cpp:
(WebCore::logResourceResponseSource):
(WebCore::ResourceLoader::didReceiveResponse):
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::networkKey):
(WebCore::DiagnosticLoggingKeys::diskCacheKey):
(WebCore::DiagnosticLoggingKeys::diskCacheAfterValidationKey):
(WebCore::DiagnosticLoggingKeys::resourceResponseKey):
(WebCore::DiagnosticLoggingKeys::scriptKey):
(WebCore::DiagnosticLoggingKeys::sourceKey):
* page/DiagnosticLoggingKeys.h:

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

Source/WebCore/ChangeLog
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/page/DiagnosticLoggingKeys.cpp
Source/WebCore/page/DiagnosticLoggingKeys.h

index d65d72f..7cf23c5 100644 (file)
@@ -1,3 +1,27 @@
+2015-02-02  Chris Dumez  <cdumez@apple.com>
+
+        Add diagnostic logging for ResourceResponse's source
+        https://bugs.webkit.org/show_bug.cgi?id=141170
+        <rdar://problem/19632080>
+
+        Reviewed by Antti Koivisto.
+
+        Add diagnostic logging for ResourceResponse's source (network, disk
+        cache, disk cache after validation) to give us an idea of our network
+        cache efficacy.
+
+        * loader/ResourceLoader.cpp:
+        (WebCore::logResourceResponseSource):
+        (WebCore::ResourceLoader::didReceiveResponse):
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::networkKey):
+        (WebCore::DiagnosticLoggingKeys::diskCacheKey):
+        (WebCore::DiagnosticLoggingKeys::diskCacheAfterValidationKey):
+        (WebCore::DiagnosticLoggingKeys::resourceResponseKey):
+        (WebCore::DiagnosticLoggingKeys::scriptKey):
+        (WebCore::DiagnosticLoggingKeys::sourceKey):
+        * page/DiagnosticLoggingKeys.h:
+
 2015-02-02  Dhi Aurrahman  <diorahman@rockybars.com>
 
         Optimize matchesLangPseudoClass() of :lang()
index 8db4774..f6ad593 100644 (file)
 
 #include "ApplicationCacheHost.h"
 #include "AuthenticationChallenge.h"
+#include "DiagnosticLoggingClient.h"
+#include "DiagnosticLoggingKeys.h"
 #include "DocumentLoader.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
 #include "InspectorInstrumentation.h"
 #include "LoaderStrategy.h"
+#include "MainFrame.h"
 #include "Page.h"
 #include "PlatformStrategies.h"
 #include "ProgressTracker.h"
@@ -294,6 +297,29 @@ void ResourceLoader::didSendData(unsigned long long, unsigned long long)
 {
 }
 
+static void logResourceResponseSource(Frame* frame, ResourceResponse::Source source)
+{
+    if (!frame)
+        return;
+
+    String sourceKey;
+    switch (source) {
+    case ResourceResponse::Source::Network:
+        sourceKey = DiagnosticLoggingKeys::networkKey();
+        break;
+    case ResourceResponse::Source::DiskCache:
+        sourceKey = DiagnosticLoggingKeys::diskCacheKey();
+        break;
+    case ResourceResponse::Source::DiskCacheAfterValidation:
+        sourceKey = DiagnosticLoggingKeys::diskCacheAfterValidationKey();
+        break;
+    case ResourceResponse::Source::Unknown:
+        return;
+    }
+
+    frame->mainFrame().diagnosticLoggingClient().logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceResponseKey(), DiagnosticLoggingKeys::sourceKey(), sourceKey);
+}
+
 void ResourceLoader::didReceiveResponse(const ResourceResponse& r)
 {
     ASSERT(!m_reachedTerminalState);
@@ -302,6 +328,8 @@ void ResourceLoader::didReceiveResponse(const ResourceResponse& r)
     // anything including possibly derefing this; one example of this is Radar 3266216.
     Ref<ResourceLoader> protect(*this);
 
+    logResourceResponseSource(m_frame.get(), r.source());
+
     m_response = r;
 
     if (FormData* data = m_request.httpBody())
index 1d2df78..4645f72 100644 (file)
@@ -103,6 +103,11 @@ String DiagnosticLoggingKeys::navigationKey()
     return ASCIILiteral("navigation");
 }
 
+String DiagnosticLoggingKeys::networkKey()
+{
+    return ASCIILiteral("network");
+}
+
 String DiagnosticLoggingKeys::noCacheKey()
 {
     return ASCIILiteral("noCache");
@@ -263,6 +268,16 @@ String DiagnosticLoggingKeys::deviceProximityKey()
     return ASCIILiteral("deviceProximity");
 }
 
+String DiagnosticLoggingKeys::diskCacheKey()
+{
+    return ASCIILiteral("diskCache");
+}
+
+String DiagnosticLoggingKeys::diskCacheAfterValidationKey()
+{
+    return ASCIILiteral("diskCacheAfterValidation");
+}
+
 String DiagnosticLoggingKeys::reloadKey()
 {
     return ASCIILiteral("reload");
@@ -278,6 +293,11 @@ String DiagnosticLoggingKeys::resourceRequestKey()
     return ASCIILiteral("resourceRequest");
 }
 
+String DiagnosticLoggingKeys::resourceResponseKey()
+{
+    return ASCIILiteral("resourceResponse");
+}
+
 String DiagnosticLoggingKeys::revalidatingKey()
 {
     return ASCIILiteral("revalidating");
@@ -298,6 +318,11 @@ String DiagnosticLoggingKeys::scriptKey()
     return ASCIILiteral("script");
 }
 
+String DiagnosticLoggingKeys::sourceKey()
+{
+    return ASCIILiteral("sourceKey");
+}
+
 String DiagnosticLoggingKeys::styleSheetKey()
 {
     return ASCIILiteral("styleSheet");
index 5e54aff..7d63744 100644 (file)
@@ -40,6 +40,8 @@ public:
     static String deviceMotionKey();
     static String deviceOrientationKey();
     static String deviceProximityKey();
+    static String diskCacheKey();
+    static String diskCacheAfterValidationKey();
     static String documentLoaderStoppingKey();
     static String engineFailedToLoadKey();
     static String expiredKey();
@@ -61,6 +63,7 @@ public:
     static String mediaLoadingFailedKey();
     static String mustRevalidateIsExpiredKey();
     static String navigationKey();
+    static String networkKey();
     static String noCacheKey();
     static String noCurrentHistoryItemKey();
     static String noDocumentLoaderKey();
@@ -86,9 +89,11 @@ public:
     static String reloadKey();
     static String resourceKey();
     static String resourceRequestKey();
+    static String resourceResponseKey();
     static String revalidatingKey();
     static String sameLoadKey();
     static String scriptKey();
+    static String sourceKey();
     static String styleSheetKey();
     static String svgDocumentKey();
     static String unusedKey();