Fix bustage from TestPipe.cpp; turns out NS_NewPipe2 isn't exported from XPCOM -- who knew? r+a=bustage
authorjwalden@mit.edu
Fri, 21 Sep 2007 00:59:09 -0700
changeset 6181 0ae8d19196bbf365082b6ffcd2a85de3b750366b
parent 6180 80d8fd8d7432b86415821c32a2a0b63cdbfce695
child 6182 246198dfdd004dc7c13bfb9743a86f82ae353a77
push idunknown
push userunknown
push dateunknown
milestone1.9a8pre
Fix bustage from TestPipe.cpp; turns out NS_NewPipe2 isn't exported from XPCOM -- who knew? r+a=bustage
xpcom/tests/TestHarness.h
xpcom/tests/TestPipe.cpp
--- a/xpcom/tests/TestHarness.h
+++ b/xpcom/tests/TestHarness.h
@@ -32,23 +32,24 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /*
  * 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>
 #include <stdlib.h>
 
 class ScopedXPCOM
 {
   public:
--- a/xpcom/tests/TestPipe.cpp
+++ b/xpcom/tests/TestPipe.cpp
@@ -35,16 +35,43 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "TestHarness.h"
 
 #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
  * which <size>-byte locations in mMemory are empty and which are filled.
  * Pretty stupid, but enough to test bug 394692.
  */
 class BackwardsAllocator : public nsIMemory
 {