Back to index

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

#include <xpcprivate.h>

Collaboration diagram for XPCPerThreadData:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~XPCPerThreadData ()
nsresult GetException (nsIException **aException)
nsresult SetException (nsIException *aException)
nsIExceptionManagerGetExceptionManager ()
JSBool EnsureExceptionManager ()
XPCJSContextStackGetJSContextStack ()
XPCCallContextGetCallContext () const
XPCCallContextSetCallContext (XPCCallContext *ccx)
jsval GetResolveName () const
jsval SetResolveName (jsval name)
XPCWrappedNativeGetResolvingWrapper () const
XPCWrappedNativeSetResolvingWrapper (XPCWrappedNative *w)
void Cleanup ()
PRBool IsValid () const
XPCContextGetRecentXPCContext (JSContext *cx) const
void SetRecentContext (JSContext *cx, XPCContext *xpcc)
void ClearRecentContext ()
AutoMarkingPtr ** GetAutoRootsAdr ()
void MarkAutoRootsBeforeJSFinalize (JSContext *cx)
void MarkAutoRootsAfterJSFinalize ()
jsuword GetStackLimit () const

Static Public Member Functions

static XPCPerThreadDataGetData ()
static void CleanupAllThreads ()
static PRLockGetLock ()
static XPCPerThreadDataIterateThreads (XPCPerThreadData **iteratorp)
static void InitStatics ()

Private Member Functions

 XPCPerThreadData ()

Private Attributes

XPCJSContextStackmJSContextStack
XPCPerThreadDatamNextThread
XPCCallContextmCallContext
jsval mResolveName
XPCWrappedNativemResolvingWrapper
JSContextmMostRecentJSContext
XPCContextmMostRecentXPCContext
nsIExceptionManagermExceptionManager
nsIExceptionmException
JSBool mExceptionManagerNotAvailable
AutoMarkingPtrmAutoRoots
jsuword mStackLimit

Static Private Attributes

static PRLockgLock = nsnull
static XPCPerThreadDatagThreads = nsnull
static PRUintn gTLSIndex = BAD_TLS_INDEX

Detailed Description

Definition at line 2786 of file xpcprivate.h.


Constructor & Destructor Documentation

Definition at line 437 of file xpcthreadcontext.cpp.

{
    Cleanup();

    // Unlink 'this' from the list of threads.
    if(gLock)
    {
        nsAutoLock lock(gLock);
        if(gThreads == this)
            gThreads = mNextThread;
        else
        {
            XPCPerThreadData* cur = gThreads;
            while(cur)
            {
                if(cur->mNextThread == this)
                {
                    cur->mNextThread = mNextThread;
                    break;
                }
                cur = cur->mNextThread;
            }
        }
    }

    if(gLock && !gThreads)
    {
        PR_DestroyLock(gLock);
        gLock = nsnull;
    }
}

Here is the call graph for this function:

Definition at line 398 of file xpcthreadcontext.cpp.

Here is the caller graph for this function:


Member Function Documentation

Definition at line 424 of file xpcthreadcontext.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 554 of file xpcthreadcontext.cpp.

