Bug 1194555 - Part 4: Rename GetReportsState PendingProcessesState. r=njn
authorEric Rahm <erahm@mozilla.com>
Wed, 14 Oct 2015 16:52:57 -0700
changeset 301184 c3a95dcbc56b273686e9d613cbf907afb600b96d
parent 301183 c08f47894887fc3d6777842d041f4cc176f234a6
child 301185 8db37a722f8326f39042dd2f38d0814fc20ad552
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1194555
milestone44.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 1194555 - Part 4: Rename GetReportsState PendingProcessesState. r=njn
xpcom/base/nsMemoryReporterManager.cpp
xpcom/base/nsMemoryReporterManager.h
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -1351,17 +1351,17 @@ nsMemoryReporterManager::Init()
 nsMemoryReporterManager::nsMemoryReporterManager()
   : mMutex("nsMemoryReporterManager::mMutex")
   , mIsRegistrationBlocked(false)
   , mStrongReporters(new StrongReportersTable())
   , mWeakReporters(new WeakReportersTable())
   , mSavedStrongReporters(nullptr)
   , mSavedWeakReporters(nullptr)
   , mNextGeneration(1)
-  , mGetReportsState(nullptr)
+  , mPendingProcessesState(nullptr)
 {
 }
 
 nsMemoryReporterManager::~nsMemoryReporterManager()
 {
   delete mStrongReporters;
   delete mWeakReporters;
   NS_ASSERTION(!mSavedStrongReporters, "failed to restore strong reporters");
@@ -1409,54 +1409,54 @@ nsMemoryReporterManager::GetReportsExten
   // Memory reporters are not necessarily threadsafe, so this function must
   // be called from the main thread.
   if (!NS_IsMainThread()) {
     MOZ_CRASH();
   }
 
   uint32_t generation = mNextGeneration++;
 
-  if (mGetReportsState) {
+  if (mPendingProcessesState) {
     // A request is in flight.  Don't start another one.  And don't report
     // an error;  just ignore it, and let the in-flight request finish.
     MEMORY_REPORTING_LOG("GetReports (gen=%u, s->gen=%u): abort\n",
-                         generation, mGetReportsState->mGeneration);
+                         generation, mPendingProcessesState->mGeneration);
     return NS_OK;
   }
 
   MEMORY_REPORTING_LOG("GetReports (gen=%u)\n", generation);
 
   uint32_t concurrency = Preferences::GetUint("memory.report_concurrency", 1);
   MOZ_ASSERT(concurrency >= 1);
   if (concurrency < 1) {
     concurrency = 1;
   }
-  mGetReportsState = new GetReportsState(generation,
-                                         aAnonymize,
-                                         aMinimize,
-                                         concurrency,
-                                         aHandleReport,
-                                         aHandleReportData,
-                                         aFinishReporting,
-                                         aFinishReportingData,
-                                         aDMDDumpIdent);
+  mPendingProcessesState = new PendingProcessesState(generation,
+                                                     aAnonymize,
+                                                     aMinimize,
+                                                     concurrency,
+                                                     aHandleReport,
+                                                     aHandleReportData,
+                                                     aFinishReporting,
+                                                     aFinishReportingData,
+                                                     aDMDDumpIdent);
 
   if (aMinimize) {
     rv = MinimizeMemoryUsage(NS_NewRunnableMethod(
       this, &nsMemoryReporterManager::StartGettingReports));
   } else {
     rv = StartGettingReports();
   }
   return rv;
 }
 
 nsresult
 nsMemoryReporterManager::StartGettingReports()
 {
-  GetReportsState* s = mGetReportsState;
+  PendingProcessesState* s = mPendingProcessesState;
   nsresult rv;
 
   // Get reports for this process.
   FILE* parentDMDFile = nullptr;
 #ifdef MOZ_DMD
   if (!s->mDMDDumpIdent.IsEmpty()) {
     rv = nsMemoryInfoDumper::OpenDMDFile(s->mDMDDumpIdent, getpid(),
                                                   &parentDMDFile);
@@ -1547,23 +1547,23 @@ nsMemoryReporterManager::GetReportsForTh
   if (aDMDFile) {
     return nsMemoryInfoDumper::DumpDMDToFile(aDMDFile);
   }
 #endif
 
   return NS_OK;
 }
 
-nsMemoryReporterManager::GetReportsState*
+nsMemoryReporterManager::PendingProcessesState*
 nsMemoryReporterManager::GetStateForGeneration(uint32_t aGeneration)
 {
   // Memory reporting only happens on the main thread.
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
-  GetReportsState* s = mGetReportsState;
+  PendingProcessesState* s = mPendingProcessesState;
 
   if (!s) {
     // If we reach here, then:
     //
     // - A child process reported back too late, and no subsequent request
     //   is in flight.
     //
     // So there's nothing to be done.  Just ignore it.
@@ -1590,17 +1590,17 @@ nsMemoryReporterManager::GetStateForGene
 // This function has no return value.  If something goes wrong, there's no
 // clear place to report the problem to, but that's ok -- we will end up
 // hitting the timeout and executing TimeoutCallback().
 void
 nsMemoryReporterManager::HandleChildReport(
   uint32_t aGeneration,
   const dom::MemoryReport& aChildReport)
 {
-  GetReportsState* s = GetStateForGeneration(aGeneration);
+  PendingProcessesState* s = GetStateForGeneration(aGeneration);
   if (!s) {
     return;
   }
 
   // Child reports should have a non-empty process.
   MOZ_ASSERT(!aChildReport.process().IsEmpty());
 
   // If the call fails, ignore and continue.
@@ -1610,17 +1610,17 @@ nsMemoryReporterManager::HandleChildRepo
                              aChildReport.units(),
                              aChildReport.amount(),
                              aChildReport.desc(),
                              s->mHandleReportData);
 }
 
 /* static */ bool
 nsMemoryReporterManager::StartChildReport(mozilla::dom::ContentParent* aChild,
-                                          const GetReportsState* aState)
+                                          const PendingProcessesState* aState)
 {
 #ifdef MOZ_NUWA_PROCESS
   if (aChild->IsNuwaProcess()) {
     return false;
   }
 #endif
 
   if (!aChild->IsAlive()) {
@@ -1648,17 +1648,17 @@ nsMemoryReporterManager::StartChildRepor
 #endif
   return aChild->SendPMemoryReportRequestConstructor(
     aState->mGeneration, aState->mAnonymize, aState->mMinimize, dmdFileDesc);
 }
 
 void
 nsMemoryReporterManager::EndProcessReport(uint32_t aGeneration, bool aSuccess)
 {
-  GetReportsState* s = GetStateForGeneration(aGeneration);
+  PendingProcessesState* s = GetStateForGeneration(aGeneration);
   if (!s) {
     return;
   }
 
   MOZ_ASSERT(s->mNumProcessesRunning > 0);
   s->mNumProcessesRunning--;
   s->mNumProcessesCompleted++;
   MEMORY_REPORTING_LOG("HandleChildReports (aGen=%u): process %u %s"
@@ -1695,22 +1695,22 @@ nsMemoryReporterManager::EndProcessRepor
     FinishReporting();
   }
 }
 
 /* static */ void
 nsMemoryReporterManager::TimeoutCallback(nsITimer* aTimer, void* aData)
 {
   nsMemoryReporterManager* mgr = static_cast<nsMemoryReporterManager*>(aData);
-  GetReportsState* s = mgr->mGetReportsState;
+  PendingProcessesState* s = mgr->mPendingProcessesState;
 
   // Release assert because: if the pointer is null we're about to
   // crash regardless of DEBUG, and this way the compiler doesn't
   // complain about unused variables.
-  MOZ_RELEASE_ASSERT(s, "mgr->mGetReportsState");
+  MOZ_RELEASE_ASSERT(s, "mgr->mPendingProcessesState");
   MEMORY_REPORTING_LOG("TimeoutCallback (s->gen=%u; %u running, %u pending)\n",
                        s->mGeneration, s->mNumProcessesRunning,
                        static_cast<unsigned>(s->mChildrenPending.Length()));
 
   // We don't bother sending any kind of cancellation message to the child
   // processes that haven't reported back.
   mgr->FinishReporting();
 }
@@ -1718,33 +1718,33 @@ nsMemoryReporterManager::TimeoutCallback
 nsresult
 nsMemoryReporterManager::FinishReporting()
 {
   // Memory reporting only happens on the main thread.
   if (!NS_IsMainThread()) {
     MOZ_CRASH();
   }
 
-  MOZ_ASSERT(mGetReportsState);
+  MOZ_ASSERT(mPendingProcessesState);
   MEMORY_REPORTING_LOG("FinishReporting (s->gen=%u; %u processes reported)\n",
-                       mGetReportsState->mGeneration,
-                       mGetReportsState->mNumProcessesCompleted);
+                       mPendingProcessesState->mGeneration,
+                       mPendingProcessesState->mNumProcessesCompleted);
 
-  // Call this before deleting |mGetReportsState|.  That way, if
+  // Call this before deleting |mPendingProcessesState|.  That way, if
   // |mFinishReportData| calls GetReports(), it will silently abort, as
   // required.
-  nsresult rv = mGetReportsState->mFinishReporting->Callback(
-    mGetReportsState->mFinishReportingData);
+  nsresult rv = mPendingProcessesState->mFinishReporting->Callback(
+    mPendingProcessesState->mFinishReportingData);
 
-  delete mGetReportsState;
-  mGetReportsState = nullptr;
+  delete mPendingProcessesState;
+  mPendingProcessesState = nullptr;
   return rv;
 }
 
-nsMemoryReporterManager::GetReportsState::GetReportsState(
+nsMemoryReporterManager::PendingProcessesState::PendingProcessesState(
     uint32_t aGeneration, bool aAnonymize, bool aMinimize,
     uint32_t aConcurrencyLimit,
     nsIHandleReportCallback* aHandleReport,
     nsISupports* aHandleReportData,
     nsIFinishReportingCallback* aFinishReporting,
     nsISupports* aFinishReportingData,
     const nsAString& aDMDDumpIdent)
   : mGeneration(aGeneration)
--- a/xpcom/base/nsMemoryReporterManager.h
+++ b/xpcom/base/nsMemoryReporterManager.h
@@ -43,17 +43,17 @@ public:
 
   typedef nsTHashtable<nsRefPtrHashKey<nsIMemoryReporter>> StrongReportersTable;
   typedef nsTHashtable<nsPtrHashKey<nsIMemoryReporter>> WeakReportersTable;
 
   // Inter-process memory reporting proceeds as follows.
   //
   // - GetReports() (declared within NS_DECL_NSIMEMORYREPORTERMANAGER)
   //   synchronously gets memory reports for the current process, sets up some
-  //   state (mGetReportsState) for when child processes report back --
+  //   state (mPendingProcessesState) for when child processes report back --
   //   including a timer -- and starts telling child processes to get memory
   //   reports.  Control then returns to the main event loop.
   //
   //   The number of concurrent child process reports is limited by the pref
   //   "memory.report_concurrency" in order to prevent the memory overhead of
   //   memory reporting from causing problems, especially on B2G when swapping
   //   to compressed RAM; see bug 1154053.
   //
@@ -103,17 +103,17 @@ public:
   //   this late stage.
   //
   // - If the time-out occurs after a child process has sent some reports but
   //   before it has signaled completion (see bug 1151597), then what it
   //   successfully sent will be included, with no explicit indication that it
   //   is incomplete.
   //
   // Now, what what happens if a child process is created/destroyed in the
-  // middle of a request?  Well, GetReportsState is initialized with an array
+  // middle of a request?  Well, PendingProcessesState is initialized with an array
   // of child process actors as of when the report started.  So...
   //
   // - If a process is created after reporting starts, it won't be sent a
   //   request for reports.  So the reported data will reflect how things were
   //   when the request began.
   //
   // - If a process is destroyed before it starts reporting back, the reported
   //   data will reflect how things are when the request ends.
@@ -200,48 +200,48 @@ private:
   WeakReportersTable* mWeakReporters;
 
   // These two are only used for testing purposes.
   StrongReportersTable* mSavedStrongReporters;
   WeakReportersTable* mSavedWeakReporters;
 
   uint32_t mNextGeneration;
 
-  struct GetReportsState
+  struct PendingProcessesState
   {
     uint32_t                             mGeneration;
     bool                                 mAnonymize;
     bool                                 mMinimize;
     nsCOMPtr<nsITimer>                   mTimer;
     nsTArray<nsRefPtr<mozilla::dom::ContentParent>> mChildrenPending;
     uint32_t                             mNumProcessesRunning;
     uint32_t                             mNumProcessesCompleted;
     uint32_t                             mConcurrencyLimit;
     nsCOMPtr<nsIHandleReportCallback>    mHandleReport;
     nsCOMPtr<nsISupports>                mHandleReportData;
     nsCOMPtr<nsIFinishReportingCallback> mFinishReporting;
     nsCOMPtr<nsISupports>                mFinishReportingData;
     nsString                             mDMDDumpIdent;
 
-    GetReportsState(uint32_t aGeneration, bool aAnonymize, bool aMinimize,
-                    uint32_t aConcurrencyLimit,
-                    nsIHandleReportCallback* aHandleReport,
-                    nsISupports* aHandleReportData,
-                    nsIFinishReportingCallback* aFinishReporting,
-                    nsISupports* aFinishReportingData,
-                    const nsAString& aDMDDumpIdent);
+    PendingProcessesState(uint32_t aGeneration, bool aAnonymize, bool aMinimize,
+                          uint32_t aConcurrencyLimit,
+                          nsIHandleReportCallback* aHandleReport,
+                          nsISupports* aHandleReportData,
+                          nsIFinishReportingCallback* aFinishReporting,
+                          nsISupports* aFinishReportingData,
+                          const nsAString& aDMDDumpIdent);
   };
 
   // When this is non-null, a request is in flight.  Note: We use manual
   // new/delete for this because its lifetime doesn't match block scope or
   // anything like that.
-  GetReportsState* mGetReportsState;
+  PendingProcessesState* mPendingProcessesState;
 
-  GetReportsState* GetStateForGeneration(uint32_t aGeneration);
+  PendingProcessesState* GetStateForGeneration(uint32_t aGeneration);
   static bool StartChildReport(mozilla::dom::ContentParent* aChild,
-                               const GetReportsState* aState);
+                               const PendingProcessesState* aState);
 };
 
 #define NS_MEMORY_REPORTER_MANAGER_CID \
 { 0xfb97e4f5, 0x32dd, 0x497a, \
 { 0xba, 0xa2, 0x7d, 0x1e, 0x55, 0x7, 0x99, 0x10 } }
 
 #endif // nsMemoryReporterManager_h__