Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions
nsXPCOM.h File Reference
#include "nscore.h"
#include "nsXPCOMCID.h"

Go to the source code of this file.

Classes

struct  nsStaticModuleInfo
 Some clients of XPCOM have statically linked components (not dynamically loaded component DLLs), which can be passed to NS_InitXPCOM3 using this structure. More...

Defines

#define XPCOM_DIRECTORY_PROVIDER_CATEGORY   "xpcom-directory-providers"
 Categories (in the category manager service) used by XPCOM:
#define NS_XPCOM_STARTUP_CATEGORY   "xpcom-startup"
 A category which is read after component registration but before NS_InitXPCOM returns.
#define NS_XPCOM_STARTUP_OBSERVER_ID   "xpcom-startup"
 Observer topics (in the observer service) used by XPCOM:
#define NS_XPCOM_SHUTDOWN_OBSERVER_ID   "xpcom-shutdown"
 At XPCOM shutdown, this topic is notified.
#define NS_XPCOM_CATEGORY_ENTRY_ADDED_OBSERVER_ID   "xpcom-category-entry-added"
 This topic is notified when an entry was added to a category in the category manager.
#define NS_XPCOM_CATEGORY_ENTRY_REMOVED_OBSERVER_ID   "xpcom-category-entry-removed"
 This topic is notified when an entry was removed from a category in the category manager.
#define NS_XPCOM_CATEGORY_CLEARED_OBSERVER_ID   "xpcom-category-cleared"
 This topic is notified when an a category was cleared in the category manager.

Typedefs

typedef nsIFilelocation
typedef nsIFile nsIModule ** return_cobj

Functions

