rv = NS_NewISupportsArray(getter_AddRefs(uriList)); RETURN_IF_FAILED(rv, "NS_NewISupportsArray");
uriList = do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv); RETURN_IF_FAILED(rv, "do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID)");
int main(int argc, char **argv){     if (test_common_init(&argc, &argv) != 0)        return -1;    nsresult rv;    if (argc == 1) {        printf("usage: TestPageLoad <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);        PRTime start, finish;        rv = NS_NewISupportsArray(getter_AddRefs(uriList));        RETURN_IF_FAILED(rv, "NS_NewISupportsArray");        // 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");        printf("Loading necko ... \n");        nsCOMPtr<nsIChannel> chan;        nsCOMPtr<nsIStreamListener> listener = new MyListener();        nsCOMPtr<nsIInterfaceRequestor> callbacks = new MyNotifications();        rv = NS_NewURI(getter_AddRefs(baseURI), argv[1]);        RETURN_IF_FAILED(rv, "NS_NewURI");        rv = NS_NewChannel(getter_AddRefs(chan), baseURI, nsnull, nsnull, callbacks);        RETURN_IF_FAILED(rv, "NS_OpenURI");        gKeepRunning++;        //TIMER STARTED-----------------------        printf("Starting clock ... \n");        start = PR_Now();        rv = chan->AsyncOpen(listener, nsnull);        RETURN_IF_FAILED(rv, "AsyncOpen");        while (gKeepRunning) {            gEventQ->ProcessPendingEvents();        }        finish = PR_Now();        PRUint32 totalTime32;        PRUint64 totalTime64;        LL_SUB(totalTime64, finish, start);        LL_L2UI(totalTime32, totalTime64);        printf("\n\n--------------------\nAll done:\nnum found:%d\nnum start:%d\n", numFound, numStart);        printf("\n\n>>PageLoadTime>>%u>>\n\n", totalTime32);    } // 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;}