Bug 1375281 - Part 1: Add getHeapAllocatedAsync() to nsIMemoryReporter.idl. r=erahm
authorCervantes Yu <cyu@mozilla.com>
Thu, 06 Jul 2017 11:19:32 +0800
changeset 367557 800cae1681846f50fa6dc51baf218d17c1422975
parent 367556 fc07a79051918f888c67f456f85da6b1c55ef103
child 367558 5f92b3b576253070f7c8df5410a9f3f58b2028c3
push id32137
push usercbook@mozilla.com
push dateThu, 06 Jul 2017 09:18:21 +0000
treeherdermozilla-central@018b3829d0a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1375281
milestone56.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 1375281 - Part 1: Add getHeapAllocatedAsync() to nsIMemoryReporter.idl. r=erahm nsIMemoryReporter::getHeapAllocatedAsync() is added to get attribute 'heapAllocated' asynchronously. MozReview-Commit-ID: 96KyZpCeTG1
xpcom/base/nsIMemoryReporter.idl
xpcom/base/nsMemoryReporterManager.cpp
--- a/xpcom/base/nsIMemoryReporter.idl
+++ b/xpcom/base/nsIMemoryReporter.idl
@@ -200,16 +200,22 @@ interface nsIMemoryReporter : nsISupport
 };
 
 [scriptable, function, uuid(548b3909-c04d-4ca6-8466-b8bee3837457)]
 interface nsIFinishReportingCallback : nsISupports
 {
   void callback(in nsISupports data);
 };
 
+[scriptable, function, uuid(1a80cd0f-0d9e-4397-be69-68ad28fe5175)]
+interface nsIHeapAllocatedCallback : nsISupports
+{
+  void callback(in int64_t bytesAllocated);
+};
+
 [scriptable, builtinclass, uuid(2998574d-8993-407a-b1a5-8ad7417653e1)]
 interface nsIMemoryReporterManager : nsISupports
 {
   /*
    * Initialize.
    */
   [must_use] void init();
 
@@ -407,16 +413,22 @@ interface nsIMemoryReporterManager : nsI
   /*
    * These attributes indicate DMD's status. "Enabled" means enabled at
    * build-time.
    */
   [infallible] readonly attribute boolean isDMDEnabled;
   [infallible] readonly attribute boolean isDMDRunning;
 
   /*
+   * Asynchronously gets attribute 'heapAllocated'. The value is returned in
+   * the callback argument.
+   */
+  [must_use] void getHeapAllocatedAsync(in nsIHeapAllocatedCallback callback);
+
+  /*
    * Run a series of GC/CC's in an attempt to minimize the application's memory
    * usage.  When we're finished, we invoke the given runnable if it's not
    * null.
    */
   [must_use] void minimizeMemoryUsage(in nsIRunnable callback);
 
   /*
    * Measure the memory that is known to be owned by this tab, split up into
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -2368,16 +2368,22 @@ nsMemoryReporterManager::GetHeapAllocate
   *aAmount = stats.allocated;
   return NS_OK;
 #else
   *aAmount = 0;
   return NS_ERROR_NOT_AVAILABLE;
 #endif
 }
 
+NS_IMETHODIMP
+nsMemoryReporterManager::GetHeapAllocatedAsync(nsIHeapAllocatedCallback *aCallback)
+{
+  return NS_ERROR_NOT_AVAILABLE;
+}
+
 // This has UNITS_PERCENTAGE, so it is multiplied by 100x.
 NS_IMETHODIMP
 nsMemoryReporterManager::GetHeapOverheadFraction(int64_t* aAmount)
 {
 #ifdef HAVE_JEMALLOC_STATS
   jemalloc_stats_t stats;
   jemalloc_stats(&stats);
   *aAmount = HeapOverheadFraction(&stats);