b=392351, implement about:memory framework core, relading with forward-declaration victory; r=shaver,sr=bsdmedberg
This commit is contained in:
52
xpcom/base/nsMemoryReporterManager.cpp
Normal file
52
xpcom/base/nsMemoryReporterManager.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsMemoryReporterManager.h"
|
||||
|
||||
#include "nsArrayEnumerator.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMemoryReporterManager, nsIMemoryReporterManager)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryReporterManager::EnumerateReporters(nsISimpleEnumerator **result)
|
||||
{
|
||||
return NS_NewArrayEnumerator(result, mReporters);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryReporterManager::RegisterReporter(nsIMemoryReporter *reporter)
|
||||
{
|
||||
if (mReporters.IndexOf(reporter) != -1)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mReporters.AppendObject(reporter);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryReporterManager::UnregisterReporter(nsIMemoryReporter *reporter)
|
||||
{
|
||||
if (!mReporters.RemoveObject(reporter))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_RegisterMemoryReporter (nsIMemoryReporter *reporter)
|
||||
{
|
||||
nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
|
||||
if (mgr == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
return mgr->RegisterReporter(reporter);
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter)
|
||||
{
|
||||
nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
|
||||
if (mgr == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
return mgr->UnregisterReporter(reporter);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user