зеркало из https://github.com/mozilla/pjs.git
Bug 735280 - Part 1: Connect XPCWrappedNativeScope and Components. r=bholley
This commit is contained in:
Родитель
1d9db6868d
Коммит
244e16e5eb
|
@ -4245,8 +4245,9 @@ nsXPCComponents::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsXPCComponents::nsXPCComponents()
|
nsXPCComponents::nsXPCComponents(XPCWrappedNativeScope* aScope)
|
||||||
: mInterfaces(nsnull),
|
: mScope(aScope),
|
||||||
|
mInterfaces(nsnull),
|
||||||
mInterfacesByID(nsnull),
|
mInterfacesByID(nsnull),
|
||||||
mClasses(nsnull),
|
mClasses(nsnull),
|
||||||
mClassesByID(nsnull),
|
mClassesByID(nsnull),
|
||||||
|
@ -4256,6 +4257,7 @@ nsXPCComponents::nsXPCComponents()
|
||||||
mConstructor(nsnull),
|
mConstructor(nsnull),
|
||||||
mUtils(nsnull)
|
mUtils(nsnull)
|
||||||
{
|
{
|
||||||
|
MOZ_ASSERT(aScope, "aScope must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsXPCComponents::~nsXPCComponents()
|
nsXPCComponents::~nsXPCComponents()
|
||||||
|
@ -4434,7 +4436,7 @@ nsXPCComponents::AttachNewComponentsObject(XPCCallContext& ccx,
|
||||||
if (!aGlobal)
|
if (!aGlobal)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
nsXPCComponents* components = new nsXPCComponents();
|
nsXPCComponents* components = new nsXPCComponents(aScope);
|
||||||
if (!components)
|
if (!components)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -190,11 +190,15 @@ XPCWrappedNativeScope::IsDyingScope(XPCWrappedNativeScope *scope)
|
||||||
void
|
void
|
||||||
XPCWrappedNativeScope::SetComponents(nsXPCComponents* aComponents)
|
XPCWrappedNativeScope::SetComponents(nsXPCComponents* aComponents)
|
||||||
{
|
{
|
||||||
NS_IF_ADDREF(aComponents);
|
|
||||||
NS_IF_RELEASE(mComponents);
|
|
||||||
mComponents = aComponents;
|
mComponents = aComponents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsXPCComponents*
|
||||||
|
XPCWrappedNativeScope::GetComponents()
|
||||||
|
{
|
||||||
|
return mComponents;
|
||||||
|
}
|
||||||
|
|
||||||
// Dummy JS class to let wrappers w/o an xpc prototype share
|
// Dummy JS class to let wrappers w/o an xpc prototype share
|
||||||
// scopes. By doing this we avoid allocating a new scope for every
|
// scopes. By doing this we avoid allocating a new scope for every
|
||||||
// wrapper on creation of the wrapper, and most wrappers won't need
|
// wrapper on creation of the wrapper, and most wrappers won't need
|
||||||
|
@ -308,9 +312,14 @@ XPCWrappedNativeScope::~XPCWrappedNativeScope()
|
||||||
if (mContext)
|
if (mContext)
|
||||||
mContext->RemoveScope(this);
|
mContext->RemoveScope(this);
|
||||||
|
|
||||||
|
// This should not be necessary, since the Components object should die
|
||||||
|
// with the scope but just in case.
|
||||||
|
if (mComponents)
|
||||||
|
mComponents->mScope = nsnull;
|
||||||
|
|
||||||
// XXX we should assert that we are dead or that xpconnect has shutdown
|
// XXX we should assert that we are dead or that xpconnect has shutdown
|
||||||
// XXX might not want to do this at xpconnect shutdown time???
|
// XXX might not want to do this at xpconnect shutdown time???
|
||||||
NS_IF_RELEASE(mComponents);
|
mComponents = nsnull;
|
||||||
|
|
||||||
JSRuntime *rt = mRuntime->GetJSRuntime();
|
JSRuntime *rt = mRuntime->GetJSRuntime();
|
||||||
mGlobalJSObject.finalize(rt);
|
mGlobalJSObject.finalize(rt);
|
||||||
|
|
|
@ -1610,6 +1610,7 @@ public:
|
||||||
IsDyingScope(XPCWrappedNativeScope *scope);
|
IsDyingScope(XPCWrappedNativeScope *scope);
|
||||||
|
|
||||||
void SetComponents(nsXPCComponents* aComponents);
|
void SetComponents(nsXPCComponents* aComponents);
|
||||||
|
nsXPCComponents *GetComponents();
|
||||||
void SetGlobal(XPCCallContext& ccx, JSObject* aGlobal, nsISupports* aNative);
|
void SetGlobal(XPCCallContext& ccx, JSObject* aGlobal, nsISupports* aNative);
|
||||||
|
|
||||||
static void InitStatics() { gScopes = nsnull; gDyingScopes = nsnull; }
|
static void InitStatics() { gScopes = nsnull; gDyingScopes = nsnull; }
|
||||||
|
@ -1659,7 +1660,7 @@ private:
|
||||||
Native2WrappedNativeMap* mWrappedNativeMap;
|
Native2WrappedNativeMap* mWrappedNativeMap;
|
||||||
ClassInfo2WrappedNativeProtoMap* mWrappedNativeProtoMap;
|
ClassInfo2WrappedNativeProtoMap* mWrappedNativeProtoMap;
|
||||||
ClassInfo2WrappedNativeProtoMap* mMainThreadWrappedNativeProtoMap;
|
ClassInfo2WrappedNativeProtoMap* mMainThreadWrappedNativeProtoMap;
|
||||||
nsXPCComponents* mComponents;
|
nsRefPtr<nsXPCComponents> mComponents;
|
||||||
XPCWrappedNativeScope* mNext;
|
XPCWrappedNativeScope* mNext;
|
||||||
// The JS global object for this scope. If non-null, this will be the
|
// The JS global object for this scope. If non-null, this will be the
|
||||||
// default parent for the XPCWrappedNatives that have us as the scope,
|
// default parent for the XPCWrappedNatives that have us as the scope,
|
||||||
|
@ -3911,10 +3912,12 @@ public:
|
||||||
virtual ~nsXPCComponents();
|
virtual ~nsXPCComponents();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsXPCComponents();
|
nsXPCComponents(XPCWrappedNativeScope* aScope);
|
||||||
void ClearMembers();
|
void ClearMembers();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class XPCWrappedNativeScope;
|
||||||
|
XPCWrappedNativeScope* mScope;
|
||||||
nsXPCComponents_Interfaces* mInterfaces;
|
nsXPCComponents_Interfaces* mInterfaces;
|
||||||
nsXPCComponents_InterfacesByID* mInterfacesByID;
|
nsXPCComponents_InterfacesByID* mInterfacesByID;
|
||||||
nsXPCComponents_Classes* mClasses;
|
nsXPCComponents_Classes* mClasses;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче