Back to index

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS MyHandler (const char *path, nsIAsyncInputStream *in, nsIAsyncOutputStream *out)
virtual ~MyHandler ()
NS_IMETHOD OnOutputStreamReady (nsIAsyncOutputStream *out)
NS_IMETHOD OnInputStreamReady (nsIAsyncInputStream *in)
void onOutputStreamReady (in nsIAsyncOutputStream aStream)
 Called to indicate that the stream is either writable or closed.
void onInputStreamReady (in nsIAsyncInputStream aStream)
 Called to indicate that the stream is either readable or closed.

Private Attributes

nsCOMPtr< nsIAsyncInputStreammInput
nsCOMPtr< nsIAsyncOutputStreammOutput
nsCString mBuf
PRUint32 mWriteOffset

Detailed Description

Definition at line 112 of file TestSocketTransport.cpp.


Constructor & Destructor Documentation

Definition at line 118 of file TestSocketTransport.cpp.

        : mInput(in)
        , mOutput(out)
        , mWriteOffset(0)
        {
            mBuf = NS_LITERAL_CSTRING("GET ")
                 + nsDependentCString(path)
                 + NS_LITERAL_CSTRING(" HTTP/1.0\r\n\r\n");
        }
virtual MyHandler::~MyHandler ( ) [inline, virtual]

Definition at line 129 of file TestSocketTransport.cpp.

{}

Member Function Documentation

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

Parameters:
aStreamThe stream whose asyncWait method was called.

Definition at line 157 of file TestSocketTransport.cpp.

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

        nsresult rv;
        PRUint32 n;
        char buf[500];

        rv = in->Read(buf, sizeof(buf), &n);

        LOG(("  read returned [rv=%x count=%u]\n", rv, n));

        if (NS_FAILED(rv) || (n == 0)) {
            if (rv != NS_BASE_STREAM_WOULD_BLOCK) {
                PostDoneEvent();
                return NS_OK;
            }
        }

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

Here is the call graph for this function:

Definition at line 132 of file TestSocketTransport.cpp.

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

        nsresult rv;
        PRUint32 n, count = mBuf.Length() - mWriteOffset;

        rv = out->Write(mBuf.get() + mWriteOffset, count, &n);

        LOG(("  write returned [rv=%x count=%u]\n", rv, n));

        if (NS_FAILED(rv) || (n == 0)) {
            if (rv != NS_BASE_STREAM_WOULD_BLOCK) {
                LOG(("  done writing; starting to read\n"));
                mInput->AsyncWait(this, 0, 0, nsnull);
                return NS_OK;
            }
        }

        mWriteOffset += n;

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

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.

Member Data Documentation

Definition at line 182 of file TestSocketTransport.cpp.

Definition at line 180 of file TestSocketTransport.cpp.

Definition at line 181 of file TestSocketTransport.cpp.

Definition at line 183 of file TestSocketTransport.cpp.


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