Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes
XPCWrappedNativeProto Class Reference

#include <xpcprivate.h>

Collaboration diagram for XPCWrappedNativeProto:
Collaboration graph
[legend]

List of all members.

Public Member Functions

XPCWrappedNativeScopeGetScope () const
XPCJSRuntimeGetRuntime () const
JSObjectGetJSProtoObject () const
nsIClassInfoGetClassInfo () const
XPCNativeSetGetSet () const
XPCNativeScriptableInfoGetScriptableInfo ()
void ** GetSecurityInfoAddr ()
JSUint32 GetClassInfoFlags () const
JSBool ClassIsSingleton () GET_IT(SINGLETON) JSBool ClassIsThreadSafe() GET_IT(THREADSAFE) JSBool ClassIsMainThreadOnly() GET_IT(MAIN_THREAD_ONLY) JSBool ClassIsDOMObject() GET_IT(DOM_OBJECT) JSBool ClassIsPluginObject() GET_IT(PLUGIN_OBJECT) JSBool IsShared() const
XPCLockGetLock () const
void SetScriptableInfo (XPCNativeScriptableInfo *si)
void JSProtoObjectFinalized (JSContext *cx, JSObject *obj)
void SystemIsBeingShutDown (XPCCallContext &ccx)
void DebugDump (PRInt16 depth)
void MarkBeforeJSFinalize (JSContext *cx)
void AutoMark (JSContext *)
void Mark () const
 ~XPCWrappedNativeProto ()

Static Public Member Functions

static XPCWrappedNativeProtoGetNewOrUsed (XPCCallContext &ccx, XPCWrappedNativeScope *Scope, nsIClassInfo *ClassInfo, const XPCNativeScriptableCreateInfo *ScriptableCreateInfo, JSBool ForceNoSharing, JSBool isGlobal)

Protected Member Functions

 XPCWrappedNativeProto (const XPCWrappedNativeProto &r)
XPCWrappedNativeProtooperator= (const XPCWrappedNativeProto &r)
 XPCWrappedNativeProto (XPCWrappedNativeScope *Scope, nsIClassInfo *ClassInfo, PRUint32 ClassInfoFlags, XPCNativeSet *Set)
JSBool Init (XPCCallContext &ccx, JSBool isGlobal, const XPCNativeScriptableCreateInfo *scriptableCreateInfo)

Private Attributes

XPCWrappedNativeScopemScope
JSObjectmJSProtoObject
nsCOMPtr< nsIClassInfomClassInfo
PRUint32 mClassInfoFlags
XPCNativeSetmSet
voidmSecurityInfo
XPCNativeScriptableInfomScriptableInfo

Detailed Description

Definition at line 1624 of file xpcprivate.h.


Constructor & Destructor Documentation

Definition at line 73 of file xpcwrappednativeproto.cpp.

{
    NS_ASSERTION(!mJSProtoObject, "JSProtoObject still alive");

    MOZ_COUNT_DTOR(XPCWrappedNativeProto);

#ifdef DEBUG
    PR_AtomicDecrement(&gDEBUG_LiveProtoCount);
#endif
    
    // Note that our weak ref to mScope is not to be trusted at this point.

    XPCNativeSet::ClearCacheEntryForClassInfo(mClassInfo);

    delete mScriptableInfo;
}

Here is the call graph for this function:

Here is the caller graph for this function:

XPCWrappedNativeProto::XPCWrappedNativeProto ( XPCWrappedNativeScope Scope,
nsIClassInfo ClassInfo,
PRUint32  ClassInfoFlags,
XPCNativeSet Set 
) [protected]

