Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim:set ts=4 sw=4 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsXPComPrivate_h__
8 #define nsXPComPrivate_h__
10 #include "nscore.h"
11 #include "nsXPCOM.h"
12 #include "nsXPCOMStrings.h"
13 #include "xptcall.h"
15 class nsStringContainer;
16 class nsCStringContainer;
17 class nsIComponentLoader;
18 class nsPurpleBufferEntry;
20 /**
21 * During this shutdown notification all threads which run XPCOM code must
22 * be joined.
23 */
24 #define NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID "xpcom-shutdown-threads"
26 /**
27 * During this shutdown notification all module loaders must unload XPCOM
28 * modules.
29 */
30 #define NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID "xpcom-shutdown-loaders"
32 // PUBLIC
33 typedef nsresult (* InitFunc)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider);
34 typedef nsresult (* ShutdownFunc)(nsIServiceManager* servMgr);
35 typedef nsresult (* GetServiceManagerFunc)(nsIServiceManager* *result);
36 typedef nsresult (* GetComponentManagerFunc)(nsIComponentManager* *result);
37 typedef nsresult (* GetComponentRegistrarFunc)(nsIComponentRegistrar* *result);
38 typedef nsresult (* GetMemoryManagerFunc)(nsIMemory* *result);
39 typedef nsresult (* NewLocalFileFunc)(const nsAString &path, bool followLinks, nsIFile* *result);
40 typedef nsresult (* NewNativeLocalFileFunc)(const nsACString &path, bool followLinks, nsIFile* *result);
42 typedef nsresult (* GetDebugFunc)(nsIDebug* *result);
44 typedef nsresult (* StringContainerInitFunc)(nsStringContainer&);
45 typedef nsresult (* StringContainerInit2Func)(nsStringContainer&, const char16_t *, uint32_t, uint32_t);
46 typedef void (* StringContainerFinishFunc)(nsStringContainer&);
47 typedef uint32_t (* StringGetDataFunc)(const nsAString&, const char16_t**, bool*);
48 typedef uint32_t (* StringGetMutableDataFunc)(nsAString&, uint32_t, char16_t**);
49 typedef char16_t* (* StringCloneDataFunc)(const nsAString&);
50 typedef nsresult (* StringSetDataFunc)(nsAString&, const char16_t*, uint32_t);
51 typedef nsresult (* StringSetDataRangeFunc)(nsAString&, uint32_t, uint32_t, const char16_t*, uint32_t);
52 typedef nsresult (* StringCopyFunc)(nsAString &, const nsAString &);
53 typedef void (* StringSetIsVoidFunc)(nsAString &, const bool);
54 typedef bool (* StringGetIsVoidFunc)(const nsAString &);
56 typedef nsresult (* CStringContainerInitFunc)(nsCStringContainer&);
57 typedef nsresult (* CStringContainerInit2Func)(nsCStringContainer&, const char *, uint32_t, uint32_t);
58 typedef void (* CStringContainerFinishFunc)(nsCStringContainer&);
59 typedef uint32_t (* CStringGetDataFunc)(const nsACString&, const char**, bool*);
60 typedef uint32_t (* CStringGetMutableDataFunc)(nsACString&, uint32_t, char**);
61 typedef char* (* CStringCloneDataFunc)(const nsACString&);
62 typedef nsresult (* CStringSetDataFunc)(nsACString&, const char*, uint32_t);
63 typedef nsresult (* CStringSetDataRangeFunc)(nsACString&, uint32_t, uint32_t, const char*, uint32_t);
64 typedef nsresult (* CStringCopyFunc)(nsACString &, const nsACString &);
65 typedef void (* CStringSetIsVoidFunc)(nsACString &, const bool);
66 typedef bool (* CStringGetIsVoidFunc)(const nsACString &);
68 typedef nsresult (* CStringToUTF16)(const nsACString &, nsCStringEncoding, nsAString &);
69 typedef nsresult (* UTF16ToCString)(const nsAString &, nsCStringEncoding, nsACString &);
71 typedef void* (* AllocFunc)(size_t size);
72 typedef void* (* ReallocFunc)(void* ptr, size_t size);
73 typedef void (* FreeFunc)(void* ptr);
75 typedef void (* DebugBreakFunc)(uint32_t aSeverity,
76 const char *aStr, const char *aExpr,
77 const char *aFile, int32_t aLine);
79 typedef void (* xpcomVoidFunc)();
80 typedef void (* LogAddRefFunc)(void*, nsrefcnt, const char*, uint32_t);
81 typedef void (* LogReleaseFunc)(void*, nsrefcnt, const char*);
82 typedef void (* LogCtorFunc)(void*, const char*, uint32_t);
83 typedef void (* LogCOMPtrFunc)(void*, nsISupports*);
85 typedef nsresult (* GetXPTCallStubFunc)(REFNSIID, nsIXPTCProxy*, nsISomeInterface**);
86 typedef void (* DestroyXPTCallStubFunc)(nsISomeInterface*);
87 typedef nsresult (* InvokeByIndexFunc)(nsISupports*, uint32_t, uint32_t, nsXPTCVariant*);
88 typedef bool (* CycleCollectorFunc)(nsISupports*);
89 typedef nsPurpleBufferEntry*
90 (* CycleCollectorSuspect2Func)(void*, nsCycleCollectionParticipant*);
91 typedef bool (* CycleCollectorForget2Func)(nsPurpleBufferEntry*);
92 typedef void (* CycleCollectorSuspect3Func)(void*, nsCycleCollectionParticipant*,nsCycleCollectingAutoRefCnt*,bool*);
93 // PRIVATE AND DEPRECATED
94 typedef NS_CALLBACK(XPCOMExitRoutine)(void);
96 typedef nsresult (* RegisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine, uint32_t priority);
97 typedef nsresult (* UnregisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine);
99 typedef struct XPCOMFunctions{
100 uint32_t version;
101 uint32_t size;
103 InitFunc init;
104 ShutdownFunc shutdown;
105 GetServiceManagerFunc getServiceManager;
106 GetComponentManagerFunc getComponentManager;
107 GetComponentRegistrarFunc getComponentRegistrar;
108 GetMemoryManagerFunc getMemoryManager;
109 NewLocalFileFunc newLocalFile;
110 NewNativeLocalFileFunc newNativeLocalFile;
112 RegisterXPCOMExitRoutineFunc registerExitRoutine;
113 UnregisterXPCOMExitRoutineFunc unregisterExitRoutine;
115 // Added for Mozilla 1.5
116 GetDebugFunc getDebug;
117 void* getTraceRefcnt;
119 // Added for Mozilla 1.7
120 StringContainerInitFunc stringContainerInit;
121 StringContainerFinishFunc stringContainerFinish;
122 StringGetDataFunc stringGetData;
123 StringSetDataFunc stringSetData;
124 StringSetDataRangeFunc stringSetDataRange;
125 StringCopyFunc stringCopy;
126 CStringContainerInitFunc cstringContainerInit;
127 CStringContainerFinishFunc cstringContainerFinish;
128 CStringGetDataFunc cstringGetData;
129 CStringSetDataFunc cstringSetData;
130 CStringSetDataRangeFunc cstringSetDataRange;
131 CStringCopyFunc cstringCopy;
132 CStringToUTF16 cstringToUTF16;
133 UTF16ToCString utf16ToCString;
134 StringCloneDataFunc stringCloneData;
135 CStringCloneDataFunc cstringCloneData;
137 // Added for Mozilla 1.8
138 AllocFunc allocFunc;
139 ReallocFunc reallocFunc;
140 FreeFunc freeFunc;
141 StringContainerInit2Func stringContainerInit2;
142 CStringContainerInit2Func cstringContainerInit2;
143 StringGetMutableDataFunc stringGetMutableData;
144 CStringGetMutableDataFunc cstringGetMutableData;
145 void* init3; // obsolete
147 // Added for Mozilla 1.9
148 DebugBreakFunc debugBreakFunc;
149 xpcomVoidFunc logInitFunc;
150 xpcomVoidFunc logTermFunc;
151 LogAddRefFunc logAddRefFunc;
152 LogReleaseFunc logReleaseFunc;
153 LogCtorFunc logCtorFunc;
154 LogCtorFunc logDtorFunc;
155 LogCOMPtrFunc logCOMPtrAddRefFunc;
156 LogCOMPtrFunc logCOMPtrReleaseFunc;
157 GetXPTCallStubFunc getXPTCallStubFunc;
158 DestroyXPTCallStubFunc destroyXPTCallStubFunc;
159 InvokeByIndexFunc invokeByIndexFunc;
160 CycleCollectorFunc cycleSuspectFunc; // obsolete: use cycleSuspect3Func
161 CycleCollectorFunc cycleForgetFunc; // obsolete
162 StringSetIsVoidFunc stringSetIsVoid;
163 StringGetIsVoidFunc stringGetIsVoid;
164 CStringSetIsVoidFunc cstringSetIsVoid;
165 CStringGetIsVoidFunc cstringGetIsVoid;
167 // Added for Mozilla 1.9.1
168 CycleCollectorSuspect2Func cycleSuspect2Func; // obsolete: use cycleSuspect3Func
169 CycleCollectorForget2Func cycleForget2Func; // obsolete
171 CycleCollectorSuspect3Func cycleSuspect3Func;
173 } XPCOMFunctions;
175 typedef nsresult (*GetFrozenFunctionsFunc)(XPCOMFunctions *entryPoints, const char* libraryPath);
176 XPCOM_API(nsresult)
177 NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath);
180 namespace mozilla {
182 /**
183 * Shutdown XPCOM. You must call this method after you are finished
184 * using xpcom.
185 *
186 * @param servMgr The service manager which was returned by NS_InitXPCOM.
187 * This will release servMgr. You may pass null.
188 *
189 * @return NS_OK for success;
190 * other error codes indicate a failure during shutdown
191 *
192 */
193 nsresult
194 ShutdownXPCOM(nsIServiceManager* servMgr);
196 void SetICUMemoryFunctions();
198 /**
199 * C++ namespaced version of NS_LogTerm.
200 */
201 void LogTerm();
203 } // namespace mozilla
206 // think hard before changing this
207 #define XPCOM_GLUE_VERSION 1
210 /* XPCOM Specific Defines
211 *
212 * XPCOM_DLL - name of the loadable xpcom library on disk.
213 * XUL_DLL - name of the loadable XUL library on disk
214 * XPCOM_SEARCH_KEY - name of the environment variable that can be
215 * modified to include additional search paths.
216 * GRE_CONF_NAME - Name of the GRE Configuration file
217 */
219 #if defined(XP_WIN32)
221 #define XPCOM_SEARCH_KEY "PATH"
222 #define GRE_CONF_NAME "gre.config"
223 #define GRE_WIN_REG_LOC L"Software\\mozilla.org\\GRE"
224 #define XPCOM_DLL XUL_DLL
225 #define LXPCOM_DLL LXUL_DLL
226 #define XUL_DLL "xul.dll"
227 #define LXUL_DLL L"xul.dll"
229 #else // Unix
230 #include <limits.h> // for PATH_MAX
232 #define XPCOM_DLL XUL_DLL
234 // you have to love apple..
235 #ifdef XP_MACOSX
236 #define XPCOM_SEARCH_KEY "DYLD_LIBRARY_PATH"
237 #define GRE_FRAMEWORK_NAME "XUL.framework"
238 #define XUL_DLL "XUL"
239 #else
240 #define XPCOM_SEARCH_KEY "LD_LIBRARY_PATH"
241 #define XUL_DLL "libxul" MOZ_DLL_SUFFIX
242 #endif
244 #define GRE_CONF_NAME ".gre.config"
245 #define GRE_CONF_PATH "/etc/gre.conf"
246 #define GRE_CONF_DIR "/etc/gre.d"
247 #define GRE_USER_CONF_DIR ".gre.d"
248 #endif
250 #if defined(XP_WIN)
251 #define XPCOM_FILE_PATH_SEPARATOR "\\"
252 #define XPCOM_ENV_PATH_SEPARATOR ";"
253 #elif defined(XP_UNIX)
254 #define XPCOM_FILE_PATH_SEPARATOR "/"
255 #define XPCOM_ENV_PATH_SEPARATOR ":"
256 #else
257 #error need_to_define_your_file_path_separator_and_illegal_characters
258 #endif
260 #ifdef AIX
261 #include <sys/param.h>
262 #endif
264 #ifndef MAXPATHLEN
265 #ifdef PATH_MAX
266 #define MAXPATHLEN PATH_MAX
267 #elif defined(_MAX_PATH)
268 #define MAXPATHLEN _MAX_PATH
269 #elif defined(CCHMAXPATH)
270 #define MAXPATHLEN CCHMAXPATH
271 #else
272 #define MAXPATHLEN 1024
273 #endif
274 #endif
276 extern bool gXPCOMShuttingDown;
277 extern bool gXPCOMThreadsShutDown;
279 namespace mozilla {
280 namespace services {
282 /**
283 * Clears service cache, sets gXPCOMShuttingDown
284 */
285 void Shutdown();
287 } // namespace services
288 } // namespace mozilla
290 #endif