зеркало из https://github.com/mozilla/pjs.git
Bug 325229 part 2 - Stub out the old exitroutine functions which are fatally flawed, r=darin
This commit is contained in:
Родитель
5e55605551
Коммит
10ed2f1d36
|
@ -39,12 +39,6 @@
|
|||
#ifndef nsXPComPrivate_h__
|
||||
#define nsXPComPrivate_h__
|
||||
|
||||
// Map frozen functions to private symbol names if not using strict API.
|
||||
#ifdef MOZILLA_INTERNAL_API
|
||||
# define NS_RegisterXPCOMExitRoutine NS_RegisterXPCOMExitRoutine_P
|
||||
# define NS_UnregisterXPCOMExitRoutine NS_UnregisterXPCOMExitRoutine_P
|
||||
#endif
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "nsStringAPI.h"
|
||||
|
@ -65,36 +59,6 @@ class nsIComponentLoader;
|
|||
*/
|
||||
#define NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID "xpcom-shutdown-loaders"
|
||||
|
||||
/**
|
||||
* Private Method to register an exit routine. This method
|
||||
* allows you to setup a callback that will be called from
|
||||
* the NS_ShutdownXPCOM function after all services and
|
||||
* components have gone away.
|
||||
*
|
||||
* This API is for the exclusive use of the xpcom glue library.
|
||||
*
|
||||
* Note that these APIs are NOT threadsafe and must be called on the
|
||||
* main thread.
|
||||
*
|
||||
* @status FROZEN
|
||||
* @param exitRoutine pointer to user defined callback function
|
||||
* of type XPCOMExitRoutine.
|
||||
* @param priority higher priorities are called before lower
|
||||
* priorities.
|
||||
*
|
||||
* @return NS_OK for success;
|
||||
* other error codes indicate a failure.
|
||||
*
|
||||
*/
|
||||
typedef NS_CALLBACK(XPCOMExitRoutine)(void);
|
||||
|
||||
XPCOM_API(nsresult)
|
||||
NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority);
|
||||
|
||||
XPCOM_API(nsresult)
|
||||
NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine);
|
||||
|
||||
|
||||
// PUBLIC
|
||||
typedef nsresult (* InitFunc)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider);
|
||||
typedef nsresult (* Init3Func)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider, nsStaticModuleInfo const *staticComponents, PRUint32 componentCount);
|
||||
|
@ -146,7 +110,9 @@ typedef void (* LogReleaseFunc)(void*, nsrefcnt, const char*);
|
|||
typedef void (* LogCtorFunc)(void*, const char*, PRUint32);
|
||||
typedef void (* LogCOMPtrFunc)(void*, nsISupports*);
|
||||
|
||||
// PRIVATE
|
||||
// PRIVATE AND DEPRECATED
|
||||
typedef NS_CALLBACK(XPCOMExitRoutine)(void);
|
||||
|
||||
typedef nsresult (* RegisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine, PRUint32 priority);
|
||||
typedef nsresult (* UnregisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine);
|
||||
|
||||
|
|
|
@ -627,51 +627,6 @@ NS_InitXPCOM3(nsIServiceManager* *result,
|
|||
}
|
||||
|
||||
|
||||
static nsVoidArray* gExitRoutines;
|
||||
|
||||
static void CallExitRoutines()
|
||||
{
|
||||
if (!gExitRoutines)
|
||||
return;
|
||||
|
||||
PRInt32 count = gExitRoutines->Count();
|
||||
for (PRInt32 i = 0; i < count; i++) {
|
||||
XPCOMExitRoutine func = (XPCOMExitRoutine) gExitRoutines->ElementAt(i);
|
||||
func();
|
||||
}
|
||||
gExitRoutines->Clear();
|
||||
delete gExitRoutines;
|
||||
gExitRoutines = nsnull;
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority)
|
||||
{
|
||||
// priority are not used right now. It will need to be implemented as more
|
||||
// classes are moved into the glue library --dougt
|
||||
if (!gExitRoutines) {
|
||||
gExitRoutines = new nsVoidArray();
|
||||
if (!gExitRoutines) {
|
||||
NS_WARNING("Failed to allocate gExitRoutines");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool okay = gExitRoutines->AppendElement((void*)exitRoutine);
|
||||
return okay ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine)
|
||||
{
|
||||
if (!gExitRoutines)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool okay = gExitRoutines->RemoveElement((void*)exitRoutine);
|
||||
return okay ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NS_ShutdownXPCOM()
|
||||
//
|
||||
|
@ -806,8 +761,6 @@ NS_ShutdownXPCOM(nsIServiceManager* servMgr)
|
|||
// 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) {
|
||||
|
|
|
@ -206,22 +206,6 @@ NS_NewNativeLocalFile(const nsACString &path, PRBool followLinks, nsILocalFile*
|
|||
return xpcomFunctions.newNativeLocalFile(path, followLinks, result);
|
||||
}
|
||||
|
||||
XPCOM_API(nsresult)
|
||||
NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority)
|
||||
{
|
||||
if (!xpcomFunctions.registerExitRoutine)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
return xpcomFunctions.registerExitRoutine(exitRoutine, priority);
|
||||
}
|
||||
|
||||
XPCOM_API(nsresult)
|
||||
NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine)
|
||||
{
|
||||
if (!xpcomFunctions.unregisterExitRoutine)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
return xpcomFunctions.unregisterExitRoutine(exitRoutine);
|
||||
}
|
||||
|
||||
XPCOM_API(nsresult)
|
||||
NS_GetDebug(nsIDebug* *result)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,20 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* Private Method to register an exit routine. This method
|
||||
* used to allow you to setup a callback that will be called from
|
||||
* the NS_ShutdownXPCOM function after all services and
|
||||
* components have gone away. It was fatally flawed in that the component
|
||||
* DLL could be released before the exit function was called; it is now a
|
||||
* stub implementation that does nothing.
|
||||
*/
|
||||
XPCOM_API(nsresult)
|
||||
NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority);
|
||||
|
||||
XPCOM_API(nsresult)
|
||||
NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine);
|
||||
|
||||
static const XPCOMFunctions kFrozenFunctions = {
|
||||
XPCOM_GLUE_VERSION,
|
||||
sizeof(XPCOMFunctions),
|
||||
|
@ -52,8 +66,8 @@ static const XPCOMFunctions kFrozenFunctions = {
|
|||
&NS_GetMemoryManager_P,
|
||||
&NS_NewLocalFile_P,
|
||||
&NS_NewNativeLocalFile_P,
|
||||
&NS_RegisterXPCOMExitRoutine_P,
|
||||
&NS_UnregisterXPCOMExitRoutine_P,
|
||||
&NS_RegisterXPCOMExitRoutine,
|
||||
&NS_UnregisterXPCOMExitRoutine,
|
||||
|
||||
// these functions were added post 1.4
|
||||
&NS_GetDebug_P,
|
||||
|
@ -302,18 +316,16 @@ NS_LogCOMPtrRelease(void *aCOMPtr, nsISupports* aObject)
|
|||
* Stubs for nsXPCOMPrivate.h
|
||||
*/
|
||||
|
||||
#undef NS_RegisterXPCOMExitRoutine
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority)
|
||||
{
|
||||
return NS_RegisterXPCOMExitRoutine_P(exitRoutine, priority);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#undef NS_UnregisterXPCOMExitRoutine
|
||||
EXPORT_XPCOM_API(nsresult)
|
||||
NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine)
|
||||
{
|
||||
return NS_UnregisterXPCOMExitRoutine_P(exitRoutine);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче