Bug 1388134 - Move some OS.Constants.Path members to lazy init r=baku
authorDoug Thayer <dothayer@mozilla.com>
Wed, 17 Oct 2018 17:36:04 +0000
changeset 441716 dd3bdf404bfb94d8d14d5099589c67a6e22a6ecb
parent 441715 3a4b8a6a0881ee031ce226f7a725d283e28f1137
child 441717 3f01db01f1d3e286ee75b8c349e6c2915512a96f
push id34873
push userdluca@mozilla.com
push dateWed, 17 Oct 2018 22:54:14 +0000
treeherdermozilla-central@bfd23ad81ef4 [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
@@ -100,55 +100,23 @@ 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,26 +214,17 @@ 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.
@@ -930,30 +889,16 @@ OSFileConstantsService::DefineOSFileCons
   }
 
   // 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.");