[MutationObservers] Add histogram collection for usage of DOM Mutation Events
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Nov 2011 01:23:35 +0000 (01:23 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Nov 2011 01:23:35 +0000 (01:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72316

Patch by Rafael Weinstein <rafaelw@chromium.org> on 2011-11-14
Reviewed by Ryosuke Niwa.

This patch adds six calls in ~Document() which simply pipe-out to the embedder
the (already-collected) bits of whether varous DOM Mutation Events were registered
on the document.

No tests needed. No functional changes.

* dom/Document.cpp:
(WebCore::histogramMutationEventUsage):
(WebCore::Document::~Document):

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

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp

index adb2aedf6ed18bfada8dedafde02c44d38f662cc..4f650488828dd2e816ae3c185cf130dcb0a140e3 100644 (file)
@@ -1,3 +1,20 @@
+2011-11-14  Rafael Weinstein  <rafaelw@chromium.org>
+
+        [MutationObservers] Add histogram collection for usage of DOM Mutation Events
+        https://bugs.webkit.org/show_bug.cgi?id=72316
+
+        Reviewed by Ryosuke Niwa.
+
+        This patch adds six calls in ~Document() which simply pipe-out to the embedder
+        the (already-collected) bits of whether varous DOM Mutation Events were registered
+        on the document.
+
+        No tests needed. No functional changes.
+
+        * dom/Document.cpp:
+        (WebCore::histogramMutationEventUsage):
+        (WebCore::Document::~Document):
+
 2011-11-14  Simon Fraser  <simon.fraser@apple.com>
 
         div with webkit-transform + webkit-box-reflect disappears when switching tabs
index 3a7f4ec80269ebf8f5f7a5d05f0785570673918e..896dfbe8eac8fd1244acc4126c72d910877a87e3 100644 (file)
 #include <wtf/StdLibExtras.h>
 #include <wtf/text/StringBuffer.h>
 
+#if PLATFORM(CHROMIUM)
+#include "PlatformSupport.h"
+#endif
+
 #if ENABLE(SHARED_WORKERS)
 #include "SharedWorkerRepository.h"
 #endif
@@ -493,6 +497,18 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
     m_docID = docID++;
 }
 
+#if PLATFORM(CHROMIUM)
+static void histogramMutationEventUsage(const unsigned short& listenerTypes)
+{
+    PlatformSupport::histogramEnumeration("DOMAPI.PerDocumentMutationEventUsage.DOMSubtreeModified", static_cast<bool>(listenerTypes & Document::DOMSUBTREEMODIFIED_LISTENER), 2);
+    PlatformSupport::histogramEnumeration("DOMAPI.PerDocumentMutationEventUsage.DOMNodeInserted", static_cast<bool>(listenerTypes & Document::DOMNODEINSERTED_LISTENER), 2);
+    PlatformSupport::histogramEnumeration("DOMAPI.PerDocumentMutationEventUsage.DOMNodeRemoved", static_cast<bool>(listenerTypes & Document::DOMNODEREMOVED_LISTENER), 2);
+    PlatformSupport::histogramEnumeration("DOMAPI.PerDocumentMutationEventUsage.DOMNodeRemovedFromDocument", static_cast<bool>(listenerTypes & Document::DOMNODEREMOVEDFROMDOCUMENT_LISTENER), 2);
+    PlatformSupport::histogramEnumeration("DOMAPI.PerDocumentMutationEventUsage.DOMNodeInsertedIntoDocument", static_cast<bool>(listenerTypes & Document::DOMNODEINSERTEDINTODOCUMENT_LISTENER), 2);
+    PlatformSupport::histogramEnumeration("DOMAPI.PerDocumentMutationEventUsage.DOMCharacterDataModified", static_cast<bool>(listenerTypes & Document::DOMCHARACTERDATAMODIFIED_LISTENER), 2);
+}
+#endif
+
 Document::~Document()
 {
     ASSERT(!renderer());
@@ -505,6 +521,10 @@ Document::~Document()
 
     m_scriptRunner.clear();
 
+#if PLATFORM(CHROMIUM)
+    histogramMutationEventUsage(m_listenerTypes);
+#endif
+
     removeAllEventListeners();
 
     // Currently we believe that Document can never outlive the parser.