Remove unused InspectorCounters.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Feb 2014 20:15:44 +0000 (20:15 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 26 Feb 2014 20:15:44 +0000 (20:15 +0000)
<https://webkit.org/b/129367>

The InspectorCounters code was only used to implement two layout test
APIs (window.internals.numberOfLive{Nodes,Documents}) yet it had hooks
in crazy places like Node construction and destruction.

Rewrote the internals APIs to iterate over all live Documents instead,
totaling up their referencing Node count. Added a process-global
Document::allDocuments() HashSet to make this whole thing possible.

Reviewed by Sam Weinig.

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.exp.in:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSEventListener.cpp:
* dom/Document.cpp:
(WebCore::Document::allDocuments):
(WebCore::Document::Document):
(WebCore::Document::~Document):
* dom/Document.h:
(WebCore::Node::Node):
* dom/Node.cpp:
(WebCore::Node::~Node):
* inspector/InspectorAllInOne.cpp:
* inspector/InspectorCounters.cpp: Removed.
* inspector/InspectorCounters.h: Removed.
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::start):
(WebCore::InspectorTimelineAgent::innerAddRecordToTimeline):
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
* inspector/InspectorTimelineAgent.h:
* inspector/protocol/Timeline.json:
* platform/ThreadGlobalData.cpp:
* testing/Internals.cpp:
(WebCore::Internals::numberOfLiveNodes):
(WebCore::Internals::numberOfLiveDocuments):
* testing/Internals.h:
* testing/Internals.idl:

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

22 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSEventListener.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Node.cpp
Source/WebCore/inspector/InspectorAllInOne.cpp
Source/WebCore/inspector/InspectorCounters.cpp [deleted file]
Source/WebCore/inspector/InspectorCounters.h [deleted file]
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.h
Source/WebCore/inspector/protocol/Timeline.json
Source/WebCore/platform/ThreadGlobalData.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in

index 608fe05..7355b54 100644 (file)
@@ -1561,7 +1561,6 @@ set(WebCore_SOURCES
     inspector/InspectorCSSAgent.cpp
     inspector/InspectorClient.cpp
     inspector/InspectorController.cpp
-    inspector/InspectorCounters.cpp
     inspector/InspectorDOMAgent.cpp
     inspector/InspectorDOMDebuggerAgent.cpp
     inspector/InspectorDOMStorageAgent.cpp
index 04bdc16..6257e25 100644 (file)
@@ -1,3 +1,49 @@
+2014-02-26  Andreas Kling  <akling@apple.com>
+
+        Remove unused InspectorCounters.
+        <https://webkit.org/b/129367>
+
+        The InspectorCounters code was only used to implement two layout test
+        APIs (window.internals.numberOfLive{Nodes,Documents}) yet it had hooks
+        in crazy places like Node construction and destruction.
+
+        Rewrote the internals APIs to iterate over all live Documents instead,
+        totaling up their referencing Node count. Added a process-global
+        Document::allDocuments() HashSet to make this whole thing possible.
+
+        Reviewed by Sam Weinig.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * WebCore.exp.in:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSEventListener.cpp:
+        * dom/Document.cpp:
+        (WebCore::Document::allDocuments):
+        (WebCore::Document::Document):
+        (WebCore::Document::~Document):
+        * dom/Document.h:
+        (WebCore::Node::Node):
+        * dom/Node.cpp:
+        (WebCore::Node::~Node):
+        * inspector/InspectorAllInOne.cpp:
+        * inspector/InspectorCounters.cpp: Removed.
+        * inspector/InspectorCounters.h: Removed.
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::start):
+        (WebCore::InspectorTimelineAgent::innerAddRecordToTimeline):
+        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
+        * inspector/InspectorTimelineAgent.h:
+        * inspector/protocol/Timeline.json:
+        * platform/ThreadGlobalData.cpp:
+        * testing/Internals.cpp:
+        (WebCore::Internals::numberOfLiveNodes):
+        (WebCore::Internals::numberOfLiveDocuments):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2014-02-26  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Remove console.profiles from window.console API
index 1bdfdef..ff6b071 100644 (file)
@@ -3764,8 +3764,6 @@ webcore_sources += \
        Source/WebCore/inspector/InspectorConsoleInstrumentation.h \
        Source/WebCore/inspector/InspectorController.cpp \
        Source/WebCore/inspector/InspectorController.h \
