Backout 30bfb150da06 (bug 449315) due to unit test timeouts.
[wine-gecko.git] / xpcom / base / nsMemoryReporterManager.cpp
blob71be9834905f224c724b8885a8c27b84f10414f1
2 #include "nsCOMPtr.h"
3 #include "nsServiceManagerUtils.h"
4 #include "nsMemoryReporterManager.h"
6 #include "nsArrayEnumerator.h"
8 NS_IMPL_ISUPPORTS1(nsMemoryReporterManager, nsIMemoryReporterManager)
10 NS_IMETHODIMP
11 nsMemoryReporterManager::EnumerateReporters(nsISimpleEnumerator **result)
13 return NS_NewArrayEnumerator(result, mReporters);
16 NS_IMETHODIMP
17 nsMemoryReporterManager::RegisterReporter(nsIMemoryReporter *reporter)
19 if (mReporters.IndexOf(reporter) != -1)
20 return NS_ERROR_FAILURE;
22 mReporters.AppendObject(reporter);
23 return NS_OK;
26 NS_IMETHODIMP
27 nsMemoryReporterManager::UnregisterReporter(nsIMemoryReporter *reporter)
29 if (!mReporters.RemoveObject(reporter))
30 return NS_ERROR_FAILURE;
32 return NS_OK;
35 NS_COM nsresult
36 NS_RegisterMemoryReporter (nsIMemoryReporter *reporter)
38 nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
39 if (mgr == nsnull)
40 return NS_ERROR_FAILURE;
41 return mgr->RegisterReporter(reporter);
44 NS_COM nsresult
45 NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter)
47 nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
48 if (mgr == nsnull)
49 return NS_ERROR_FAILURE;
50 return mgr->UnregisterReporter(reporter);