|
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/. */ |
|
5 |
|
6 #include "gfxPrefs.h" |
|
7 |
|
8 #include "mozilla/Preferences.h" |
|
9 #include "MainThreadUtils.h" |
|
10 |
|
11 using namespace mozilla; |
|
12 |
|
13 gfxPrefs* gfxPrefs::sInstance = nullptr; |
|
14 |
|
15 void |
|
16 gfxPrefs::DestroySingleton() |
|
17 { |
|
18 if (sInstance) { |
|
19 delete sInstance; |
|
20 sInstance = nullptr; |
|
21 } |
|
22 } |
|
23 |
|
24 bool |
|
25 gfxPrefs::SingletonExists() |
|
26 { |
|
27 return sInstance != nullptr; |
|
28 } |
|
29 |
|
30 gfxPrefs::gfxPrefs() |
|
31 { |
|
32 // Needs to be created on the main thread. |
|
33 MOZ_ASSERT(NS_IsMainThread(), "must be constructed on the main thread"); |
|
34 } |
|
35 |
|
36 gfxPrefs::~gfxPrefs() |
|
37 { |
|
38 MOZ_ASSERT(NS_IsMainThread(), "must be destructed on the main thread"); |
|
39 } |
|
40 |
|
41 void gfxPrefs::PrefAddVarCache(bool* aVariable, |
|
42 const char* aPref, |
|
43 bool aDefault) |
|
44 { |
|
45 Preferences::AddBoolVarCache(aVariable, aPref, aDefault); |
|
46 } |
|
47 |
|
48 void gfxPrefs::PrefAddVarCache(int32_t* aVariable, |
|
49 const char* aPref, |
|
50 int32_t aDefault) |
|
51 { |
|
52 Preferences::AddIntVarCache(aVariable, aPref, aDefault); |
|
53 } |
|
54 |
|
55 void gfxPrefs::PrefAddVarCache(uint32_t* aVariable, |
|
56 const char* aPref, |
|
57 uint32_t aDefault) |
|
58 { |
|
59 Preferences::AddUintVarCache(aVariable, aPref, aDefault); |
|
60 } |
|
61 |
|
62 void gfxPrefs::PrefAddVarCache(float* aVariable, |
|
63 const char* aPref, |
|
64 float aDefault) |
|
65 { |
|
66 Preferences::AddFloatVarCache(aVariable, aPref, aDefault); |
|
67 } |
|
68 |
|
69 bool gfxPrefs::PrefGet(const char* aPref, bool aDefault) |
|
70 { |
|
71 return Preferences::GetBool(aPref, aDefault); |
|
72 } |
|
73 |
|
74 int32_t gfxPrefs::PrefGet(const char* aPref, int32_t aDefault) |
|
75 { |
|
76 return Preferences::GetInt(aPref, aDefault); |
|
77 } |
|
78 |
|
79 uint32_t gfxPrefs::PrefGet(const char* aPref, uint32_t aDefault) |
|
80 { |
|
81 return Preferences::GetUint(aPref, aDefault); |
|
82 } |
|
83 |
|
84 float gfxPrefs::PrefGet(const char* aPref, float aDefault) |
|
85 { |
|
86 return Preferences::GetFloat(aPref, aDefault); |
|
87 } |
|
88 |