Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
nsInputStreamReadyEvent Class Reference
Inheritance diagram for nsInputStreamReadyEvent:
Inheritance graph
[legend]
Collaboration diagram for nsInputStreamReadyEvent:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS nsInputStreamReadyEvent (nsIInputStreamCallback *callback, nsIEventTarget *target)
NS_IMETHOD OnInputStreamReady (nsIAsyncInputStream *stream)
void onInputStreamReady (in nsIAsyncInputStream aStream)
 Called to indicate that the stream is either readable or closed.

Public Attributes

PRCList link
PLHandleEventProc handler
PLDestroyEventProc destructor
voidowner
voidsynchronousResult
PRLocklock
PRCondVarcondVar
PRBool handled

Private Member Functions

 ~nsInputStreamReadyEvent ()
 PR_STATIC_CALLBACK (void *) EventHandler(PLEvent *plevent)
 PR_STATIC_CALLBACK (void) EventCleanup(PLEvent *plevent)

Private Attributes

nsCOMPtr< nsIAsyncInputStreammStream
nsCOMPtr< nsIInputStreamCallbackmCallback
nsCOMPtr< nsIEventTargetmTarget

Detailed Description

Definition at line 48 of file nsStreamUtils.cpp.


Constructor & Destructor Documentation

Definition at line 54 of file nsStreamUtils.cpp.

        : mCallback(callback)
        , mTarget(target)
    {
    }

Definition at line 62 of file nsStreamUtils.cpp.

    {
        if (mCallback) {
            nsresult rv;
            //
            // whoa!!  looks like we never posted this event.  take care to
            // release mCallback on the correct thread.  if mTarget lives on the
            // calling thread, then we are ok.  otherwise, we have to try to 
            // proxy the Release over the right thread.  if that thread is dead,
            // then there's nothing we can do... better to leak than crash.
            //
            PRBool val;
            rv = mTarget->IsOnCurrentThread(&val);
            if (NS_FAILED(rv) || !val) {
                nsCOMPtr<nsIInputStreamCallback> event;
                NS_NewInputStreamReadyEvent(getter_AddRefs(event), mCallback, mTarget);
                mCallback = 0;
                if (event) {
                    rv = event->OnInputStreamReady(nsnull);
                    if (NS_FAILED(rv)) {
                        NS_NOTREACHED("leaking stream event");
                        nsISupports *sup = event;
                        NS_ADDREF(sup);
                    }
                }
            }
        }
    }

Here is the call graph for this function:


Member Function Documentation

Definition at line 92 of file nsStreamUtils.cpp.

    {
        mStream = stream;

        // will be released when event is handled
        NS_ADDREF_THIS();

        PL_InitEvent(this, nsnull, EventHandler, EventCleanup);

        if (NS_FAILED(mTarget->PostEvent(this))) {
            NS_WARNING("PostEvent failed");
            NS_RELEASE_THIS();
            return NS_ERROR_FAILURE;
        }

        return NS_OK;
    }

Here is the call graph for this function:

Called to indicate that the stream is either readable or closed.

Parameters:
aStreamThe stream whose asyncWait method was called.

Definition at line 115 of file nsStreamUtils.cpp.

    {
        nsInputStreamReadyEvent *ev = (nsInputStreamReadyEvent *) plevent;
        // bypass event delivery if this is a cleanup event...
        if (ev->mCallback)
            ev->mCallback->OnInputStreamReady(ev->mStream);
        ev->mCallback = 0;
        return NULL;
    }

Definition at line 125 of file nsStreamUtils.cpp.


Member Data Documentation

PRCondVar * PLEvent::condVar [inherited]

Definition at line 514 of file nsIEventQueueService.idl.

Definition at line 510 of file nsIEventQueueService.idl.

PRBool PLEvent::handled [inherited]

Definition at line 515 of file nsIEventQueueService.idl.

Definition at line 509 of file nsIEventQueueService.idl.

PRCList PLEvent::link [inherited]

Definition at line 508 of file nsIEventQueueService.idl.

PRLock * PLEvent::lock [inherited]

Definition at line 513 of file nsIEventQueueService.idl.

Definition at line 112 of file nsStreamUtils.cpp.

Definition at line 111 of file nsStreamUtils.cpp.

Definition at line 113 of file nsStreamUtils.cpp.

void * PLEvent::owner [inherited]

Definition at line 511 of file nsIEventQueueService.idl.

Definition at line 512 of file nsIEventQueueService.idl.


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