Definition at line 51 of file xpcwrappednativeproto.cpp.

    : mScope(Scope),
      mJSProtoObject(nsnull),
      mClassInfo(ClassInfo),
      mClassInfoFlags(ClassInfoFlags),
      mSet(Set),
      mSecurityInfo(nsnull),
      mScriptableInfo(nsnull)
{
    // This native object lives as long as its associated JSObject - killed
    // by finalization of the JSObject (or explicitly if Init fails).

    MOZ_COUNT_CTOR(XPCWrappedNativeProto);

#ifdef DEBUG
    PR_AtomicIncrement(&gDEBUG_LiveProtoCount);
#endif
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 1698 of file xpcprivate.h.

{}

Definition at line 1664 of file xpcprivate.h.

Definition at line 246 of file xpcwrappednativeproto.cpp.

{
#ifdef DEBUG
    depth-- ;
    XPC_LOG_ALWAYS(("XPCWrappedNativeProto @ %x", this));
    XPC_LOG_INDENT();
        XPC_LOG_ALWAYS(("gDEBUG_LiveProtoCount is %d", gDEBUG_LiveProtoCount));
        XPC_LOG_ALWAYS(("mScope @ %x", mScope));
        XPC_LOG_ALWAYS(("mJSProtoObject @ %x", mJSProtoObject));
        XPC_LOG_ALWAYS(("mSet @ %x", mSet));
        XPC_LOG_ALWAYS(("mSecurityInfo of %x", mSecurityInfo));
        XPC_LOG_ALWAYS(("mScriptableInfo @ %x", mScriptableInfo));
        if(depth && mScriptableInfo)
        {
            XPC_LOG_INDENT();
            XPC_LOG_ALWAYS(("mScriptable @ %x", mScriptableInfo->GetCallback()));
            XPC_LOG_ALWAYS(("mFlags of %x", (PRUint32)mScriptableInfo->GetFlags()));
            XPC_LOG_ALWAYS(("mJSClass @ %x", mScriptableInfo->GetJSClass()));
            XPC_LOG_OUTDENT();
        }
    XPC_LOG_OUTDENT();
#endif
}

Here is the call graph for this function:

Definition at line 1645 of file xpcprivate.h.

{return mClassInfo;}

Here is the caller graph for this function:

JSUint32 XPCWrappedNativeProto::GetClassInfoFlags ( ) const [inline]

Definition at line 1657 of file xpcprivate.h.

{return mClassInfoFlags;}

Definition at line 1642 of file xpcprivate.h.

{return mJSProtoObject;}

Here is the caller graph for this function:

Definition at line 1677 of file xpcprivate.h.

        {return ClassIsThreadSafe() ? GetRuntime()->GetMapLock() : nsnull;}

Here is the call graph for this function:

XPCWrappedNativeProto * XPCWrappedNativeProto::GetNewOrUsed ( XPCCallContext ccx,
XPCWrappedNativeScope Scope,
nsIClassInfo ClassInfo,
const XPCNativeScriptableCreateInfo ScriptableCreateInfo,
JSBool  ForceNoSharing,
JSBool  isGlobal 
) [static]

Definition at line 174 of file xpcwrappednativeproto.cpp.

{
    NS_ASSERTION(Scope, "bad param");
    NS_ASSERTION(ClassInfo, "bad param");

    AutoMarkingWrappedNativeProtoPtr proto(ccx);
    ClassInfo2WrappedNativeProtoMap* map;
    XPCLock* lock;
    JSBool shared;

    JSUint32 ciFlags;
    if(NS_FAILED(ClassInfo->GetFlags(&ciFlags)))
        ciFlags = 0;

    if(ciFlags & XPC_PROTO_DONT_SHARE)
    {
        NS_ERROR("reserved flag set!");
        ciFlags &= ~XPC_PROTO_DONT_SHARE;
    }

    if(ForceNoSharing || (ciFlags & nsIClassInfo::PLUGIN_OBJECT) ||
       (ScriptableCreateInfo &&
        ScriptableCreateInfo->GetFlags().DontSharePrototype()))
    {
        ciFlags |= XPC_PROTO_DONT_SHARE;
        shared = JS_FALSE;
    }
    else
    {
        shared = JS_TRUE;
    }

    if(shared)
    {
        map = Scope->GetWrappedNativeProtoMap();
        lock = Scope->GetRuntime()->GetMapLock();
        {   // scoped lock
            XPCAutoLock al(lock);
            proto = map->Find(ClassInfo);
            if(proto)
                return proto;
        }
    }

    AutoMarkingNativeSetPtr set(ccx);
    set = XPCNativeSet::GetNewOrUsed(ccx, ClassInfo);
    if(!set)
        return nsnull;

    proto = new XPCWrappedNativeProto(Scope, ClassInfo, ciFlags, set);

    if(!proto || !proto->Init(ccx, isGlobal, ScriptableCreateInfo))
    {
        delete proto.get();
        return nsnull;
    }

    if(shared)
    {   // scoped lock
        XPCAutoLock al(lock);
        map->Add(ClassInfo, proto);
    }

    return proto;
}

Here is the call graph for this function:

Definition at line 1639 of file xpcprivate.h.

{return mScope->GetRuntime();}

Here is the caller graph for this function:

Definition at line 1636 of file xpcprivate.h.

{return mScope;}

Here is the caller graph for this function:

Definition at line 1651 of file xpcprivate.h.

{return mScriptableInfo;}

Here is the caller graph for this function:

Definition at line 1654 of file xpcprivate.h.

{return &mSecurityInfo;}

Here is the caller graph for this function:

Definition at line 1648 of file xpcprivate.h.

{return mSet;}

Here is the caller graph for this function:

JSBool XPCWrappedNativeProto::Init ( XPCCallContext ccx,
JSBool  isGlobal,
const XPCNativeScriptableCreateInfo scriptableCreateInfo 
) [protected]

Definition at line 91 of file xpcwrappednativeproto.cpp.

{
    if(scriptableCreateInfo && scriptableCreateInfo->GetCallback())
    {
        mScriptableInfo =
            XPCNativeScriptableInfo::Construct(ccx, isGlobal, scriptableCreateInfo);
        if(!mScriptableInfo)
            return JS_FALSE;
    }

    JSClass* jsclazz = mScriptableInfo &&
                       mScriptableInfo->GetFlags().AllowPropModsToPrototype() ?
                            &XPC_WN_ModsAllowed_Proto_JSClass :
                            &XPC_WN_NoMods_Proto_JSClass;

    JSObject *parent = mScope->GetGlobalJSObject();

    mJSProtoObject = JS_NewObject(ccx, jsclazz,
                                  mScope->GetPrototypeJSObject(),
                                  parent);

    JSBool ok = mJSProtoObject && JS_SetPrivate(ccx, mJSProtoObject, this);

    // Propagate the system flag from parent to child.
    if(ok && JS_IsSystemObject(ccx, parent))
        JS_FlagSystemObject(ccx, mJSProtoObject);

    DEBUG_ReportShadowedMembers(mSet, nsnull, this);

    return ok;
}

Here is the call graph for this function:

Definition at line 127 of file xpcwrappednativeproto.cpp.

{
    NS_ASSERTION(obj == mJSProtoObject, "huh?");

    // Map locking is not necessary since we are running gc.

    if(IsShared())
    {
        // Only remove this proto from the map if it is the one in the map.
        ClassInfo2WrappedNativeProtoMap* map = 
            GetScope()->GetWrappedNativeProtoMap();
        if(map->Find(mClassInfo) == this)
            map->Remove(mClassInfo);
    }

    GetRuntime()->GetDetachedWrappedNativeProtoMap()->Remove(this);
    GetRuntime()->GetDyingWrappedNativeProtoMap()->Add(this);

    mJSProtoObject = nsnull;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void XPCWrappedNativeProto::Mark ( ) const [inline]

Definition at line 1701 of file xpcprivate.h.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1692 of file xpcprivate.h.

        {if(mJSProtoObject)
            JS_MarkGCThing(cx, mJSProtoObject, 
                           "XPCWrappedNativeProto::mJSProtoObject", nsnull);
         if(mScriptableInfo) mScriptableInfo->Mark();}

Here is the call graph for this function:

XPCWrappedNativeProto& XPCWrappedNativeProto::operator= ( const XPCWrappedNativeProto r) [protected]

Definition at line 1680 of file xpcprivate.h.

        {NS_ASSERTION(!mScriptableInfo, "leak here!"); mScriptableInfo = si;}

Here is the caller graph for this function:

Definition at line 149 of file xpcwrappednativeproto.cpp.

{
    // Note that the instance might receive this call multiple times
    // as we walk to here from various places.

#ifdef XPC_TRACK_PROTO_STATS
    static PRBool DEBUG_DumpedStats = PR_FALSE;
    if(!DEBUG_DumpedStats)
    {
        printf("%d XPCWrappedNativeProto(s) alive at shutdown\n",
               gDEBUG_LiveProtoCount);
        DEBUG_DumpedStats = PR_TRUE;
    }
#endif

    if(mJSProtoObject)
    {
        // short circuit future finalization
        JS_SetPrivate(ccx, mJSProtoObject, nsnull);
        mJSProtoObject = nsnull;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 1733 of file xpcprivate.h.

Definition at line 1734 of file xpcprivate.h.

Definition at line 1732 of file xpcprivate.h.

Definition at line 1731 of file xpcprivate.h.

Definition at line 1737 of file xpcprivate.h.

Definition at line 1736 of file xpcprivate.h.

Definition at line 1735 of file xpcprivate.h.


The documentation for this class was generated from the following files: