Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
TestHttp.cpp File Reference
#include "nsNetUtil.h"
#include "nsIEventQueueService.h"
#include "nsIServiceManager.h"
#include "nsIComponentRegistrar.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIProgressEventSink.h"

Go to the source code of this file.

Classes

class  MyListener
class  MyNotifications

Defines

#define RETURN_IF_FAILED(rv, step)

Functions

static NS_DEFINE_CID (kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID)
 NS_IMPL_ISUPPORTS2 (MyListener, nsIRequestObserver, nsIStreamListener) NS_IMETHODIMP MyListener
 NS_IMPL_THREADSAFE_ISUPPORTS2 (MyNotifications, nsIInterfaceRequestor, nsIProgressEventSink) NS_IMETHODIMP MyNotifications
int main (int argc, char **argv)
 The Xalan testcases app.

Variables

static nsIEventQueuegEventQ = nsnull
static PRBool gKeepRunning = PR_TRUE

Define Documentation

#define RETURN_IF_FAILED (   rv,
  step 
)
Value:
PR_BEGIN_MACRO \
    if (NS_FAILED(rv)) { \
        printf(">>> %s failed: rv=%x\n", step, rv); \
        return rv;\
    } \
    PR_END_MACRO

Definition at line 9 of file TestHttp.cpp.


Function Documentation

int main ( int  argc,
char **  argv 
)

The Xalan testcases app.

Definition at line 129 of file TestHttp.cpp.

{
    nsresult rv;

    if (argc == 1) {
        printf("usage: TestHttp <url>\n");
        return -1;
    }
    {
        nsCOMPtr<nsIServiceManager> servMan;
        NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
        nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
        NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
        if (registrar)
            registrar->AutoRegister(nsnull);

        // Create the Event Queue for this thread...
        nsCOMPtr<nsIEventQueueService> eqs =
                 do_GetService(kEventQueueServiceCID, &rv);
        RETURN_IF_FAILED(rv, "do_GetService(EventQueueService)");

        rv = eqs->CreateMonitoredThreadEventQueue();
        RETURN_IF_FAILED(rv, "CreateMonitoredThreadEventQueue");

        rv = eqs->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
        RETURN_IF_FAILED(rv, "GetThreadEventQueue");

        nsCOMPtr<nsIURI> uri;
        nsCOMPtr<nsIChannel> chan;
        nsCOMPtr<nsIStreamListener> listener = new MyListener();
        nsCOMPtr<nsIInterfaceRequestor> callbacks = new MyNotifications();

        rv = NS_NewURI(getter_AddRefs(uri), argv[1]);
        RETURN_IF_FAILED(rv, "NS_NewURI");

        rv = NS_NewChannel(getter_AddRefs(chan), uri, nsnull, nsnull, callbacks);
        RETURN_IF_FAILED(rv, "NS_OpenURI");

        rv = chan->AsyncOpen(listener, nsnull);
        RETURN_IF_FAILED(rv, "AsyncOpen");

        while (gKeepRunning)
            gEventQ->ProcessPendingEvents();

        printf(">>> done\n");
    } // this scopes the nsCOMPtrs
    // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
    rv = NS_ShutdownXPCOM(nsnull);
    NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
    return 0;
}

Here is the call graph for this function:

Definition at line 36 of file TestHttp.cpp.

{
    printf(">>> OnStartRequest\n");
    return NS_OK;
}

Definition at line 98 of file TestHttp.cpp.

{
    return QueryInterface(iid, result);
}

Variable Documentation

Definition at line 18 of file TestHttp.cpp.

Definition at line 19 of file TestHttp.cpp.