Bug 682216 - add a memory reporter for libnestegg's memory; r=njn,kinetik

This commit is contained in:
Nathan Froyd 2014-04-08 10:36:30 -04:00
parent f8eb10577d
commit 39705c09f6
2 changed files with 34 additions and 0 deletions

View File

@ -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

View File

@ -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<size_t> CountingAllocatorBase<VPXReporter>::sAmount(0);
#endif /* MOZ_VPX */
#ifdef MOZ_WEBM
class NesteggReporter MOZ_FINAL : public nsIMemoryReporter
, public CountingAllocatorBase<NesteggReporter>
{
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<size_t> CountingAllocatorBase<NesteggReporter>::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();