Bug 622160:
authorPatrick Brunschwig <patrick@enigmail.net>
Tue, 07 Jun 2011 19:27:18 +0200
changeset 2 3aa8d8e7a70a4ec2fe6fa1499b4c4cbbb7cc3e48
parent 1 d08ddca17732cdb9d92dda87ee66cf7c21ce22db
child 3 a93d3439b0e619517e1d6518e2d07ff76c91d69a
push id3
push userpatrick@enigmail.net
push dateTue, 07 Jun 2011 17:27:30 +0000
bugs622160
Bug 622160: Fix compilation on Gecko 5.0; remove compatibility pre-Gecko 5.0 r=cjones
build/nsIPCModule.cpp
makemake
readme.txt
src/ipc.h
src/nsIPCBuffer.cpp
src/nsIPCBuffer.h
src/nsPipeTransport.cpp
src/nsPipeTransport.h
--- a/build/nsIPCModule.cpp
+++ b/build/nsIPCModule.cpp
@@ -34,49 +34,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "ipc.h"
 #include "nsIClassInfoImpl.h"
 
 #include "nsPipeTransport.h"
 #include "nsIPCBuffer.h"
 
-#if MOZILLA_MAJOR_VERSION < 2
-
-#include "nsIGenericFactory.h"
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsPipeTransport)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsIPCBuffer)
-
-
-// CIDs implemented by module
-static const nsModuleComponentInfo components[] =
-{
-
-    { NS_PIPETRANSPORT_CLASSNAME,
-      NS_PIPETRANSPORT_CID,
-      NS_PIPETRANSPORT_CONTRACTID,
-      nsPipeTransportConstructor
-    },
-
-    { NS_IPCBUFFER_CLASSNAME,
-      NS_IPCBUFFER_CID,
-      NS_IPCBUFFER_CONTRACTID,
-      nsIPCBufferConstructor
-    }
-
-};
-
-// Module entry point
-NS_IMPL_NSGETMODULE(nsIPCModule, components)
-
-#else
- // Gecko >= 2.0
-
- #include "mozilla/ModuleUtils.h"
+#include "mozilla/ModuleUtils.h"
 
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsPipeTransport)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIPCBuffer)
 
 NS_DEFINE_NAMED_CID(NS_PIPETRANSPORT_CID);
 NS_DEFINE_NAMED_CID(NS_IPCBUFFER_CID);
 
 const mozilla::Module::CIDEntry kIPCModuleCIDs[] = {
@@ -94,9 +62,8 @@ const mozilla::Module::ContractIDEntry k
 static const mozilla::Module kIPCModule = {
   mozilla::Module::kVersion,
   kIPCModuleCIDs,
   kIPCModuleContracts,
   NULL
 };
 
 NSMODULE_DEFN(nsIPCModule) = &kIPCModule;
-#endif
new file mode 100755
--- /dev/null
+++ b/makemake
@@ -0,0 +1,193 @@
+#!/usr/bin/perl
+
+# **** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "MPL"); you may not use this file
+# except in compliance with the MPL. You may obtain a copy of
+# the MPL at http://www.mozilla.org/MPL/
+#
+# Software distributed under the MPL is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the MPL for the specific language governing
+# rights and limitations under the MPL.
+#
+# The Original Code is ipccode.
+#
+# The Initial Developer of the Original Code is Patrick Brunschwig.
+# Portions created by Patrick Brunschwig <patrick@mozilla-enigmail.org> are
+# Copyright (C) 2011 Patrick Brunschwig. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# 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 *****
+
+# makemake: script to generate Makefile from Makefile.in
+#           -r:     process recursively all subdirectories
+#           -o DIR: use DIR as MOZ_OBJDIR
+# Usage: makemake [-o @TOPSRCDIR@/somedir] [-r]
+
+my $makelist="./Makefile.in";
+my $mozObjDir=".";
+my $makefile;
+
+my $cwd=`pwd`;
+chomp($cwd);
+my $topdir=$cwd;
+my $depth="";
+
+open(MAKEFILE, $makelist) || die ("Could not open '$makelist'\n");
+while (my $l = <MAKEFILE>) {
+  chomp($l);
+  if ($l =~ /^\s*DEPTH\s*=/) {
+    $l =~ s/(^\s*DEPTH\s*=\s*)(.*)$/$2/;
+    $depth = $l;
+  }
+}
+close(MAKEFILE);
+
+if ($depth eq "") {
+  while ( (length($topdir)>0) && ( basename($topdir) ne "mozilla" )) {
+    $topdir=dirname($topdir);
+  }
+}
+else {
+  chdir($depth) || die "Directory '$depth' not found\n";
+  chdir("..");
+  $topdir=`pwd`;
+  chomp($topdir);
+  chdir($cwd);
+}
+print "INFO: found toplevel source directory $topdir\n";
+
+
+if (open(MOZCONFIG, "$topdir/.mozconfig")) {
+  while (my $l = <MOZCONFIG>) {
+    chomp($l);
+    if ($l =~ /^\s*mk_add_options\s+MOZ_OBJDIR\s*=/) {
+      $l =~ s/(^\s*mk_add_options\s+MOZ_OBJDIR\s*=\s*)(.*)$/$2/;
+      $mozObjDir = $l;
+    }
+  }
+  close(MOZCONFIG);
+}
+else {
+  print "INFO: no .mozconfig file found\n";
+}
+
+
+while ( $#ARGV >= 0 ) {
+  if ($ARGV[0] eq "-o") {
+    $mozObjDir=$ARGV[1];
+    shift @ARGV;
+  }
+  if ($ARGV[0] eq "-r") {
+    $makelist=`find . -name Makefile.in -print`;
+    break;
+  }
+  shift @ARGV;
+}
+
+
+$mozObjDir =~ s/\@TOPSRCDIR\@/$topdir/;
+
+if ($mozObjDir eq ".") {
+  print "INFO: no MOZ_OBJDIR used\n";
+}
+else {
+  print "INFO: using MOZ_OBJDIR=$mozObjDir\n\n";
+}
+
+foreach $makefile (split(/[ \n\r]+/, $makelist)) {
+  $makefile =~ s/^\.\///;
+  my $dir=dirname("$cwd/$makefile");
+
+  my $wd=$dir;
+  print "Processing: $wd\n";
+  my $top_srcdir="";
+  my $newMakefile = $makefile;
+  $newMakefile =~ s/.in$//;
+
+  if ($mozObjDir eq ".") {
+    # no OBJDIR specified
+    if ($depth eq "") {
+      while ( (length($wd)>0) && (basename($wd) ne "mozilla") ) {
+        if (length($top_srcdir) == 0) {
+          $top_srcdir="..";
+        }
+        else {
+          $top_srcdir="../$top_srcdir";
+        }
+        $wd=dirname($wd);
+      }
+    }
+    else {
+      $top_srcdir=$topdir;
+    }
+    $srcdir=".";
+  }
+  else {
+    # using OBJDIR
+    if ($depth eq "") {
+      # while ( (length($wd)>0) && (basename($wd) ne "mozilla") ) {
+      while ( length($wd)>0 ) {
+        $wd=dirname($wd);
+      }
+      $top_srcdir="$wd";
+    }
+    else {
+      $top_srcdir="$topdir";
+    }
+    $srcdir=$dir;
+    my $targetDir=$srcdir;
+    $targetDir =~ s/$top_srcdir/$mozObjDir/x;
+    system("mkdir -p '$targetDir'");
+    $newMakefile=sprintf("%s/%s", $targetDir, basename($newMakefile));
+  }
+
+  # print "Creating file $newMakefile\n";
+  open(INFILE, $makefile) || die ("cannot open input file '$makefile'\n");
+  open(OUTFILE, ">$newMakefile") || die ("cannot open output file '$newMakefile'\n");
+
+  my $line;
+  while ($line = <INFILE>) {
+    $line =~ s/\@srcdir\@/$srcdir/g;
+    $line =~ s/\@top_srcdir\@/$top_srcdir\/mozilla/g;
+    print OUTFILE $line;
+  }
+  close(INFILE);
+  close(OUTFILE);
+}
+
+if ($mozObjDir eq ".") {
+  print "Done\n\n";
+}
+else {
+  my $newWd=$cwd;
+  $newWd =~ s/$topdir/$mozObjDir/x;
+  print "Done. The code can now be compiled from $newWd\n\n";
+}
+
+sub basename {
+  my $fn=$_[0];
+  $fn =~ s/^(.*)\/(.*)$/$2/;
+  return $fn;
+}
+
+sub dirname {
+  my $dn=$_[0];
+  $dn =~ s/^(.*)\/(.*)$/$1/;
+  return $dn;
+}
new file mode 100644
--- /dev/null
+++ b/readme.txt
@@ -0,0 +1,16 @@
+Compiling ipccode
+*****************
+
+To compile ipccode, follow these steps:
+1. Compile a complete Firefox build
+2. Copy the ipcode directory into src/mozilla/extensions
+3. cd to src/mozilla/extensions/ipccode
+4. execute: ./makemake -r
+5. cd to @MOZ_OBDIR@/mozilla/extensions/ipccode and execute "make"
+
+Notes
+*****
+makemake cannot handle symbolic links, you need to cd to the real directory
+of your source code.
+makemake tries to read your .mozconfig file to determine @MOZ_OBJDIR@. You can
+alternatively provide your own MOZ_OBJDIR using makemake -o
--- a/src/ipc.h
+++ b/src/ipc.h
@@ -31,29 +31,16 @@
  * 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 ***** */
 
 #ifndef ipc_h__
 #define ipc_h__
 
-
-// To be removed for final commit, left here because I also (need to) compile it
-// for TB 3.1
-
-#if MOZILLA_MAJOR_VERSION < 2
-#if MOZ_THUNDERBIRD || MOZ_SUITE || MOZ_STATIC_MAIL_BUILD
-
-#define _IPC_FORCE_INTERNAL_API 1
-#define MOZILLA_INTERNAL_API
-
-#endif
-#endif // MOZILLA_MAJOR_VERSION
-
 #ifdef FORCE_PR_LOG
 #include "nsIThread.h"
 #include "nsThreadUtils.h"
 
 #define IPC_GET_THREAD(myThread) NS_GetCurrentThread(getter_AddRefs(myThread))
 
 #endif  // FORCE_PR_LOG
 #endif // ipc_h__
--- a/src/nsIPCBuffer.cpp
+++ b/src/nsIPCBuffer.cpp
@@ -33,17 +33,17 @@
 
 // Logging of debug output
 // The following define statement should occur before any include statements
 #define FORCE_PR_LOG       /* Allow logging even in release build */
 
 #include "ipc.h"
 #include "prlog.h"
 #include "nsCOMPtr.h"
-#include "nsAutoLock.h"
+#include "mozilla/Mutex.h"
 #include "nsIInputStream.h"
 #include "nsIThread.h"
 #include "nsIHttpChannel.h"
 #include "nsNetUtil.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsNetCID.h"
 #include "nsStringGlue.h"
@@ -61,16 +61,18 @@ PRLogModuleInfo* gIPCBufferLog = NULL;
 #define NS_PIPE_CONSOLE_BUFFER_SIZE   (1024)
 
 static const PRUint32 kCharMax = NS_PIPE_CONSOLE_BUFFER_SIZE;
 
 ///////////////////////////////////////////////////////////////////////////////
 
 // nsIPCBuffer implementation
 
+using namespace mozilla;
+
 // nsISupports implementation
 NS_IMPL_THREADSAFE_ISUPPORTS6(nsIPCBuffer,
                               nsIRequestObserver,
                               nsIStreamListener,
                               nsIPipeListener,
                               nsIIPCBuffer,
                               nsIInputStream,
                               nsIRunnable)
@@ -82,18 +84,17 @@ nsIPCBuffer::nsIPCBuffer() :
     mInitialized(PR_FALSE),
     mThreadJoined(PR_FALSE),
     mOverflowed(PR_FALSE),
     mOverflowFile(PR_FALSE),
 
     mRequestStarted(PR_FALSE),
     mRequestStopped(PR_FALSE),
 
-    mLock(nsnull),
-
+    mLock("nsIPCBuffer.lock"),
     mMaxBytes(0),
     mByteCount(0),
     mStreamOffset(0),
 
     mByteBuf(""),
 
     mPipeWrite(IPC_NULL_HANDLE),
     mPipeRead(IPC_NULL_HANDLE),
@@ -127,18 +128,16 @@ nsIPCBuffer::~nsIPCBuffer()
   nsCOMPtr<nsIThread> myThread;
   IPC_GET_THREAD(myThread);
   DEBUG_LOG(("nsIPCBuffer:: >>>>>>>>> DTOR(%p): myThread=%p\n",
          this, myThread.get()));
 #endif
 
   Finalize(PR_TRUE);
 
-  if (mLock)
-    PR_DestroyLock(mLock);
 }
 
 
 ///////////////////////////////////////////////////////////////////////////////
 // nsIPCBuffer methods:
 ///////////////////////////////////////////////////////////////////////////////
 
 nsresult