-       Source/WebCore/inspector/InspectorCounters.cpp \
-       Source/WebCore/inspector/InspectorCounters.h \
        Source/WebCore/inspector/InspectorDOMAgent.cpp \
        Source/WebCore/inspector/InspectorDOMAgent.h \
        Source/WebCore/inspector/InspectorDOMDebuggerAgent.cpp \
index 6731585..62e8b2c 100644 (file)
@@ -1212,6 +1212,7 @@ __ZN7WebCore8BlobData10appendBlobERKNS_3URLExx
 __ZN7WebCore8BlobData14setContentTypeERKN3WTF6StringE
 __ZN7WebCore8CSSValue7destroyEv
 __ZN7WebCore8Document11createRangeEv
+__ZN7WebCore8Document12allDocumentsEv
 __ZN7WebCore8Document12updateLayoutEv
 __ZN7WebCore8Document13createElementERKNS_13QualifiedNameEb
 __ZN7WebCore8Document14createTextNodeERKN3WTF6StringE
@@ -2836,7 +2837,6 @@ __ZN7WebCore16HTMLInputElement25selectColorInColorChooserERKNS_5ColorE
 
 #if ENABLE(INSPECTOR)
 __ZN7WebCore15InspectorClient31doDispatchMessageOnFrontendPageEPNS_4PageERKN3WTF6StringE
-__ZN7WebCore17InspectorCounters12counterValueENS0_11CounterTypeE
 __ZN7WebCore19InspectorController15connectFrontendEPN9Inspector24InspectorFrontendChannelE
 __ZN7WebCore19InspectorController18disconnectFrontendEN9Inspector25InspectorDisconnectReasonE
 __ZN7WebCore19InspectorController18setProfilerEnabledEb
index 871b73e..39b4c53 100644 (file)
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
-    <ClCompile Include="..\inspector\InspectorCounters.cpp">
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
-    </ClCompile>
     <ClCompile Include="..\inspector\InspectorCSSAgent.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     <ClInclude Include="..\inspector\InspectorClient.h" />
     <ClInclude Include="..\inspector\InspectorConsoleInstrumentation.h" />
     <ClInclude Include="..\inspector\InspectorController.h" />
-    <ClInclude Include="..\inspector\InspectorCounters.h" />
     <ClInclude Include="..\inspector\InspectorCSSAgent.h" />
     <ClInclude Include="..\inspector\InspectorDatabaseAgent.h" />
     <ClInclude Include="..\inspector\InspectorDatabaseInstrumentation.h" />
index e47d8bf..402a8a1 100644 (file)
     <ClCompile Include="..\inspector\InspectorController.cpp">
       <Filter>inspector</Filter>
     </ClCompile>
-    <ClCompile Include="..\inspector\InspectorCounters.cpp">
-      <Filter>inspector</Filter>
-    </ClCompile>
     <ClCompile Include="..\inspector\InspectorCSSAgent.cpp">
       <Filter>inspector</Filter>
     </ClCompile>
     <ClInclude Include="..\inspector\InspectorController.h">
       <Filter>inspector</Filter>
     </ClInclude>
-    <ClInclude Include="..\inspector\InspectorCounters.h">
-      <Filter>inspector</Filter>
-    </ClInclude>
     <ClInclude Include="..\inspector\InspectorCSSAgent.h">
       <Filter>inspector</Filter>
     </ClInclude>
