Bug 1805996 - Implement scaffolding for a memory reporter in FOG r=chutten

This is a minimal implementation, which does not measure any of the
Glean-internal/metric memory usage yet.

Differential Revision: https://phabricator.services.mozilla.com/D207137
This commit is contained in:
Jan-Erik Rediger 2024-05-22 14:59:18 +00:00
Родитель a44891c523
Коммит fa26b4418b
2 изменённых файлов: 23 добавлений и 1 удалений

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

@ -65,6 +65,7 @@ already_AddRefed<FOG> FOG::GetSingleton() {
MOZ_LOG(sLog, LogLevel::Debug, ("FOG::GetSingleton()"));
gFOG = new FOG();
gFOG->InitMemoryReporter();
if (XRE_IsParentProcess()) {
nsresult rv;
@ -106,6 +107,8 @@ already_AddRefed<FOG> FOG::GetSingleton() {
void FOG::Shutdown() {
MOZ_ASSERT(XRE_IsParentProcess());
UnregisterWeakMemoryReporter(this);
glean::impl::fog_shutdown();
}
@ -421,6 +424,22 @@ FOG::TestRegisterRuntimePing(
return NS_OK;
}
void FOG::InitMemoryReporter() { RegisterWeakMemoryReporter(this); }
MOZ_DEFINE_MALLOC_SIZE_OF(FOGMallocSizeOf)
NS_IMETHODIMP
FOG::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
bool aAnonymize) {
mozilla::MallocSizeOf aMallocSizeOf = FOGMallocSizeOf;
MOZ_COLLECT_REPORT("explicit/fog/impl", KIND_HEAP, UNITS_BYTES,
aMallocSizeOf(this),
"Memory used by the FOG core implementation");
return NS_OK;
}
NS_IMPL_ISUPPORTS(FOG, nsIFOG, nsIObserver)
} // namespace mozilla

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

@ -8,16 +8,19 @@
#include "nsIFOG.h"
#include "nsIObserver.h"
#include "nsIMemoryReporter.h"
namespace mozilla {
class FOG final : public nsIFOG, public nsIObserver {
class FOG final : public nsIFOG, public nsIObserver, public nsIMemoryReporter {
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIFOG
NS_DECL_NSIOBSERVER
NS_DECL_NSIMEMORYREPORTER
public:
FOG() = default;
static already_AddRefed<FOG> GetSingleton();
void InitMemoryReporter();
private:
~FOG() = default;