typedef nsresult (PR_CALLBACK *nsGetModuleProc)(nsIComponentManager *aCompMgr
 Every XPCOM component implements this function signature, which is the only entrypoint XPCOM uses to the function.
NS_COM nsresult NS_InitXPCOM2 (nsIServiceManager **result, nsIFile *binDirectory, nsIDirectoryServiceProvider *appFileLocationProvider)
 Initialises XPCOM.
NS_COM nsresult NS_InitXPCOM3 (nsIServiceManager **result, nsIFile *binDirectory, nsIDirectoryServiceProvider *appFileLocationProvider, nsStaticModuleInfo const *staticComponents, PRUint32 componentCount)
 Initialises XPCOM with static components.
NS_COM nsresult NS_ShutdownXPCOM (nsIServiceManager *servMgr)
 Shutdown XPCOM.
NS_COM nsresult NS_GetServiceManager (nsIServiceManager **result)
 Public Method to access to the service manager.
NS_COM nsresult NS_GetComponentManager (nsIComponentManager **result)
 Public Method to access to the component manager.
NS_COM nsresult NS_GetComponentRegistrar (nsIComponentRegistrar **result)
 Public Method to access to the component registration manager.
NS_COM nsresult NS_GetMemoryManager (nsIMemory **result)
 Public Method to access to the memory manager.
NS_COM nsresult NS_NewLocalFile (const nsAString &path, PRBool followLinks, nsILocalFile **result)
 Public Method to create an instance of a nsILocalFile.
NS_COM nsresult NS_NewNativeLocalFile (const nsACString &path, PRBool followLinks, nsILocalFile **result)
NS_COM voidNS_Alloc (PRSize size)
 Allocates a block of memory of a particular size.
NS_COM voidNS_Realloc (void *ptr, PRSize size)
 Reallocates a block of memory to a new size.
NS_COM void NS_Free (void *ptr)
 Frees a block of memory.
NS_COM nsresult NS_GetDebug (nsIDebug **result)
NS_COM nsresult NS_GetTraceRefcnt (nsITraceRefcnt **result)

Class Documentation

struct nsStaticModuleInfo

Some clients of XPCOM have statically linked components (not dynamically loaded component DLLs), which can be passed to NS_InitXPCOM3 using this structure.

FROZEN

Definition at line 133 of file nsXPCOM.h.

Class Members
nsGetModuleProc getModule
const char * name

Define Documentation

#define NS_XPCOM_CATEGORY_CLEARED_OBSERVER_ID   "xpcom-category-cleared"

This topic is notified when an a category was cleared in the category manager.

The subject of the notification will be the category manager, and the data will be the name of the cleared category. The notification will occur on the main thread.

FROZEN

Definition at line 414 of file nsXPCOM.h.

This topic is notified when an entry was added to a category in the category manager.

The subject of the notification will be the name of the added entry as an nsISupportsCString, and the data will be the name of the category. The notification will occur on the main thread.

FROZEN

Definition at line 392 of file nsXPCOM.h.

This topic is notified when an entry was removed from a category in the category manager.

The subject of the notification will be the name of the removed entry as an nsISupportsCString, and the data will be the name of the category. The notification will occur on the main thread.

FROZEN

Definition at line 403 of file nsXPCOM.h.

At XPCOM shutdown, this topic is notified.

All components must release any interface references to objects in other modules when this topic is notified.

FROZEN

Definition at line 382 of file nsXPCOM.h.

#define NS_XPCOM_STARTUP_CATEGORY   "xpcom-startup"

A category which is read after component registration but before NS_InitXPCOM returns.

Each category entry is treated as the contractID of a service: each service is instantiated, and if it implements nsIObserver the nsIObserver.observe method is called with the "xpcom-startup" topic.

FROZEN

Definition at line 358 of file nsXPCOM.h.

#define NS_XPCOM_STARTUP_OBSERVER_ID   "xpcom-startup"

Observer topics (in the observer service) used by XPCOM:

At XPCOM startup after component registration is complete, the following topic is notified. In order to receive this notification, component must register their contract ID in the category manager,

See also:
NS_XPCOM_STARTUP_CATEGORY FROZEN

Definition at line 373 of file nsXPCOM.h.

Categories (in the category manager service) used by XPCOM:

A category which is read after component registration but before the "xpcom-startup" notifications. Each category entry is treated as the contract ID of a service which implements nsIDirectoryServiceProvider. Each directory service provider is installed in the global directory service.

FROZEN

Definition at line 348 of file nsXPCOM.h.


Typedef Documentation

typedef nsIFile* location

Definition at line 84 of file nsXPCOM.h.

Definition at line 84 of file nsXPCOM.h.


Function Documentation

NS_COM void* NS_Alloc ( PRSize  size)

Allocates a block of memory of a particular size.

If the memory cannot be allocated (because of an out-of-memory condition), null is returned.

FROZEN

Parameters:
sizeThe size of the block to allocate
Returns:
The block of memory
Note:
This function is thread-safe.

Definition at line 333 of file nsMemoryImpl.cpp.

{
    NS_ASSERTION(size, "NS_Alloc of size 0");

    void* result = MALLOC1(size);
    if (! result) {
        // Request an asynchronous flush
        sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
    }
    return result;
}

Here is the caller graph for this function:

NS_COM void NS_Free ( void ptr)

Frees a block of memory.

Null is a permissible value, in which case no action is taken.

FROZEN

Parameters:
ptrThe block of memory to free. This block must originally have been allocated by NS_Alloc or NS_Realloc
Note:
This function is thread-safe.

Definition at line 358 of file nsMemoryImpl.cpp.

{
    PR_Free(ptr);
}

Here is the caller graph for this function:

Public Method to access to the component manager.

FROZEN

Parameters:
resultInterface pointer to the service
Returns:
NS_OK for success; other error codes indicate a failure during initialisation.

Definition at line 3707 of file nsComponentManager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Public Method to access to the component registration manager.

FROZEN

Parameters:
resultInterface pointer to the service
Returns:
NS_OK for success; other error codes indicate a failure during initialisation.

Definition at line 3745 of file nsComponentManager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 429 of file nsXPComInit.cpp.

{
    nsresult rv = NS_OK;
    if (!gDebug)
    {
        rv = nsDebugImpl::Create(nsnull, 
                                 NS_GET_IID(nsIDebug), 
                                 (void**)&gDebug);
    }
    NS_IF_ADDREF(*result = gDebug);
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Public Method to access to the memory manager.

See nsIMemory

FROZEN

Parameters:
resultInterface pointer to the memory manager
Returns:
NS_OK for success; other error codes indicate a failure during initialisation.

Definition at line 475 of file nsMemoryImpl.cpp.

{
    return sGlobalMemory.QueryInterface(NS_GET_IID(nsIMemory), (void**) result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Public Method to access to the service manager.

FROZEN

Parameters:
resultInterface pointer to the service manager
Returns:
NS_OK for success; other error codes indicate a failure during initialisation.

Definition at line 3724 of file nsComponentManager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 447 of file nsXPComInit.cpp.

{
#ifdef NS_BUILD_REFCNT_LOGGING
    nsresult rv = NS_OK;
    if (!gTraceRefcnt)
    {
        rv = nsTraceRefcntImpl::Create(nsnull, 
                                       NS_GET_IID(nsITraceRefcnt), 
                                       (void**)&gTraceRefcnt);
    }
    NS_IF_ADDREF(*result = gTraceRefcnt);
    return rv;
#else
    return NS_ERROR_NOT_INITIALIZED;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_COM nsresult NS_InitXPCOM2 ( nsIServiceManager **  result,
nsIFile binDirectory,
nsIDirectoryServiceProvider appFileLocationProvider 
)

Initialises XPCOM.

You must call one of the NS_InitXPCOM methods before proceeding to use xpcom. The one exception is that you may call NS_NewLocalFile to create a nsIFile.

FROZEN

Note:
Use NS_NewLocalFile or NS_NewNativeLocalFile to create the file object you supply as the bin directory path in this call. The function may be safely called before the rest of XPCOM or embedding has been initialised.
Parameters:
resultThe service manager. You may pass null.
binDirectoryThe directory containing the component registry and runtime libraries; or use nsnull to use the working directory.
appFileLocationProviderThe object to be used by Gecko that specifies to Gecko where to find profiles, the component registry preferences and so on; or use nsnull for the default behaviour.
See also:
NS_NewLocalFile
nsILocalFile
nsIDirectoryServiceProvider
Returns:
NS_OK for success; NS_ERROR_NOT_INITIALIZED if static globals were not initialized, which can happen if XPCOM is reloaded, but did not completly shutdown. Other error codes indicate a failure during initialisation.

Definition at line 470 of file nsXPComInit.cpp.

{
    return NS_InitXPCOM3(result, binDirectory, appFileLocationProvider, nsnull, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_COM nsresult NS_InitXPCOM3 ( nsIServiceManager **  result,
nsIFile binDirectory,
nsIDirectoryServiceProvider appFileLocationProvider,
nsStaticModuleInfo const staticComponents,
PRUint32  componentCount 
)

Initialises XPCOM with static components.

You must call one of the NS_InitXPCOM methods before proceeding to use xpcom. The one exception is that you may call NS_NewLocalFile to create a nsIFile.

FROZEN

Note:
Use NS_NewLocalFile or NS_NewNativeLocalFile to create the file object you supply as the bin directory path in this call. The function may be safely called before the rest of XPCOM or embedding has been initialised.
Parameters:
resultThe service manager. You may pass null.
binDirectoryThe directory containing the component registry and runtime libraries; or use nsnull to use the working directory.
appFileLocationProviderThe object to be used by Gecko that specifies to Gecko where to find profiles, the component registry preferences and so on; or use nsnull for the default behaviour.
staticComponentsAn array of static components. Passing null causes default (builtin) components to be registered, if present.
componentCountNumber of elements in staticComponents
See also:
NS_NewLocalFile
nsILocalFile
nsIDirectoryServiceProvider
XRE_GetStaticComponents
Returns:
NS_OK for success; NS_ERROR_NOT_INITIALIZED if static globals were not initialized, which can happen if XPCOM is reloaded, but did not completly shutdown. Other error codes indicate a failure during initialisation.

Definition at line 477 of file nsXPComInit.cpp.

{
    nsresult rv = NS_OK;

#ifdef MOZ_ENABLE_LIBXUL
    if (!staticComponents) {
        staticComponents = kPStaticModules;
        componentCount = kStaticModuleCount;
    }
#endif

     // We are not shutting down
    gXPCOMShuttingDown = PR_FALSE;

#ifdef NS_BUILD_REFCNT_LOGGING
    nsTraceRefcntImpl::Startup();
#endif

    // Establish the main thread here.
    rv = nsIThread::SetMainThread();
    if (NS_FAILED(rv)) return rv;

    // Set up the timer globals/timer thread
    rv = nsTimerImpl::Startup();
    NS_ENSURE_SUCCESS(rv, rv);

    // Startup the memory manager
    rv = nsMemoryImpl::Startup();
    if (NS_FAILED(rv)) return rv;

#ifndef WINCE
    // If the locale hasn't already been setup by our embedder,
    // get us out of the "C" locale and into the system 
    if (strcmp(setlocale(LC_ALL, NULL), "C") == 0)
        setlocale(LC_ALL, "");
#endif

#if defined(XP_UNIX) || defined(XP_OS2)
    NS_StartupNativeCharsetUtils();
#endif
    NS_StartupLocalFile();

    StartupSpecialSystemDirectory();

    rv = nsDirectoryService::RealInit();
    if (NS_FAILED(rv))
        return rv;

    // Create the Component/Service Manager
    nsComponentManagerImpl *compMgr = NULL;

    if (nsComponentManagerImpl::gComponentManager == NULL)
    {
        compMgr = new nsComponentManagerImpl();
        if (compMgr == NULL)
            return NS_ERROR_OUT_OF_MEMORY;
        NS_ADDREF(compMgr);
        
        nsCOMPtr<nsIFile> xpcomLib;
                
        PRBool value;
        if (binDirectory)
        {
            rv = binDirectory->IsDirectory(&value);

            if (NS_SUCCEEDED(rv) && value) {
                nsDirectoryService::gService->Set(NS_XPCOM_INIT_CURRENT_PROCESS_DIR, binDirectory);
                binDirectory->Clone(getter_AddRefs(xpcomLib));
            }
        }
        else {
            nsDirectoryService::gService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, 
                                              NS_GET_IID(nsIFile), 
                                              getter_AddRefs(xpcomLib));
        }

        if (xpcomLib) {
            xpcomLib->AppendNative(nsDependentCString(XPCOM_DLL));
            nsDirectoryService::gService->Set(NS_XPCOM_LIBRARY_FILE, xpcomLib);
        }
        
        if (appFileLocationProvider) {
            rv = nsDirectoryService::gService->RegisterProvider(appFileLocationProvider);
            if (NS_FAILED(rv)) return rv;
        }

        rv = compMgr->Init(staticComponents, componentCount);
        if (NS_FAILED(rv))
        {
            NS_RELEASE(compMgr);
            return rv;
        }

        nsComponentManagerImpl::gComponentManager = compMgr;

        if (result) {
            nsIServiceManager *serviceManager =
                NS_STATIC_CAST(nsIServiceManager*, compMgr);

            NS_ADDREF(*result = serviceManager);
        }
    }

    nsCOMPtr<nsIMemory> memory;
    NS_GetMemoryManager(getter_AddRefs(memory));
    // dougt - these calls will be moved into a new interface when nsIComponentManager is frozen.
    rv = compMgr->RegisterService(kMemoryCID, memory);
    if (NS_FAILED(rv)) return rv;

    rv = compMgr->RegisterService(kComponentManagerCID, NS_STATIC_CAST(nsIComponentManager*, compMgr));
    if (NS_FAILED(rv)) return rv;

#ifdef GC_LEAK_DETECTOR
  rv = NS_InitLeakDetector();
    if (NS_FAILED(rv)) return rv;
#endif

    // 2. Register the global services with the component manager so that
    //    clients can create new objects.

    // Category Manager
    {
      nsCOMPtr<nsIFactory> categoryManagerFactory;
      if ( NS_FAILED(rv = NS_CategoryManagerGetFactory(getter_AddRefs(categoryManagerFactory))) )
        return rv;

      NS_DEFINE_CID(kCategoryManagerCID, NS_CATEGORYMANAGER_CID);

      rv = compMgr->RegisterFactory(kCategoryManagerCID,
                                    NS_CATEGORYMANAGER_CLASSNAME,
                                    NS_CATEGORYMANAGER_CONTRACTID,
                                    categoryManagerFactory,
                                    PR_TRUE);
      if ( NS_FAILED(rv) ) return rv;
    }

    // what I want to do here is QI for a Component Registration Manager.  Since this
    // has not been invented yet, QI to the obsolete manager.  Kids, don't do this at home.
    nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(
        NS_STATIC_CAST(nsIComponentManager*,compMgr), &rv);
    if (registrar) {
        for (int i = 0; i < components_length; i++)
            RegisterGenericFactory(registrar, &components[i]);
    }
    rv = nsComponentManagerImpl::gComponentManager->ReadPersistentRegistry();
#ifdef DEBUG    
    if (NS_FAILED(rv)) {
        printf("No Persistent Registry Found.\n");        
    }
#endif

    if ( NS_FAILED(rv) || CheckUpdateFile()) {
        // if we find no persistent registry, we will try to autoregister
        // the default components directory.
        nsComponentManagerImpl::gComponentManager->AutoRegister(nsnull);

        // If the application is using a GRE, then, 
        // auto register components in the GRE directory as well.
        //
        // The application indicates that it's using an GRE by
        // returning a valid nsIFile when queried (via appFileLocProvider)
        // for the NS_GRE_DIR atom as shown below
        //

        if ( appFileLocationProvider ) {
            nsCOMPtr<nsIFile> greDir;
            PRBool persistent = PR_TRUE;

            appFileLocationProvider->GetFile(NS_GRE_DIR, &persistent, getter_AddRefs(greDir));

            if (greDir) {
#ifdef DEBUG_dougt
                printf("start - Registering GRE components\n");
#endif
                rv = nsDirectoryService::gService->Get(NS_GRE_COMPONENT_DIR,
                                                       NS_GET_IID(nsIFile),
                                                       getter_AddRefs(greDir));
                if (NS_FAILED(rv)) {
                    NS_ERROR("Could not get GRE components directory!");
                    return rv;
                }

                // If the GRE contains any loaders, we want to know about it so that we can cause another
                // autoregistration of the applications component directory.
                int loaderCount = nsComponentManagerImpl::gComponentManager->GetLoaderCount();
                rv = nsComponentManagerImpl::gComponentManager->AutoRegister(greDir);
                
                if (loaderCount != nsComponentManagerImpl::gComponentManager->GetLoaderCount()) 
                    nsComponentManagerImpl::gComponentManager->AutoRegisterNonNativeComponents(nsnull);        

#ifdef DEBUG_dougt
                printf("end - Registering GRE components\n");
#endif          
                if (NS_FAILED(rv)) {
                    NS_ERROR("Could not AutoRegister GRE components");
                    return rv;
                }
            }
        }

        //
        // If additional component directories have been specified, then
        // register them as well.
        //

        nsCOMPtr<nsISimpleEnumerator> dirList;
        nsDirectoryService::gService->Get(NS_XPCOM_COMPONENT_DIR_LIST,
                                          NS_GET_IID(nsISimpleEnumerator),
                                          getter_AddRefs(dirList));
        if (dirList) {
            PRBool hasMore;
            while (NS_SUCCEEDED(dirList->HasMoreElements(&hasMore)) && hasMore) {
                nsCOMPtr<nsISupports> elem;
                dirList->GetNext(getter_AddRefs(elem));
                if (elem) {
                    nsCOMPtr<nsIFile> dir = do_QueryInterface(elem);
                    if (dir)
                        nsComponentManagerImpl::gComponentManager->AutoRegister(dir);

                    // XXX should we worry about new component loaders being
                    // XXX defined by this process?
                }
            }
        }


        // Make sure the compreg file's mod time is current.
        nsCOMPtr<nsIFile> compregFile;
        rv = nsDirectoryService::gService->Get(NS_XPCOM_COMPONENT_REGISTRY_FILE,
                                               NS_GET_IID(nsIFile),
                                               getter_AddRefs(compregFile));
        compregFile->SetLastModifiedTime(PR_Now() / 1000);
    }
    
    // Pay the cost at startup time of starting this singleton.
    nsIInterfaceInfoManager* iim = XPTI_GetInterfaceInfoManager();
    NS_IF_RELEASE(iim);

    // After autoreg, but before we actually instantiate any components,
    // add any services listed in the "xpcom-directory-providers" category
    // to the directory service.
    nsDirectoryService::gService->RegisterCategoryProviders();

    // Notify observers of xpcom autoregistration start
    NS_CreateServicesFromCategory(NS_XPCOM_STARTUP_OBSERVER_ID, 
                                  nsnull,
                                  NS_XPCOM_STARTUP_OBSERVER_ID);
    
    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_COM nsresult NS_NewLocalFile ( const nsAString &  path,
PRBool  followLinks,
nsILocalFile **  result 
)

Public Method to create an instance of a nsILocalFile.

This function may be called prior to NS_InitXPCOM.

FROZEN

Parameters:
pathA string which specifies a full file path to a location. Relative paths will be treated as an error (NS_ERROR_FILE_UNRECOGNIZED_PATH). |NS_NewNativeLocalFile|'s path must be in the filesystem charset.
followLinksThis attribute will determine if the nsLocalFile will auto resolve symbolic links. By default, this value will be false on all non unix systems. On unix, this attribute is effectively a noop.
resultInterface pointer to a new instance of an nsILocalFile
Returns:
NS_OK for success; other error codes indicate a failure.

Definition at line 209 of file nsXPCOMGlue.cpp.

{
    if (!xpcomFunctions.newLocalFile)
        return NS_ERROR_NOT_INITIALIZED;
    return xpcomFunctions.newLocalFile(path, followLinks, result);
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_COM nsresult NS_NewNativeLocalFile ( const nsACString &  path,
PRBool  followLinks,
nsILocalFile **  result 
)

Definition at line 217 of file nsXPCOMGlue.cpp.

Here is the call graph for this function:

NS_COM void* NS_Realloc ( void ptr,
PRSize  size 
)

Reallocates a block of memory to a new size.

FROZEN

Parameters:
ptrThe block of memory to reallocate. This block must originally have been allocated by NS_Alloc or NS_Realloc
sizeThe new size. If 0, frees the block like NS_Free
Returns:
The reallocated block of memory
Note:
This function is thread-safe.

If ptr is null, this function behaves like NS_Alloc. If s is the size of the block to which ptr points, the first min(s, size) bytes of ptr's block are copied to the new block. If the allocation succeeds, ptr is freed and a pointer to the new block is returned. If the allocation fails, ptr is not freed and null is returned. The returned value may be the same as ptr.

Definition at line 346 of file nsMemoryImpl.cpp.

{
    NS_ASSERTION(size, "NS_Realloc of size 0");
    void* result = REALLOC1(ptr, size);
    if (! result) {
        // Request an asynchronous flush
        sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), PR_FALSE);
    }
    return result;
}

Shutdown XPCOM.

You must call this method after you are finished using xpcom.

FROZEN

Parameters:
servMgrThe service manager which was returned by NS_InitXPCOM. This will release servMgr. You may pass null.
Returns:
NS_OK for success; other error codes indicate a failure during initialisation.

Definition at line 794 of file nsXPComInit.cpp.

{

    // Notify observers of xpcom shutting down
    nsresult rv = NS_OK;
    {
        // Block it so that the COMPtr will get deleted before we hit
        // servicemanager shutdown
        nsCOMPtr<nsIObserverService> observerService =
                 do_GetService("@mozilla.org/observer-service;1", &rv);
        if (NS_SUCCEEDED(rv))
        {
            nsCOMPtr<nsIServiceManager> mgr;
            rv = NS_GetServiceManager(getter_AddRefs(mgr));
            if (NS_SUCCEEDED(rv))
            {
                (void) observerService->NotifyObservers(mgr,
                                                        NS_XPCOM_SHUTDOWN_OBSERVER_ID,
                                                        nsnull);
            }
        }
    }

    // grab the event queue so that we can process events one last time before exiting
    nsCOMPtr <nsIEventQueue> currentQ;
    {
        nsCOMPtr<nsIEventQueueService> eventQService =
                 do_GetService(kEventQueueServiceCID, &rv);

        if (eventQService) {
            eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(currentQ));
        }
    }
    // XPCOM is officially in shutdown mode NOW
    // Set this only after the observers have been notified as this
    // will cause servicemanager to become inaccessible.
    gXPCOMShuttingDown = PR_TRUE;

#ifdef DEBUG_dougt
    fprintf(stderr, "* * * * XPCOM shutdown. Access will be denied * * * * \n");
#endif
    // We may have AddRef'd for the caller of NS_InitXPCOM, so release it
    // here again:
    NS_IF_RELEASE(servMgr);

    // Shutdown global servicemanager
    if (nsComponentManagerImpl::gComponentManager) {
        nsComponentManagerImpl::gComponentManager->FreeServices();
    }

    if (currentQ) {
        currentQ->ProcessPendingEvents();
        currentQ = 0;
    }
    
    nsProxyObjectManager::Shutdown();

    // Release the directory service
    NS_IF_RELEASE(nsDirectoryService::gService);

    // Shutdown nsLocalFile string conversion
    NS_ShutdownLocalFile();
#ifdef XP_UNIX
    NS_ShutdownNativeCharsetUtils();
#endif

    // Shutdown the timer thread and all timers that might still be alive before
    // shutting down the component manager
    nsTimerImpl::Shutdown();

    CallExitRoutines();

    // Shutdown xpcom. This will release all loaders and cause others holding
    // a refcount to the component manager to release it.
    if (nsComponentManagerImpl::gComponentManager) {
        rv = (nsComponentManagerImpl::gComponentManager)->Shutdown();
        NS_ASSERTION(NS_SUCCEEDED(rv), "Component Manager shutdown failed.");
    } else
        NS_WARNING("Component Manager was never created ...");

    // Release our own singletons
    // Do this _after_ shutting down the component manager, because the
    // JS component loader will use XPConnect to call nsIModule::canUnload,
    // and that will spin up the InterfaceInfoManager again -- bad mojo
    XPTI_FreeInterfaceInfoManager();

    // Finally, release the component manager last because it unloads the
    // libraries:
    if (nsComponentManagerImpl::gComponentManager) {
      nsrefcnt cnt;
      NS_RELEASE2(nsComponentManagerImpl::gComponentManager, cnt);
      NS_WARN_IF_FALSE(cnt == 0, "Component Manager being held past XPCOM shutdown.");
    }
    nsComponentManagerImpl::gComponentManager = nsnull;

#ifdef DEBUG
    _FreeAutoLockStatics();
#endif

    ShutdownSpecialSystemDirectory();

    EmptyEnumeratorImpl::Shutdown();
    nsMemoryImpl::Shutdown();

    nsThread::Shutdown();
    NS_PurgeAtomTable();

    NS_IF_RELEASE(gDebug);

#ifdef NS_BUILD_REFCNT_LOGGING
    nsTraceRefcntImpl::DumpStatistics();
    nsTraceRefcntImpl::ResetStatistics();
    nsTraceRefcntImpl::Shutdown();
#endif

#ifdef GC_LEAK_DETECTOR
    // Shutdown the Leak detector.
    NS_ShutdownLeakDetector();
#endif

    return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

typedef nsresult ( PR_CALLBACK nsGetModuleProc)

Every XPCOM component implements this function signature, which is the only entrypoint XPCOM uses to the function.

Module Callbacks.

FROZEN