mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
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 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
4cb234ed7e
commit
9335edc840
@ -102,48 +102,14 @@ 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)
|
||||
}
|
||||
};
|
||||
|
||||
@ -251,17 +217,6 @@ OSFileConstantsService::InitOSFileConstants()
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
@ -919,10 +874,6 @@ OSFileConstantsService::DefineOSFileConstants(JSContext* aCx,
|
||||
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)) {
|
||||
@ -935,20 +886,6 @@ OSFileConstantsService::DefineOSFileConstants(JSContext* aCx,
|
||||
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)
|
||||
|
@ -86,6 +86,9 @@ for (let [constProp, dirKey] of [
|
||||
["winAppDataDir", "AppData"],
|
||||
["winLocalAppDataDir", "LocalAppData"],
|
||||
["winStartMenuProgsDir", "Progs"],
|
||||
["tmpDir", "TmpD"],
|
||||
["homeDir", "Home"],
|
||||
["macUserLibDir", "ULibDir"],
|
||||
]) {
|
||||
|
||||
if (constProp in SharedAll.Constants.Path) {
|
||||
|
Loading…
Reference in New Issue
Block a user