Bug 1388134 - Move some OS.Constants.Path members to lazy init r=baku
☠☠ backed out by 017a4a49c716 ☠ ☠
authorDoug Thayer <dothayer@mozilla.com>
Mon, 01 Oct 2018 16:54:31 +0000
changeset 494759 238ec26bef308495ac182b6b66dc5cb6803ea5b4
parent 494758 6341cb6ae607587609d46353fee88a1d737a7fa2
child 494760 aeb38f1ace8d5f278d0e436e8dcfc68dc9da07c8
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1388134
milestone64.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 1388134 - Move some OS.Constants.Path members to lazy init r=baku These calls to GetPathToSpecialDir are performing some unnecessary IO during early startup which we'd like to defer. Simply adding the required ones to the list in osfile_async_front.jsm should mostly get us there. Differential Revision: https://phabricator.services.mozilla.com/D6079
dom/system/OSFileConstants.cpp
toolkit/components/osfile/modules/osfile_async_front.jsm
--- a/dom/system/OSFileConstants.cpp
+++ b/dom/system/OSFileConstants.cpp
@@ -97,58 +97,24 @@ StaticRefPtr<OSFileConstantsService> gIn
 
 struct
 OSFileConstantsService::Paths
 {
   /**
    * The name of the directory holding all the libraries (libxpcom, libnss, etc.)
    */
   nsString libDir;
-  nsString tmpDir;
   nsString profileDir;
   nsString localProfileDir;
-  /**
-   * The user's home directory
-   */
-  nsString homeDir;
-  /**
-   * The user's 'application data' directory.
-   * Windows:
-   *   HOME = Documents and Settings\$USER\Application Data
-   *   UAppData = $HOME[\$vendor]\$name
-   *
-   * Unix:
-   *   HOME = ~
-   *   UAppData = $HOME/.[$vendor/]$name
-   *
-   * Mac:
-   *   HOME = ~
-   *   UAppData = $HOME/Library/Application Support/$name
-   */
-  nsString userApplicationDataDir;
-
-#if defined(XP_MACOSX)
-  /**
-   * The user's Library directory.
-   */
-  nsString macUserLibDir;
-#endif // defined(XP_MACOSX)
 
   Paths()
   {
     libDir.SetIsVoid(true);
-    tmpDir.SetIsVoid(true);
     profileDir.SetIsVoid(true);
     localProfileDir.SetIsVoid(true);
-    homeDir.SetIsVoid(true);
-    userApplicationDataDir.SetIsVoid(true);
-
-#if defined(XP_MACOSX)
-    macUserLibDir.SetIsVoid(true);
-#endif // defined(XP_MACOSX)
   }
 };
 
 /**
  * Return the path to one of the special directories.
  *
  * @param aKey The key to the special directory (e.g. "TmpD", "ProfD", ...)
  * @param aOutPath The path to the special directory. In case of error,
@@ -246,27 +212,16 @@ OSFileConstantsService::InitOSFileConsta
       return rv;
     }
     rv = obsService->AddObserver(this, "profile-do-change", false);
     if (NS_FAILED(rv)) {
       return rv;
     }
   }
 
-  // For other directories, ignore errors (they may be undefined on
-  // some platforms or in non-Firefox embeddings of Gecko).
-
-  GetPathToSpecialDir(NS_OS_TEMP_DIR, paths->tmpDir);
-  GetPathToSpecialDir(NS_OS_HOME_DIR, paths->homeDir);
-  GetPathToSpecialDir(XRE_USER_APP_DATA_DIR, paths->userApplicationDataDir);
-
-#if defined(XP_MACOSX)
-  GetPathToSpecialDir(NS_MAC_USER_LIB_DIR, paths->macUserLibDir);
-#endif // defined(XP_MACOSX)
-
   mPaths = std::move(paths);
 
   // Get the umask from the system-info service.
   // The property will always be present, but it will be zero on
   // non-Unix systems.
   // nsSystemInfo::gUserUmask is initialized by NS_InitXPCOM2 so we don't need
   // to initialize the service.
   mUserUmask = nsSystemInfo::gUserUmask;
@@ -914,46 +869,28 @@ OSFileConstantsService::DefineOSFileCons
   if (!SetStringProperty(aCx, objPath, "libxul", libxul)) {
     return false;
   }
 
   if (!SetStringProperty(aCx, objPath, "libDir", mPaths->libDir)) {
     return false;
   }
 
-  if (!SetStringProperty(aCx, objPath, "tmpDir", mPaths->tmpDir)) {
-    return false;
-  }
-
   // Configure profileDir only if it is available at this stage
   if (!mPaths->profileDir.IsVoid()
     && !SetStringProperty(aCx, objPath, "profileDir", mPaths->profileDir)) {
     return false;
   }
 
   // Configure localProfileDir only if it is available at this stage
   if (!mPaths->localProfileDir.IsVoid()
     && !SetStringProperty(aCx, objPath, "localProfileDir", mPaths->localProfileDir)) {
     return false;
   }
 
-  if (!SetStringProperty(aCx, objPath, "homeDir", mPaths->homeDir)) {
-    return false;
-  }
-
-  if (!SetStringProperty(aCx, objPath, "userApplicationDataDir", mPaths->userApplicationDataDir)) {
-    return false;
-  }
-
-#if defined(XP_MACOSX)
-  if (!SetStringProperty(aCx, objPath, "macUserLibDir", mPaths->macUserLibDir)) {
-    return false;
-  }
-#endif // defined(XP_MACOSX)
-
   // sqlite3 is linked from different places depending on the platform
   nsAutoString libsqlite3;
 #if defined(ANDROID)
   // On Android, we use the system's libsqlite3
   libsqlite3.AppendLiteral(MOZ_DLL_PREFIX);
   libsqlite3.AppendLiteral("sqlite3");
   libsqlite3.AppendLiteral(MOZ_DLL_SUFFIX);
 #elif defined(XP_WIN)
--- a/toolkit/components/osfile/modules/osfile_async_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_async_front.jsm
@@ -81,16 +81,19 @@ function lazyPathGetter(constProp, dirKe
 
 for (let [constProp, dirKey] of [
   ["localProfileDir", "ProfLD"],
   ["profileDir", "ProfD"],
   ["userApplicationDataDir", "UAppData"],
   ["winAppDataDir", "AppData"],
   ["winLocalAppDataDir", "LocalAppData"],
   ["winStartMenuProgsDir", "Progs"],
+  ["tmpDir", "TmpD"],
+  ["homeDir", "Home"],
+  ["macUserLibDir", "ULibDir"],
   ]) {
 
   if (constProp in SharedAll.Constants.Path) {
     continue;
   }
 
   LOG("Installing lazy getter for OS.Constants.Path." + constProp +
       " because it isn't defined and profile may not be loaded.");