mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 14:25:49 +00:00
Bug 1838542 - Eliminate the most common warning spam from nsXREDirProvider::GetFile(). r=xpcom-reviewers,jstutte
Currently, this function warns any time it fails to return something. However, this warning happens extremely frequently in two cases: when the property is unknown or when somebody tries to get a profile directory in a child process. This patch eliminates those. It also consolidates some profile cases. Hopefully an additional 2 strcmps on common cases won't matter. Differential Revision: https://phabricator.services.mozilla.com/D181007
This commit is contained in:
parent
a6856ce2b4
commit
adb9a5e722
@ -327,13 +327,29 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
|
||||
|
||||
nsCOMPtr<nsIFile> file;
|
||||
|
||||
if (!strcmp(aProperty, NS_APP_USER_PROFILE_LOCAL_50_DIR)) {
|
||||
if (!strcmp(aProperty, NS_APP_USER_PROFILE_LOCAL_50_DIR) ||
|
||||
!strcmp(aProperty, NS_APP_PROFILE_LOCAL_DIR_STARTUP)) {
|
||||
if (mProfileLocalDir) {
|
||||
rv = mProfileLocalDir->Clone(getter_AddRefs(file));
|
||||
} else {
|
||||
// Profile directories are only set up in the parent process.
|
||||
// We don't expect every caller to check if they are in the right process,
|
||||
// so fail immediately to avoid warning spam.
|
||||
NS_WARNING_ASSERTION(!XRE_IsParentProcess(),
|
||||
"tried to get profile in parent too early");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else if (!strcmp(aProperty, NS_APP_USER_PROFILE_50_DIR)) {
|
||||
} else if (!strcmp(aProperty, NS_APP_USER_PROFILE_50_DIR) ||
|
||||
!strcmp(aProperty, NS_APP_PROFILE_DIR_STARTUP)) {
|
||||
if (mProfileDir) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
} else {
|
||||
// Profile directories are only set up in the parent process.
|
||||
// We don't expect every caller to check if they are in the right process,
|
||||
// so fail immediately to avoid warning spam.
|
||||
NS_WARNING_ASSERTION(!XRE_IsParentProcess(),
|
||||
"tried to get profile in parent too early");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else if (!strcmp(aProperty, NS_GRE_DIR)) {
|
||||
// On Android, internal files are inside the APK, a zip file, so this
|
||||
@ -388,14 +404,6 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
|
||||
rv = GetUserProfilesLocalDir(getter_AddRefs(file));
|
||||
} else if (!strcmp(aProperty, XRE_EXECUTABLE_FILE)) {
|
||||
rv = XRE_GetBinaryPath(getter_AddRefs(file));
|
||||
} else if (!strcmp(aProperty, NS_APP_PROFILE_DIR_STARTUP)) {
|
||||
if (mProfileDir) {
|
||||
rv = mProfileDir->Clone(getter_AddRefs(file));
|
||||
}
|
||||
} else if (!strcmp(aProperty, NS_APP_PROFILE_LOCAL_DIR_STARTUP)) {
|
||||
if (mProfileLocalDir) {
|
||||
rv = mProfileLocalDir->Clone(getter_AddRefs(file));
|
||||
}
|
||||
}
|
||||
#if defined(XP_UNIX) || defined(XP_MACOSX)
|
||||
else if (!strcmp(aProperty, XRE_SYS_LOCAL_EXTENSION_PARENT_DIR)) {
|
||||
@ -470,6 +478,11 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent,
|
||||
rv = file->AppendNative(nsLiteralCString(PREF_OVERRIDE_DIRNAME));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = EnsureDirectoryExists(file);
|
||||
} else {
|
||||
// We don't know anything about this property. Fail without warning, because
|
||||
// otherwise we'll get too much warning spam due to
|
||||
// nsDirectoryService::Get() trying everything it gets with every provider.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user