From 6ca1704821be2754378306b7c8cdd2ad6b568f29 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Tue, 8 Apr 2014 10:36:30 -0400 Subject: [PATCH] Bug 682216 - add a memory reporter for libnestegg's memory; r=njn,kinetik --- layout/media/symbols.def.in | 1 + xpcom/build/nsXPComInit.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/layout/media/symbols.def.in b/layout/media/symbols.def.in index 85a5d95722c..d6754ce9e92 100644 --- a/layout/media/symbols.def.in +++ b/layout/media/symbols.def.in @@ -28,6 +28,7 @@ nestegg_track_video_params nestegg_tstamp_scale nestegg_has_cues nestegg_sniff +nestegg_set_halloc_func #endif #ifdef MOZ_WEBM_ENCODER writeSimpleBlock diff --git a/xpcom/build/nsXPComInit.cpp b/xpcom/build/nsXPComInit.cpp index cf6039b4528..8c7575c0d8c 100644 --- a/xpcom/build/nsXPComInit.cpp +++ b/xpcom/build/nsXPComInit.cpp @@ -137,6 +137,9 @@ extern nsresult nsStringInputStreamConstructor(nsISupports *, REFNSIID, void **) #ifdef MOZ_VPX #include "vpx_mem/vpx_mem.h" #endif +#ifdef MOZ_WEBM +#include "nestegg/nestegg.h" +#endif #include "GeckoProfiler.h" @@ -418,6 +421,28 @@ NS_IMPL_ISUPPORTS1(VPXReporter, nsIMemoryReporter) /* static */ template<> Atomic CountingAllocatorBase::sAmount(0); #endif /* MOZ_VPX */ +#ifdef MOZ_WEBM +class NesteggReporter MOZ_FINAL : public nsIMemoryReporter + , public CountingAllocatorBase +{ +public: + NS_DECL_ISUPPORTS + +private: + NS_IMETHODIMP + CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData) + { + return MOZ_COLLECT_REPORT( + "explicit/media/libnestegg", KIND_HEAP, UNITS_BYTES, MemoryAllocated(), + "Memory allocated through libnestegg for WebM media files."); + } +}; + +NS_IMPL_ISUPPORTS1(NesteggReporter, nsIMemoryReporter) + +/* static */ template<> Atomic CountingAllocatorBase::sAmount(0); +#endif /* MOZ_WEBM */ + EXPORT_XPCOM_API(nsresult) NS_InitXPCOM2(nsIServiceManager* *result, nsIFile* binDirectory, @@ -588,6 +613,11 @@ NS_InitXPCOM2(nsIServiceManager* *result, memmove); #endif +#ifdef MOZ_WEBM + // And for libnestegg. + nestegg_set_halloc_func(NesteggReporter::CountingRealloc); +#endif + // Initialize the JS engine. if (!JS_Init()) { NS_RUNTIMEABORT("JS_Init failed"); @@ -641,6 +671,9 @@ NS_InitXPCOM2(nsIServiceManager* *result, #ifdef MOZ_VPX RegisterStrongMemoryReporter(new VPXReporter()); #endif +#ifdef MOZ_WEBM + RegisterStrongMemoryReporter(new NesteggReporter()); +#endif mozilla::Telemetry::Init();