VirtualBox

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

Last change on this file since 53433 was 28992, checked in by vboxsync, 15 years ago

xpcom: spaces, temp hack to fetch proxy release into the image on darwin - right fix is to add all .a into final library unconditionally, like done on Linux and Solaris

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