From d6059627f339059ab3201d4470792550ca167064 Mon Sep 17 00:00:00 2001 From: Mounir Lamouri Date: Tue, 9 Aug 2011 14:58:41 +0200 Subject: [PATCH] Bug 674112 - Make nsNavigator participate to the DOM Memory Reporter. r=jst --- dom/base/nsGlobalWindow.cpp | 31 +++++++++++++++++++++++++++++++ dom/base/nsGlobalWindow.h | 12 +++--------- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 109a80763975..adbd43debb10 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -10075,6 +10075,19 @@ nsGlobalWindow::HasPerformanceSupport() return Preferences::GetBool("dom.enable_performance", PR_FALSE); } +PRInt64 +nsGlobalWindow::SizeOf() const +{ + PRInt64 size = sizeof(*this); + + if (IsInnerWindow() && mDoc) { + size += mDoc->SizeOf(); + } + + size += mNavigator ? mNavigator->SizeOf() : 0; + + return size; +} // nsGlobalChromeWindow implementation @@ -11227,3 +11240,21 @@ NS_IMETHODIMP nsNavigator::GetMozNotification(nsIDOMDesktopNotificationCenter ** NS_ADDREF(*aRetVal = mNotification); return NS_OK; } + +PRInt64 +nsNavigator::SizeOf() const +{ + PRInt64 size = sizeof(*this); + + // TODO: add SizeOf() to nsMimeTypeArray, bug 674113. + size += mMimeTypes ? sizeof(*mMimeTypes.get()) : 0; + // TODO: add SizeOf() to nsPluginArray, bug 674114. + size += mPlugins ? sizeof(*mPlugins.get()) : 0; + // TODO: add SizeOf() to nsGeolocation, bug 674115. + size += mGeolocation ? sizeof(*mGeolocation.get()) : 0; + // TODO: add SizeOf() to nsDesktopNotificationCenter, bug 674116. + size += mNotification ? sizeof(*mNotification.get()) : 0; + + return size; +} + diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 23696445be6d..d9b1d72e41be 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -538,15 +538,7 @@ public: return sWindowsById; } - PRInt64 SizeOf() const { - PRInt64 size = sizeof(*this); - - if (IsInnerWindow() && mDoc) { - size += mDoc->SizeOf(); - } - - return size; - } + PRInt64 SizeOf() const; private: // Enable updates for the accelerometer. @@ -1076,6 +1068,8 @@ public: static bool HasDesktopNotificationSupport(); + PRInt64 SizeOf() const; + protected: nsRefPtr mMimeTypes; nsRefPtr mPlugins;