bug 860027 - lazily get the list of interfaces r=bholley

This commit is contained in:
Trevor Saunders 2013-05-03 17:22:46 -04:00
parent b53dcf2bff
commit e6f2cf55d3

View File

@ -218,7 +218,6 @@ nsXPCComponents_Interfaces::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
nsXPCComponents_Interfaces::nsXPCComponents_Interfaces()
{
XPTInterfaceInfoManager::GetSingleton()->GetScriptableInterfaces(mInterfaces);
}
nsXPCComponents_Interfaces::~nsXPCComponents_Interfaces()
@ -259,6 +258,13 @@ nsXPCComponents_Interfaces::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
case JSENUMERATE_INIT:
case JSENUMERATE_INIT_ALL:
{
// Lazily init the list of interfaces when someone tries to
// enumerate them.
if (mInterfaces.IsEmpty()) {
XPTInterfaceInfoManager::GetSingleton()->
GetScriptableInterfaces(mInterfaces);
}
*statep = JSVAL_ZERO;
if (idp)
*idp = INT_TO_JSID(mInterfaces.Length());
@ -500,7 +506,6 @@ nsXPCComponents_InterfacesByID::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
nsXPCComponents_InterfacesByID::nsXPCComponents_InterfacesByID()
{
XPTInterfaceInfoManager::GetSingleton()->GetScriptableInterfaces(mInterfaces);
}
nsXPCComponents_InterfacesByID::~nsXPCComponents_InterfacesByID()
@ -539,6 +544,13 @@ nsXPCComponents_InterfacesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper,
case JSENUMERATE_INIT:
case JSENUMERATE_INIT_ALL:
{
// Lazily init the list of interfaces when someone tries to
// enumerate them.
if (mInterfaces.IsEmpty()) {
XPTInterfaceInfoManager::GetSingleton()->
GetScriptableInterfaces(mInterfaces);
}
*statep = JSVAL_ZERO;
if (idp)
*idp = INT_TO_JSID(mInterfaces.Length());