AutoMarkingNativeInterfacePtr iface(ccx);  const nsIID* iid; if(NS_FAILED(info->GetIIDShared(&iid)) || !iid) return nsnull;  XPCJSRuntime* rt = ccx.GetRuntime();  IID2NativeInterfaceMap* map = rt->GetIID2NativeInterfaceMap(); if(!map) return nsnull;
nsresult rv;  nsCOMPtr<nsISupports> identity(do_QueryInterface(Object)); if(!identity) { NS_ERROR("This XPCOM object fails in QueryInterface to nsISupports!"); return NS_ERROR_FAILURE; }  XPCLock* mapLock = Scope->GetRuntime()->GetMapLock();      AutoMarkingWrappedNativePtr wrapper(ccx);  Native2WrappedNativeMap* map = Scope->GetWrappedNativeMap();
XPCNativeInterface::GetNewOrUsed(XPCCallContext& ccx, nsIInterfaceInfo* info){    AutoMarkingNativeInterfacePtr iface(ccx);    const nsIID* iid;    if(NS_FAILED(info->GetIIDShared(&iid)) || !iid)        return nsnull;    XPCJSRuntime* rt = ccx.GetRuntime();    IID2NativeInterfaceMap* map = rt->GetIID2NativeInterfaceMap();    if(!map)        return nsnull;    {   // scoped lock        XPCAutoLock lock(rt->GetMapLock());        iface = map->Find(*iid);    }    if(iface)        return iface;    iface = NewInstance(ccx, info);    if(!iface)        return nsnull;    {   // scoped lock        XPCAutoLock lock(rt->GetMapLock());        XPCNativeInterface* iface2 = map->Add(iface);        if(!iface2)        {            NS_ERROR("failed to add our interface!");            DestroyInstance(ccx, rt, iface);            iface = nsnull;        }        else if(iface2 != iface)        {            DestroyInstance(ccx, rt, iface);            iface = iface2;        }    }    return iface;}