Fix bustage from TestPipe.cpp; turns out NS_NewPipe2 isn't exported from XPCOM -- who knew? r+a=bustage

git-svn-id: svn://10.0.0.236/trunk@236427 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jwalden%mit.edu 2007-09-21 07:59:09 +00:00
parent 1e089da103
commit ddf249d5cc
2 changed files with 29 additions and 1 deletions

View File

@ -37,13 +37,14 @@
/*
* Test harness for XPCOM objects, providing a scoped XPCOM initializer,
* nsCOMPtr, nsRefPtr, and stdio.h/stdlib.h.
* nsCOMPtr, nsRefPtr, do_CreateInstance, and stdio.h/stdlib.h.
*/
#ifndef TestHarness_h__
#define TestHarness_h__
#include "nsIServiceManager.h"
#include "nsComponentManagerUtils.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include <stdio.h>

View File

@ -40,6 +40,33 @@
#include "nsIPipe.h"
#include "nsIMemory.h"
/** NS_NewPipe2 reimplemented, because it's not exported by XPCOM */
nsresult NS_NewPipe2(nsIAsyncInputStream** input,
nsIAsyncOutputStream** output,
PRBool nonBlockingInput = PR_FALSE,
PRBool nonBlockingOutput = PR_FALSE,
size_t segmentSize = 0,
PRUint32 segmentCount = 0,
nsIMemory* segmentAlloc = nsnull)
{
nsCOMPtr<nsIPipe> pipe = do_CreateInstance("@mozilla.org/pipe;1");
if (!pipe)
return NS_ERROR_OUT_OF_MEMORY;
nsresult rv = pipe->Init(nonBlockingInput,
nonBlockingOutput,
segmentSize,
segmentCount,
segmentAlloc);
if (NS_FAILED(rv))
return rv;
pipe->GetInputStream(input);
pipe->GetOutputStream(output);
return NS_OK;
}
/**
* Allocator can allocate exactly count * size bytes, stored at mMemory;
* immediately after the end of this is a byte-map of 0/1 values indicating