VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/build/nsXPCOM.h@ 109281

Last change on this file since 109281 was 109067, checked in by vboxsync, 4 weeks ago

libs/xpcom,Main/glue,++: Bake the automatic re-registration of XPCOM components (in the components directory) into the NS_InitXPCOM2 call to avoid the problem of VBoxXPCOMIPCC.so/dylib being engaged at the end of NS_InitXPCOM2 and unable to re-register if this is done later by the client code. Added a fFlagsInit parameter to indicate whether this auto reg behaviour is required or not and renamed NS_InitXPCOM2 to NS_InitXPCOM2Ex (the latter to prevent confusion). bugref:10896 ticketref:22193

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
Line 
1/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
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/
9 *
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
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#ifndef nsXPCOM_h__
39#define nsXPCOM_h__
40
41#include "nscore.h"
42#include "nsXPCOMCID.h"
43
44#ifdef VBOX
45# include <iprt/thread.h>
46#endif
47
48#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
49#define NS_IsXPCOMInitialized VBoxNsxpNS_IsXPCOMInitialized
50#define NS_InitXPCOM2Ex VBoxNsxpNS_InitXPCOM2Ex
51#define NS_ShutdownXPCOM VBoxNsxpNS_ShutdownXPCOM
52#define NS_NewNativeLocalFile VBoxNsxpNS_NewNativeLocalFile
53#define NS_GetServiceManager VBoxNsxpNS_GetServiceManager
54#define NS_GetComponentManager VBoxNsxpNS_GetComponentManager
55#define NS_GetComponentRegistrar VBoxNsxpNS_GetComponentRegistrar
56#define NS_GetDebug VBoxNsxpNS_GetDebug
57#define NS_GetMemoryManager VBoxNsxpNS_GetMemoryManager
58#define NS_GetTraceRefcnt VBoxNsxpNS_GetTraceRefcnt
59#define NS_NewLocalFile VBoxNsxpNS_NewLocalFile
60#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
61
62class nsAString;
63class nsACString;
64
65class nsIComponentManager;
66class nsIComponentRegistrar;
67class nsIServiceManager;
68class nsIFile;
69class nsILocalFile;
70class nsIDirectoryServiceProvider;
71class nsIDebug;
72class nsITraceRefcnt;
73
74#ifdef VBOX
75typedef RTTHREADINT *RTTHREAD;
76
77/**
78 * Checks whether XPCOM was initialized by a call to NS_InitXPCOM2Ex().
79 */
80extern "C" NS_COM PRBool
81NS_IsXPCOMInitialized(void);
82
83extern "C" NS_COM nsresult
84NS_GetMainThread(RTTHREAD *phThreadMain);
85#endif
86
87/**
88 * Initialises XPCOM. You must call this method before proceeding
89 * to use xpcom. The one exception is that you may call
90 * NS_NewLocalFile to create a nsIFile.
91 *
92 * @status FROZEN
93 *
94 * @note Use <CODE>NS_NewLocalFile</CODE> or <CODE>NS_NewNativeLocalFile</CODE>
95 * to create the file object you supply as the bin directory path in this
96 * call. The function may be safely called before the rest of XPCOM or
97 * embedding has been initialised.
98 *
99 * @param result The service manager. You may pass null.
100 *
101 * @param binDirectory The directory containing the component
102 * registry and runtime libraries;
103 * or use <CODE>nsnull</CODE> to use the working
104 * directory.
105 *
106 * @param appFileLocationProvider The object to be used by Gecko that specifies
107 * to Gecko where to find profiles, the component
108 * registry preferences and so on; or use
109 * <CODE>nsnull</CODE> for the default behaviour.
110 *
111 * @param fInitFlags NS_INIT_XPCOM_F_XXX values ORed together or zero.
112 * This was added during @bugref{10896} to workaround
113 * the problem that the IPC client component was already
114 * in use by the time NS_InitXPCOM2Ex returns and thus
115 * cannot be auto-re-registered by the client.
116 * (The actual need to trigger auto-reregistration of
117 * components is questionable, though, as it ought only
118 * to be needed after installing a new version,
119 * but we've always done it as part of our COM init glue
120 * code (see Main/glue/initterm.cpp).)
121 *
122 * @see NS_NewLocalFile
123 * @see nsILocalFile
124 * @see nsIDirectoryServiceProvider
125 *
126 * @return NS_OK for success;
127 * NS_ERROR_NOT_INITIALIZED if static globals were not initialied, which
128 * can happen if XPCOM is reloaded, but did not completly shutdown.
129 * other error codes indicate a failure during initialisation.
130 *
131 */
132extern "C" NS_COM nsresult
133NS_InitXPCOM2Ex(nsIServiceManager* *result,
134 nsIFile* binDirectory,
135 nsIDirectoryServiceProvider* appFileLocationProvider,
136 PRUint32 fFlags);
137
138/** @name NS_INIT_XPCOM_F_XXX - Flags for NS_InitXPCOM2Ex.
139 * @{ */
140/** Auto-register components. */
141#define NS_INIT_XPCOM_F_AUTO_REGISTER_COMPONENTS 1
142/** Auto-register components and return any failure status.
143 * @note When using this, always call NS_ShutdownXPCOM(nsnull) on failure
144 * (generally a good idea). */
145#define NS_INIT_XPCOM_F_AUTO_REGISTER_COMPONENTS_WITH_STATUS 2
146/** @} */
147
148/**
149 * Shutdown XPCOM. You must call this method after you are finished
150 * using xpcom.
151 *
152 * @status FROZEN
153 *
154 * @param servMgr The service manager which was returned by
155 * NS_InitXPCOM2Ex. This will release servMgr.
156 * You may pass null.
157 *
158 * @return NS_OK for success;
159 * other error codes indicate a failure during initialisation.
160 *
161 */
162extern "C" NS_COM nsresult
163NS_ShutdownXPCOM(nsIServiceManager* servMgr);
164
165
166/**
167 * Public Method to access to the service manager.
168 *
169 * @status FROZEN
170 * @param result Interface pointer to the service manager
171 *
172 * @return NS_OK for success;
173 * other error codes indicate a failure during initialisation.
174 *
175 */
176extern "C" NS_COM nsresult
177NS_GetServiceManager(nsIServiceManager* *result);
178
179/**
180 * Public Method to access to the component manager.
181 *
182 * @status FROZEN
183 * @param result Interface pointer to the service
184 *
185 * @return NS_OK for success;
186 * other error codes indicate a failure during initialisation.
187 *
188 */
189extern "C" NS_COM nsresult
190NS_GetComponentManager(nsIComponentManager* *result);
191
192/**
193 * Public Method to access to the component registration manager.
194 *
195 * @status FROZEN
196 * @param result Interface pointer to the service
197 *
198 * @return NS_OK for success;
199 * other error codes indicate a failure during initialisation.
200 *
201 */
202extern "C" NS_COM nsresult
203NS_GetComponentRegistrar(nsIComponentRegistrar* *result);
204
205/**
206 * Public Method to create an instance of a nsILocalFile. This function
207 * may be called prior to NS_InitXPCOM2Ex.
208 *
209 * @status FROZEN
210 *
211 * @param path
212 * A string which specifies a full file path to a
213 * location. Relative paths will be treated as an
214 * error (NS_ERROR_FILE_UNRECOGNIZED_PATH).
215 * |NS_NewNativeLocalFile|'s path must be in the
216 * filesystem charset.
217 * @param followLinks
218 * This attribute will determine if the nsLocalFile will auto
219 * resolve symbolic links. By default, this value will be false
220 * on all non unix systems. On unix, this attribute is effectively
221 * a noop.
222 * @param result Interface pointer to a new instance of an nsILocalFile
223 *
224 * @return NS_OK for success;
225 * other error codes indicate a failure.
226 */
227
228extern "C" NS_COM nsresult
229NS_NewLocalFile(const nsAString &path,
230 PRBool followLinks,
231 nsILocalFile* *result);
232
233extern "C" NS_COM nsresult
234NS_NewNativeLocalFile(const nsACString &path,
235 PRBool followLinks,
236 nsILocalFile* *result);
237
238
239extern "C" NS_COM nsresult
240NS_GetDebug(nsIDebug* *result);
241
242extern "C" NS_COM nsresult
243NS_GetTraceRefcnt(nsITraceRefcnt* *result);
244
245#endif
Note: See TracBrowser for help on using the repository browser.

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