diff --git a/mozilla/xpcom/tests/TestHarness.h b/mozilla/xpcom/tests/TestHarness.h index ac90c47a12f..f81807baec0 100644 --- a/mozilla/xpcom/tests/TestHarness.h +++ b/mozilla/xpcom/tests/TestHarness.h @@ -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 diff --git a/mozilla/xpcom/tests/TestPipe.cpp b/mozilla/xpcom/tests/TestPipe.cpp index 08d3b6ff759..d47b7c86cc2 100644 --- a/mozilla/xpcom/tests/TestPipe.cpp +++ b/mozilla/xpcom/tests/TestPipe.cpp @@ -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 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