Exemple #1
0
WrappedNativeSuspecter(JSDHashTable *table, JSDHashEntryHdr *hdr,
                       uint32 number, void *arg)
{
    SuspectClosure* closure = static_cast<SuspectClosure*>(arg);
    XPCWrappedNative* wrapper = ((Native2WrappedNativeMap::Entry*)hdr)->value;
    XPCWrappedNativeProto* proto = wrapper->GetProto();
    if(proto && proto->ClassIsMainThreadOnly() && wrapper->IsValid())
    {
        NS_ASSERTION(NS_IsMainThread(), 
                     "Suspecting wrapped natives from non-main thread");

#ifndef DEBUG_CC
        // Only record objects that might be part of a cycle as roots.
        if(!JS_IsAboutToBeFinalized(closure->cx, wrapper->GetFlatJSObject()))
            return JS_DHASH_NEXT;
#endif

        closure->cb.NoteRoot(nsIProgrammingLanguage::JAVASCRIPT,
                             wrapper->GetFlatJSObject(),
                             nsXPConnect::GetXPConnect());
    }

    return JS_DHASH_NEXT;
}