michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "gfxPrefs.h" michael@0: michael@0: #include "mozilla/Preferences.h" michael@0: #include "MainThreadUtils.h" michael@0: michael@0: using namespace mozilla; michael@0: michael@0: gfxPrefs* gfxPrefs::sInstance = nullptr; michael@0: michael@0: void michael@0: gfxPrefs::DestroySingleton() michael@0: { michael@0: if (sInstance) { michael@0: delete sInstance; michael@0: sInstance = nullptr; michael@0: } michael@0: } michael@0: michael@0: bool michael@0: gfxPrefs::SingletonExists() michael@0: { michael@0: return sInstance != nullptr; michael@0: } michael@0: michael@0: gfxPrefs::gfxPrefs() michael@0: { michael@0: // Needs to be created on the main thread. michael@0: MOZ_ASSERT(NS_IsMainThread(), "must be constructed on the main thread"); michael@0: } michael@0: michael@0: gfxPrefs::~gfxPrefs() michael@0: { michael@0: MOZ_ASSERT(NS_IsMainThread(), "must be destructed on the main thread"); michael@0: } michael@0: michael@0: void gfxPrefs::PrefAddVarCache(bool* aVariable, michael@0: const char* aPref, michael@0: bool aDefault) michael@0: { michael@0: Preferences::AddBoolVarCache(aVariable, aPref, aDefault); michael@0: } michael@0: michael@0: void gfxPrefs::PrefAddVarCache(int32_t* aVariable, michael@0: const char* aPref, michael@0: int32_t aDefault) michael@0: { michael@0: Preferences::AddIntVarCache(aVariable, aPref, aDefault); michael@0: } michael@0: michael@0: void gfxPrefs::PrefAddVarCache(uint32_t* aVariable, michael@0: const char* aPref, michael@0: uint32_t aDefault) michael@0: { michael@0: Preferences::AddUintVarCache(aVariable, aPref, aDefault); michael@0: } michael@0: michael@0: void gfxPrefs::PrefAddVarCache(float* aVariable, michael@0: const char* aPref, michael@0: float aDefault) michael@0: { michael@0: Preferences::AddFloatVarCache(aVariable, aPref, aDefault); michael@0: } michael@0: michael@0: bool gfxPrefs::PrefGet(const char* aPref, bool aDefault) michael@0: { michael@0: return Preferences::GetBool(aPref, aDefault); michael@0: } michael@0: michael@0: int32_t gfxPrefs::PrefGet(const char* aPref, int32_t aDefault) michael@0: { michael@0: return Preferences::GetInt(aPref, aDefault); michael@0: } michael@0: michael@0: uint32_t gfxPrefs::PrefGet(const char* aPref, uint32_t aDefault) michael@0: { michael@0: return Preferences::GetUint(aPref, aDefault); michael@0: } michael@0: michael@0: float gfxPrefs::PrefGet(const char* aPref, float aDefault) michael@0: { michael@0: return Preferences::GetFloat(aPref, aDefault); michael@0: } michael@0: