Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
TestCallbacks.cpp File Reference
#include "TestCommon.h"
#include <stdio.h>
#include "nspr.h"
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsIEventQueueService.h"
#include "nsIIOService.h"
#include "nsIServiceManager.h"
#include "nsIStreamListener.h"
#include "nsIInputStream.h"
#include "nsCRT.h"
#include "nsIChannel.h"
#include "nsIURL.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDNSService.h"
#include "nsISimpleEnumerator.h"
#include "nsXPIDLString.h"
#include "nsNetUtil.h"

Go to the source code of this file.


class  nsIEquals
class  ConsumerContext
class  Consumer




nsresult StartLoad (const char *)
int main (int argc, char *argv[])


static int gKeepRunning = 0
static nsIEventQueuegEventQ = nsnull
static PRBool gError = PR_FALSE

Define Documentation

{ 0x11c5c8ee, 0x1dd2, 0x11b2, \
      { 0xa8, 0x93, 0xbb, 0x23, 0xa1, 0xb6, 0x27, 0x76 }}

Definition at line 69 of file TestCallbacks.cpp.

Function Documentation

int main ( int  argc,
char *  argv[] 

Definition at line 243 of file TestCallbacks.cpp.

    if (test_common_init(&argc, &argv) != 0)
        return -1;

    nsresult rv = NS_OK;
    PRBool cmdLineURL = PR_FALSE;

    if (argc > 1) {
        // run in signle url mode
        cmdLineURL = PR_TRUE;

    rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
    if (NS_FAILED(rv)) return rv;

    // Create the Event Queue for this thread...
    nsCOMPtr<nsIEventQueueService> eventQService = 
             do_GetService(kEventQueueServiceCID, &rv);
    if (NS_FAILED(rv)) return rv;

    rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
    if (NS_FAILED(rv)) return rv;

    if (cmdLineURL) {
        rv = StartLoad(argv[1]);
    } else {
        rv = StartLoad("http://badhostnamexyz/test.txt");
    if (NS_FAILED(rv)) return rv;

    // Enter the message pump to allow the URL load to proceed.
    while ( gKeepRunning ) {
        PLEvent *gEvent;

    if (gError) {
        fprintf(stderr, "\n\n-------ERROR-------\n\n");
    return rv;

Here is the call graph for this function:

static NS_DEFINE_CID ( kIOServiceCID  ,
) [static]
nsresult StartLoad ( const char *  aURISpec)

Definition at line 287 of file TestCallbacks.cpp.

    nsresult rv = NS_OK;

    // create a context
    ConsumerContext *context = new ConsumerContext;
    nsCOMPtr<nsISupports> contextSup = do_QueryInterface(context, &rv);
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIIOService> serv = do_GetService(kIOServiceCID, &rv);
    if (NS_FAILED(rv)) return rv;

    // create a uri
    nsCOMPtr<nsIURI> uri;
    rv = NS_NewURI(getter_AddRefs(uri), aURISpec);
    if (NS_FAILED(rv)) return rv;

    // create a channel
    nsCOMPtr<nsIChannel> channel;
    rv = serv->NewChannelFromURI(uri, getter_AddRefs(channel));
    if (NS_FAILED(rv)) return rv;

    Consumer *consumer = new Consumer;
    rv = consumer->Init(uri, channel, contextSup);
    if (NS_FAILED(rv)) return rv;

    // kick off the load
    nsCOMPtr<nsIRequest> request;
    return channel->AsyncOpen(NS_STATIC_CAST(nsIStreamListener*, consumer), contextSup);

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

PRBool gError = PR_FALSE [static]

Definition at line 67 of file TestCallbacks.cpp.

Definition at line 66 of file TestCallbacks.cpp.

int gKeepRunning = 0 [static]

Definition at line 65 of file TestCallbacks.cpp.