index 7c9a5e7..0543e06 100644 (file)
                F12171F516A8CED2000053CA /* WebVTTElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F12171F316A8BC63000053CA /* WebVTTElement.cpp */; };
                F12171F616A8CF0B000053CA /* WebVTTElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F12171F416A8BC63000053CA /* WebVTTElement.h */; };
                F293B27E56C112F373FFF27E /* DNSResolveQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C60128060078BB70E367A95 /* DNSResolveQueue.cpp */; };
-               F325A40A14EE36FA007324E2 /* InspectorCounters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F325A40814EE36FA007324E2 /* InspectorCounters.cpp */; };
-               F325A40B14EE36FA007324E2 /* InspectorCounters.h in Headers */ = {isa = PBXBuildFile; fileRef = F325A40914EE36FA007324E2 /* InspectorCounters.h */; settings = {ATTRIBUTES = (Private, ); }; };
                F33F0282120947F200E5743A /* ScriptProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F33F0281120947F200E5743A /* ScriptProfile.cpp */; };
                F344C7141125B82C00F26EEE /* InspectorFrontendClient.h in Headers */ = {isa = PBXBuildFile; fileRef = F344C7121125B82C00F26EEE /* InspectorFrontendClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                F344C75311294D9D00F26EEE /* InspectorFrontendClientLocal.h in Headers */ = {isa = PBXBuildFile; fileRef = F344C75211294D9D00F26EEE /* InspectorFrontendClientLocal.h */; settings = {ATTRIBUTES = (Private, ); }; };
                EDEC98020AED7E170059137F /* WebCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCorePrefix.h; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
                F12171F316A8BC63000053CA /* WebVTTElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebVTTElement.cpp; sourceTree = "<group>"; };
                F12171F416A8BC63000053CA /* WebVTTElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVTTElement.h; sourceTree = "<group>"; };
-               F325A40814EE36FA007324E2 /* InspectorCounters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorCounters.cpp; sourceTree = "<group>"; };
-               F325A40914EE36FA007324E2 /* InspectorCounters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorCounters.h; sourceTree = "<group>"; };
                F33F0281120947F200E5743A /* ScriptProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptProfile.cpp; sourceTree = "<group>"; };
                F344C7121125B82C00F26EEE /* InspectorFrontendClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFrontendClient.h; sourceTree = "<group>"; };
                F344C75211294D9D00F26EEE /* InspectorFrontendClientLocal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFrontendClientLocal.h; sourceTree = "<group>"; };
                                F3F5CF1012ED81A80084C569 /* InspectorConsoleInstrumentation.h */,
                                1C81B9570E97330800266E07 /* InspectorController.cpp */,
                                1C81B9560E97330800266E07 /* InspectorController.h */,
-                               F325A40814EE36FA007324E2 /* InspectorCounters.cpp */,
-                               F325A40914EE36FA007324E2 /* InspectorCounters.h */,
                                82AB1741124B99EC00C5069D /* InspectorCSSAgent.cpp */,
                                82AB1742124B99EC00C5069D /* InspectorCSSAgent.h */,
                                7AB0B1BE1211A62200A76940 /* InspectorDatabaseAgent.cpp */,
                                1C81B95C0E97330800266E07 /* InspectorClient.h in Headers */,
                                F3F5CF1112ED81A80084C569 /* InspectorConsoleInstrumentation.h in Headers */,
                                1C81B95A0E97330800266E07 /* InspectorController.h in Headers */,
-                               F325A40B14EE36FA007324E2 /* InspectorCounters.h in Headers */,
                                82AB1744124B99EC00C5069D /* InspectorCSSAgent.h in Headers */,
                                4A9CC82116BF9BB400EC645A /* InspectorCSSOMWrappers.h in Headers */,
                                7AB0B1C11211A62200A76940 /* InspectorDatabaseAgent.h in Headers */,
                                B885E8D411E06DD2009FFBF4 /* InspectorApplicationCacheAgent.cpp in Sources */,
                                7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */,
                                1C81B95B0E97330800266E07 /* InspectorController.cpp in Sources */,
-                               F325A40A14EE36FA007324E2 /* InspectorCounters.cpp in Sources */,
                                82AB1743124B99EC00C5069D /* InspectorCSSAgent.cpp in Sources */,
                                4A9CC82016BF9BB400EC645A /* InspectorCSSOMWrappers.cpp in Sources */,
                                7AB0B1C01211A62200A76940 /* InspectorDatabaseAgent.cpp in Sources */,
index 4d3f1f0..960b67e 100644 (file)
@@ -23,7 +23,6 @@
 #include "BeforeUnloadEvent.h"
 #include "Event.h"
 #include "Frame.h"
-#include "InspectorCounters.h"
 #include "JSEvent.h"
 #include "JSEventTarget.h"
 #include "JSMainThreadExecState.h"
index a11200b..bbe606f 100644 (file)
@@ -392,6 +392,12 @@ bool TextAutoSizingTraits::isDeletedValue(const TextAutoSizingKey& value)
 }
 #endif
 
+HashSet<Document*>& Document::allDocuments()
+{
+    static NeverDestroyed<HashSet<Document*>> documents;
+    return documents;
+}
+
 Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsigned constructionFlags)
     : ContainerNode(*this, CreateDocument)
     , TreeScope(*this)
@@ -508,6 +514,8 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
     , m_hasInjectedPlugInsScript(false)
     , m_renderTreeBeingDestroyed(false)
 {
+    allDocuments().add(this);
+
     // We depend on the url getting immediately set in subframes, but we
     // also depend on the url NOT getting immediately set in opened windows.
     // See fast/dom/early-frame-url.html
@@ -535,8 +543,6 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
 
     for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListAndCollectionCounts); ++i)
         m_nodeListAndCollectionCounts[i] = 0;
-
-    InspectorCounters::incrementCounter(InspectorCounters::DocumentCounter);
 }
 
 static void histogramMutationEventUsage(const unsigned short& listenerTypes)
@@ -571,6 +577,8 @@ PassRefPtr<Document> Document::create(ScriptExecutionContext& context)
 
 Document::~Document()
 {
+    allDocuments().remove(this);
+
     ASSERT(!renderView());
     ASSERT(!m_inPageCache);
     ASSERT(m_ranges.isEmpty());
@@ -636,8 +644,6 @@ Document::~Document()
 
     for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListAndCollectionCounts); ++i)
         ASSERT(!m_nodeListAndCollectionCounts[i]);
-
-    InspectorCounters::decrementCounter(InspectorCounters::DocumentCounter);
 }
 
 void Document::removedLastRef()
index b38b9cb..89f71c5 100644 (file)
@@ -37,7 +37,6 @@
 #include "FocusDirection.h"
 #include "HitTestRequest.h"
 #include "IconURL.h"
-#include "InspectorCounters.h"
 #include "MutationObserver.h"
 #include "PageVisibilityState.h"
 #include "PlatformScreen.h"
@@ -287,8 +286,12 @@ public:
         }
     }
 
+    unsigned referencingNodeCount() const { return m_referencingNodeCount; }
+
     void removedLastRef();
 
+    static HashSet<Document*>& allDocuments();
+
     MediaQueryMatcher& mediaQueryMatcher();
 
     using ContainerNode::ref;
@@ -1725,8 +1728,6 @@ inline Node::Node(Document& document, ConstructionType type)
 #if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS)
     trackForDebugging();
 #endif
-
-    InspectorCounters::incrementCounter(InspectorCounters::NodeCounter);
 }
 
 inline ScriptExecutionContext* Node::scriptExecutionContext() const
index bc4bf1f..b38e4b2 100644 (file)
@@ -309,8 +309,6 @@ Node::~Node()
         willBeDeletedFrom(document());
 
     document().decrementReferencingNodeCount();
-
-    InspectorCounters::decrementCounter(InspectorCounters::NodeCounter);
 }
 
 void Node::willBeDeletedFrom(Document& document)
index d4d1657..209c5a3 100644 (file)
@@ -33,7 +33,6 @@
 #include "InspectorCSSAgent.cpp"
 #include "InspectorClient.cpp"
 #include "InspectorController.cpp"
