Back to index

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

#include <nsProxyEventPrivate.h>

Inheritance diagram for nsProxyEventClass:
Inheritance graph
[legend]
Collaboration diagram for nsProxyEventClass:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_IMETHOD DelegatedQueryInterface (nsProxyEventObject *self, REFNSIID aIID, void **aInstancePtr)
nsIInterfaceInfoGetInterfaceInfo () const
const nsIIDGetProxiedIID () const

Static Public Member Functions

static NS_DECL_ISUPPORTS
nsProxyEventClass
GetNewOrUsedClass (REFNSIID aIID)

Protected Member Functions

 nsProxyEventClass ()
 nsProxyEventClass (REFNSIID aIID, nsIInterfaceInfo *aInfo)

Private Member Functions

 ~nsProxyEventClass ()
nsresult CallQueryInterfaceOnProxy (nsProxyEventObject *self, REFNSIID aIID, nsProxyEventObject **aInstancePtr)

Private Attributes

nsIID mIID
nsCOMPtr< nsIInterfaceInfomInfo
uint32mDescriptors

Detailed Description

Definition at line 74 of file nsProxyEventPrivate.h.


Constructor & Destructor Documentation

Definition at line 152 of file nsProxyEventClass.cpp.

{
    NS_WARNING("This constructor should never be called");
}
nsProxyEventClass::nsProxyEventClass ( REFNSIID  aIID,
nsIInterfaceInfo aInfo 
) [protected]

Definition at line 157 of file nsProxyEventClass.cpp.

: mIID(aIID),
  mDescriptors(NULL)
{
    NS_ADDREF_THIS();
    
    mInfo = aInfo;

    /* add use to the used classes */
    nsIDKey key(aIID);

    nsProxyObjectManager *manager = nsProxyObjectManager::GetInstance();
    if (manager == nsnull) return;
       // dont need to lock the map, because this is only called
       // by GetNewOrUsed which locks it for us.

       nsHashtable *iidToClassMap =  manager->GetIIDToProxyClassMap();
    
    if (iidToClassMap != nsnull)
    {
        iidToClassMap->Put(&key, this);
#ifdef LIFETIME_CACHE
              // extra addref to hold it in the cache
        NS_ADDREF_THIS();
#endif
#ifdef PROXYEVENTCLASS_DEBUG
              char* iidStr = aIID.ToString();
              printf("GetNewOrUsedClass  %s put\n", iidStr);
              nsCRT::free(iidStr);
#endif
    }

    uint16 methodCount;
    if(NS_SUCCEEDED(mInfo->GetMethodCount(&methodCount)))
    {
        if(methodCount)
        {
            int wordCount = (methodCount/32)+1;
            if(NULL != (mDescriptors = new uint32[wordCount]))
            {
                memset(mDescriptors, 0, wordCount * sizeof(uint32));
            }
        }
        else
        {
            mDescriptors = &zero_methods_descriptor;
        }
    }
}

Here is the call graph for this function:

Definition at line 207 of file nsProxyEventClass.cpp.

