зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1541226 - Cache GetUserDataDirectory to improve IO performance r=mconley
Differential Revision: https://phabricator.services.mozilla.com/D32825 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e3d132a966
Коммит
8fe6331bd1
|
@ -74,11 +74,6 @@ const startupPhases = {
|
|||
// Anything done before or during app-startup must have a compelling reason
|
||||
// to run before we have even selected the user profile.
|
||||
"before profile selection": [
|
||||
{ // bug 1541226
|
||||
path: "UAppData:",
|
||||
condition: WIN,
|
||||
stat: 3,
|
||||
},
|
||||
{ // bug 1541200
|
||||
path: "UAppData:Crash Reports/InstallTime20*",
|
||||
condition: AppConstants.MOZ_CRASHREPORTER,
|
||||
|
@ -100,11 +95,6 @@ const startupPhases = {
|
|||
read: 1,
|
||||
close: 1,
|
||||
},
|
||||
{ // bug 1541226
|
||||
path: "DefProfLRt.parent:",
|
||||
condition: WIN,
|
||||
stat: 1,
|
||||
},
|
||||
{ // At least the read seems unavoidable for a regular startup.
|
||||
path: "UAppData:profiles.ini",
|
||||
condition: MAC,
|
||||
|
@ -130,7 +120,7 @@ const startupPhases = {
|
|||
{ // bug 1541226, bug 1363586, bug 1541593
|
||||
path: "ProfD:",
|
||||
condition: WIN,
|
||||
stat: 3,
|
||||
stat: 1,
|
||||
},
|
||||
{
|
||||
path: "ProfLD:.startup-incomplete",
|
||||
|
@ -225,7 +215,7 @@ const startupPhases = {
|
|||
{ // bug 1541226
|
||||
path: "ProfD:",
|
||||
condition: WIN,
|
||||
stat: 2,
|
||||
stat: 1,
|
||||
},
|
||||
{
|
||||
path: "XCurProcD:blocklist.xml",
|
||||
|
@ -289,16 +279,6 @@ const startupPhases = {
|
|||
read: 3,
|
||||
close: 3,
|
||||
},
|
||||
{ // bug 1541246
|
||||
path: "XREUSysExt:",
|
||||
condition: WIN,
|
||||
stat: 1,
|
||||
},
|
||||
{ // bug 1541246
|
||||
path: "XRESysExtDev:",
|
||||
condition: WIN,
|
||||
stat: 1,
|
||||
},
|
||||
{ // bug 1541246
|
||||
path: "ProfD:extensions",
|
||||
condition: WIN,
|
||||
|
|
|
@ -2356,7 +2356,8 @@ static void ExtractCompatVersionInfo(const nsACString& aCompatVersion,
|
|||
}
|
||||
|
||||
aAppVersion = Substring(aCompatVersion, 0, underscorePos);
|
||||
aAppBuildID = Substring(aCompatVersion, underscorePos + 1, slashPos - (underscorePos + 1));
|
||||
aAppBuildID = Substring(aCompatVersion, underscorePos + 1,
|
||||
slashPos - (underscorePos + 1));
|
||||
aPlatformBuildID = Substring(aCompatVersion, slashPos + 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,8 @@ static already_AddRefed<nsIFile> CreateProcessSandboxTempDir(
|
|||
nsXREDirProvider* gDirServiceProvider = nullptr;
|
||||
nsIFile* gDataDirHomeLocal = nullptr;
|
||||
nsIFile* gDataDirHome = nullptr;
|
||||
nsCOMPtr<nsIFile> gDataDirProfileLocal = nullptr;
|
||||
nsCOMPtr<nsIFile> gDataDirProfile = nullptr;
|
||||
|
||||
// These are required to allow nsXREDirProvider to be usable in xpcshell tests.
|
||||
// where gAppData is null.
|
||||
|
@ -1075,6 +1077,9 @@ nsXREDirProvider::DoStartup() {
|
|||
void nsXREDirProvider::DoShutdown() {
|
||||
AUTO_PROFILER_LABEL("nsXREDirProvider::DoShutdown", OTHER);
|
||||
|
||||
gDataDirProfileLocal = nullptr;
|
||||
gDataDirProfile = nullptr;
|
||||
|
||||
if (mProfileNotified) {
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
mozilla::services::GetObserverService();
|
||||
|
@ -1341,6 +1346,18 @@ nsXREDirProvider::SetUserDataDirectory(nsIFile* aFile, bool aLocal) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsresult nsXREDirProvider::SetUserDataProfileDirectory(nsCOMPtr<nsIFile>& aFile,
|
||||
bool aLocal) {
|
||||
if (aLocal) {
|
||||
gDataDirProfileLocal = aFile;
|
||||
} else {
|
||||
gDataDirProfile = aFile;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile,
|
||||
bool aLocal) {
|
||||
// Copied from nsAppFileLocationProvider (more or less)
|
||||
|
@ -1506,41 +1523,35 @@ nsresult nsXREDirProvider::GetSystemExtensionsDirectory(nsIFile** aFile) {
|
|||
|
||||
nsresult nsXREDirProvider::GetUserDataDirectory(nsIFile** aFile, bool aLocal) {
|
||||
nsCOMPtr<nsIFile> localDir;
|
||||
|
||||
if (aLocal && gDataDirProfileLocal) {
|
||||
return gDataDirProfileLocal->Clone(aFile);
|
||||
}
|
||||
if (!aLocal && gDataDirProfile) {
|
||||
return gDataDirProfile->Clone(aFile);
|
||||
}
|
||||
|
||||
nsresult rv = GetUserDataDirectoryHome(getter_AddRefs(localDir), aLocal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = AppendProfilePath(localDir, aLocal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#ifdef DEBUG_jungshik
|
||||
nsAutoCString cwd;
|
||||
localDir->GetNativePath(cwd);
|
||||
printf("nsXREDirProvider::GetUserDataDirectory: %s\n", cwd.get());
|
||||
#endif
|
||||
rv = EnsureDirectoryExists(localDir);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsXREDirProvider::SetUserDataProfileDirectory(localDir, aLocal);
|
||||
|
||||
localDir.forget(aFile);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXREDirProvider::EnsureDirectoryExists(nsIFile* aDirectory) {
|
||||
bool exists;
|
||||
nsresult rv = aDirectory->Exists(&exists);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
#ifdef DEBUG_jungshik
|
||||
if (!exists) {
|
||||
nsAutoCString cwd;
|
||||
aDirectory->GetNativePath(cwd);
|
||||
printf("nsXREDirProvider::EnsureDirectoryExists: %s does not\n", cwd.get());
|
||||
}
|
||||
#endif
|
||||
if (!exists) rv = aDirectory->Create(nsIFile::DIRECTORY_TYPE, 0700);
|
||||
#ifdef DEBUG_jungshik
|
||||
if (NS_FAILED(rv))
|
||||
NS_WARNING("nsXREDirProvider::EnsureDirectoryExists: create failed");
|
||||
#endif
|
||||
nsresult rv = aDirectory->Create(nsIFile::DIRECTORY_TYPE, 0700);
|
||||
|
||||
if (rv == NS_ERROR_FILE_ALREADY_EXISTS) {
|
||||
rv = NS_OK;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -154,6 +154,10 @@ class nsXREDirProvider final : public nsIDirectoryServiceProvider2,
|
|||
nsCOMPtr<nsIFile> mPluginProcessSandboxTempDir;
|
||||
#endif
|
||||
nsCOMArray<nsIFile> mAppBundleDirectories;
|
||||
|
||||
private:
|
||||
static nsresult SetUserDataProfileDirectory(nsCOMPtr<nsIFile>& aFile,
|
||||
bool aLocal);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче