From b7a03a8ba19d5837e1baeb722e270f3623fc336e Mon Sep 17 00:00:00 2001 From: "beard%netscape.com" Date: Sat, 2 Sep 2000 08:23:50 +0000 Subject: [PATCH] hooked up Leak Detector contextual menu. --- xpfe/browser/resources/content/navigator.js | 47 ++++++++++++------- .../resources/content/navigatorOverlay.xul | 13 ++++- .../resources/locale/en-US/navigator.dtd | 6 ++- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/xpfe/browser/resources/content/navigator.js b/xpfe/browser/resources/content/navigator.js index e35049a2a1c..783c880b41e 100644 --- a/xpfe/browser/resources/content/navigator.js +++ b/xpfe/browser/resources/content/navigator.js @@ -1529,31 +1529,42 @@ function dumpExpr( expr ) { dump( expr+"="+eval(expr)+"\n" ); } -var leakDetector = null; - -function getLeakDetector() +// Initialize the LeakDetector class. +function LeakDetector(verbose) { - leakDetector = createInstance("component://netscape/xpcom/leakdetector", "nsILeakDetector"); - if (leakDetector == null) { - dump("Could not create leak detector, leak detection probably\n"); - dump("not compiled into this browser\n"); - } + this.verbose = verbose; + try { + this.vtable = createInstance("component://netscape/xpcom/leakdetector", "nsILeakDetector"); + } catch (err) { + } } +var leakDetector = new LeakDetector(false); // Dumps current set of memory leaks. -function dumpMemoryLeaks() { - if (leakDetector == null) - getLeakDetector(); - if (leakDetector != null) - leakDetector.dumpLeaks(); +function dumpMemoryLeaks() +{ + leakDetector.vtable.dumpLeaks(); } -function traceObject(object) +// Traces all objects reachable from the chrome document. +function traceChrome() { - if (leakDetector == null) - getLeakDetector(); - if (leakDetector != null) - leakDetector.traceObject(object); + leakDetector.vtable.traceObject(document, leakDetector.verbose); +} + +// Traces all objects reachable from the content document. +function traceDocument() +{ + // keep the chrome document out of the dump. + leakDetector.vtable.markObject(document, true); + leakDetector.vtable.traceObject(window._content, leakDetector.verbose); + leakDetector.vtable.markObject(document, false); +} + +// Controls whether or not we do verbose tracing. +function traceVerbose(verbose) +{ + leakDetector.verbose = (verbose == "true"); } var consoleListener = { diff --git a/xpfe/browser/resources/content/navigatorOverlay.xul b/xpfe/browser/resources/content/navigatorOverlay.xul index 40f92b5a258..1e69eba25ce 100644 --- a/xpfe/browser/resources/content/navigatorOverlay.xul +++ b/xpfe/browser/resources/content/navigatorOverlay.xul @@ -524,8 +524,17 @@ oncommand="goPreferences('pref-themes.xul','chrome://communicator/content/pref/p - - + + + + + + + + + + + diff --git a/xpfe/browser/resources/locale/en-US/navigator.dtd b/xpfe/browser/resources/locale/en-US/navigator.dtd index 0ce1cb6bcaa..3b259826bd8 100644 --- a/xpfe/browser/resources/locale/en-US/navigator.dtd +++ b/xpfe/browser/resources/locale/en-US/navigator.dtd @@ -300,8 +300,10 @@ - - + + + +