Bug 980419 - Don't access preferences omt in nsMemoryInfoDumper.cpp r=bsmedberg

This commit is contained in:
Fabrice Desré 2014-03-21 13:50:44 -07:00
parent e9fc16e201
commit 57b5964974

View File

@ -374,6 +374,10 @@ public:
class FifoWatcher : public FdWatcher
{
public:
FifoWatcher(nsCString aPath)
: mDirPath(aPath)
{}
static void MaybeCreate()
{
MOZ_ASSERT(NS_IsMainThread());
@ -389,8 +393,12 @@ public:
return;
}
nsAutoCString dirPath;
Preferences::GetCString(
"memory_info_dumper.watch_fifo.directory", &dirPath);
// The FifoWatcher is held alive by the observer service.
nsRefPtr<FifoWatcher> fw = new FifoWatcher();
nsRefPtr<FifoWatcher> fw = new FifoWatcher(dirPath);
fw->Init();
}
@ -400,14 +408,12 @@ public:
// there. Otherwise, put it into the system's tmp directory.
nsCOMPtr<nsIFile> file;
nsAutoCString dirPath;
nsresult rv = Preferences::GetCString(
"memory_info_dumper.watch_fifo.directory", &dirPath);
if (NS_SUCCEEDED(rv)) {
rv = XRE_GetFileFromPath(dirPath.get(), getter_AddRefs(file));
nsresult rv;
if (mDirPath.Length() > 0) {
rv = XRE_GetFileFromPath(mDirPath.get(), getter_AddRefs(file));
if (NS_FAILED(rv)) {
LOG("FifoWatcher failed to open file \"%s\"", dirPath.get());
LOG("FifoWatcher failed to open file \"%s\"", mDirPath.get());
return -1;
}
} else {
@ -529,6 +535,9 @@ public:
LOG("Got unexpected value from fifo; ignoring it.");
}
}
private:
nsAutoCString mDirPath;
};
} // anonymous namespace