VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/build/nsXPComInit.cpp@ 20282

Last change on this file since 20282 was 20282, checked in by vboxsync, 16 years ago

libs/xpcom: fix race for EventQueueService singleton creation, which causes the client to be unresponsive to requests from VBoxSVC, causing lots of trouble. Also a few other minor bugfixes which can lead to crashes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 39.3 KB
Line 
1/* -*- Mode: C++; tab-width: 4; 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#include "nsXPCOM.h"
39#include "nsXPCOMPrivate.h"
40#include "nscore.h"
41#include "prlink.h"
42#include "nsCOMPtr.h"
43#include "nsObserverList.h"
44#include "nsObserverService.h"
45#include "nsProperties.h"
46#include "nsIProperties.h"
47#include "nsPersistentProperties.h"
48#include "nsScriptableInputStream.h"
49#include "nsBinaryStream.h"
50#include "nsStorageStream.h"
51
52#include "nsMemoryImpl.h"
53#include "nsDebugImpl.h"
54#include "nsTraceRefcntImpl.h"
55#include "nsErrorService.h"
56#include "nsByteBuffer.h"
57
58#include "nsSupportsArray.h"
59#include "nsArray.h"
60#include "nsSupportsPrimitives.h"
61#include "nsConsoleService.h"
62#include "nsExceptionService.h"
63
64#include "nsComponentManager.h"
65#include "nsCategoryManagerUtils.h"
66#include "nsIServiceManager.h"
67#include "nsGenericFactory.h"
68
69#include "nsEventQueueService.h"
70#include "nsEventQueue.h"
71#ifdef VBOX
72# include "nsEventQueueUtils.h"
73#endif /* VBOX */
74
75#include "nsIProxyObjectManager.h"
76#include "nsProxyEventPrivate.h" // access to the impl of nsProxyObjectManager for the generic factory registration.
77
78#include "xptinfo.h"
79#include "nsIInterfaceInfoManager.h"
80
81#include "nsTimerImpl.h"
82#include "TimerThread.h"
83
84#include "nsThread.h"
85#include "nsProcess.h"
86#include "nsEnvironment.h"
87
88#include "nsEmptyEnumerator.h"
89
90#include "nsILocalFile.h"
91#include "nsLocalFile.h"
92#if defined(XP_UNIX) || defined(XP_OS2)
93#include "nsNativeCharsetUtils.h"
94#endif
95#include "nsDirectoryService.h"
96#include "nsDirectoryServiceDefs.h"
97#include "nsCategoryManager.h"
98#include "nsICategoryManager.h"
99#include "nsStringStream.h"
100#include "nsMultiplexInputStream.h"
101
102#include "nsFastLoadService.h"
103
104#include "nsAtomService.h"
105#include "nsAtomTable.h"
106#include "nsTraceRefcnt.h"
107#include "nsTimelineService.h"
108
109#include "nsVariant.h"
110
111#ifdef GC_LEAK_DETECTOR
112#include "nsLeakDetector.h"
113#endif
114#include "nsRecyclingAllocator.h"
115
116#include "SpecialSystemDirectory.h"
117
118#include "ipcdclient.h"
119#include "ipcService.h"
120#include "ipcConfig.h"
121#include "ipcCID.h"
122#include "ipcLockService.h"
123#include "ipcLockCID.h"
124#include "tmTransactionService.h"
125#include "ipcDConnectService.h"
126
127#include <locale.h>
128
129// Registry Factory creation function defined in nsRegistry.cpp
130// We hook into this function locally to create and register the registry
131// Since noone outside xpcom needs to know about this and nsRegistry.cpp
132// does not have a local include file, we are putting this definition
133// here rather than in nsIRegistry.h
134extern nsresult NS_RegistryGetFactory(nsIFactory** aFactory);
135extern nsresult NS_CategoryManagerGetFactory( nsIFactory** );
136
137#ifdef DEBUG
138extern void _FreeAutoLockStatics();
139#endif
140
141static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
142static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID);
143static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
144
145NS_GENERIC_FACTORY_CONSTRUCTOR(nsProcess)
146NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsEventQueueServiceImpl, Init)
147
148#define NS_ENVIRONMENT_CLASSNAME "Environment Service"
149
150#include "nsXPCOM.h"
151// ds/nsISupportsPrimitives
152#define NS_SUPPORTS_ID_CLASSNAME "Supports ID"
153#define NS_SUPPORTS_CSTRING_CLASSNAME "Supports String"
154#define NS_SUPPORTS_STRING_CLASSNAME "Supports WString"
155#define NS_SUPPORTS_PRBOOL_CLASSNAME "Supports PRBool"
156#define NS_SUPPORTS_PRUINT8_CLASSNAME "Supports PRUint8"
157#define NS_SUPPORTS_PRUINT16_CLASSNAME "Supports PRUint16"
158#define NS_SUPPORTS_PRUINT32_CLASSNAME "Supports PRUint32"
159#define NS_SUPPORTS_PRUINT64_CLASSNAME "Supports PRUint64"
160#define NS_SUPPORTS_PRTIME_CLASSNAME "Supports PRTime"
161#define NS_SUPPORTS_CHAR_CLASSNAME "Supports Char"
162#define NS_SUPPORTS_PRINT16_CLASSNAME "Supports PRInt16"
163#define NS_SUPPORTS_PRINT32_CLASSNAME "Supports PRInt32"
164#define NS_SUPPORTS_PRINT64_CLASSNAME "Supports PRInt64"
165#define NS_SUPPORTS_FLOAT_CLASSNAME "Supports float"
166#define NS_SUPPORTS_DOUBLE_CLASSNAME "Supports double"
167#define NS_SUPPORTS_VOID_CLASSNAME "Supports void"
168#define NS_SUPPORTS_INTERFACE_POINTER_CLASSNAME "Supports interface pointer"
169
170NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsIDImpl)
171NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsStringImpl)
172NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsCStringImpl)
173NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRBoolImpl)
174NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint8Impl)
175NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint16Impl)
176NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint32Impl)
177NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRUint64Impl)
178NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRTimeImpl)
179NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsCharImpl)
180NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt16Impl)
181NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt32Impl)
182NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsPRInt64Impl)
183NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsFloatImpl)
184NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsDoubleImpl)
185NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsVoidImpl)
186NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsInterfacePointerImpl)
187
188NS_GENERIC_FACTORY_CONSTRUCTOR(nsArray)
189NS_GENERIC_FACTORY_CONSTRUCTOR(nsConsoleService)
190NS_GENERIC_FACTORY_CONSTRUCTOR(nsAtomService)
191NS_GENERIC_FACTORY_CONSTRUCTOR(nsExceptionService)
192NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerImpl)
193NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerManager)
194NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryOutputStream)
195NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinaryInputStream)
196NS_GENERIC_FACTORY_CONSTRUCTOR(nsStorageStream)
197
198NS_GENERIC_FACTORY_CONSTRUCTOR(nsVariant)
199
200NS_GENERIC_FACTORY_CONSTRUCTOR(nsRecyclingAllocatorImpl)
201
202#ifdef MOZ_TIMELINE
203NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimelineService)
204#endif
205
206static NS_METHOD
207nsXPTIInterfaceInfoManagerGetSingleton(nsISupports* outer,
208 const nsIID& aIID,
209 void* *aInstancePtr)
210{
211 NS_ENSURE_ARG_POINTER(aInstancePtr);
212 NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
213
214 nsCOMPtr<nsIInterfaceInfoManager> iim(dont_AddRef(XPTI_GetInterfaceInfoManager()));
215 if (!iim) {
216 return NS_ERROR_FAILURE;
217 }
218
219 return iim->QueryInterface(aIID, aInstancePtr);
220}
221
222
223PR_STATIC_CALLBACK(nsresult)
224RegisterGenericFactory(nsIComponentRegistrar* registrar,
225 const nsModuleComponentInfo *info)
226{
227 nsresult rv;
228 nsIGenericFactory* fact;
229 rv = NS_NewGenericFactory(&fact, info);
230 if (NS_FAILED(rv)) return rv;
231
232 rv = registrar->RegisterFactory(info->mCID,
233 info->mDescription,
234 info->mContractID,
235 fact);
236 NS_RELEASE(fact);
237 return rv;
238}
239
240// In order to support the installer, we need
241// to be told out of band if we should cause
242// an autoregister. If the file ".autoreg" exists in the binary
243// directory, we check its timestamp against the timestamp of the
244// compreg.dat file. If the .autoreg file is newer, we autoregister.
245static PRBool CheckUpdateFile()
246{
247 nsresult rv;
248 nsCOMPtr<nsIProperties> directoryService;
249 nsDirectoryService::Create(nsnull,
250 NS_GET_IID(nsIProperties),
251 getter_AddRefs(directoryService));
252
253 if (!directoryService)
254 return PR_FALSE;
255
256 nsCOMPtr<nsIFile> file;
257 rv = directoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
258 NS_GET_IID(nsIFile),
259 getter_AddRefs(file));
260
261 if (NS_FAILED(rv)) {
262 NS_WARNING("Getting NS_XPCOM_CURRENT_PROCESS_DIR failed");
263 return PR_FALSE;
264 }
265
266 file->AppendNative(nsDependentCString(".autoreg"));
267
268 PRBool exists;
269 file->Exists(&exists);
270 if (!exists)
271 return PR_FALSE;
272
273 nsCOMPtr<nsIFile> compregFile;
274 rv = directoryService->Get(NS_XPCOM_COMPONENT_REGISTRY_FILE,
275 NS_GET_IID(nsIFile),
276 getter_AddRefs(compregFile));
277
278
279 if (NS_FAILED(rv)) {
280 NS_WARNING("Getting NS_XPCOM_COMPONENT_REGISTRY_FILE failed");
281 return PR_FALSE;
282 }
283
284 // Don't need to check whether compreg exists; if it doesn't
285 // we won't even be here.
286
287 PRInt64 compregModTime, autoregModTime;
288 compregFile->GetLastModifiedTime(&compregModTime);
289 file->GetLastModifiedTime(&autoregModTime);
290
291 return LL_CMP(autoregModTime, >, compregModTime);
292}
293
294#if 0 /// @todo later
295NS_GENERIC_FACTORY_CONSTRUCTOR(ipcService)
296NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ipcLockService, Init)
297NS_GENERIC_FACTORY_CONSTRUCTOR(tmTransactionService)
298NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ipcDConnectService, Init)
299
300// enable this code to make the IPC DCONNECT service auto-start.
301NS_METHOD
302ipcDConnectServiceRegisterProc(nsIComponentManager *aCompMgr,
303 nsIFile *aPath,
304 const char *registryLocation,
305 const char *componentType,
306 const nsModuleComponentInfo *info)
307{
308 //
309 // add ipcService to the XPCOM startup category
310 //
311 nsCOMPtr<nsICategoryManager> catman(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
312 if (catman) {
313 nsXPIDLCString prevEntry;
314 catman->AddCategoryEntry(NS_XPCOM_STARTUP_OBSERVER_ID, "ipcDConnectService",
315 IPC_DCONNECTSERVICE_CONTRACTID, PR_TRUE, PR_TRUE,
316 getter_Copies(prevEntry));
317 }
318 return NS_OK;
319}
320
321NS_METHOD
322ipcDConnectServiceUnregisterProc(nsIComponentManager *aCompMgr,
323 nsIFile *aPath,
324 const char *registryLocation,
325 const nsModuleComponentInfo *info)
326{
327 nsCOMPtr<nsICategoryManager> catman(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
328 if (catman)
329 catman->DeleteCategoryEntry(NS_XPCOM_STARTUP_OBSERVER_ID,
330 IPC_DCONNECTSERVICE_CONTRACTID, PR_TRUE);
331 return NS_OK;
332}
333#endif
334
335nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = NULL;
336nsIProperties *gDirectoryService = NULL;
337PRBool gXPCOMShuttingDown = PR_FALSE;
338
339// For each class that wishes to support nsIClassInfo, add a line like this
340// NS_DECL_CLASSINFO(nsMyClass)
341
342#define COMPONENT(NAME, Ctor) \
343 { NS_##NAME##_CLASSNAME, NS_##NAME##_CID, NS_##NAME##_CONTRACTID, Ctor }
344
345#define COMPONENT_CI(NAME, Ctor, Class) \
346 { NS_##NAME##_CLASSNAME, NS_##NAME##_CID, NS_##NAME##_CONTRACTID, Ctor, \
347 NULL, NULL, NULL, NS_CI_INTERFACE_GETTER_NAME(Class), NULL, \
348 &NS_CLASSINFO_NAME(Class) }
349
350static const nsModuleComponentInfo components[] = {
351 COMPONENT(MEMORY, nsMemoryImpl::Create),
352 COMPONENT(DEBUG, nsDebugImpl::Create),
353#define NS_ERRORSERVICE_CLASSNAME NS_ERRORSERVICE_NAME
354 COMPONENT(ERRORSERVICE, nsErrorService::Create),
355
356 COMPONENT(BYTEBUFFER, ByteBufferImpl::Create),
357 COMPONENT(SCRIPTABLEINPUTSTREAM, nsScriptableInputStream::Create),
358 COMPONENT(BINARYINPUTSTREAM, nsBinaryInputStreamConstructor),
359 COMPONENT(BINARYOUTPUTSTREAM, nsBinaryOutputStreamConstructor),
360 COMPONENT(STORAGESTREAM, nsStorageStreamConstructor),
361
362#define NS_PROPERTIES_CLASSNAME "Properties"
363 COMPONENT(PROPERTIES, nsProperties::Create),
364
365#define NS_PERSISTENTPROPERTIES_CID NS_IPERSISTENTPROPERTIES_CID /* sigh */
366 COMPONENT(PERSISTENTPROPERTIES, nsPersistentProperties::Create),
367
368 COMPONENT(SUPPORTSARRAY, nsSupportsArray::Create),
369 COMPONENT(ARRAY, nsArrayConstructor),
370 COMPONENT(CONSOLESERVICE, nsConsoleServiceConstructor),
371 COMPONENT(EXCEPTIONSERVICE, nsExceptionServiceConstructor),
372 COMPONENT(ATOMSERVICE, nsAtomServiceConstructor),
373#ifdef MOZ_TIMELINE
374 COMPONENT(TIMELINESERVICE, nsTimelineServiceConstructor),
375#endif
376 COMPONENT(OBSERVERSERVICE, nsObserverService::Create),
377 COMPONENT(GENERICFACTORY, nsGenericFactory::Create),
378 COMPONENT(EVENTQUEUESERVICE, nsEventQueueServiceImplConstructor),
379 COMPONENT(EVENTQUEUE, nsEventQueueImpl::Create),
380 COMPONENT(THREAD, nsThread::Create),
381
382#define NS_XPCOMPROXY_CID NS_PROXYEVENT_MANAGER_CID
383 COMPONENT(XPCOMPROXY, nsProxyObjectManager::Create),
384
385 COMPONENT(TIMER, nsTimerImplConstructor),
386 COMPONENT(TIMERMANAGER, nsTimerManagerConstructor),
387
388#define COMPONENT_SUPPORTS(TYPE, Type) \
389 COMPONENT(SUPPORTS_##TYPE, nsSupports##Type##ImplConstructor)
390
391 COMPONENT_SUPPORTS(ID, ID),
392 COMPONENT_SUPPORTS(STRING, String),
393 COMPONENT_SUPPORTS(CSTRING, CString),
394 COMPONENT_SUPPORTS(PRBOOL, PRBool),
395 COMPONENT_SUPPORTS(PRUINT8, PRUint8),
396 COMPONENT_SUPPORTS(PRUINT16, PRUint16),
397 COMPONENT_SUPPORTS(PRUINT32, PRUint32),
398 COMPONENT_SUPPORTS(PRUINT64, PRUint64),
399 COMPONENT_SUPPORTS(PRTIME, PRTime),
400 COMPONENT_SUPPORTS(CHAR, Char),
401 COMPONENT_SUPPORTS(PRINT16, PRInt16),
402 COMPONENT_SUPPORTS(PRINT32, PRInt32),
403 COMPONENT_SUPPORTS(PRINT64, PRInt64),
404 COMPONENT_SUPPORTS(FLOAT, Float),
405 COMPONENT_SUPPORTS(DOUBLE, Double),
406 COMPONENT_SUPPORTS(VOID, Void),
407 COMPONENT_SUPPORTS(INTERFACE_POINTER, InterfacePointer),
408
409#undef COMPONENT_SUPPORTS
410#define NS_LOCAL_FILE_CLASSNAME "Local File Specification"
411 COMPONENT(LOCAL_FILE, nsLocalFile::nsLocalFileConstructor),
412#define NS_DIRECTORY_SERVICE_CLASSNAME "nsIFile Directory Service"
413 COMPONENT(DIRECTORY_SERVICE, nsDirectoryService::Create),
414 COMPONENT(PROCESS, nsProcessConstructor),
415 COMPONENT(ENVIRONMENT, nsEnvironment::Create),
416
417 COMPONENT(STRINGINPUTSTREAM, nsStringInputStreamConstructor),
418 COMPONENT(MULTIPLEXINPUTSTREAM, nsMultiplexInputStreamConstructor),
419
420 COMPONENT(FASTLOADSERVICE, nsFastLoadService::Create),
421 COMPONENT(VARIANT, nsVariantConstructor),
422 COMPONENT(INTERFACEINFOMANAGER_SERVICE, nsXPTIInterfaceInfoManagerGetSingleton),
423
424 COMPONENT(RECYCLINGALLOCATOR, nsRecyclingAllocatorImplConstructor),
425
426#if 0 /// @todo later
427 { IPC_SERVICE_CLASSNAME,
428 IPC_SERVICE_CID,
429 IPC_SERVICE_CONTRACTID,
430 ipcServiceConstructor },
431 /*
432 ipcServiceRegisterProc,
433 ipcServiceUnregisterProc },
434 */
435 //
436 // extensions go here:
437 //
438 { IPC_LOCKSERVICE_CLASSNAME,
439 IPC_LOCKSERVICE_CID,
440 IPC_LOCKSERVICE_CONTRACTID,
441 ipcLockServiceConstructor },
442 { IPC_TRANSACTIONSERVICE_CLASSNAME,
443 IPC_TRANSACTIONSERVICE_CID,
444 IPC_TRANSACTIONSERVICE_CONTRACTID,
445 tmTransactionServiceConstructor },
446
447#ifdef BUILD_DCONNECT
448 { IPC_DCONNECTSERVICE_CLASSNAME,
449 IPC_DCONNECTSERVICE_CID,
450 IPC_DCONNECTSERVICE_CONTRACTID,
451 ipcDConnectServiceConstructor,
452 ipcDConnectServiceRegisterProc,
453 ipcDConnectServiceUnregisterProc },
454#endif
455#endif
456};
457
458#undef COMPONENT
459
460const int components_length = sizeof(components) / sizeof(components[0]);
461
462// gMemory will be freed during shutdown.
463static nsIMemory* gMemory = nsnull;
464nsresult NS_COM NS_GetMemoryManager(nsIMemory* *result)
465{
466 nsresult rv = NS_OK;
467 if (!gMemory)
468 {
469 rv = nsMemoryImpl::Create(nsnull,
470 NS_GET_IID(nsIMemory),
471 (void**)&gMemory);
472 }
473 NS_IF_ADDREF(*result = gMemory);
474 return rv;
475}
476
477// gDebug will be freed during shutdown.
478static nsIDebug* gDebug = nsnull;
479nsresult NS_COM NS_GetDebug(nsIDebug** result)
480{
481 nsresult rv = NS_OK;
482 if (!gDebug)
483 {
484 rv = nsDebugImpl::Create(nsnull,
485 NS_GET_IID(nsIDebug),
486 (void**)&gDebug);
487 }
488 NS_IF_ADDREF(*result = gDebug);
489 return rv;
490}
491
492#ifdef NS_BUILD_REFCNT_LOGGING
493// gTraceRefcnt will be freed during shutdown.
494static nsITraceRefcnt* gTraceRefcnt = nsnull;
495#endif
496
497nsresult NS_COM NS_GetTraceRefcnt(nsITraceRefcnt** result)
498{
499#ifdef NS_BUILD_REFCNT_LOGGING
500 nsresult rv = NS_OK;
501 if (!gTraceRefcnt)
502 {
503 rv = nsTraceRefcntImpl::Create(nsnull,
504 NS_GET_IID(nsITraceRefcnt),
505 (void**)&gTraceRefcnt);
506 }
507 NS_IF_ADDREF(*result = gTraceRefcnt);
508 return rv;
509#else
510 return NS_ERROR_NOT_INITIALIZED;
511#endif
512}
513
514nsresult NS_COM NS_InitXPCOM(nsIServiceManager* *result,
515 nsIFile* binDirectory)
516{
517 return NS_InitXPCOM2(result, binDirectory, nsnull);
518}
519
520nsresult NS_COM NS_InitXPCOM2(nsIServiceManager* *result,
521 nsIFile* binDirectory,
522 nsIDirectoryServiceProvider* appFileLocationProvider)
523{
524 nsresult rv = NS_OK;
525
526 // We are not shutting down
527 gXPCOMShuttingDown = PR_FALSE;
528
529#ifdef NS_BUILD_REFCNT_LOGGING
530 nsTraceRefcntImpl::Startup();
531#endif
532
533 // Establish the main thread here.
534 rv = nsIThread::SetMainThread();
535 if (NS_FAILED(rv)) return rv;
536
537 // Set up the timer globals/timer thread
538 rv = nsTimerImpl::Startup();
539 NS_ENSURE_SUCCESS(rv, rv);
540
541 // Startup the memory manager
542 rv = nsMemoryImpl::Startup();
543 if (NS_FAILED(rv)) return rv;
544
545 // If the locale hasn't already been setup by our embedder,
546 // get us out of the "C" locale and into the system
547 if (strcmp(setlocale(LC_ALL, NULL), "C") == 0)
548 setlocale(LC_ALL, "");
549
550#if defined(XP_UNIX) || defined(XP_OS2)
551 NS_StartupNativeCharsetUtils();
552#endif
553 NS_StartupLocalFile();
554
555 StartupSpecialSystemDirectory();
556
557 // Start the directory service so that the component manager init can use it.
558 rv = nsDirectoryService::Create(nsnull,
559 NS_GET_IID(nsIProperties),
560 (void**)&gDirectoryService);
561 if (NS_FAILED(rv))
562 return rv;
563
564 nsCOMPtr<nsIDirectoryService> dirService = do_QueryInterface(gDirectoryService, &rv);
565 if (NS_FAILED(rv))
566 return rv;
567 rv = dirService->Init();
568 if (NS_FAILED(rv))
569 return rv;
570
571 // Create the Component/Service Manager
572 nsComponentManagerImpl *compMgr = NULL;
573
574 if (nsComponentManagerImpl::gComponentManager == NULL)
575 {
576 compMgr = new nsComponentManagerImpl();
577 if (compMgr == NULL)
578 return NS_ERROR_OUT_OF_MEMORY;
579 NS_ADDREF(compMgr);
580
581 nsCOMPtr<nsIFile> xpcomLib;
582
583 PRBool value;
584 if (binDirectory)
585 {
586 rv = binDirectory->IsDirectory(&value);
587
588 if (NS_SUCCEEDED(rv) && value) {
589 gDirectoryService->Set(NS_XPCOM_INIT_CURRENT_PROCESS_DIR, binDirectory);
590 binDirectory->Clone(getter_AddRefs(xpcomLib));
591 }
592 }
593 else {
594 gDirectoryService->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
595 NS_GET_IID(nsIFile),
596 getter_AddRefs(xpcomLib));
597 }
598
599 if (xpcomLib) {
600 xpcomLib->AppendNative(nsDependentCString(XPCOM_DLL));
601 gDirectoryService->Set(NS_XPCOM_LIBRARY_FILE, xpcomLib);
602 }
603
604 if (appFileLocationProvider) {
605 rv = dirService->RegisterProvider(appFileLocationProvider);
606 if (NS_FAILED(rv)) return rv;
607 }
608
609 rv = compMgr->Init();
610 if (NS_FAILED(rv))
611 {
612 NS_RELEASE(compMgr);
613 return rv;
614 }
615
616 nsComponentManagerImpl::gComponentManager = compMgr;
617
618 if (result) {
619 nsIServiceManager *serviceManager =
620 NS_STATIC_CAST(nsIServiceManager*, compMgr);
621
622 NS_ADDREF(*result = serviceManager);
623 }
624 }
625
626 nsCOMPtr<nsIMemory> memory;
627 NS_GetMemoryManager(getter_AddRefs(memory));
628 // dougt - these calls will be moved into a new interface when nsIComponentManager is frozen.
629 rv = compMgr->RegisterService(kMemoryCID, memory);
630 if (NS_FAILED(rv)) return rv;
631
632 rv = compMgr->RegisterService(kComponentManagerCID, NS_STATIC_CAST(nsIComponentManager*, compMgr));
633 if (NS_FAILED(rv)) return rv;
634
635#ifdef GC_LEAK_DETECTOR
636 rv = NS_InitLeakDetector();
637 if (NS_FAILED(rv)) return rv;
638#endif
639
640 // 2. Register the global services with the component manager so that
641 // clients can create new objects.
642
643 // Category Manager
644 {
645 nsCOMPtr<nsIFactory> categoryManagerFactory;
646 if ( NS_FAILED(rv = NS_CategoryManagerGetFactory(getter_AddRefs(categoryManagerFactory))) )
647 return rv;
648
649 NS_DEFINE_CID(kCategoryManagerCID, NS_CATEGORYMANAGER_CID);
650
651 rv = compMgr->RegisterFactory(kCategoryManagerCID,
652 NS_CATEGORYMANAGER_CLASSNAME,
653 NS_CATEGORYMANAGER_CONTRACTID,
654 categoryManagerFactory,
655 PR_TRUE);
656 if ( NS_FAILED(rv) ) return rv;
657 }
658
659 // what I want to do here is QI for a Component Registration Manager. Since this
660 // has not been invented yet, QI to the obsolete manager. Kids, don't do this at home.
661 nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(
662 NS_STATIC_CAST(nsIComponentManager*,compMgr), &rv);
663 if (registrar) {
664 for (int i = 0; i < components_length; i++)
665 RegisterGenericFactory(registrar, &components[i]);
666 }
667 rv = nsComponentManagerImpl::gComponentManager->ReadPersistentRegistry();
668#ifdef DEBUG
669 if (NS_FAILED(rv)) {
670 printf("No Persistent Registry Found.\n");
671 }
672#endif
673
674#if 0 /// @todo later
675 rv = IPC_Init();
676 if (NS_FAILED(rv))
677 return rv;
678#endif
679
680 if ( NS_FAILED(rv) || CheckUpdateFile()) {
681 // if we find no persistent registry, we will try to autoregister
682 // the default components directory.
683 nsComponentManagerImpl::gComponentManager->AutoRegister(nsnull);
684
685 // If the application is using a GRE, then,
686 // auto register components in the GRE directory as well.
687 //
688 // The application indicates that it's using an GRE by
689 // returning a valid nsIFile when queried (via appFileLocProvider)
690 // for the NS_GRE_DIR atom as shown below
691 //
692
693 if ( appFileLocationProvider ) {
694 nsCOMPtr<nsIFile> greDir;
695 PRBool persistent = PR_TRUE;
696
697 appFileLocationProvider->GetFile(NS_GRE_DIR, &persistent, getter_AddRefs(greDir));
698
699 if (greDir) {
700#ifdef DEBUG_dougt
701 printf("start - Registering GRE components\n");
702#endif
703 rv = gDirectoryService->Get(NS_GRE_COMPONENT_DIR,
704 NS_GET_IID(nsIFile),
705 getter_AddRefs(greDir));
706 if (NS_FAILED(rv)) {
707 NS_ERROR("Could not get GRE components directory!");
708 return rv;
709 }
710
711 // If the GRE contains any loaders, we want to know about it so that we can cause another
712 // autoregistration of the applications component directory.
713 int loaderCount = nsComponentManagerImpl::gComponentManager->GetLoaderCount();
714 rv = nsComponentManagerImpl::gComponentManager->AutoRegister(greDir);
715
716 if (loaderCount != nsComponentManagerImpl::gComponentManager->GetLoaderCount())
717 nsComponentManagerImpl::gComponentManager->AutoRegisterNonNativeComponents(nsnull);
718
719#ifdef DEBUG_dougt
720 printf("end - Registering GRE components\n");
721#endif
722 if (NS_FAILED(rv)) {
723 NS_ERROR("Could not AutoRegister GRE components");
724 return rv;
725 }
726 }
727 }
728
729 //
730 // If additional component directories have been specified, then
731 // register them as well.
732 //
733
734 nsCOMPtr<nsISimpleEnumerator> dirList;
735 gDirectoryService->Get(NS_XPCOM_COMPONENT_DIR_LIST,
736 NS_GET_IID(nsISimpleEnumerator),
737 getter_AddRefs(dirList));
738 if (dirList) {
739 PRBool hasMore;
740 while (NS_SUCCEEDED(dirList->HasMoreElements(&hasMore)) && hasMore) {
741 nsCOMPtr<nsISupports> elem;
742 dirList->GetNext(getter_AddRefs(elem));
743 if (elem) {
744 nsCOMPtr<nsIFile> dir = do_QueryInterface(elem);
745 if (dir)
746 nsComponentManagerImpl::gComponentManager->AutoRegister(dir);
747
748 // XXX should we worry about new component loaders being
749 // XXX defined by this process?
750 }
751 }
752 }
753
754
755 // Make sure the compreg file's mod time is current.
756 nsCOMPtr<nsIFile> compregFile;
757 rv = gDirectoryService->Get(NS_XPCOM_COMPONENT_REGISTRY_FILE,
758 NS_GET_IID(nsIFile),
759 getter_AddRefs(compregFile));
760 compregFile->SetLastModifiedTime(PR_Now() / 1000);
761 }
762
763 // Pay the cost at startup time of starting this singleton.
764 nsIInterfaceInfoManager* iim = XPTI_GetInterfaceInfoManager();
765 NS_IF_RELEASE(iim);
766#ifdef VBOX
767 // Must initialize the EventQueueService singleton before anyone is
768 // using it. The notification below creates a thread which races creating
769 // the EventQueueService creation otherwise, no matter what.
770 nsCOMPtr<nsIEventQueue> eventQ;
771 rv = NS_GetMainEventQ(getter_AddRefs(eventQ));
772 if (NS_FAILED(rv)) {
773 NS_ERROR("Could not create event queue for main thread");
774 return rv;
775 }
776#endif /* VBOX */
777
778 // Notify observers of xpcom autoregistration start
779 NS_CreateServicesFromCategory(NS_XPCOM_STARTUP_OBSERVER_ID,
780 nsnull,
781 NS_XPCOM_STARTUP_OBSERVER_ID);
782
783 return NS_OK;
784}
785
786
787static nsVoidArray* gExitRoutines;
788
789static void CallExitRoutines()
790{
791 if (!gExitRoutines)
792 return;
793
794 PRInt32 count = gExitRoutines->Count();
795 for (PRInt32 i = 0; i < count; i++) {
796 XPCOMExitRoutine func = (XPCOMExitRoutine) gExitRoutines->ElementAt(i);
797 func();
798 }
799 gExitRoutines->Clear();
800 delete gExitRoutines;
801 gExitRoutines = nsnull;
802}
803
804nsresult NS_COM
805NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority)
806{
807 // priority are not used right now. It will need to be implemented as more
808 // classes are moved into the glue library --dougt
809 if (!gExitRoutines) {
810 gExitRoutines = new nsVoidArray();
811 if (!gExitRoutines) {
812 NS_WARNING("Failed to allocate gExitRoutines");
813 return NS_ERROR_FAILURE;
814 }
815 }
816
817 PRBool okay = gExitRoutines->AppendElement((void*)exitRoutine);
818 return okay ? NS_OK : NS_ERROR_FAILURE;
819}
820
821nsresult NS_COM
822NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine)
823{
824 if (!gExitRoutines)
825 return NS_ERROR_FAILURE;
826
827 PRBool okay = gExitRoutines->RemoveElement((void*)exitRoutine);
828 return okay ? NS_OK : NS_ERROR_FAILURE;
829}
830
831
832//
833// NS_ShutdownXPCOM()
834//
835// The shutdown sequence for xpcom would be
836//
837// - Release the Global Service Manager
838// - Release all service instances held by the global service manager
839// - Release the Global Service Manager itself
840// - Release the Component Manager
841// - Release all factories cached by the Component Manager
842// - Unload Libraries
843// - Release Contractid Cache held by Component Manager
844// - Release dll abstraction held by Component Manager
845// - Release the Registry held by Component Manager
846// - Finally, release the component manager itself
847//
848nsresult NS_COM NS_ShutdownXPCOM(nsIServiceManager* servMgr)
849{
850
851 // Notify observers of xpcom shutting down
852 nsresult rv = NS_OK;
853 {
854 // Block it so that the COMPtr will get deleted before we hit
855 // servicemanager shutdown
856 nsCOMPtr<nsIObserverService> observerService =
857 do_GetService("@mozilla.org/observer-service;1", &rv);
858 if (NS_SUCCEEDED(rv))
859 {
860 nsCOMPtr<nsIServiceManager> mgr;
861 rv = NS_GetServiceManager(getter_AddRefs(mgr));
862 if (NS_SUCCEEDED(rv))
863 {
864 (void) observerService->NotifyObservers(mgr,
865 NS_XPCOM_SHUTDOWN_OBSERVER_ID,
866 nsnull);
867 }
868 }
869 }
870
871 // grab the event queue so that we can process events one last time before exiting
872 nsCOMPtr <nsIEventQueue> currentQ;
873 {
874 nsCOMPtr<nsIEventQueueService> eventQService =
875 do_GetService(kEventQueueServiceCID, &rv);
876
877 if (eventQService) {
878 eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(currentQ));
879 }
880 }
881 // XPCOM is officially in shutdown mode NOW
882 // Set this only after the observers have been notified as this
883 // will cause servicemanager to become inaccessible.
884 gXPCOMShuttingDown = PR_TRUE;
885
886#ifdef DEBUG_dougt
887 fprintf(stderr, "* * * * XPCOM shutdown. Access will be denied * * * * \n");
888#endif
889
890#if 0 /// @todo later
891 IPC_Shutdown();
892#endif
893
894 // We may have AddRef'd for the caller of NS_InitXPCOM, so release it
895 // here again:
896 NS_IF_RELEASE(servMgr);
897
898 // Shutdown global servicemanager
899 if (nsComponentManagerImpl::gComponentManager) {
900 nsComponentManagerImpl::gComponentManager->FreeServices();
901 }
902 nsServiceManager::ShutdownGlobalServiceManager(nsnull);
903
904 if (currentQ) {
905 currentQ->ProcessPendingEvents();
906 currentQ = 0;
907 }
908
909 nsProxyObjectManager::Shutdown();
910
911 // Release the directory service
912 NS_IF_RELEASE(gDirectoryService);
913
914 // Shutdown nsLocalFile string conversion
915 NS_ShutdownLocalFile();
916#ifdef XP_UNIX
917 NS_ShutdownNativeCharsetUtils();
918#endif
919
920 // Shutdown the timer thread and all timers that might still be alive before
921 // shutting down the component manager
922 nsTimerImpl::Shutdown();
923
924 CallExitRoutines();
925
926 // Shutdown xpcom. This will release all loaders and cause others holding
927 // a refcount to the component manager to release it.
928 if (nsComponentManagerImpl::gComponentManager) {
929 rv = (nsComponentManagerImpl::gComponentManager)->Shutdown();
930 NS_ASSERTION(NS_SUCCEEDED(rv), "Component Manager shutdown failed.");
931 } else
932 NS_WARNING("Component Manager was never created ...");
933
934 // Release our own singletons
935 // Do this _after_ shutting down the component manager, because the
936 // JS component loader will use XPConnect to call nsIModule::canUnload,
937 // and that will spin up the InterfaceInfoManager again -- bad mojo
938 XPTI_FreeInterfaceInfoManager();
939
940 // Finally, release the component manager last because it unloads the
941 // libraries:
942 if (nsComponentManagerImpl::gComponentManager) {
943 nsrefcnt cnt;
944 NS_RELEASE2(nsComponentManagerImpl::gComponentManager, cnt);
945 NS_WARN_IF_FALSE(cnt == 0, "Component Manager being held past XPCOM shutdown.");
946 }
947 nsComponentManagerImpl::gComponentManager = nsnull;
948
949#ifdef DEBUG
950 _FreeAutoLockStatics();
951#endif
952
953 ShutdownSpecialSystemDirectory();
954
955 EmptyEnumeratorImpl::Shutdown();
956 nsMemoryImpl::Shutdown();
957 NS_IF_RELEASE(gMemory);
958
959 nsThread::Shutdown();
960 NS_PurgeAtomTable();
961
962 NS_IF_RELEASE(gDebug);
963
964#ifdef NS_BUILD_REFCNT_LOGGING
965 nsTraceRefcntImpl::DumpStatistics();
966 nsTraceRefcntImpl::ResetStatistics();
967 nsTraceRefcntImpl::Shutdown();
968#endif
969
970#ifdef GC_LEAK_DETECTOR
971 // Shutdown the Leak detector.
972 NS_ShutdownLeakDetector();
973#endif
974
975 return NS_OK;
976}
977
978#define GET_FUNC(_tag, _decl, _name) \
979 functions->_tag = (_decl) PR_FindSymbol(xpcomLib, _name); \
980 if (!functions->_tag) goto end
981
982nsresult NS_COM PR_CALLBACK
983NS_GetFrozenFunctions(XPCOMFunctions *functions, const char* libraryPath)
984{
985 if (!functions)
986 return NS_ERROR_OUT_OF_MEMORY;
987
988 if (functions->version != XPCOM_GLUE_VERSION)
989 return NS_ERROR_FAILURE;
990
991 PRLibrary *xpcomLib = PR_LoadLibrary(libraryPath);
992 if (!xpcomLib)
993 return NS_ERROR_FAILURE;
994
995 nsresult rv = NS_ERROR_FAILURE;
996
997#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
998 GET_FUNC(init, InitFunc, "VBoxNsxpNS_InitXPCOM2");
999 GET_FUNC(shutdown, ShutdownFunc, "VBoxNsxpNS_ShutdownXPCOM");
1000 GET_FUNC(getServiceManager, GetServiceManagerFunc, "VBoxNsxpNS_GetServiceManager");
1001 GET_FUNC(getComponentManager, GetComponentManagerFunc, "VBoxNsxpNS_GetComponentManager");
1002 GET_FUNC(getComponentRegistrar, GetComponentRegistrarFunc, "VBoxNsxpNS_GetComponentRegistrar");
1003 GET_FUNC(getMemoryManager, GetMemoryManagerFunc, "VBoxNsxpNS_GetMemoryManager");
1004 GET_FUNC(newLocalFile, NewLocalFileFunc, "VBoxNsxpNS_NewLocalFile");
1005 GET_FUNC(newNativeLocalFile, NewNativeLocalFileFunc, "VBoxNsxpNS_NewNativeLocalFile");
1006 GET_FUNC(registerExitRoutine, RegisterXPCOMExitRoutineFunc, "VBoxNsxpNS_RegisterXPCOMExitRoutine");
1007 GET_FUNC(unregisterExitRoutine, UnregisterXPCOMExitRoutineFunc, "VBoxNsxpNS_UnregisterXPCOMExitRoutine");
1008#else /* !VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
1009 GET_FUNC(init, InitFunc, "NS_InitXPCOM2");
1010 GET_FUNC(shutdown, ShutdownFunc, "NS_ShutdownXPCOM");
1011 GET_FUNC(getServiceManager, GetServiceManagerFunc, "NS_GetServiceManager");
1012 GET_FUNC(getComponentManager, GetComponentManagerFunc, "NS_GetComponentManager");
1013 GET_FUNC(getComponentRegistrar, GetComponentRegistrarFunc, "NS_GetComponentRegistrar");
1014 GET_FUNC(getMemoryManager, GetMemoryManagerFunc, "NS_GetMemoryManager");
1015 GET_FUNC(newLocalFile, NewLocalFileFunc, "NS_NewLocalFile");
1016 GET_FUNC(newNativeLocalFile, NewNativeLocalFileFunc, "NS_NewNativeLocalFile");
1017 GET_FUNC(registerExitRoutine, RegisterXPCOMExitRoutineFunc, "NS_RegisterXPCOMExitRoutine");
1018 GET_FUNC(unregisterExitRoutine, UnregisterXPCOMExitRoutineFunc, "NS_UnregisterXPCOMExitRoutine");
1019#endif /* !VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
1020
1021 // these functions were added post 1.4 (need to check size of |functions|)
1022 if (functions->size > offsetof(XPCOMFunctions, getTraceRefcnt)) {
1023#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
1024 GET_FUNC(getDebug, GetDebugFunc, "VBoxNsxpNS_GetDebug");
1025 GET_FUNC(getTraceRefcnt, GetTraceRefcntFunc, "VBoxNsxpNS_GetTraceRefcnt");
1026#else /* !VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
1027 GET_FUNC(getDebug, GetDebugFunc, "NS_GetDebug");
1028 GET_FUNC(getTraceRefcnt, GetTraceRefcntFunc, "NS_GetTraceRefcnt");
1029#endif /* !VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
1030 }
1031
1032 // these functions were added post 1.6 (need to check size of |functions|)
1033 if (functions->size > offsetof(XPCOMFunctions, cstringCloneData)) {
1034#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
1035 GET_FUNC(stringContainerInit, StringContainerInitFunc, "VBoxNsxpNS_StringContainerInit");
1036 GET_FUNC(stringContainerFinish, StringContainerFinishFunc, "VBoxNsxpNS_StringContainerFinish");
1037 GET_FUNC(stringGetData, StringGetDataFunc, "VBoxNsxpNS_StringGetData");
1038 GET_FUNC(stringSetData, StringSetDataFunc, "VBoxNsxpNS_StringSetData");
1039 GET_FUNC(stringSetDataRange, StringSetDataRangeFunc, "VBoxNsxpNS_StringSetDataRange");
1040 GET_FUNC(stringCopy, StringCopyFunc, "VBoxNsxpNS_StringCopy");
1041 GET_FUNC(cstringContainerInit, CStringContainerInitFunc, "VBoxNsxpNS_CStringContainerInit");
1042 GET_FUNC(cstringContainerFinish, CStringContainerFinishFunc, "VBoxNsxpNS_CStringContainerFinish");
1043 GET_FUNC(cstringGetData, CStringGetDataFunc, "VBoxNsxpNS_CStringGetData");
1044 GET_FUNC(cstringSetData, CStringSetDataFunc, "VBoxNsxpNS_CStringSetData");
1045 GET_FUNC(cstringSetDataRange, CStringSetDataRangeFunc, "VBoxNsxpNS_CStringSetDataRange");
1046 GET_FUNC(cstringCopy, CStringCopyFunc, "VBoxNsxpNS_CStringCopy");
1047 GET_FUNC(cstringToUTF16, CStringToUTF16, "VBoxNsxpNS_CStringToUTF16");
1048 GET_FUNC(utf16ToCString, UTF16ToCString, "VBoxNsxpNS_UTF16ToCString");
1049 GET_FUNC(stringCloneData, StringCloneDataFunc, "VBoxNsxpNS_StringCloneData");
1050 GET_FUNC(cstringCloneData, CStringCloneDataFunc, "VBoxNsxpNS_CStringCloneData");
1051#else /* !VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
1052 GET_FUNC(stringContainerInit, StringContainerInitFunc, "NS_StringContainerInit");
1053 GET_FUNC(stringContainerFinish, StringContainerFinishFunc, "NS_StringContainerFinish");
1054 GET_FUNC(stringGetData, StringGetDataFunc, "NS_StringGetData");
1055 GET_FUNC(stringSetData, StringSetDataFunc, "NS_StringSetData");
1056 GET_FUNC(stringSetDataRange, StringSetDataRangeFunc, "NS_StringSetDataRange");
1057 GET_FUNC(stringCopy, StringCopyFunc, "NS_StringCopy");
1058 GET_FUNC(cstringContainerInit, CStringContainerInitFunc, "NS_CStringContainerInit");
1059 GET_FUNC(cstringContainerFinish, CStringContainerFinishFunc, "NS_CStringContainerFinish");
1060 GET_FUNC(cstringGetData, CStringGetDataFunc, "NS_CStringGetData");
1061 GET_FUNC(cstringSetData, CStringSetDataFunc, "NS_CStringSetData");
1062 GET_FUNC(cstringSetDataRange, CStringSetDataRangeFunc, "NS_CStringSetDataRange");
1063 GET_FUNC(cstringCopy, CStringCopyFunc, "NS_CStringCopy");
1064 GET_FUNC(cstringToUTF16, CStringToUTF16, "NS_CStringToUTF16");
1065 GET_FUNC(utf16ToCString, UTF16ToCString, "NS_UTF16ToCString");
1066 GET_FUNC(stringCloneData, StringCloneDataFunc, "NS_StringCloneData");
1067 GET_FUNC(cstringCloneData, CStringCloneDataFunc, "NS_CStringCloneData");
1068#endif /* !VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
1069 }
1070
1071 rv = NS_OK;
1072end:
1073 PR_UnloadLibrary(xpcomLib); // the library is refcnt'ed above by the caller.
1074 return rv;
1075}
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