1 /* -*- Mode: C++; tab-width: 50; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2008
20 * the Initial Developer. All Rights Reserved.
23 * Vladimir Vukicevic <vladimir@pobox.com> (original author)
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include
"nsISupports.idl"
41 interface nsISimpleEnumerator
;
43 [scriptable
, uuid(d298b942
-3e66
-4cd3
-9ff5
-46abc69147a7
)]
44 interface nsIMemoryReporter
: nsISupports
47 * The path that this memory usage should be reported under.
49 * Normally "/"-delimited for organization.
51 readonly attribute
string path
;
54 * A human-readable description of this memory usage report
56 readonly attribute
string description
;
59 * The current amount of memory in use, as reported by this memory
62 readonly attribute
long long memoryUsed
;
65 [scriptable
, uuid(7c62de18
-1edd
-40f8
-9da2
-a8c622763074
)]
66 interface nsIMemoryReporterManager
: nsISupports
69 * Return an enumerator of nsIMemoryReporters that are currently registered.
71 nsISimpleEnumerator enumerateReporters
();
74 * Register the given nsIMemoryReporter. It is an error to register
75 * more than one reporter with the same path. After a reporter is
76 * registered, it will be available via enumerateReporters(). The
77 * Manager service will hold a strong reference to the given reporter.
79 void registerReporter
(in nsIMemoryReporter reporter
);
82 * Unregister the given memory reporter.
84 void unregisterReporter
(in nsIMemoryReporter reporter
);
94 #define NS_MEMORY_REPORTER_IMPLEMENT
(_classname
,_path
,_desc
,_usageFunction
,_dataptr
) \
95 class MemoryReporter_##_classname
: public nsIMemoryReporter
{ \
98 NS_IMETHOD GetPath
(char **memoryPath
) { *memoryPath
= strdup
(_path
); return NS_OK
; } \
99 NS_IMETHOD GetDescription
(char **desc
) { *desc
= strdup
(_desc
); return NS_OK
; } \
100 NS_IMETHOD GetMemoryUsed
(PRInt64
*memoryUsed
) { *memoryUsed
= _usageFunction
(_dataptr
); return NS_OK
; } \
102 NS_IMPL_ISUPPORTS1
(MemoryReporter_##_classname
, nsIMemoryReporter
)
104 #define NS_MEMORY_REPORTER_NAME
(_classname
) MemoryReporter_##_classname
106 NS_COM nsresult NS_RegisterMemoryReporter
(nsIMemoryReporter
*reporter
);
107 NS_COM nsresult NS_UnregisterMemoryReporter
(nsIMemoryReporter
*reporter
);