@@ -177,22 +176,16 @@ nsIPCBuffer::Finalize(PRBool destructor)
   return NS_OK;
 }
 
 nsresult
 nsIPCBuffer::Init()
 {
   DEBUG_LOG(("nsIPCBuffer::Init: \n"));
 
-  if (!mLock) {
-    mLock = PR_NewLock();
-    if (!mLock)
-      return NS_ERROR_OUT_OF_MEMORY;
-  }
-
   mInitialized = PR_TRUE;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsIPCBuffer::Open(PRInt32 maxBytes, PRBool overflowFile)
 {
@@ -501,17 +494,17 @@ nsIPCBuffer::RemoveTempFile()
 
 
 NS_IMETHODIMP
 nsIPCBuffer::GetData(char** _retval)
 {
   NS_ENSURE_FALSE(mFinalized, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
-  nsAutoLock lock(mLock);
+  MutexAutoLock lock(mLock);
 
   if (!_retval)
     return NS_ERROR_NULL_POINTER;
 
   // Copy portion of console data to be returned
   nsCAutoString bufCopy (mByteBuf);
 
   // Replace any NULs with '0'
@@ -539,17 +532,17 @@ nsIPCBuffer::GetData(char** _retval)
 NS_IMETHODIMP
 nsIPCBuffer::Observe(nsIRequestObserver* observer, nsISupports* context)
 {
   NS_ENSURE_FALSE(mFinalized, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
   NS_ENSURE_ARG(observer);
 
-  nsAutoLock lock(mLock);
+  MutexAutoLock lock(mLock);
   DEBUG_LOG(("nsIPCBuffer::Observe: %p, %p\n", observer, context));
 
   mObserver = observer;
   mObserverContext = context;
 
   return NS_OK;
 }
 
@@ -566,33 +559,33 @@ nsIPCBuffer::GetJoinable(PRBool *_retval
 
 
 NS_IMETHODIMP
 nsIPCBuffer::Shutdown()
 {
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
   // allow to perform even if mFinalized is true
 
-  nsAutoLock lock(mLock);
+  MutexAutoLock lock(mLock);
   DEBUG_LOG(("nsIPCBuffer::Shutdown:\n"));
 
   Finalize(PR_FALSE);
 
   return NS_OK;
 }
 
 
 
 NS_IMETHODIMP
 nsIPCBuffer::GetByteData(PRUint32 *count, char **data)
 {
   NS_ENSURE_FALSE(mFinalized, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
-  nsAutoLock lock(mLock);
+  MutexAutoLock lock(mLock);
 
   DEBUG_LOG(("nsIPCBuffer::GetByteData:\n"));
 
   if (!count || !data)
     return NS_ERROR_NULL_POINTER;
 
   // Copy bytes
   *count = mByteBuf.Length();
@@ -610,17 +603,17 @@ nsIPCBuffer::GetByteData(PRUint32 *count
 
 
 NS_IMETHODIMP
 nsIPCBuffer::GetOverflowed(PRBool *_retval)
 {
   NS_ENSURE_FALSE(mFinalized, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
-  nsAutoLock lock(mLock);
+  MutexAutoLock lock(mLock);
 
   DEBUG_LOG(("nsIPCBuffer::GetOverflowed: %d\n", (int) mOverflowed));
 
   *_retval = mOverflowed;
 
   return NS_OK;
 }
 
@@ -651,17 +644,17 @@ nsIPCBuffer::WriteBuf(const char* buf, P
   DEBUG_LOG(("nsIPCBuffer::WriteBuf: %d (%d)\n", count, mByteCount));
 
   NS_ENSURE_FALSE(mFinalized, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
   NS_ENSURE_ARG(buf);
 
   nsresult rv;
-  nsAutoLock lock(mLock);
+  MutexAutoLock lock(mLock);
 
   if (count <= 0)
     return NS_OK;
 
   mByteCount += count;
 
   if (mOverflowed) {
     if (!mOverflowFile)
@@ -705,17 +698,17 @@ nsIPCBuffer::Join()
 {
   NS_ENSURE_FALSE(mFinalized, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
   nsresult rv;
 
   {
     // Nested lock to avoid deadlock while waiting for Join
-    nsAutoLock lock(mLock);
+    MutexAutoLock lock(mLock);
     DEBUG_LOG(("nsIPCBuffer::Join:\n"));
 
     if (mThreadJoined || !mPipeThread)
       return NS_OK;
 
     if (mPipeWrite) {
       // Close write pipe before joining
       IPC_Close(mPipeWrite);
@@ -735,17 +728,17 @@ nsIPCBuffer::Join()
 NS_IMETHODIMP
 nsIPCBuffer::GetFileDesc(IPCFileDesc **_retval)
 {
   NS_ENSURE_FALSE(mFinalized, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
   nsresult rv;
 
-  nsAutoLock lock(mLock);
+  MutexAutoLock lock(mLock);
 
   DEBUG_LOG(("nsIPCBuffer::GetFileDesc:\n"));
 
   NS_ENSURE_ARG_POINTER(_retval);
 
   if (!mFinalized && !mPipeThread) {
     // Create pipe pair
     PRStatus status = IPC_CreateInheritablePipe(&mPipeRead, &mPipeWrite,
@@ -778,17 +771,17 @@ nsIPCBuffer::OnStartRequest(nsIRequest *
   DEBUG_LOG(("nsIPCBuffer::OnStartRequest:\n"));
 
   NS_ENSURE_FALSE(mFinalized, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
   nsIRequestObserver* observer;
   nsISupports* observerContext;
   {
-    nsAutoLock lock(mLock);
+    MutexAutoLock lock(mLock);
 
     mRequestStarted = PR_TRUE;
 
     if (!mObserver)
       return NS_OK;
 
     observer = mObserver;
     observerContext = mObserverContext;
@@ -804,17 +797,17 @@ nsIPCBuffer::OnStopRequest(nsIRequest* a
   DEBUG_LOG(("nsIPCBuffer::OnStopRequest:\n"));
 
   NS_ENSURE_FALSE(mFinalized, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
   nsIRequestObserver* observer;
   nsISupports* observerContext;
   {
-    nsAutoLock lock(mLock);
+    MutexAutoLock lock(mLock);
 
     mRequestStopped = PR_TRUE;
     CloseTempOutStream();
 
     if (!mObserver)
       return NS_OK;
 
     observer = mObserver;
--- a/src/nsIPCBuffer.h
+++ b/src/nsIPCBuffer.h
@@ -41,16 +41,17 @@
 
 #include "nsIIPCBuffer.h"
 #include "nsIInputStream.h"
 #include "nsIFileStreams.h"
 #include "nsIRunnable.h"
 #include "nsIThread.h"
 #include "nsCOMPtr.h"
 #include "nsStringGlue.h"
+#include "mozilla/Mutex.h"
 
 // Implementation class for nsIIPCBuffer
 class nsIPCBuffer : public nsIIPCBuffer,
                     public nsIInputStream,
                     public nsIRunnable
 {
 public:
     NS_DECL_ISUPPORTS
@@ -83,17 +84,17 @@ protected:
     PRBool                              mInitialized;
     PRBool                              mThreadJoined;
     PRBool                              mOverflowed;
     PRBool                              mOverflowFile;
 
     PRBool                              mRequestStarted;
     PRBool                              mRequestStopped;
 
-    PRLock*                             mLock;
+    mozilla::Mutex                      mLock;
 
     PRInt32                             mMaxBytes;
     PRUint32                            mByteCount;
     PRUint32                            mStreamOffset;
 
     nsCString                           mByteBuf;
 
     IPCFileDesc*                        mPipeWrite;
--- a/src/nsPipeTransport.cpp
+++ b/src/nsPipeTransport.cpp
@@ -36,17 +36,17 @@
 
 // Logging of debug output
 // The following define statement should occur before any include statements
 #define FORCE_PR_LOG       /* Allow logging even in release build */
 
 #include "ipc.h"
 #include "nsPipeTransport.h"
 #include "prlog.h"
-#include "nsAutoLock.h"
+#include "mozilla/Mutex.h"
 #include "plstr.h"
 #include "nsAutoPtr.h"
 #include "nsStringGlue.h"
 #include "netCore.h"
 
 #include "nsComponentManagerUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIServiceManager.h"
@@ -86,16 +86,18 @@ static const PRUint32 kCharMax = NS_PIPE
 // Default time after which a process is assumed to be dead (in ms.)
 #define DEFAULT_PROCESS_TIMEOUT_IN_MS  3600*1000
 
 // Time to wait after transmitting any kill string to process (in milliseconds)
 #define KILL_WAIT_TIME_IN_MS 20
 
 ///////////////////////////////////////////////////////////////////////////////
 
+using namespace mozilla;
+
 nsPipeTransport::nsPipeTransport() :
       mInitialized(PR_FALSE),
       mFinalized(PR_FALSE),
       mNoProxy(PR_FALSE),
       mStartedRequest(PR_FALSE),
 
       mPipeState(PIPE_NOT_YET_OPENED),
       mStdoutStream(STREAM_NOT_YET_OPENED),
@@ -1670,31 +1672,29 @@ NS_IMETHODIMP nsPipeTransport::Run(PRBoo
 NS_IMETHODIMP nsPipeTransport::RunAsync(const char **args,
                                     PRUint32 argCount,
                                     nsIObserver* observer,
                                     PRBool holdWeak)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
-#if MOZILLA_MAJOR_VERSION > 1
 NS_IMETHODIMP nsPipeTransport::Runw(PRBool blocking, const PRUnichar **args,
                                     PRUint32 argCount)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP nsPipeTransport::RunwAsync(const PRUnichar **args,
                                     PRUint32 argCount,
                                     nsIObserver* observer,
                                     PRBool holdWeak)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
-#endif
 
 ///////////////////////////////////////////////////////////////////////////////
 // nsIOutputStreamCallback methods:
 // (Should be invoked in the thread creating nsIPipeTransport object)
 ///////////////////////////////////////////////////////////////////////////////
 
 NS_IMETHODIMP
 nsPipeTransport::OnOutputStreamReady(nsIAsyncOutputStream* outStr)
@@ -1841,16 +1841,17 @@ nsPipeTransport::StopRequest(nsresult aS
 NS_IMPL_THREADSAFE_ISUPPORTS1 (nsStdoutPoller,
                                nsIRunnable)
 
 
 // nsStdoutPoller implementation
 nsStdoutPoller::nsStdoutPoller() :
     mInitialized(PR_FALSE),
     mFinalized(PR_FALSE),
+    mLock("nsPipeTransport.lock"),
     mInterrupted(PR_FALSE),
     mLoggingEnabled(PR_FALSE),
     mJoinableThread(PR_FALSE),
 
     mHeadersBuf(""),
     mHeadersBufSize(0),
     mHeadersLastNewline(0),
     mRequestStarted(PR_FALSE),
@@ -1865,17 +1866,16 @@ nsStdoutPoller::nsStdoutPoller() :
 {
 #ifdef FORCE_PR_LOG
   nsCOMPtr<nsIThread> myThread;
   IPC_GET_THREAD(myThread);
   DEBUG_LOG(("nsStdoutPoller:: <<<<<<<<< CTOR(%p): myThread=%p\n",
          this, myThread.get()));
 #endif
 
-  mLock = PR_NewLock();
 }
 
 
 nsStdoutPoller::~nsStdoutPoller()
 {
 #ifdef FORCE_PR_LOG
   nsCOMPtr<nsIThread> myThread;
   IPC_GET_THREAD(myThread);
@@ -1909,18 +1909,16 @@ nsStdoutPoller::~nsStdoutPoller()
 
   if (mPollFD) {
     PR_Free(mPollFD);
     mPollFD = nsnull;
   }
 
   // Clear header buffer
   mHeadersBuf.Assign("");
-
-  PR_DestroyLock(mLock);
 }
 
 
 ///////////////////////////////////////////////////////////////////////////////
 // nsStdoutPoller methods:
 ///////////////////////////////////////////////////////////////////////////////
 
 nsresult
@@ -2027,17 +2025,17 @@ nsStdoutPoller::Finalize(PRBool destruct
   nsresult rv = NS_OK;
 
   if (mFinalized)
     return NS_OK;
 
   mFinalized = PR_TRUE;
 
   {
-    nsAutoLock lock(mLock);
+    MutexAutoLock lock(mLock);
     // Set thread interrupted flag to avoid race conditions
     // when freeing mStdoutThread/mPollableEvent
     mInterrupted = PR_TRUE;
   }
 
   DEBUG_LOG(("nsStdoutPoller::Finalize:\n"));
 
   nsCOMPtr<nsIRunnable> self;
@@ -2054,41 +2052,41 @@ nsStdoutPoller::Finalize(PRBool destruct
 
   return rv;
 }
 
 
 NS_IMETHODIMP
 nsStdoutPoller::GetLoggingEnabled(PRBool *aLoggingEnabled)
 {
-  nsAutoLock lock(mLock);
+  MutexAutoLock lock(mLock);
 
   DEBUG_LOG(("nsStdoutPoller::GetLoggingEnabled: \n"));
   *aLoggingEnabled = mLoggingEnabled;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsStdoutPoller::SetLoggingEnabled(PRBool aLoggingEnabled)
 {
-  nsAutoLock lock(mLock);
+  MutexAutoLock lock(mLock);
 
   DEBUG_LOG(("nsStdoutPoller::SetLoggingEnabled: %d\n", aLoggingEnabled));
   mLoggingEnabled = aLoggingEnabled;
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
 nsStdoutPoller::IsInterrupted(PRBool* interrupted)
 {
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
   {
-    nsAutoLock lock(mLock);
+    MutexAutoLock lock(mLock);
 
 #ifdef FORCE_PR_LOG
     nsCOMPtr<nsIThread> myThread;
     IPC_GET_THREAD(myThread);
     DEBUG_LOG(("nsStdoutPoller::IsInterrupted: %p, myThread=%p\n",
            mInterrupted, myThread.get()));
 #endif
     NS_ENSURE_ARG_POINTER(interrupted);
@@ -2133,17 +2131,17 @@ nsStdoutPoller::Join()
   */
 NS_IMETHODIMP
 nsStdoutPoller::Interrupt(PRBool* alreadyInterrupted)
 {
 
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
   {
-    nsAutoLock lock(mLock);
+    MutexAutoLock lock(mLock);
 
     if (!alreadyInterrupted)
       *alreadyInterrupted = mInterrupted;
 
     if (mInterrupted)
       return NS_OK;
 
     mInterrupted = PR_TRUE;
--- a/src/nsPipeTransport.h
+++ b/src/nsPipeTransport.h
@@ -32,16 +32,17 @@
  * 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 ***** */
 
 
 #ifndef nsPipeTransport_h__
 #define nsPipeTransport_h__
 
+#include "ipc.h"
 #include "nspr.h"
 #include "IPCProcess.h"
 
 #include "nsIPipeTransport.h"
 #include "nsIPipeListener.h"
 #include "nsIRunnable.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsITransport.h"
@@ -52,16 +53,17 @@
 #include "nsILoadGroup.h"
 #include "nsCOMPtr.h"
 #include "nsIStreamListener.h"
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsIProcess.h"
 #include "nsThreadUtils.h"
 #include "nsStringGlue.h"
+#include "mozilla/Mutex.h"
 
 #include "nsIAsyncInputStream.h"
 #include "nsIAsyncOutputStream.h"
 
 #define NS_PIPE_TRANSPORT_DEFAULT_SEGMENT_SIZE   (2*1024)
 #define NS_PIPE_TRANSPORT_DEFAULT_BUFFER_SIZE    (8*1024)
 #define NS_PIPE_TRANSPORT_DEFAULT_HEADERS_SIZE   (4*1024)
 
@@ -259,17 +261,17 @@ public:
      */
     NS_IMETHODIMP SetLoggingEnabled(PRBool aLoggingEnabled);
 
 
 protected:
     PRBool                              mInitialized;
     PRBool                              mFinalized;
 
-    PRLock*                             mLock;
+    mozilla::Mutex                      mLock;
     PRBool                              mInterrupted;
     PRBool                              mLoggingEnabled;
     PRBool                              mJoinableThread;
 
     PRIntervalTime                      mTimeoutInterval;
 
     nsCString                           mHeadersBuf;
     PRUint32                            mHeadersBufSize;