Bug 1077099: Set mGREBinDir in nsXREDirProvider::Initialize to avoid returning NULL in nsXREDirProvider::GetGREBinDir. r=bsmedberg
authorStephen Pohl <spohl.mozilla.bugs@gmail.com>
Fri, 10 Oct 2014 15:06:50 -0400
changeset 209879 fb27bd0c00841ba23ccfcde67f7ca6f7e7f0edeb
parent 209878 fb6af789bc67305f9fb503c372d571d1c68a4e5d
child 209880 9c87dcd656286c82f8575bf41a1295009756b29b
push id27628
push userkwierso@gmail.com
push dateSat, 11 Oct 2014 02:00:16 +0000
treeherdermozilla-central@f74ad36bb97b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs1077099
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1077099: Set mGREBinDir in nsXREDirProvider::Initialize to avoid returning NULL in nsXREDirProvider::GetGREBinDir. r=bsmedberg
ipc/testshell/XPCShellEnvironment.cpp
toolkit/xre/nsXREDirProvider.cpp
--- a/ipc/testshell/XPCShellEnvironment.cpp
+++ b/ipc/testshell/XPCShellEnvironment.cpp
@@ -57,21 +57,23 @@ class XPCShellDirProvider : public nsIDi
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIDIRECTORYSERVICEPROVIDER
 
     XPCShellDirProvider() { }
     ~XPCShellDirProvider() { }
 
-    bool SetGREDir(const char *dir);
-    void ClearGREDir() { mGREDir = nullptr; }
+    bool SetGREDirs(const char *dir);
+    void ClearGREDirs() { mGREDir = nullptr;
+                          mGREBinDir = nullptr; }
 
 private:
     nsCOMPtr<nsIFile> mGREDir;
+    nsCOMPtr<nsIFile> mGREBinDir;
 };
 
 inline XPCShellEnvironment*
 Environment(Handle<JSObject*> global)
 {
     AutoSafeJSContext cx;
     JSAutoCompartment ac(cx, global);
     Rooted<Value> v(cx);
@@ -406,31 +408,41 @@ NS_IMETHODIMP_(MozExternalRefCountType)
 XPCShellDirProvider::Release()
 {
     return 1;
 }
 
 NS_IMPL_QUERY_INTERFACE(XPCShellDirProvider, nsIDirectoryServiceProvider)
 
 bool
-XPCShellDirProvider::SetGREDir(const char *dir)
+XPCShellDirProvider::SetGREDirs(const char *dir)
 {
     nsresult rv = XRE_GetFileFromPath(dir, getter_AddRefs(mGREDir));
+    if (NS_SUCCEEDED(rv)) {
+        mGREDir->Clone(getter_AddRefs(mGREBinDir));
+#ifdef XP_MACOSX
+        mGREBinDir->SetNativeLeafName(NS_LITERAL_CSTRING("MacOS"));
+#endif
+    }
     return NS_SUCCEEDED(rv);
 }
 
 NS_IMETHODIMP
 XPCShellDirProvider::GetFile(const char *prop,
                              bool *persistent,
                              nsIFile* *result)
 {
     if (mGREDir && !strcmp(prop, NS_GRE_DIR)) {
         *persistent = true;
         NS_ADDREF(*result = mGREDir);
         return NS_OK;
+    } else if (mGREBinDir && !strcmp(prop, NS_GRE_BIN_DIR)) {
+        *persistent = true;
+        NS_ADDREF(*result = mGREBinDir);
+        return NS_OK;
     }
 
     return NS_ERROR_FAILURE;
 }
 
 // static
 XPCShellEnvironment*
 XPCShellEnvironment::CreateEnvironment()
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -98,16 +98,20 @@ nsXREDirProvider::Initialize(nsIFile *aX
                              nsIDirectoryServiceProvider* aAppProvider)
 {
   NS_ENSURE_ARG(aXULAppDir);
   NS_ENSURE_ARG(aGREDir);
 
   mAppProvider = aAppProvider;
   mXULAppDir = aXULAppDir;
   mGREDir = aGREDir;
+  mGREDir->Clone(getter_AddRefs(mGREBinDir));
+#ifdef XP_MACOSX
+  mGREBinDir->SetNativeLeafName(NS_LITERAL_CSTRING("MacOS"));
+#endif
 
   if (!mProfileDir) {
     nsCOMPtr<nsIDirectoryServiceProvider> app(do_QueryInterface(mAppProvider));
     if (app) {
       bool per = false;
       app->GetFile(NS_APP_USER_PROFILE_50_DIR, &per, getter_AddRefs(mProfileDir));
       NS_ASSERTION(per, "NS_APP_USER_PROFILE_50_DIR must be persistent!"); 
       NS_ASSERTION(mProfileDir, "NS_APP_USER_PROFILE_50_DIR not defined! This shouldn't happen!"); 
@@ -274,22 +278,16 @@ nsXREDirProvider::GetFile(const char* aP
   }
 
   *aPersistent = true;
 
   if (!strcmp(aProperty, NS_GRE_DIR)) {
     return mGREDir->Clone(aFile);
   }
   else if (!strcmp(aProperty, NS_GRE_BIN_DIR)) {
-    if (!mGREBinDir) {
-      mGREDir->Clone(getter_AddRefs(mGREBinDir));
-#ifdef XP_MACOSX
-      mGREBinDir->SetNativeLeafName(NS_LITERAL_CSTRING("MacOS"));
-#endif
-    }
     return mGREBinDir->Clone(aFile);
   }
   else if (!strcmp(aProperty, NS_OS_CURRENT_PROCESS_DIR) ||
            !strcmp(aProperty, NS_APP_INSTALL_CLEANUP_DIR)) {
     return GetAppDir()->Clone(aFile);
   }
 
   rv = NS_ERROR_FAILURE;