Log navigation types using DiagnosticLoggingClient
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jan 2015 22:30:59 +0000 (22:30 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jan 2015 22:30:59 +0000 (22:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140323

Reviewed by Darin Adler.

Log navigation types using DiagnosticLoggingClient to help us understand
what types of navigations are common and give us an estimate on the
total number of navigations.

* loader/FrameLoader.cpp:
(WebCore::logNavigation):
(WebCore::FrameLoader::loadWithDocumentLoader):
(WebCore::logNavigationWithFeatureCounter): Deleted.
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::navigationKey):
* page/DiagnosticLoggingKeys.h:

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

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

index d8e7f62..2f5c549 100644 (file)
@@ -1,3 +1,22 @@
+2015-01-12  Chris Dumez  <cdumez@apple.com>
+
+        Log navigation types using DiagnosticLoggingClient
+        https://bugs.webkit.org/show_bug.cgi?id=140323
+
+        Reviewed by Darin Adler.
+
+        Log navigation types using DiagnosticLoggingClient to help us understand
+        what types of navigations are common and give us an estimate on the
+        total number of navigations.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::logNavigation):
+        (WebCore::FrameLoader::loadWithDocumentLoader):
+        (WebCore::logNavigationWithFeatureCounter): Deleted.
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::navigationKey):
+        * page/DiagnosticLoggingKeys.h:
+
 2015-01-12  Brian J. Burg  <burg@cs.washington.edu>
 
         Web Inspector: ASSERT under WebCore::InspectorResourceAgent::loadResource
index 0118c50..d8aa5b6 100644 (file)
@@ -1377,37 +1377,50 @@ void FrameLoader::load(DocumentLoader* newDocumentLoader)
     loadWithDocumentLoader(newDocumentLoader, type, 0, AllowNavigationToInvalidURL::Yes);
 }
 
-static void logNavigationWithFeatureCounter(Page* page, FrameLoadType type)
+static void logNavigation(MainFrame& frame, FrameLoadType type)
 {
-    const char* key;
+    const char* featureCounterKey;
+    String navigationDescription;
     switch (type) {
     case FrameLoadType::Standard:
-        key = FeatureCounterNavigationStandardKey;
+        featureCounterKey = FeatureCounterNavigationStandardKey;
+        navigationDescription = ASCIILiteral("standard");
         break;
     case FrameLoadType::Back:
-        key = FeatureCounterNavigationBackKey;
+        featureCounterKey = FeatureCounterNavigationBackKey;
+        navigationDescription = ASCIILiteral("back");
         break;
     case FrameLoadType::Forward:
-        key = FeatureCounterNavigationForwardKey;
+        featureCounterKey = FeatureCounterNavigationForwardKey;
+        navigationDescription = ASCIILiteral("forward");
         break;
     case FrameLoadType::IndexedBackForward:
-        key = FeatureCounterNavigationIndexedBackForwardKey;
+        featureCounterKey = FeatureCounterNavigationIndexedBackForwardKey;
+        navigationDescription = ASCIILiteral("indexedBackForward");
         break;
     case FrameLoadType::Reload:
-        key = FeatureCounterNavigationReloadKey;
+        featureCounterKey = FeatureCounterNavigationReloadKey;
+        navigationDescription = ASCIILiteral("reload");
         break;
     case FrameLoadType::Same:
-        key = FeatureCounterNavigationSameKey;
+        featureCounterKey = FeatureCounterNavigationSameKey;
+        navigationDescription = ASCIILiteral("same");
         break;
     case FrameLoadType::ReloadFromOrigin:
-        key = FeatureCounterNavigationReloadFromOriginKey;
+        featureCounterKey = FeatureCounterNavigationReloadFromOriginKey;
+        navigationDescription = ASCIILiteral("reloadFromOrigin");
         break;
     case FrameLoadType::Replace:
     case FrameLoadType::RedirectWithLockedBackForwardList:
         // Not logging those for now.
         return;
     }
-    FEATURE_COUNTER_INCREMENT_KEY(page, key);
+    if (frame.settings().diagnosticLoggingEnabled()) {
+        if (auto* client = frame.diagnosticLoggingClient())
+            client->logDiagnosticMessage(DiagnosticLoggingKeys::navigationKey(), navigationDescription);
+    }
+    // FIXME: Remove once DiagnosticLoggingClient works on iOS.
+    FEATURE_COUNTER_INCREMENT_KEY(frame.page(), featureCounterKey);
 }
 
 void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType type, PassRefPtr<FormState> prpFormState, AllowNavigationToInvalidURL allowNavigationToInvalidURL)
@@ -1430,7 +1443,7 @@ void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType t
 
     // Log main frame navigation types.
     if (m_frame.isMainFrame())
-        logNavigationWithFeatureCounter(m_frame.page(), type);
+        logNavigation(static_cast<MainFrame&>(m_frame), type);
 
     policyChecker().setLoadType(type);
     RefPtr<FormState> formState = prpFormState;
index 996447c..66eb27d 100644 (file)
@@ -93,5 +93,10 @@ String DiagnosticLoggingKeys::engineFailedToLoadKey()
     return WTF::ASCIILiteral("engineFailedToLoad");
 }
 
+WTF::String DiagnosticLoggingKeys::navigationKey()
+{
+    return WTF::ASCIILiteral("navigation");
+}
+
 }
 
index af606dd..1df4020 100644 (file)
@@ -43,6 +43,7 @@ public:
     static String pageContainsAtLeastOneMediaEngineKey();
     static String pageLoadedKey();
     static String engineFailedToLoadKey();
+    static String navigationKey();
 
     // Success keys.
     static String passKey();