Bug 590790, part 1 - Add getTotalSize() methods to nsWindowSizes and nsArenaMemoryStats. r=njn
authorJonathan Watt <jwatt@jwatt.org>
Thu, 08 May 2014 10:52:13 +0100
changeset 190927 a520a43d065c54fd65a0fd1351e56e2b148ba9a5
parent 190926 15680e55195c68c876414ca8521a546dd2292915
child 190928 8a968bedfccac7559e6aea17a1640c6512a68c13
push idunknown
push userunknown
push dateunknown
reviewersnjn
bugs590790
milestone32.0a1
Bug 590790, part 1 - Add getTotalSize() methods to nsWindowSizes and nsArenaMemoryStats. r=njn
dom/base/nsWindowMemoryReporter.h
layout/base/nsArenaMemoryStats.h
--- a/dom/base/nsWindowMemoryReporter.h
+++ b/dom/base/nsWindowMemoryReporter.h
@@ -49,16 +49,26 @@ public:
 
   void addToTabSizes(nsTabSizes *sizes) const {
     #define ADD_TO_TAB_SIZES(kind, mSize) sizes->add(nsTabSizes::kind, mSize);
     FOR_EACH_SIZE(ADD_TO_TAB_SIZES)
     #undef ADD_TO_TAB_SIZES
     mArenaStats.addToTabSizes(sizes);
   }
 
+  size_t getTotalSize() const
+  {
+    size_t total = 0;
+    #define ADD_TO_TOTAL_SIZE(kind, mSize) total += mSize;
+    FOR_EACH_SIZE(ADD_TO_TOTAL_SIZE)
+    #undef ADD_TO_TOTAL_SIZE
+    total += mArenaStats.getTotalSize();
+    return total;
+  }
+
   #define DECL_SIZE(kind, mSize) size_t mSize;
   FOR_EACH_SIZE(DECL_SIZE);
   #undef DECL_SIZE
 
   uint32_t mDOMEventTargetsCount;
   uint32_t mDOMEventListenersCount;
 
   nsArenaMemoryStats mArenaStats;
--- a/layout/base/nsArenaMemoryStats.h
+++ b/layout/base/nsArenaMemoryStats.h
@@ -61,16 +61,29 @@ struct nsArenaMemoryStats {
     FOR_EACH_SIZE(ADD_TO_TAB_SIZES)
     #undef ADD_TO_TAB_SIZES
     #define FRAME_ID(classname) \
       sizes->add(nsTabSizes::Other, FRAME_ID_STAT_FIELD(classname));
     #include "nsFrameIdList.h"
     #undef FRAME_ID
   }
 
+  size_t getTotalSize() const
+  {
+    size_t total = 0;
+    #define ADD_TO_TOTAL_SIZE(kind, mSize) total += mSize;
+    FOR_EACH_SIZE(ADD_TO_TOTAL_SIZE)
+    #undef ADD_TO_TOTAL_SIZE
+    #define FRAME_ID(classname) \
+    total += FRAME_ID_STAT_FIELD(classname);
+    #include "nsFrameIdList.h"
+    #undef FRAME_ID
+    return total;
+  }
+
   #define DECL_SIZE(kind, mSize) size_t mSize;
   FOR_EACH_SIZE(DECL_SIZE)
   #undef DECL_SIZE
   #define FRAME_ID(classname) size_t FRAME_ID_STAT_FIELD(classname);
   #include "nsFrameIdList.h"
   #undef FRAME_ID
   int dummy;  // present just to absorb the trailing comma from FRAME_ID in the
               // constructor