Bug 674112 - Make nsNavigator participate to the DOM Memory Reporter. r=jst
authorMounir Lamouri <mounir.lamouri@gmail.com>
Tue, 09 Aug 2011 14:58:41 +0200
changeset 74120 13d1b63d5a696dafaa9c92391316c4edf7f2858c
parent 74119 8d7c38e31bdc68f3ab8fa171512fc7962ffbf432
child 74121 3015d5cb3a9c493d3d53f828a2a42e1ea7d86419
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersjst
bugs674112
milestone8.0a1
Bug 674112 - Make nsNavigator participate to the DOM Memory Reporter. r=jst
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -10070,16 +10070,29 @@ nsGlobalWindow::HasIndexedDBSupport()
 
 // static
 bool
 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
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalChromeWindow)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGlobalChromeWindow,
                                                   nsGlobalWindow)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mBrowserDOMWindow)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mMessageManager)
@@ -11222,8 +11235,26 @@ NS_IMETHODIMP nsNavigator::GetMozNotific
                                                   scx);
   if (!mNotification) {
     return NS_ERROR_FAILURE;
   }
 
   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;
+}
+
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -533,25 +533,17 @@ public:
   static bool HasIndexedDBSupport();
 
   static bool HasPerformanceSupport();
 
   static WindowByIdTable* GetWindowsTable() {
     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.
   void EnableDeviceMotionUpdates();
 
   // Disables updates for the accelerometer.
   void DisableDeviceMotionUpdates();
 
@@ -1071,16 +1063,18 @@ public:
     return mDocShell;
   }
 
   void LoadingNewDocument();
   nsresult RefreshMIMEArray();
 
   static bool HasDesktopNotificationSupport();
 
+  PRInt64 SizeOf() const;
+
 protected:
   nsRefPtr<nsMimeTypeArray> mMimeTypes;
   nsRefPtr<nsPluginArray> mPlugins;
   nsRefPtr<nsGeolocation> mGeolocation;
   nsRefPtr<nsDesktopNotificationCenter> mNotification;
   nsIDocShell* mDocShell; // weak reference
 };