Bug 619487: Assert when preferences are used off the main thread. r=dbaron

This commit is contained in:
Kyle Huey 2014-03-05 17:58:01 -08:00
Родитель 6ca9eaaa7d
Коммит d56fde36e2
3 изменённых файлов: 14 добавлений и 3 удалений

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

@ -402,6 +402,8 @@ Preferences::GetInstanceForService()
bool
Preferences::InitStaticMembers()
{
MOZ_ASSERT(NS_IsMainThread());
if (!sShutdown && !sPreferences) {
nsCOMPtr<nsIPrefService> prefService =
do_GetService(NS_PREFSERVICE_CONTRACTID);

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

@ -182,7 +182,7 @@ class nsPrefBranch : public nsIPrefBranchInternal,
{
friend class mozilla::PreferenceServiceReporter;
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_ISUPPORTS
NS_DECL_NSIPREFBRANCH
NS_DECL_NSIPREFBRANCH2
NS_DECL_NSIOBSERVER
@ -235,7 +235,7 @@ public:
nsPrefLocalizedString();
virtual ~nsPrefLocalizedString();
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_ISUPPORTS
NS_FORWARD_NSISUPPORTSSTRING(mUnicodeString->)
NS_FORWARD_NSISUPPORTSPRIMITIVE(mUnicodeString->)
@ -253,7 +253,7 @@ private:
class nsRelativeFilePref : public nsIRelativeFilePref
{
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_ISUPPORTS
NS_DECL_NSIRELATIVEFILEPREF
nsRelativeFilePref();

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

@ -8,6 +8,7 @@
#include "prefapi.h"
#include "prefapi_private_data.h"
#include "prefread.h"
#include "MainThreadUtils.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
@ -575,6 +576,8 @@ pref_DeleteItem(PLDHashTable *table, PLDHashEntryHdr *heh, uint32_t i, void *arg
nsresult
PREF_DeleteBranch(const char *branch_name)
{
MOZ_ASSERT(NS_IsMainThread());
int len = (int)strlen(branch_name);
if (!gHashTable.ops)
@ -642,6 +645,8 @@ pref_ClearUserPref(PLDHashTable *table, PLDHashEntryHdr *he, uint32_t,
nsresult
PREF_ClearAllUserPrefs()
{
MOZ_ASSERT(NS_IsMainThread());
if (!gHashTable.ops)
return NS_ERROR_NOT_INITIALIZED;
@ -716,6 +721,8 @@ static void pref_SetValue(PrefValue* oldValue, PrefValue newValue, PrefType type
PrefHashEntry* pref_HashTableLookup(const void *key)
{
MOZ_ASSERT(NS_IsMainThread());
PrefHashEntry* result =
static_cast<PrefHashEntry*>(PL_DHashTableOperate(&gHashTable, key, PL_DHASH_LOOKUP));
@ -727,6 +734,8 @@ PrefHashEntry* pref_HashTableLookup(const void *key)
nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t flags)
{
MOZ_ASSERT(NS_IsMainThread());
if (!gHashTable.ops)
return NS_ERROR_OUT_OF_MEMORY;