if (mTestAsyncOpen) { TestConnectionOpenObserver* obs = new TestConnectionOpenObserver(this); if (obs == nsnull) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(obs); rv = mTransport->AsyncOpen(obs, nsnull); NS_RELEASE(obs); if (NS_FAILED(rv)) { printf("Error: AsyncOpen failed..."); } }
TestConnection::Run(void){  nsresult rv = NS_OK;  // Create the Event Queue for this thread...  NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv);  if (NS_FAILED(rv)) return rv;  rv = eventQService->CreateThreadEventQueue();  if (NS_FAILED(rv)) return rv;  //  // Make sure that all resources were allocated in the constructor...  //  if (!mTransport) {    rv = NS_ERROR_FAILURE;  }  if (NS_SUCCEEDED(rv)) {    if (mIsAsync) {      //      // Initiate an async read...      //      rv = mTransport->AsyncRead(0, -1, mTransport, this);      if (NS_FAILED(rv)) {        printf("Error: AsyncRead failed...");      } else {        rv = WriteBuffer();      }      Pump_PLEvents(eventQService);        }    else {      while (NS_SUCCEEDED(rv)) {        rv = WriteBuffer();        if (NS_SUCCEEDED(rv)) {          rv = ReadBuffer();        }      }    }  }  printf("Transport thread exiting...\n");  return rv;}