Bug 1163103 - stop using NS_GetSpecialDirectory off the main thread within the cycle collector (via nsDumpUtils.cpp), r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D42856

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2019-08-21 17:23:03 +00:00
Родитель ede48d4cc5
Коммит 51739da3cb
2 изменённых файлов: 12 добавлений и 3 удалений

Просмотреть файл

@ -133,10 +133,14 @@ EXPORTS.mozilla += [
'TupleCycleCollection.h',
]
SOURCES += [
# nsDebugImpl isn't unified because we disable PGO so that NS_ABORT_OOM isn't
# optimized away oddly.
SOURCES += [
'nsDebugImpl.cpp',
# nsDumpUtils.cpp includes SpecialSystemDirectory.h which includes
# nsLocalFileMac.h which upsets other files in this dir that have a different
# idea about what `TextRange` means.
'nsDumpUtils.cpp',
]
SOURCES['nsDebugImpl.cpp'].no_pgo = True
@ -164,7 +168,6 @@ UNIFIED_SOURCES += [
'nsCycleCollectionParticipant.cpp',
'nsCycleCollector.cpp',
'nsCycleCollectorTraceJSHelpers.cpp',
'nsDumpUtils.cpp',
'nsErrorService.cpp',
'nsGZFileWriter.cpp',
'nsID.cpp',

Просмотреть файл

@ -13,6 +13,7 @@
#include "nsIObserverService.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Unused.h"
#include "SpecialSystemDirectory.h"
#ifdef XP_UNIX // {
# include "mozilla/Preferences.h"
@ -417,7 +418,12 @@ nsresult nsDumpUtils::OpenTempFile(const nsACString& aFilename, nsIFile** aFile,
#endif
nsresult rv;
if (!*aFile) {
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, aFile);
if (NS_IsMainThread()) {
// This allows tests to override, but isn't safe off-mainthread.
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, aFile);
} else {
rv = GetSpecialSystemDirectory(OS_TemporaryDirectory, aFile);
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}