Bug 542053 - OOPP do not work in XR builds. Use NS_GRE_DIR when determining exe path of child process. r=bsmedberg
authorDoug Turner <dougt@dougt.org>
Mon, 15 Mar 2010 10:08:27 -0700
changeset 39465 0b615190e79f1d03bd7f8048f8f58e92449171d0
parent 39464 c7938ef72f6f43be933eec3ca3f6b395909df723
child 39466 dd447218e3347a4bc0f12002e077f2ede831eafe
push id12210
push userdougt@mozilla.com
push dateMon, 15 Mar 2010 18:19:25 +0000
treeherdermozilla-central@dd447218e334 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs542053
milestone1.9.3a4pre
Bug 542053 - OOPP do not work in XR builds. Use NS_GRE_DIR when determining exe path of child process. r=bsmedberg
ipc/glue/GeckoChildProcessHost.cpp
ipc/glue/GeckoChildProcessHost.h
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -174,18 +174,32 @@ GeckoChildProcessHost::PerformAsyncLaunc
 //--------------------------------------------------
 #if defined(OS_POSIX)
   // For POSIX, we have to be extremely anal about *not* using
   // std::wstring in code compiled with Mozilla's -fshort-wchar
   // configuration, because chromium is compiled with -fno-short-wchar
   // and passing wstrings from one config to the other is unsafe.  So
   // we split the logic here.
 
-  FilePath exePath = FilePath(CommandLine::ForCurrentProcess()->argv()[0]);
-  exePath = exePath.DirName();
+  FilePath exePath;
+
+  nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
+  nsCOMPtr<nsIFile> greDir;
+  nsresult rv = directoryService->Get(NS_GRE_DIR, NS_GET_IID(nsIFile), getter_AddRefs(greDir));
+  if (NS_SUCCEEDED(rv))
+  {
+    nsCString path;
+    greDir->GetNativePath(path);
+    exePath = FilePath(path.get());
+  }
+  else
+  {
+    exePath = FilePath(CommandLine::ForCurrentProcess()->argv()[0]);
+    exePath = exePath.DirName();
+  }
   exePath = exePath.AppendASCII(MOZ_CHILD_PROCESS_NAME);
 
   // remap the IPC socket fd to a well-known int, as the OS does for
   // STDOUT_FILENO, for example
   int srcChannelFd, dstChannelFd;
   channel().GetClientFileDescriptorMapping(&srcChannelFd, &dstChannelFd);
   mFileMap.push_back(std::pair<int,int>(srcChannelFd, dstChannelFd));
 
--- a/ipc/glue/GeckoChildProcessHost.h
+++ b/ipc/glue/GeckoChildProcessHost.h
@@ -42,16 +42,19 @@
 #include "base/scoped_ptr.h"
 #include "base/waitable_event.h"
 #include "chrome/common/child_process_host.h"
 
 #include "mozilla/Monitor.h"
 
 #include "nsXULAppAPI.h"        // for GeckoProcessType
 
+#include "nsDirectoryServiceDefs.h"
+#include "nsIFile.h"
+
 namespace mozilla {
 namespace ipc {
 
 class GeckoChildProcessHost : public ChildProcessHost
 {
 protected:
   typedef mozilla::Monitor Monitor;