1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "mozilla/Preferences.h"
9 #include "MainThreadUtils.h"
11 using namespace mozilla
;
13 gfxPrefs
* gfxPrefs::sInstance
= nullptr;
14 bool gfxPrefs::sInstanceHasBeenDestroyed
= false;
17 gfxPrefs::DestroySingleton()
22 sInstanceHasBeenDestroyed
= true;
24 MOZ_ASSERT(!SingletonExists());
28 gfxPrefs::SingletonExists()
30 return sInstance
!= nullptr;
35 gfxPrefs::AssertMainThread();
40 gfxPrefs::AssertMainThread();
43 void gfxPrefs::AssertMainThread()
45 MOZ_ASSERT(NS_IsMainThread(), "this code must be run on the main thread");
48 void gfxPrefs::PrefAddVarCache(bool* aVariable
,
52 Preferences::AddBoolVarCache(aVariable
, aPref
, aDefault
);
55 void gfxPrefs::PrefAddVarCache(int32_t* aVariable
,
59 Preferences::AddIntVarCache(aVariable
, aPref
, aDefault
);
62 void gfxPrefs::PrefAddVarCache(uint32_t* aVariable
,
66 Preferences::AddUintVarCache(aVariable
, aPref
, aDefault
);
69 void gfxPrefs::PrefAddVarCache(float* aVariable
,
73 Preferences::AddFloatVarCache(aVariable
, aPref
, aDefault
);
76 bool gfxPrefs::PrefGet(const char* aPref
, bool aDefault
)
78 return Preferences::GetBool(aPref
, aDefault
);
81 int32_t gfxPrefs::PrefGet(const char* aPref
, int32_t aDefault
)
83 return Preferences::GetInt(aPref
, aDefault
);
86 uint32_t gfxPrefs::PrefGet(const char* aPref
, uint32_t aDefault
)
88 return Preferences::GetUint(aPref
, aDefault
);
91 float gfxPrefs::PrefGet(const char* aPref
, float aDefault
)
93 return Preferences::GetFloat(aPref
, aDefault
);
96 void gfxPrefs::PrefSet(const char* aPref
, bool aValue
)
98 Preferences::SetBool(aPref
, aValue
);
101 void gfxPrefs::PrefSet(const char* aPref
, int32_t aValue
)
103 Preferences::SetInt(aPref
, aValue
);
106 void gfxPrefs::PrefSet(const char* aPref
, uint32_t aValue
)
108 Preferences::SetUint(aPref
, aValue
);
111 void gfxPrefs::PrefSet(const char* aPref
, float aValue
)
113 Preferences::SetFloat(aPref
, aValue
);