VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/glue/nsTraceRefcnt.cpp@ 26286

Last change on this file since 26286 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is XPCOM
15 *
16 * The Initial Developer of the Original Code is Doug Turner <dougt@meer.net>
17 *
18 * Portions created by the Initial Developer are Copyright (C) 2003
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 *
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
34 *
35 * ***** END LICENSE BLOCK ***** */
36
37#include "nsXPCOM.h"
38#include "nsXPCOMPrivate.h"
39#include "nsCOMPtr.h"
40#include "nsIServiceManager.h"
41#include "nsTraceRefcnt.h"
42#include "nsTraceRefcntImpl.h"
43
44static nsITraceRefcnt* gTraceRefcntObject = nsnull;
45
46static NS_METHOD FreeTraceRefcntObject(void)
47{
48 NS_IF_RELEASE(gTraceRefcntObject);
49 return NS_OK;
50}
51
52#define ENSURE_TRACEOBJECT \
53 (gTraceRefcntObject || SetupTraceRefcntObject() != nsnull)
54
55static nsITraceRefcnt* SetupTraceRefcntObject()
56{
57 NS_GetTraceRefcnt(&gTraceRefcntObject);
58 if (gTraceRefcntObject)
59 NS_RegisterXPCOMExitRoutine(FreeTraceRefcntObject, 0);
60 return gTraceRefcntObject;
61}
62
63#ifdef XPCOM_GLUE
64nsresult GlueStartupTraceRefcnt()
65{
66 NS_GetTraceRefcnt(&gTraceRefcntObject);
67 if (!gTraceRefcntObject)
68 return NS_ERROR_FAILURE;
69 return NS_OK;
70}
71
72void GlueShutdownTraceRefcnt()
73{
74 NS_IF_RELEASE(gTraceRefcntObject);
75}
76#endif
77
78NS_COM void
79nsTraceRefcnt::LogAddRef(void * aPtr, nsrefcnt aNewRefcnt, const char *aTypeName, PRUint32 aInstanceSize)
80{
81 if (!ENSURE_TRACEOBJECT)
82 return;
83 gTraceRefcntObject->LogAddRef(aPtr, aNewRefcnt, aTypeName, aInstanceSize);
84}
85
86NS_COM void
87nsTraceRefcnt::LogRelease(void * aPtr, nsrefcnt aNewRefcnt, const char *aTypeName)
88{
89 if (!ENSURE_TRACEOBJECT)
90 return;
91 gTraceRefcntObject->LogRelease(aPtr, aNewRefcnt, aTypeName);
92}
93
94NS_COM void
95nsTraceRefcnt::LogCtor(void * aPtr, const char *aTypeName, PRUint32 aInstanceSize)
96{
97 if (!ENSURE_TRACEOBJECT)
98 return;
99 gTraceRefcntObject->LogCtor(aPtr, aTypeName, aInstanceSize);
100}
101
102NS_COM void
103nsTraceRefcnt::LogDtor(void * aPtr, const char *aTypeName, PRUint32 aInstanceSize)
104{
105 if (!ENSURE_TRACEOBJECT)
106 return;
107 gTraceRefcntObject->LogDtor(aPtr, aTypeName, aInstanceSize);
108}
109
110NS_COM void
111nsTraceRefcnt::LogAddCOMPtr(void * aPtr, nsISupports *aObject)
112{
113 if (!ENSURE_TRACEOBJECT)
114 return;
115 gTraceRefcntObject->LogAddCOMPtr(aPtr, aObject);
116}
117
118NS_COM void
119nsTraceRefcnt::LogReleaseCOMPtr(void * aPtr, nsISupports *aObject)
120{
121 if (!ENSURE_TRACEOBJECT)
122 return;
123 gTraceRefcntObject->LogReleaseCOMPtr(aPtr, aObject);
124}
125
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette