Back to index

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

#include <nsXPITriggerInfo.h>

Collaboration diagram for nsXPITriggerInfo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsXPITriggerInfo ()
 ~nsXPITriggerInfo ()
void Add (nsXPITriggerItem *aItem)
nsXPITriggerItemGet (PRUint32 aIndex)
void SaveCallback (JSContext *aCx, jsval aVal)
PRUint32 Size ()
void SendStatus (const PRUnichar *URL, PRInt32 status)
void SetPrincipal (nsIPrincipal *aPrinc)

Private Member Functions

nsXPITriggerInfooperator= (const nsXPITriggerInfo &rhs)
 nsXPITriggerInfo (const nsXPITriggerInfo &rhs)

Private Attributes

nsVoidArray mItems
JSContextmCx
nsCOMPtr
< nsIXPConnectJSObjectHolder
mGlobalWrapper
jsval mCbval
PRThreadmThread
nsCOMPtr< nsIPrincipalmPrincipal

Detailed Description

Definition at line 112 of file nsXPITriggerInfo.h.


Constructor & Destructor Documentation

Definition at line 182 of file nsXPITriggerInfo.cpp.

Definition at line 188 of file nsXPITriggerInfo.cpp.

{
    nsXPITriggerItem* item;

    for(PRUint32 i=0; i < Size(); i++)
    {
        item = Get(i);
        if (item)
            delete item;
    }
    mItems.Clear();

    if ( mCx && !JSVAL_IS_NULL(mCbval) ) {
        JS_BeginRequest(mCx);
        JS_RemoveRoot( mCx, &mCbval );
        JS_EndRequest(mCx);
    }

    MOZ_COUNT_DTOR(nsXPITriggerInfo);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 118 of file nsXPITriggerInfo.h.

                        { if ( aItem ) mItems.AppendElement( (void*)aItem ); }

Here is the caller graph for this function:

Definition at line 121 of file nsXPITriggerInfo.h.

                        { return (nsXPITriggerItem*)mItems.ElementAt(aIndex);}

Here is the caller graph for this function:

nsXPITriggerInfo& nsXPITriggerInfo::operator= ( const nsXPITriggerInfo rhs) [private]

Definition at line 209 of file nsXPITriggerInfo.cpp.

{
    NS_ASSERTION( mCx == 0, "callback set twice, memory leak" );
    mCx = aCx;
    JSObject *obj = JS_GetGlobalObject( mCx );

    JSClass* clazz;

#ifdef JS_THREADSAFE
    clazz = ::JS_GetClass(aCx, obj);
#else
    clazz = ::JS_GetClass(obj);
#endif

    if (clazz &&
        (clazz->flags & JSCLASS_HAS_PRIVATE) &&
        (clazz->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS)) {
      mGlobalWrapper =
        do_QueryInterface((nsISupports*)::JS_GetPrivate(aCx, obj));
    }

    mCbval = aVal;
    mThread = PR_GetCurrentThread();

    if ( !JSVAL_IS_NULL(mCbval) ) {
        JS_BeginRequest(mCx);
        JS_AddRoot( mCx, &mCbval );
        JS_EndRequest(mCx);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 326 of file nsXPITriggerInfo.cpp.

{
    nsCOMPtr<nsIEventQueue> eq;
    nsresult rv;

    if ( mCx && mGlobalWrapper && !JSVAL_IS_NULL(mCbval) )
    {
        nsCOMPtr<nsIEventQueueService> EQService =
                 do_GetService(kEventQueueServiceCID, &rv);
        if ( NS_SUCCEEDED( rv ) )
        {
            rv = EQService->GetThreadEventQueue(mThread, getter_AddRefs(eq));
            if ( NS_SUCCEEDED(rv) )
            {
                // create event and post it
                XPITriggerEvent* event = new XPITriggerEvent();
                if (event)
                {
                    PL_InitEvent(&event->e, 0,
                        (PLHandleEventProc)handleTriggerEvent,
                        (PLDestroyEventProc)destroyTriggerEvent);

                    event->URL      = URL;
                    event->status   = status;
                    event->cx       = mCx;
                    event->princ    = mPrincipal;

                    JSObject *obj = nsnull;

                    mGlobalWrapper->GetJSObject(&obj);

                    event->global   = OBJECT_TO_JSVAL(obj);

                    event->cbval    = mCbval;
                    JS_BeginRequest(event->cx);
                    JS_AddNamedRoot( event->cx, &event->cbval,
                                     "XPITriggerEvent::cbval" );
                    JS_EndRequest(event->cx);

                    // Hold a strong reference to keep the underlying
                    // JSContext from dying before we handle this event.
                    event->ref      = mGlobalWrapper;

                    eq->PostEvent(&event->e);
                }
                else
                    rv = NS_ERROR_OUT_OF_MEMORY;
            }
        }

        if ( NS_FAILED( rv ) )
        {
            // couldn't get event queue -- maybe window is gone or
            // some similarly catastrophic occurrance
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 130 of file nsXPITriggerInfo.h.

{ mPrincipal = aPrinc; }

Here is the caller graph for this function:

Definition at line 126 of file nsXPITriggerInfo.h.

{ return mItems.Count(); }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 137 of file nsXPITriggerInfo.h.

Definition at line 135 of file nsXPITriggerInfo.h.

Definition at line 136 of file nsXPITriggerInfo.h.

Definition at line 134 of file nsXPITriggerInfo.h.

Definition at line 140 of file nsXPITriggerInfo.h.

Definition at line 138 of file nsXPITriggerInfo.h.


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