Bug 1329294 - Part 1: Ensure Content Temp Dir is created before use. r=bsmedberg, a=lizzard
authorBob Owen <bobowencode@gmail.com>
Mon, 10 Apr 2017 14:38:13 +0100
changeset 395813 b1cbe3c1884a5a32e2ef353922ca8ce38b072fa3
parent 395812 d39fe2cbc120f0e5a24668bb76c0fa1d71871f7f
child 395814 af42f039717e4b4ffe43d5a131b1daf1e00ef9e4
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, lizzard
bugs1329294
milestone54.0a2
Bug 1329294 - Part 1: Ensure Content Temp Dir is created before use. r=bsmedberg, a=lizzard
toolkit/xre/nsXREDirProvider.cpp
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -744,17 +744,24 @@ GetContentProcessTempBaseDirKey()
 //
 // Sets mContentTempDir so that it refers to the appropriate temp dir.
 // If the sandbox is enabled, NS_APP_CONTENT_PROCESS_TEMP_DIR, otherwise
 // NS_OS_TEMP_DIR is used.
 //
 nsresult
 nsXREDirProvider::LoadContentProcessTempDir()
 {
-  mContentTempDir = GetContentProcessSandboxTempDir();
+  // The parent is responsible for creating the sandbox temp dir.
+  if (XRE_IsParentProcess()) {
+    mContentProcessSandboxTempDir = CreateContentProcessSandboxTempDir();
+    mContentTempDir = mContentProcessSandboxTempDir;
+  } else {
+    mContentTempDir = GetContentProcessSandboxTempDir();
+  }
+
   if (mContentTempDir) {
     return NS_OK;
   } else {
     return NS_GetSpecialDirectory(NS_OS_TEMP_DIR,
                                   getter_AddRefs(mContentTempDir));
   }
 }
 
@@ -1200,20 +1207,21 @@ nsXREDirProvider::DoStartup()
 
       mozilla::Telemetry::Accumulate(mozilla::Telemetry::NUMBER_OF_PROFILES,
                                      count);
     }
 
     obsSvc->NotifyObservers(nullptr, "profile-initial-state", nullptr);
 
 #if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX)
-    // The parent is responsible for creating the sandbox temp dir
-    if (XRE_IsParentProcess()) {
-      mContentProcessSandboxTempDir = CreateContentProcessSandboxTempDir();
-      mContentTempDir = mContentProcessSandboxTempDir;
+    // Makes sure the content temp dir has been loaded if it hasn't been
+    // already. In the parent this ensures it has been created before we attempt
+    // to start any content processes.
+    if (!mContentTempDir) {
+      mozilla::Unused << NS_WARN_IF(NS_FAILED(LoadContentProcessTempDir()));
     }
 #endif
   }
   return NS_OK;
 }
 
 void
 nsXREDirProvider::DoShutdown()