{
    if(mDescriptors && mDescriptors != &zero_methods_descriptor)
        delete [] mDescriptors;

    if (nsProxyObjectManager::IsManagerShutdown())
        return;

#ifndef LIFETIME_CACHE
    nsIDKey key(mIID);
                
    nsCOMPtr<nsProxyObjectManager> manager = getter_AddRefs(nsProxyObjectManager::GetInstance());
    if (manager == nsnull) return;
       nsHashtable *iidToClassMap =  manager->GetIIDToProxyClassMap();
    
    if (iidToClassMap != nsnull)
    {
        iidToClassMap->Remove(&key);
#ifdef PROXYEVENTCLASS_DEBUG
              char* iidStr = mIID.ToString();
              printf("GetNewOrUsedClass  %s remove\n", iidStr);
              nsCRT::free(iidStr);
#endif
    }
#endif
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 235 of file nsProxyEventClass.cpp.

{
    NS_PRECONDITION(aInstancePtr, "Requires non-null result");

    nsresult rv;

    *aInstancePtr = nsnull;  // in case of error.


    // The functions we will call: QueryInterface(REFNSIID aIID, void** aInstancePtr)

    nsXPTCMiniVariant var[2];

    var[0].val.p     = (void*)&aIID;
    var[1].val.p     = (void*)aInstancePtr;

    nsCOMPtr<nsIInterfaceInfo> interfaceInfo;
    const nsXPTMethodInfo *mi;

    nsCOMPtr<nsIInterfaceInfoManager> iim = getter_AddRefs(XPTI_GetInterfaceInfoManager());

    if (!iim) return NS_NOINTERFACE;
    iim->GetInfoForName("nsISupports", getter_AddRefs(interfaceInfo));
    interfaceInfo->GetMethodInfo(0, &mi); // 0 is QueryInterface

    rv = self->CallMethod(0, mi, var);

    if (NS_SUCCEEDED(rv))
    {
        nsISupports *aIdentificationObject;

        rv = (*aInstancePtr)->QueryInterface(kProxyObject_Identity_Class_IID, (void**)&aIdentificationObject);

        if (NS_FAILED(rv))
        {
            // okay, aInstancePtr was not a proxy.  Lets create one.
            nsProxyObjectManager *manager = nsProxyObjectManager::GetInstance();
            if (manager == nsnull) 
            {
                NS_IF_RELEASE((*aInstancePtr));
                return NS_ERROR_FAILURE;
            }

            rv = manager->GetProxyForObject(self->GetQueue(), 
                                            aIID, 
                                            self->GetRealObject(), 
                                            self->GetProxyType(),
                                            (void**) &aIdentificationObject);
        }

        NS_IF_RELEASE((*aInstancePtr));
        (*aInstancePtr) = NS_STATIC_CAST(nsProxyEventObject*, aIdentificationObject);
    }
    return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 316 of file nsProxyEventClass.cpp.

{
    
    if(aIID.Equals(NS_GET_IID(ProxyEventClassIdentity)))
    {
        *aInstancePtr = NS_STATIC_CAST(void*, self);  
        NS_ADDREF(self);
        return NS_OK;
    }

    nsProxyEventObject* sibling;
    {
    nsProxyObjectManager* manager = nsProxyObjectManager::GetInstance();
    nsAutoMonitor mon(manager->GetMonitor());

    // This includes checking for nsISupports and the iid of self.
    // And it also checks for other wrappers that have been constructed
    // for this object.
    if(nsnull != (sibling = self->LockedFind(aIID)))
    {
        NS_ADDREF(sibling);
        *aInstancePtr = (void*) sibling;
        return NS_OK;
    }

    // check if asking for an interface that we inherit from
    nsCOMPtr<nsIInterfaceInfo> current = GetInterfaceInfo();
    nsCOMPtr<nsIInterfaceInfo> parent;

    while(NS_SUCCEEDED(current->GetParent(getter_AddRefs(parent))) && parent)
    {
        current = parent;

        nsIID* iid;
        if(NS_SUCCEEDED(current->GetInterfaceIID(&iid)) && iid)
        {
            PRBool found = aIID.Equals(*iid);
            nsMemory::Free(iid);
            if(found)
            {
                *aInstancePtr = (void*) self;
                NS_ADDREF(self);
                return NS_OK;
            }
        }
    }
    }

    return CallQueryInterfaceOnProxy(self, aIID, (nsProxyEventObject**)aInstancePtr);
}

Here is the call graph for this function:

Definition at line 87 of file nsProxyEventPrivate.h.

{return mInfo;}

Here is the caller graph for this function:

Definition at line 74 of file nsProxyEventClass.cpp.

{
    /* find in our hash table */
    
    nsProxyObjectManager *manager = nsProxyObjectManager::GetInstance();
    if (manager == nsnull) return nsnull;
       
       // dont need to lock the map, because this is only called
       // by nsProxyEventClass::GetNewOrUsed which locks it for us.

       nsHashtable *iidToClassMap =  manager->GetIIDToProxyClassMap();
    
    if (iidToClassMap == nsnull)
    {
        return nsnull;
    }

    nsProxyEventClass* clazz = nsnull;
    nsIDKey key(aIID);

#ifdef PROXYEVENTCLASS_DEBUG 
       char* iidStr = aIID.ToString();
       printf("GetNewOrUsedClass  %s\n", iidStr);
       nsCRT::free(iidStr);
#endif

    clazz = (nsProxyEventClass*) iidToClassMap->Get(&key);
       if(clazz)
       {
        NS_ADDREF(clazz);
#ifdef PROXYEVENTCLASS_DEBUG
              char* iidStr = aIID.ToString();
              printf("GetNewOrUsedClass  %s hit\n", iidStr);
              nsCRT::free(iidStr);
#endif
    }
    else
    {
        nsCOMPtr<nsIInterfaceInfoManager> iimgr = getter_AddRefs(XPTI_GetInterfaceInfoManager());
        if(iimgr)
        {
            nsCOMPtr<nsIInterfaceInfo> info;
            if(NS_SUCCEEDED(iimgr->GetInfoForIID(&aIID, getter_AddRefs(info))))
            {
                /* 
                   Check to see if isISupportsDescendent 
                */
                nsCOMPtr<nsIInterfaceInfo> oldest = info;
                nsCOMPtr<nsIInterfaceInfo> parent;

                while(NS_SUCCEEDED(oldest->GetParent(getter_AddRefs(parent)))&&
                      parent)
                {
                    oldest = parent;
                }

                PRBool isISupportsDescendent = PR_FALSE;
                nsID* iid;
                if(NS_SUCCEEDED(oldest->GetInterfaceIID(&iid))) 
                {
                    isISupportsDescendent = iid->Equals(NS_GET_IID(nsISupports));
                    nsMemory::Free(iid);
                }
                
                NS_ASSERTION(isISupportsDescendent, "!isISupportsDescendent");

                if (isISupportsDescendent)  
                {
                    clazz = new nsProxyEventClass(aIID, info);
                    if(!clazz->mDescriptors)
                        NS_RELEASE(clazz);  // sets clazz to NULL
                }
            }
        }
    }
    return clazz;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 88 of file nsProxyEventPrivate.h.

{return mIID; }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 98 of file nsProxyEventPrivate.h.

Definition at line 96 of file nsProxyEventPrivate.h.

Definition at line 97 of file nsProxyEventPrivate.h.


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