зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1194555 - Part 0: Cleanup GetReportsState constructor. r=njn
Move GetReportsState ctor to the impl so that mChildrenPending doesn't have to be heap allocated.
This commit is contained in:
Родитель
5342fc54c1
Коммит
dc17e5a1b8
|
@ -1438,7 +1438,6 @@ nsMemoryReporterManager::GetReportsExtended(
|
|||
aFinishReporting,
|
||||
aFinishReportingData,
|
||||
aDMDDumpIdent);
|
||||
mGetReportsState->mChildrenPending = new nsTArray<nsRefPtr<mozilla::dom::ContentParent>>();
|
||||
|
||||
if (aMinimize) {
|
||||
rv = MinimizeMemoryUsage(NS_NewRunnableMethod(
|
||||
|
@ -1479,7 +1478,7 @@ nsMemoryReporterManager::StartGettingReports()
|
|||
// to be buffered and consume (possibly scarce) memory.
|
||||
|
||||
for (size_t i = 0; i < childWeakRefs.Length(); ++i) {
|
||||
s->mChildrenPending->AppendElement(childWeakRefs[i]);
|
||||
s->mChildrenPending.AppendElement(childWeakRefs[i]);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
||||
|
@ -1676,29 +1675,29 @@ nsMemoryReporterManager::EndProcessReport(uint32_t aGeneration, bool aSuccess)
|
|||
aGeneration, s->mNumProcessesCompleted,
|
||||
aSuccess ? "completed" : "exited during report",
|
||||
s->mNumProcessesRunning,
|
||||
static_cast<unsigned>(s->mChildrenPending->Length()));
|
||||
static_cast<unsigned>(s->mChildrenPending.Length()));
|
||||
|
||||
// Start pending children up to the concurrency limit.
|
||||
while (s->mNumProcessesRunning < s->mConcurrencyLimit &&
|
||||
!s->mChildrenPending->IsEmpty()) {
|
||||
!s->mChildrenPending.IsEmpty()) {
|
||||
// Pop last element from s->mChildrenPending
|
||||
nsRefPtr<ContentParent> nextChild;
|
||||
nextChild.swap(s->mChildrenPending->LastElement());
|
||||
s->mChildrenPending->TruncateLength(s->mChildrenPending->Length() - 1);
|
||||
nextChild.swap(s->mChildrenPending.LastElement());
|
||||
s->mChildrenPending.TruncateLength(s->mChildrenPending.Length() - 1);
|
||||
// Start report (if the child is still alive and not Nuwa).
|
||||
if (StartChildReport(nextChild, s)) {
|
||||
++s->mNumProcessesRunning;
|
||||
MEMORY_REPORTING_LOG("HandleChildReports (aGen=%u): started child report"
|
||||
" (%u running, %u pending)\n",
|
||||
aGeneration, s->mNumProcessesRunning,
|
||||
static_cast<unsigned>(s->mChildrenPending->Length()));
|
||||
static_cast<unsigned>(s->mChildrenPending.Length()));
|
||||
}
|
||||
}
|
||||
|
||||
// If all the child processes (if any) have reported, we can cancel
|
||||
// the timer (if started) and finish up. Otherwise, just return.
|
||||
if (s->mNumProcessesRunning == 0) {
|
||||
MOZ_ASSERT(s->mChildrenPending->IsEmpty());
|
||||
MOZ_ASSERT(s->mChildrenPending.IsEmpty());
|
||||
if (s->mTimer) {
|
||||
s->mTimer->Cancel();
|
||||
}
|
||||
|
@ -1718,7 +1717,7 @@ nsMemoryReporterManager::TimeoutCallback(nsITimer* aTimer, void* aData)
|
|||
MOZ_RELEASE_ASSERT(s, "mgr->mGetReportsState");
|
||||
MEMORY_REPORTING_LOG("TimeoutCallback (s->gen=%u; %u running, %u pending)\n",
|
||||
s->mGeneration, s->mNumProcessesRunning,
|
||||
static_cast<unsigned>(s->mChildrenPending->Length()));
|
||||
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.
|
||||
|
@ -1749,9 +1748,27 @@ nsMemoryReporterManager::FinishReporting()
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsMemoryReporterManager::GetReportsState::~GetReportsState()
|
||||
nsMemoryReporterManager::GetReportsState::GetReportsState(
|
||||
uint32_t aGeneration, bool aAnonymize, bool aMinimize,
|
||||
uint32_t aConcurrencyLimit,
|
||||
nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aHandleReportData,
|
||||
nsIFinishReportingCallback* aFinishReporting,
|
||||
nsISupports* aFinishReportingData,
|
||||
const nsAString& aDMDDumpIdent)
|
||||
: mGeneration(aGeneration)
|
||||
, mAnonymize(aAnonymize)
|
||||
, mMinimize(aMinimize)
|
||||
, mChildrenPending()
|
||||
, mNumProcessesRunning(1) // reporting starts with the parent
|
||||
, mNumProcessesCompleted(0)
|
||||
, mConcurrencyLimit(aConcurrencyLimit)
|
||||
, mHandleReport(aHandleReport)
|
||||
, mHandleReportData(aHandleReportData)
|
||||
, mFinishReporting(aFinishReporting)
|
||||
, mFinishReportingData(aFinishReportingData)
|
||||
, mDMDDumpIdent(aDMDDumpIdent)
|
||||
{
|
||||
delete mChildrenPending;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -211,10 +211,7 @@ private:
|
|||
bool mAnonymize;
|
||||
bool mMinimize;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
// This is a pointer to an nsTArray because otherwise C++ is
|
||||
// unhappy unless this header includes ContentParent.h, which not
|
||||
// everything that includes this header knows how to find.
|
||||
nsTArray<nsRefPtr<mozilla::dom::ContentParent>>* mChildrenPending;
|
||||
nsTArray<nsRefPtr<mozilla::dom::ContentParent>> mChildrenPending;
|
||||
uint32_t mNumProcessesRunning;
|
||||
uint32_t mNumProcessesCompleted;
|
||||
uint32_t mConcurrencyLimit;
|
||||
|
@ -230,23 +227,7 @@ private:
|
|||
nsISupports* aHandleReportData,
|
||||
nsIFinishReportingCallback* aFinishReporting,
|
||||
nsISupports* aFinishReportingData,
|
||||
const nsAString& aDMDDumpIdent)
|
||||
: mGeneration(aGeneration)
|
||||
, mAnonymize(aAnonymize)
|
||||
, mMinimize(aMinimize)
|
||||
, mChildrenPending(nullptr)
|
||||
, mNumProcessesRunning(1) // reporting starts with the parent
|
||||
, mNumProcessesCompleted(0)
|
||||
, mConcurrencyLimit(aConcurrencyLimit)
|
||||
, mHandleReport(aHandleReport)
|
||||
, mHandleReportData(aHandleReportData)
|
||||
, mFinishReporting(aFinishReporting)
|
||||
, mFinishReportingData(aFinishReportingData)
|
||||
, mDMDDumpIdent(aDMDDumpIdent)
|
||||
{
|
||||
}
|
||||
|
||||
~GetReportsState();
|
||||
const nsAString& aDMDDumpIdent);
|
||||
};
|
||||
|
||||
// When this is non-null, a request is in flight. Note: We use manual
|
||||
|
|
Загрузка…
Ссылка в новой задаче