Limit live Document tracking to debug builds.
liveDocumentSet() is only used by a debug entry point, so only extend
it on Document creation in debug builds.
R=
BUG=611702
Review-Url: https://codereview.chromium.org/2052583003
Cr-Commit-Position: refs/heads/master@{#398839}
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index ebb654a6..b4f3645 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -242,6 +242,11 @@
using namespace WTF;
using namespace Unicode;
+#ifndef NDEBUG
+using WeakDocumentSet = blink::PersistentHeapHashSet<blink::WeakMember<blink::Document>>;
+static WeakDocumentSet& liveDocumentSet();
+#endif
+
namespace blink {
using namespace HTMLNames;
@@ -367,14 +372,6 @@
static bool s_threadedParsingEnabledForTesting = true;
-using WeakDocumentSet = PersistentHeapHashSet<WeakMember<Document>>;
-
-static WeakDocumentSet& liveDocumentSet()
-{
- DEFINE_STATIC_LOCAL(WeakDocumentSet, set, ());
- return set;
-}
-
// This class doesn't work with non-Document ExecutionContext.
class AutofocusTask final : public ExecutionContextTask {
public:
@@ -514,7 +511,9 @@
// ignoring the defersLoading flag.
DCHECK(!parentDocument() || !parentDocument()->activeDOMObjectsAreSuspended());
+#ifndef NDEBUG
liveDocumentSet().add(this);
+#endif
}
Document::~Document()
@@ -5996,6 +5995,13 @@
#ifndef NDEBUG
using namespace blink;
+
+static WeakDocumentSet& liveDocumentSet()
+{
+ DEFINE_STATIC_LOCAL(WeakDocumentSet, set, ());
+ return set;
+}
+
void showLiveDocumentInstances()
{
WeakDocumentSet& set = liveDocumentSet();