{
    // I've questioned the sense of cleaning up other threads' data from the
    // start. But I got talked into it. Now I see that we *can't* do all the
    // cleaup while holding this lock. So, we are going to go to the trouble
    // to copy out the data that needs to be cleaned up *outside* of
    // the lock. Yuk!

    XPCJSContextStack** stacks = nsnull;
    int count = 0;
    int i;

    if(gLock)
    {
        nsAutoLock lock(gLock);

        for(XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread)
            count++;

        stacks = (XPCJSContextStack**) new XPCJSContextStack*[count] ;
        if(stacks)
        {
            i = 0;
            for(XPCPerThreadData* cur = gThreads; cur; cur = cur->mNextThread)
            {
                stacks[i++] = cur->mJSContextStack;
                cur->mJSContextStack = nsnull;
                cur->Cleanup();
            }
        }
    }

    if(stacks)
    {
        for(i = 0; i < count; i++)
            delete stacks[i];
        delete [] stacks;
    }

    if(gTLSIndex != BAD_TLS_INDEX)
        PR_SetThreadPrivate(gTLSIndex, nsnull);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2871 of file xpcprivate.h.

Here is the caller graph for this function:

Definition at line 2823 of file xpcprivate.h.

Here is the call graph for this function:

Definition at line 2874 of file xpcprivate.h.

{return &mAutoRoots;}

Definition at line 2844 of file xpcprivate.h.

{return mCallContext;}

Here is the caller graph for this function:

Definition at line 504 of file xpcthreadcontext.cpp.

{
    XPCPerThreadData* data;

    if(!gLock)
    {
        gLock = PR_NewLock();
        if(!gLock)
            return nsnull;
    }

    if(gTLSIndex == BAD_TLS_INDEX)
    {
        nsAutoLock lock(gLock);
        // check again now that we have the lock...
        if(gTLSIndex == BAD_TLS_INDEX)
        {
            if(PR_FAILURE ==
               PR_NewThreadPrivateIndex(&gTLSIndex, xpc_ThreadDataDtorCB))
            {
                NS_ASSERTION(0, "PR_NewThreadPrivateIndex failed!");
                gTLSIndex = BAD_TLS_INDEX;
                return nsnull;
            }
        }
    }

    data = (XPCPerThreadData*) PR_GetThreadPrivate(gTLSIndex);
    if(!data)
    {
        data = new XPCPerThreadData();
        if(!data || !data->IsValid())
        {
            NS_ASSERTION(0, "new XPCPerThreadData() failed!");
            if(data)
                delete data;
            return nsnull;
        }
        if(PR_FAILURE == PR_SetThreadPrivate(gTLSIndex, data))
        {
            NS_ASSERTION(0, "PR_SetThreadPrivate failed!");
            delete data;
            return nsnull;
        }
    }
    return data;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2795 of file xpcprivate.h.

    {
        if(EnsureExceptionManager())
            return mExceptionManager->GetCurrentException(aException);

        NS_IF_ADDREF(mException);
        *aException = mException;
        return NS_OK;
    }

Definition at line 2816 of file xpcprivate.h.

    {
        if(EnsureExceptionManager())
            return mExceptionManager;
        return nsnull;
    }

Here is the caller graph for this function:

Definition at line 2842 of file xpcprivate.h.

{return mJSContextStack;}

Here is the caller graph for this function:

static PRLock* XPCPerThreadData::GetLock ( ) [inline, static]

Definition at line 2861 of file xpcprivate.h.

{return gLock;}

Here is the caller graph for this function:

Definition at line 2865 of file xpcprivate.h.

Here is the caller graph for this function:

Definition at line 2848 of file xpcprivate.h.

{return mResolveName;}

Here is the caller graph for this function:

Definition at line 2852 of file xpcprivate.h.

Here is the caller graph for this function:

Definition at line 2879 of file xpcprivate.h.

{ return mStackLimit; }

Here is the caller graph for this function:

static void XPCPerThreadData::InitStatics ( ) [inline, static]

Definition at line 2881 of file xpcprivate.h.

Here is the caller graph for this function:

PRBool XPCPerThreadData::IsValid ( ) const [inline]

Definition at line 2859 of file xpcprivate.h.

{return mJSContextStack != nsnull;}

Here is the caller graph for this function:

Definition at line 599 of file xpcthreadcontext.cpp.

{
    *iteratorp = (*iteratorp == nsnull) ? gThreads : (*iteratorp)->mNextThread;
    return *iteratorp;
}

Here is the caller graph for this function:

Definition at line 496 of file xpcthreadcontext.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 477 of file xpcthreadcontext.cpp.

{
#ifdef XPC_TRACK_AUTOMARKINGPTR_STATS
    {
        static int maxLength = 0;
        int length = 0;
        for(AutoMarkingPtr* p = mAutoRoots; p; p = p->GetNext())
            length++;
        if(length > maxLength)
            maxLength = length;
        printf("XPC gc on thread %x with %d AutoMarkingPtrs (%d max so far)\n",
               this, length, maxLength);
    }
#endif

    if(mAutoRoots)
        mAutoRoots->MarkBeforeJSFinalize(cx);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2845 of file xpcprivate.h.

        {XPCCallContext* old = mCallContext; mCallContext = ccx; return old;}

Here is the caller graph for this function:

Definition at line 2805 of file xpcprivate.h.

    {
        if(EnsureExceptionManager())
            return mExceptionManager->SetCurrentException(aException);

        NS_IF_ADDREF(aException);
        NS_IF_RELEASE(mException);
        mException = aException;
        return NS_OK;
    }

Here is the caller graph for this function:

Definition at line 2868 of file xpcprivate.h.

Here is the caller graph for this function:

Definition at line 2849 of file xpcprivate.h.

        {jsval old = mResolveName; mResolveName = name; return old;}

Here is the caller graph for this function:

Definition at line 2853 of file xpcprivate.h.

Here is the caller graph for this function:


Member Data Documentation

PRLock * XPCPerThreadData::gLock = nsnull [static, private]

Definition at line 2915 of file xpcprivate.h.

Definition at line 2916 of file xpcprivate.h.

PRUintn XPCPerThreadData::gTLSIndex = BAD_TLS_INDEX [static, private]

Definition at line 2917 of file xpcprivate.h.

Definition at line 2907 of file xpcprivate.h.

Definition at line 2897 of file xpcprivate.h.

Definition at line 2905 of file xpcprivate.h.

Definition at line 2904 of file xpcprivate.h.

Definition at line 2906 of file xpcprivate.h.

Definition at line 2895 of file xpcprivate.h.

Definition at line 2901 of file xpcprivate.h.

Definition at line 2902 of file xpcprivate.h.

Definition at line 2896 of file xpcprivate.h.

Definition at line 2898 of file xpcprivate.h.

Definition at line 2899 of file xpcprivate.h.

Definition at line 2909 of file xpcprivate.h.


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