*info = infoObject; NS_ADDREF(*info);
infoObject->QueryInterface(NS_GET_IID(nsISupports), (void**) info);
nsSSLIOLayerNewSocket( const char *host,                        PRInt32 port,                        const char *proxyHost,                        PRInt32 proxyPort,                       PRFileDesc **fd,                        nsISupports** info,                       PRBool useTLS){    if (firstTime)    {        nsSSLIOLayerIdentity        = PR_GetUniqueIdentity("Cartman layer");        nsSSLIOLayerMethods         = *PR_GetDefaultIOMethods();                nsSSLIOLayerMethods.connect = nsSSLIOLayerConnect;        nsSSLIOLayerMethods.close   = nsSSLIOLayerClose;        nsSSLIOLayerMethods.read    = nsSSLIOLayerRead;        nsSSLIOLayerMethods.write   = nsSSLIOLayerWrite;                        nsresult result = nsServiceManager::GetService( PSM_COMPONENT_CONTRACTID,                                                        NS_GET_IID(nsIPSMComponent),                                                         (nsISupports**)&gPSMService);          if (NS_FAILED(result))            return PR_FAILURE;                firstTime                   = PR_FALSE;            }            PRFileDesc *   sock;    PRFileDesc *   layer;    PRStatus       rv;        /* Get a normal NSPR socket */    sock = PR_NewTCPSocket();      if (! sock) return NS_ERROR_OUT_OF_MEMORY;        /* disable Nagle algorithm delay for control sockets */    PRSocketOptionData sockopt;    sockopt.option = PR_SockOpt_NoDelay;    sockopt.value.no_delay = PR_TRUE;       rv = PR_SetSocketOption(sock, &sockopt);    PR_ASSERT(PR_SUCCESS == rv);            layer = PR_CreateIOLayerStub(nsSSLIOLayerIdentity, &nsSSLIOLayerMethods);    if (! layer)    {        PR_Close(sock);        return NS_ERROR_FAILURE;    }        nsPSMSocketInfo * infoObject = new nsPSMSocketInfo();    if (!infoObject)    {        PR_Close(sock);        // clean up IOLayerStub.        PR_DELETE(layer);        return NS_ERROR_FAILURE;    }    NS_ADDREF(infoObject);    infoObject->SetHostName(host);    infoObject->SetHostPort(port);    infoObject->SetProxyName(proxyHost);    infoObject->SetProxyPort(proxyPort);    infoObject->SetUseTLS(useTLS);        layer->secret = (PRFilePrivate*) infoObject;    rv = PR_PushIOLayer(sock, PR_GetLayersIdentity(sock), layer);        if (NS_FAILED(rv))    {        PR_Close(sock);        NS_RELEASE(infoObject);        PR_DELETE(layer);        return NS_ERROR_FAILURE;    }        *fd   = sock;    *info = infoObject;    NS_ADDREF(*info);    return NS_OK;}