mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 18:50:08 +00:00
Bug 845342 - Move about:memory and related dump files to the downloads dir on android. r=njn
This commit is contained in:
parent
2a0a9d9363
commit
2e8db46be9
@ -132,9 +132,6 @@
|
||||
#include <io.h>
|
||||
#include <process.h>
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
@ -1408,12 +1405,22 @@ private:
|
||||
NS_ConvertUTF16toUTF8(mFilenameIdentifier).get());
|
||||
|
||||
// Get the log directory either from $MOZ_CC_LOG_DIRECTORY or from our
|
||||
// platform's temp directory.
|
||||
// platform's temp directory. For Android, first try the downloads
|
||||
// directory which is world-readable rather than the temp directory
|
||||
// which is not.
|
||||
nsCOMPtr<nsIFile> logFile;
|
||||
if (char* env = PR_GetEnv("MOZ_CC_LOG_DIRECTORY")) {
|
||||
char* env;
|
||||
if (env = PR_GetEnv("MOZ_CC_LOG_DIRECTORY")) {
|
||||
NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true,
|
||||
getter_AddRefs(logFile));
|
||||
} else {
|
||||
}
|
||||
#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));
|
||||
}
|
||||
@ -1424,19 +1431,6 @@ private:
|
||||
|
||||
rv = logFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0644);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
#ifdef ANDROID
|
||||
{
|
||||
// On android the default system umask is 0077 which makes these files
|
||||
// unreadable to the shell user. In order to pull the dumps off a non-rooted
|
||||
// device we need to chmod them to something world-readable.
|
||||
// XXX why not logFile->SetPermissions(0644);
|
||||
nsAutoCString path;
|
||||
rv = logFile->GetNativePath(path);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
chmod(path.get(), 0644);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return logFile.forget();
|
||||
}
|
||||
|
@ -739,8 +739,18 @@ MakeFilename(const char *aPrefix, const nsAString &aIdentifier,
|
||||
static nsresult
|
||||
OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
||||
{
|
||||
nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, aFile);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
#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);
|
||||
}
|
||||
#endif
|
||||
nsresult rv;
|
||||
if (!*aFile) {
|
||||
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, aFile);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFile> file(*aFile);
|
||||
|
||||
@ -749,19 +759,6 @@ OpenTempFile(const nsACString &aFilename, nsIFile* *aFile)
|
||||
|
||||
rv = file->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0644);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
#ifdef ANDROID
|
||||
{
|
||||
// On android the default system umask is 0077 which makes these files
|
||||
// unreadable to the shell user. In order to pull the dumps off a non-rooted
|
||||
// device we need to chmod them to something world-readable.
|
||||
// XXX why not logFile->SetPermissions(0644);
|
||||
nsAutoCString path;
|
||||
rv = file->GetNativePath(path);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
chmod(path.get(), 0644);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user