зеркало из https://github.com/mozilla/gecko-dev.git
Bug 845804 - Reuse OpenTempFile from nsMemoryInfoDumper in nsCycleCollector.cpp. r=njn
CLOSED TREE
This commit is contained in:
Родитель
02245ab6dd
Коммит
27f16bb571
|
@ -123,6 +123,7 @@
|
|||
#include "nsIMemoryReporter.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsMemoryInfoDumper.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsXPCOMPrivate.h"
|
||||
#include "sampler.h"
|
||||
|
@ -1404,32 +1405,15 @@ private:
|
|||
mFilenameIdentifier.IsEmpty() ? "" : ".",
|
||||
NS_ConvertUTF16toUTF8(mFilenameIdentifier).get());
|
||||
|
||||
// Get the log directory either from $MOZ_CC_LOG_DIRECTORY or from our
|
||||
// platform's temp directory. For Android, first try the downloads
|
||||
// directory which is world-readable rather than the temp directory
|
||||
// which is not.
|
||||
// Get the log directory either from $MOZ_CC_LOG_DIRECTORY or from
|
||||
// the fallback directories in OpenTempFile.
|
||||
nsCOMPtr<nsIFile> logFile;
|
||||
char* env;
|
||||
if (env = PR_GetEnv("MOZ_CC_LOG_DIRECTORY")) {
|
||||
if (char* env = PR_GetEnv("MOZ_CC_LOG_DIRECTORY")) {
|
||||
NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true,
|
||||
getter_AddRefs(logFile));
|
||||
}
|
||||
#ifdef ANDROID
|
||||
if (!logFile && (env = PR_GetEnv("DOWNLOADS_DIRECTORY"))) {
|
||||
NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true,
|
||||
getter_AddRefs(logFile));
|
||||
}
|
||||
#endif
|
||||
if (!logFile) {
|
||||
// Ask NSPR to point us to the temp directory.
|
||||
NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(logFile));
|
||||
}
|
||||
NS_ENSURE_TRUE(logFile, nullptr);
|
||||
|
||||
nsresult rv = logFile->AppendNative(filename);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
rv = logFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0644);
|
||||
nsresult rv = nsMemoryInfoDumper::OpenTempFile(filename,
|
||||
getter_AddRefs(logFile));
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
return logFile.forget();
|
||||
|
|
|
@ -736,14 +736,17 @@ MakeFilename(const char *aPrefix, const nsAString &aIdentifier,
|
|||
getpid(), aSuffix);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
||||
/* static */ nsresult
|
||||
nsMemoryInfoDumper::OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
||||
{
|
||||
#ifdef ANDROID
|
||||
// For Android, first try the downloads directory which is world-readable
|
||||
// rather than the temp directory which is not.
|
||||
if (char *env = PR_GetEnv("DOWNLOADS_DIRECTORY")) {
|
||||
NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true, aFile);
|
||||
if (!*aFile) {
|
||||
char *env = PR_GetEnv("DOWNLOADS_DIRECTORY");
|
||||
if (env) {
|
||||
NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true, aFile);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
nsresult rv;
|
||||
|
|
|
@ -29,6 +29,15 @@ public:
|
|||
public:
|
||||
static void Initialize();
|
||||
|
||||
/**
|
||||
* This function creates a new unique file based on |aFilename| in a
|
||||
* world-readable temp directory. This is the system temp directory
|
||||
* or, in the case of Android, the downloads directory. If |aFile| is
|
||||
* non-null, it is assumed to point to a folder, and that folder is used
|
||||
* instead.
|
||||
*/
|
||||
static nsresult OpenTempFile(const nsACString &aFilename, nsIFile* *aFile);
|
||||
|
||||
private:
|
||||
static nsresult
|
||||
DumpMemoryReportsToFileImpl(const nsAString& aIdentifier);
|
||||
|
|
Загрузка…
Ссылка в новой задаче