-#include "InspectorCounters.cpp"
 #include "InspectorDOMAgent.cpp"
 #include "InspectorDOMDebuggerAgent.cpp"
 #include "InspectorDOMStorageAgent.cpp"
diff --git a/Source/WebCore/inspector/InspectorCounters.cpp b/Source/WebCore/inspector/InspectorCounters.cpp
deleted file mode 100644 (file)
index 6078734..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-* Copyright (C) 2012 Google Inc. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are
-* met:
-*
-*     * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*     * Redistributions in binary form must reproduce the above
-* copyright notice, this list of conditions and the following disclaimer
-* in the documentation and/or other materials provided with the
-* distribution.
-*     * Neither the name of Google Inc. nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include "config.h"
-
-#if ENABLE(INSPECTOR)
-
-#include "InspectorCounters.h"
-
-namespace WebCore {
-
-int InspectorCounters::s_counters[CounterTypeLength];
-
-int InspectorCounters::counterValue(CounterType type)
-{
-    return s_counters[type];
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebCore/inspector/InspectorCounters.h b/Source/WebCore/inspector/InspectorCounters.h
deleted file mode 100644 (file)
index e216c1c..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
-* Copyright (C) 2012 Google Inc. All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are
-* met:
-*
-*     * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*     * Redistributions in binary form must reproduce the above
-* copyright notice, this list of conditions and the following disclaimer
-* in the documentation and/or other materials provided with the
-* distribution.
-*     * Neither the name of Google Inc. nor the names of its
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef InspectorCounters_h
-#define InspectorCounters_h
-
-#include <wtf/FastMalloc.h>
-
-#if !ASSERT_DISABLED
-#include <wtf/MainThread.h>
-#if PLATFORM(IOS)
-#include "WebCoreThread.h"
-#endif
-#endif
-
-namespace WebCore {
-
-class InspectorCounters {
-public:
-    enum CounterType {
-        DocumentCounter,
-        NodeCounter,
-        JSEventListenerCounter,
-        CounterTypeLength
-    };
-
-    static inline void incrementCounter(CounterType type)
-    {
-#if ENABLE(INSPECTOR)
-        ASSERT(isMainThread());
-        ++s_counters[type];
-#else
-        UNUSED_PARAM(type);
-#endif
-    }
-
-    static inline void decrementCounter(CounterType type)
-    {
-#if ENABLE(INSPECTOR)
-        ASSERT(isMainThread());
-        --s_counters[type];
-#else
-        UNUSED_PARAM(type);
-#endif
-    }
-
-#if ENABLE(INSPECTOR)
-    static int counterValue(CounterType);
-#endif
-
-private:
-    InspectorCounters();
-
-#if ENABLE(INSPECTOR)
-    static int s_counters[CounterTypeLength];
-#endif
-};
-
-} // namespace WebCore
-
-#endif // !defined(InspectorCounters_h)
index eaf4aac..86916fc 100644 (file)
@@ -38,7 +38,6 @@
 #include "Frame.h"
 #include "FrameView.h"
 #include "InspectorClient.h"
-#include "InspectorCounters.h"
 #include "InspectorInstrumentation.h"
 #include "InspectorPageAgent.h"
 #include "InspectorWebFrontendDispatchers.h"
@@ -82,7 +81,7 @@ void InspectorTimelineAgent::willDestroyFrontendAndBackend(InspectorDisconnectRe
     stop(&error);
 }
 
-void InspectorTimelineAgent::start(ErrorString*, const int* maxCallStackDepth, const bool* includeDomCounters)
+void InspectorTimelineAgent::start(ErrorString*, const int* maxCallStackDepth)
 {
     if (!m_frontendDispatcher)
         return;
@@ -92,9 +91,6 @@ void InspectorTimelineAgent::start(ErrorString*, const int* maxCallStackDepth, c
     else
         m_maxCallStackDepth = 5;
 
-    if (includeDomCounters)
-        m_includeDOMCounters = *includeDomCounters;
-
     m_timeConverter.reset();
 
     m_instrumentingAgents->setInspectorTimelineAgent(this);
@@ -556,8 +552,6 @@ void InspectorTimelineAgent::innerAddRecordToTimeline(PassRefPtr<InspectorObject
 
     RefPtr<Inspector::TypeBuilder::Timeline::TimelineEvent> record = Inspector::TypeBuilder::Timeline::TimelineEvent::runtimeCast(prpRecord);
 
-    setDOMCounters(record.get());
-
     if (m_recordStack.isEmpty())
         sendEvent(record.release());
     else {
@@ -571,24 +565,6 @@ static size_t usedHeapSize()
     return JSDOMWindow::commonVM()->heap.size();
 }
 
-void InspectorTimelineAgent::setDOMCounters(Inspector::TypeBuilder::Timeline::TimelineEvent* record)
-{
-    record->setUsedHeapSize(usedHeapSize());
-
-    if (m_includeDOMCounters) {
-        int documentCount = 0;
-        int nodeCount = 0;
-        if (m_inspectorType == PageInspector) {
-            documentCount = InspectorCounters::counterValue(InspectorCounters::DocumentCounter);
-            nodeCount = InspectorCounters::counterValue(InspectorCounters::NodeCounter);
-        }
-        RefPtr<Inspector::TypeBuilder::Timeline::DOMCounters> counters = Inspector::TypeBuilder::Timeline::DOMCounters::create()
-            .setDocuments(documentCount)
-            .setNodes(nodeCount);
-        record->setCounters(counters.release());
-    }
-}
-
 void InspectorTimelineAgent::setFrameIdentifier(InspectorObject* record, Frame* frame)
 {
     if (!frame || !m_pageAgent)
@@ -626,7 +602,6 @@ InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentin
     , m_client(client)
     , m_weakFactory(this)
     , m_enabled(false)
-    , m_includeDOMCounters(false)
     , m_recordingProfile(false)
 {
 }
index 694559e..f36c503 100644 (file)
@@ -132,7 +132,7 @@ public:
     virtual void didCreateFrontendAndBackend(Inspector::InspectorFrontendChannel*, Inspector::InspectorBackendDispatcher*) override;
     virtual void willDestroyFrontendAndBackend(Inspector::InspectorDisconnectReason) override;
 
-    virtual void start(ErrorString*, const int* maxCallStackDepth, const bool* includeDomCounters) override;
+    virtual void start(ErrorString*, const int* maxCallStackDepth) override;
     virtual void stop(ErrorString*) override;
     virtual void canMonitorMainThread(ErrorString*, bool*) override;
     virtual void supportsFrameInstrumentation(ErrorString*, bool*) override;
@@ -230,7 +230,6 @@ private:
     void appendRecord(PassRefPtr<Inspector::InspectorObject> data, TimelineRecordType, bool captureCallStack, Frame*);
     void pushCurrentRecord(PassRefPtr<Inspector::InspectorObject>, TimelineRecordType, bool captureCallStack, Frame*);
 
-    void setDOMCounters(Inspector::TypeBuilder::Timeline::TimelineEvent* record);
     void setFrameIdentifier(Inspector::InspectorObject* record, Frame*);
 
     void didCompleteCurrentRecord(TimelineRecordType);
@@ -264,7 +263,6 @@ private:
     WeakPtrFactory<InspectorTimelineAgent> m_weakFactory;
 
     bool m_enabled;
-    bool m_includeDOMCounters;
     bool m_recordingProfile;
 };
 
index ae4c2a3..45c26c2 100644 (file)
@@ -3,15 +3,6 @@
     "description": "Timeline provides its clients with instrumentation records that are generated during the page runtime. Timeline instrumentation can be started and stopped using corresponding commands. While timeline is started, it is generating timeline event records.",
     "types": [
         {
-            "id": "DOMCounters",
-            "type": "object",
-            "properties": [
-                { "name": "documents", "type": "integer" },
-                { "name": "nodes", "type": "integer" }
-            ],
-            "description": "Current values of DOM counters."
-        },
-        {
             "id": "EventType",
             "type": "string",
             "enum": ["EventDispatch", "BeginFrame", "ScheduleStyleRecalculation", "RecalculateStyles", "InvalidateLayout", "Layout", "Paint", "ScrollLayer", "ResizeImage", "CompositeLayers", "ParseHTML", "TimerInstall", "TimerRemove", "TimerFire", "EvaluateScript", "MarkLoad", "MarkDOMContent", "TimeStamp", "Time", "TimeEnd", "ScheduleResourceRequest", "ResourceSendRequest", "ResourceReceiveResponse", "ResourceReceivedData", "ResourceFinish", "XHRReadyStateChange", "XHRLoad", "FunctionCall", "GCEvent", "RequestAnimationFrame", "CancelAnimationFrame", "FireAnimationFrame", "WebSocketCreate", "WebSocketSendHandshakeRequest", "WebSocketReceiveHandshakeResponse", "WebSocketDestroy"],
@@ -25,7 +16,6 @@
                 { "name": "thread", "type": "string", "optional": true, "description": "If present, identifies the thread that produced the event." },
                 { "name": "data", "type": "object", "description": "Event data." },
                 { "name": "children", "type": "array", "optional": true, "items": { "$ref": "TimelineEvent" }, "description": "Nested records." },
-                { "name": "counters", "$ref": "DOMCounters", "optional": true, "description": "Current values of DOM counters." },
                 { "name": "usedHeapSize", "type": "integer", "optional": true, "description": "Current size of JS heap." }
             ],
             "description": "Timeline record contains information about the recorded activity."
@@ -35,8 +25,7 @@
         {
             "name": "start",
             "parameters": [
-                { "name": "maxCallStackDepth", "optional": true, "type": "integer", "description": "Samples JavaScript stack traces up to <code>maxCallStackDepth</code>, defaults to 5." },
-                { "name": "includeDomCounters", "optional": true, "type": "boolean", "description": "Whether DOM counters data should be included into timeline events." }
+                { "name": "maxCallStackDepth", "optional": true, "type": "integer", "description": "Samples JavaScript stack traces up to <code>maxCallStackDepth</code>, defaults to 5." }
             ],
             "description": "Starts capturing instrumentation events."
         },
index 57e5158..bf06785 100644 (file)
@@ -29,7 +29,6 @@
 
 #include "CachedResourceRequestInitiators.h"
 #include "EventNames.h"
-#include "InspectorCounters.h"
 #include "TextCodecICU.h"
 #include "ThreadTimers.h"
 #include <wtf/MainThread.h>
index 51d4ccc..66b9d5e 100644 (file)
@@ -59,7 +59,6 @@
 #include "HistoryItem.h"
 #include "InspectorClient.h"
 #include "InspectorController.h"
-#include "InspectorCounters.h"
 #include "InspectorForwarding.h"
 #include "InspectorFrontendClientLocal.h"
 #include "InspectorInstrumentation.h"
@@ -1441,17 +1440,20 @@ const ProfilesArray& Internals::consoleProfiles() const
     return contextDocument()->domWindow()->console()->profiles();
 }
 
-#if ENABLE(INSPECTOR)
 unsigned Internals::numberOfLiveNodes() const
 {
-    return InspectorCounters::counterValue(InspectorCounters::NodeCounter);
+    unsigned nodeCount = 0;
+    for (auto* document : Document::allDocuments())
+        nodeCount += document->referencingNodeCount();
+    return nodeCount;
 }
 
 unsigned Internals::numberOfLiveDocuments() const
 {
-    return InspectorCounters::counterValue(InspectorCounters::DocumentCounter);
+    return Document::allDocuments().size();
 }
 
+#if ENABLE(INSPECTOR)
 Vector<String> Internals::consoleMessageArgumentCounts() const
 {
     Document* document = contextDocument();
index f43846b..0d45bea 100644 (file)
@@ -226,9 +226,10 @@ public:
 
     const ProfilesArray& consoleProfiles() const;
 
-#if ENABLE(INSPECTOR)
     unsigned numberOfLiveNodes() const;
     unsigned numberOfLiveDocuments() const;
+
+#if ENABLE(INSPECTOR)
     Vector<String> consoleMessageArgumentCounts() const;
     PassRefPtr<DOMWindow> openDummyInspectorFrontend(const String& url);
     void closeDummyInspectorFrontend();
index 53051f7..3571fb9 100644 (file)
     // FIXME: this will lead to BUG interals.consoleProfiles !== interals.consoleProfiles as profile will always returns new array.
     readonly attribute ScriptProfile[] consoleProfiles;
 
-    [Conditional=INSPECTOR] unsigned long numberOfLiveNodes();
-    [Conditional=INSPECTOR] unsigned long numberOfLiveDocuments();
+    unsigned long numberOfLiveNodes();
+    unsigned long numberOfLiveDocuments();
     [Conditional=INSPECTOR] sequence<DOMString> consoleMessageArgumentCounts();
     [Conditional=INSPECTOR] DOMWindow openDummyInspectorFrontend(DOMString url);
     [Conditional=INSPECTOR] void closeDummyInspectorFrontend();
index 9ee5f9a..02f9376 100644 (file)
@@ -125,7 +125,6 @@ EXPORTS
         symbolWithPointer(?broadcast@ThreadCondition@WTF@@QAEXXZ, ?broadcast@ThreadCondition@WTF@@QEAAXXZ)
         symbolWithPointer(?callOnMainThread@WTF@@YAXP6AXPAX@Z0@Z, ?callOnMainThread@WTF@@YAXP6AXPEAX@Z0@Z)
 #if ENABLE(INSPECTOR)
-        ?counterValue@InspectorCounters@WebCore@@SAHW4CounterType@12@@Z
         symbolWithPointer(?didBeginFrame@InspectorController@WebCore@@QAEXXZ, ?didBeginFrame@InspectorController@WebCore@@QEAAXXZ)
         symbolWithPointer(?didCancelFrame@InspectorController@WebCore@@QAEXXZ, ?didCancelFrame@InspectorController@WebCore@@QEAAXXZ)
 #endif
@@ -171,6 +170,7 @@ EXPORTS
         symbolWithPointer(??0String@WTF@@QAE@PB_WI@Z, ??0String@WTF@@QEAA@PEB_WI@Z)
         symbolWithPointer(??0String@WTF@@QAE@VASCIILiteral@1@@Z, ??0String@WTF@@QEAA@VASCIILiteral@1@@Z)
         symbolWithPointer(??1SerializedScriptValue@WebCore@@QAE@XZ, ??1SerializedScriptValue@WebCore@@QEAA@XZ)
+        symbolWithPointer(?allDocuments@Document@WebCore@@SAAAV?$HashSet@PAVDocument@WebCore@@U?$PtrHash@PAVDocument@WebCore@@@WTF@@U?$HashTraits@PAVDocument@WebCore@@@4@@WTF@@XZ)
         symbolWithPointer(?absoluteBoundingBoxRect@RenderObject@WebCore@@QBE?AVIntRect@2@_N@Z, ?absoluteBoundingBoxRect@RenderObject@WebCore@@QEBA?AVIntRect@2@_N@Z)
         symbolWithPointer(?absoluteBoundingBoxRectIgnoringTransforms@RenderObject@WebCore@@QBE?AVIntRect@2@XZ, ?absoluteBoundingBoxRectIgnoringTransforms@RenderObject@WebCore@@QEBA?AVIntRect@2@XZ)
         symbolWithPointer(?description@DocumentMarker@WebCore@@QBEABVString@WTF@@XZ, ?description@DocumentMarker@WebCore@@QEBAAEBVString@WTF@@XZ)