From d91dbb787fe74288218e0a03821f7c848ba4a78d Mon Sep 17 00:00:00 2001 From: "scc%netscape.com" Date: Fri, 27 Aug 1999 12:32:20 +0000 Subject: [PATCH] all changes are NS_DEBUG only. added a private static member variable to count outstanding webshells; code in constructor and destructor to do the counting; a static member function to retrieve the value; and a global function that calls that git-svn-id: svn://10.0.0.236/trunk@44816 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 28 ++++++++++++++++++++++++++++ mozilla/webshell/src/nsWebShell.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 1b41eafe5c0..315950ed0e2 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -532,8 +532,26 @@ protected: // if there is no mWindow, this will keep track of the bounds --dwc0001 nsRect mBounds; + +#ifdef NS_DEBUG +private: + // We're counting the number of |nsWebShells| to help find leaks + static unsigned long gNumberOfWebShells; + + static unsigned long TotalWebShellsInExistence() { return gNumberOfWebShells; } +#endif }; +#ifdef NS_DEBUG +unsigned long nsWebShell::gNumberOfWebShells = 0; + +unsigned long +NS_TotalWebShellsInExistence() + { + return nsWebShell::TotalWebShellsInExistence(); + } +#endif + //---------------------------------------------------------------------- // Class IID's @@ -640,6 +658,11 @@ nsresult nsWebShell::DestroyPluginHost(void) // Note: operator new zeros our memory nsWebShell::nsWebShell() { +#ifdef NS_DEBUG + // We're counting the number of |nsWebShells| to help find leaks + ++gNumberOfWebShells; +#endif + NS_INIT_REFCNT(); mHistoryIndex = -1; mScrollPref = nsScrollPreference_kAuto; @@ -729,6 +752,11 @@ nsWebShell::~nsWebShell() DestroyPluginHost(); + +#ifdef NS_DEBUG + // We're counting the number of |nsWebShells| to help find leaks + --gNumberOfWebShells; +#endif } void nsWebShell::InitFrameData(PRBool aCompleteInitScrolling) diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 1b41eafe5c0..315950ed0e2 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -532,8 +532,26 @@ protected: // if there is no mWindow, this will keep track of the bounds --dwc0001 nsRect mBounds; + +#ifdef NS_DEBUG +private: + // We're counting the number of |nsWebShells| to help find leaks + static unsigned long gNumberOfWebShells; + + static unsigned long TotalWebShellsInExistence() { return gNumberOfWebShells; } +#endif }; +#ifdef NS_DEBUG +unsigned long nsWebShell::gNumberOfWebShells = 0; + +unsigned long +NS_TotalWebShellsInExistence() + { + return nsWebShell::TotalWebShellsInExistence(); + } +#endif + //---------------------------------------------------------------------- // Class IID's @@ -640,6 +658,11 @@ nsresult nsWebShell::DestroyPluginHost(void) // Note: operator new zeros our memory nsWebShell::nsWebShell() { +#ifdef NS_DEBUG + // We're counting the number of |nsWebShells| to help find leaks + ++gNumberOfWebShells; +#endif + NS_INIT_REFCNT(); mHistoryIndex = -1; mScrollPref = nsScrollPreference_kAuto; @@ -729,6 +752,11 @@ nsWebShell::~nsWebShell() DestroyPluginHost(); + +#ifdef NS_DEBUG + // We're counting the number of |nsWebShells| to help find leaks + --gNumberOfWebShells; +#endif } void nsWebShell::InitFrameData(PRBool aCompleteInitScrolling)