Back to index

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS MyCopier ()
virtual ~MyCopier ()
NS_IMETHOD OnInputStreamReady (nsIAsyncInputStream *inStr)
NS_IMETHOD OnOutputStreamReady (nsIAsyncOutputStream *outStr)
void Close_Locked ()
void Process_Locked ()
nsresult AsyncCopy (nsITransport *srcTrans, nsITransport *destTrans)
void onInputStreamReady (in nsIAsyncInputStream aStream)
 Called to indicate that the stream is either readable or closed.
void onOutputStreamReady (in nsIAsyncOutputStream aStream)
 Called to indicate that the stream is either writable or closed.

Static Public Member Functions

static NS_METHOD FillOutputBuffer (nsIOutputStream *outStr, void *closure, char *buffer, PRUint32 offset, PRUint32 count, PRUint32 *countRead)

Protected Attributes

PRLockmLock
nsCOMPtr< nsIAsyncInputStreammInput
nsCOMPtr< nsIAsyncOutputStreammOutput
nsresult mInputCondition

Detailed Description

Definition at line 113 of file TestStreamTransport.cpp.


Constructor & Destructor Documentation

Definition at line 119 of file TestStreamTransport.cpp.

virtual MyCopier::~MyCopier ( ) [inline, virtual]

Definition at line 125 of file TestStreamTransport.cpp.

    {
        if (mLock)
            PR_DestroyLock(mLock);
        if (mInput)
            mInput->Close();
        if (mOutput)
            mOutput->Close();
    }

Here is the call graph for this function:


Member Function Documentation

nsresult MyCopier::AsyncCopy ( nsITransport srcTrans,
nsITransport destTrans 
) [inline]

Definition at line 187 of file TestStreamTransport.cpp.

    {
        mLock = PR_NewLock();
        if (!mLock)
            return NS_ERROR_OUT_OF_MEMORY;

        nsresult rv;

        nsCOMPtr<nsIInputStream> inStr;
        rv = srcTrans->OpenInputStream(0, 0, 0, getter_AddRefs(inStr));
        if (NS_FAILED(rv)) return rv;

        nsCOMPtr<nsIOutputStream> outStr;
        rv = destTrans->OpenOutputStream(0, 0, 0, getter_AddRefs(outStr));
        if (NS_FAILED(rv)) return rv;

        mInput = do_QueryInterface(inStr);
        mOutput = do_QueryInterface(outStr);

        return mInput->AsyncWait(this, 0, 0, nsnull);
    }

Here is the call graph for this function:

Definition at line 155 of file TestStreamTransport.cpp.

    {
        LOG(("Close_Locked\n"));

        mOutput->Close();
        mOutput = 0;
        mInput->Close();
        mInput = 0;

        // post done copying event
        PostDoneEvent();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

static NS_METHOD MyCopier::FillOutputBuffer ( nsIOutputStream outStr,
void closure,
char *  buffer,
PRUint32  offset,
PRUint32  count,
PRUint32 countRead 
) [inline, static]

Definition at line 209 of file TestStreamTransport.cpp.

    {
        MyCopier *self = (MyCopier *) closure;

        nsresult rv = self->mInput->Read(buffer, count, countRead);
        if (NS_FAILED(rv))
            self->mInputCondition = rv;
        else if (*countRead == 0)
            self->mInputCondition = NS_BASE_STREAM_CLOSED;

        return self->mInputCondition;
    }

Here is the caller 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 136 of file TestStreamTransport.cpp.

    {
        LOG(("OnInputStreamReady\n"));
        nsAutoLock lock(mLock);
        NS_ASSERTION(inStr == mInput, "unexpected stream");
        Process_Locked();
        return NS_OK;
    }

Here is the call graph for this function:

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

Parameters:
aStreamThe stream whose asyncWait method was called.

Definition at line 146 of file TestStreamTransport.cpp.

    {
        LOG(("OnOutputStreamReady\n"));
        nsAutoLock lock(mLock);
        NS_ASSERTION(outStr == mOutput, "unexpected stream");
        Process_Locked();
        return NS_OK;
    }

Here is the call graph for this function:

Definition at line 168 of file TestStreamTransport.cpp.

    {
        while (1) {
            mInputCondition = NS_OK; // reset

            PRUint32 n;
            nsresult rv = mOutput->WriteSegments(FillOutputBuffer, this, CHUNK_SIZE, &n);
            if (NS_FAILED(rv) || (n == 0)) {
                if (rv == NS_BASE_STREAM_WOULD_BLOCK)
                    mOutput->AsyncWait(this, 0, 0, nsnull);
                else if (mInputCondition == NS_BASE_STREAM_WOULD_BLOCK)
                    mInput->AsyncWait(this, 0, 0, nsnull);
                else
                    Close_Locked();
                break;
            }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 229 of file TestStreamTransport.cpp.

Definition at line 231 of file TestStreamTransport.cpp.

PRLock* MyCopier::mLock [protected]

Definition at line 228 of file TestStreamTransport.cpp.

Definition at line 230 of file TestStreamTransport.cpp.


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