Bug 1505522: Follow-up: Resolve gatherMemory() promise in release builds. r=me

--HG--
extra : amend_source : 71b9da131b80c5e269cd3c459306939bcada185a
This commit is contained in:
Kris Maglione 2018-12-12 11:35:13 -08:00
Родитель 77c4b9ea02
Коммит 7cbe858c62
1 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -13,6 +13,7 @@
#include "mozilla/Result.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/Services.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/SimpleEnumerator.h"
#include "mozilla/SystemGroup.h"
#include "mozilla/Telemetry.h"
@ -228,6 +229,12 @@ static inline void HandleMemoryReport(Telemetry::HistogramID aId,
nsresult MemoryTelemetry::GatherReports(
const std::function<void()>& aCompletionCallback) {
auto cleanup = MakeScopeExit([&]() {
if (aCompletionCallback) {
aCompletionCallback();
}
});
RefPtr<nsMemoryReporterManager> mgr = nsMemoryReporterManager::GetOrCreate();
MOZ_DIAGNOSTIC_ASSERT(mgr);
NS_ENSURE_TRUE(mgr, NS_ERROR_FAILURE);
@ -315,7 +322,9 @@ nsresult MemoryTelemetry::GatherReports(
#undef RECORD
nsresult rv = mThreadPool->Dispatch(runnable.forget(), NS_DISPATCH_NORMAL);
Unused << NS_WARN_IF(NS_FAILED(rv));
if (!NS_WARN_IF(NS_FAILED(rv))) {
cleanup.release();
}
// If we're running in the parent process, collect data from all processes for
// the MEMORY_TOTAL histogram.