rv = NS_AutoregisterComponents(); RETURN_IF_FAILED(rv, "NS_AutoregisterComponents");
nsCOMPtr<nsIServiceManager> servMan; NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull); nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan); NS_ASSERTION(registrar, "Null nsIComponentRegistrar"); registrar->AutoRegister(nsnull);
int main(int argc, char **argv){    nsresult rv;    if (argc == 1) {        printf("usage: TestHttp <url>\n");        return -1;    }    rv = NS_AutoregisterComponents();    RETURN_IF_FAILED(rv, "NS_AutoregisterComponents");    // 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_OpenURI(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");    return 0;}