if ( NS_FAILED( rv ) ) { DEBUG_PRINTF( PR_STDOUT, "%s %d : Error opening dialog, rv=0x%08X\n", (char *)__FILE__, (int)__LINE__, (int)rv ); }
NS_ASSERTION(NS_SUCCEEDED(rv), "Error opening dialog");
nsStreamTransfer::SelectFileAndTransferLocation( nsIChannel *aChannel,                                                 nsIDOMWindowInternal *parent,                                                 char const *contentType,                                                 char const *suggestedName ) {    // Prompt the user for the destination file.    nsCOMPtr<nsILocalFile> outputFile;    PRBool isValid = PR_FALSE;    nsresult rv = SelectFile( parent,                               getter_AddRefs( outputFile ),                              SuggestNameFor( aChannel, suggestedName ) );    if ( NS_SUCCEEDED( rv )         &&         outputFile ) {        // Try to get HTTP channel.        nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface( aChannel );        if ( httpChannel ) {            // Turn off content encoding conversions.            httpChannel->SetApplyConversion( PR_FALSE );        }        // Construct stream transfer operation to be given to dialog.        nsStreamXferOp *p= new nsStreamXferOp( aChannel, outputFile );        if ( p ) {            // Open download progress dialog.            NS_ADDREF(p);            rv = p->OpenDialog( parent );            NS_RELEASE(p);            if ( NS_FAILED( rv ) ) {                DEBUG_PRINTF( PR_STDOUT, "%s %d : Error opening dialog, rv=0x%08X\n",                              (char *)__FILE__, (int)__LINE__, (int)rv );            }        } else {            DEBUG_PRINTF( PR_STDOUT, "%s %d : Unable to create nsStreamXferOp\n",                          (char *)__FILE__, (int)__LINE__ );            rv = NS_ERROR_OUT_OF_MEMORY;        }    } else {        if ( NS_FAILED( rv ) ) {            DEBUG_PRINTF( PR_STDOUT, "Failed to select file, rv=0x%X\n", (int)rv );        } else {            // User cancelled.        }    }    return rv;}