Bug 831193 (part 21) - Make NumGhostsReporter a subclass of MemoryReporterBase. r=jlebar.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 22 Aug 2013 22:26:23 -0700
changeset 157591 eead1e72622dbf85ebb0d1fa9695e341ab5830a2
parent 157590 e4eb75e2d77e479e33ee8b08e5db1f466c19d801
child 157592 df8b1e56e1a6524d7a9f7d661ce5861dca546748
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlebar
bugs831193
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 831193 (part 21) - Make NumGhostsReporter a subclass of MemoryReporterBase. r=jlebar.
dom/base/nsWindowMemoryReporter.cpp
dom/base/nsWindowMemoryReporter.h
--- a/dom/base/nsWindowMemoryReporter.cpp
+++ b/dom/base/nsWindowMemoryReporter.cpp
@@ -747,57 +747,16 @@ GhostURLsReporter::CollectReports(
 
   // Call aCb->Callback() for each ghost window.
   ghostWindows.EnumerateEntries(ReportGhostWindowsEnumerator,
                                 &reportGhostWindowsEnumData);
 
   return reportGhostWindowsEnumData.rv;
 }
 
-NS_IMPL_ISUPPORTS1(nsWindowMemoryReporter::NumGhostsReporter,
-                   nsIMemoryReporter)
-
-nsWindowMemoryReporter::
-NumGhostsReporter::NumGhostsReporter(
-  nsWindowMemoryReporter *aWindowReporter)
-  : mWindowReporter(aWindowReporter)
-{}
-
-NS_IMETHODIMP
-nsWindowMemoryReporter::
-NumGhostsReporter::GetProcess(nsACString& aProcess)
-{
-  aProcess.AssignLiteral("");
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWindowMemoryReporter::
-NumGhostsReporter::GetPath(nsACString& aPath)
-{
-  aPath.AssignLiteral("ghost-windows");
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWindowMemoryReporter::
-NumGhostsReporter::GetKind(int32_t* aKind)
-{
-  *aKind = KIND_OTHER;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWindowMemoryReporter::
-NumGhostsReporter::GetUnits(int32_t* aUnits)
-{
-  *aUnits = nsIMemoryReporter::UNITS_COUNT;
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 nsWindowMemoryReporter::
 NumGhostsReporter::GetDescription(nsACString& aDesc)
 {
   nsPrintfCString str(
 "The number of ghost windows present (the number of nodes underneath \
 explicit/window-objects/top(none)/ghost, modulo race conditions).  A ghost \
 window is not shown in any tab, does not share a domain with any non-detached \
@@ -807,19 +766,16 @@ minimize memory usage button.\n\n\
 Ghost windows can happen legitimately, but they are often indicative of leaks \
 in the browser or add-ons.",
   mWindowReporter->GetGhostTimeout());
 
   aDesc.Assign(str);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsWindowMemoryReporter::
-NumGhostsReporter::GetAmount(int64_t* aAmount)
+int64_t
+nsWindowMemoryReporter::NumGhostsReporter::Amount()
 {
   nsTHashtable<nsUint64HashKey> ghostWindows;
   ghostWindows.Init();
   mWindowReporter->CheckForGhostWindows(&ghostWindows);
-
-  *aAmount = ghostWindows.Count();
-  return NS_OK;
+  return ghostWindows.Count();
 }
--- a/dom/base/nsWindowMemoryReporter.h
+++ b/dom/base/nsWindowMemoryReporter.h
@@ -137,25 +137,30 @@ private:
   private:
     nsRefPtr<nsWindowMemoryReporter> mWindowReporter;
   };
 
   /**
    * nsGhostWindowReporter generates the "ghost-windows" single-report, which
    * counts the number of ghost windows present.
    */
-  class NumGhostsReporter MOZ_FINAL : public nsIMemoryReporter
+  class NumGhostsReporter MOZ_FINAL : public mozilla::MemoryReporterBase
   {
   public:
-    NumGhostsReporter(nsWindowMemoryReporter* aWindowReporter);
+    NumGhostsReporter(nsWindowMemoryReporter* aWindowReporter)
+        // Description is "???" because we define GetDescription below.
+      : MemoryReporterBase("ghost-windows", KIND_OTHER, UNITS_COUNT, "???")
+      , mWindowReporter(aWindowReporter)
+    {}
 
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIMEMORYREPORTER
+    NS_IMETHOD GetDescription(nsACString& aDesc);
 
   private:
+    int64_t Amount() MOZ_OVERRIDE;
+
     nsRefPtr<nsWindowMemoryReporter> mWindowReporter;
   };
 
   // Protect ctor, use Init() instead.
   nsWindowMemoryReporter();
 
   /**
    * Get the number of seconds for which a window must satisfy ghost criteria