зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1550422
- P10. Define StaticPrefs setter. r=njn
This is used by some gfx code and is required to convert gfxPrefs into StaticPrefs. The setter only modifies the value of the StaticPref in the current process and doesn't propagate to others. Differential Revision: https://phabricator.services.mozilla.com/D31254 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
70d5224c8b
Коммит
1feb57d6e6
|
@ -56,24 +56,39 @@ class StaticPrefs {
|
|||
//
|
||||
// VARCACHE_PREF("my.varcache", my_varcache, int32_t, 99)
|
||||
//
|
||||
// we generate a static variable declaration and a getter definition:
|
||||
// we generate a static variable declaration, a getter and a setter definition.
|
||||
// A StaticPref can be set by using the corresponding Set method. For
|
||||
// example, if the accessor is Foo() then calling SetFoo(...) will update
|
||||
// the preference and also change the return value of subsequent Foo() calls.
|
||||
// Changing StaticPrefs values in one process will not affect the result in
|
||||
// other processes.
|
||||
// Important Note: The use of the Setter is strongly discouraged.
|
||||
//
|
||||
// private:
|
||||
// static int32_t sVarCache_my_varcache;
|
||||
// public:
|
||||
// static int32_t my_varcache() { return sVarCache_my_varcache; }
|
||||
// static void Setmy_varcache(int32_t aValue) {
|
||||
// sVarCache_my_varcache = aValue;
|
||||
// }
|
||||
//
|
||||
#define PREF(str, cpp_type, default_value)
|
||||
#define VARCACHE_PREF(str, id, cpp_type, default_value) \
|
||||
private: \
|
||||
static cpp_type sVarCache_##id; \
|
||||
\
|
||||
public: \
|
||||
static StripAtomic<cpp_type> id() { \
|
||||
MOZ_ASSERT(IsAtomic<cpp_type>::value || NS_IsMainThread(), \
|
||||
"Non-atomic static pref '" str \
|
||||
"' being accessed on background thread"); \
|
||||
return sVarCache_##id; \
|
||||
#define VARCACHE_PREF(str, id, cpp_type, default_value) \
|
||||
private: \
|
||||
static cpp_type sVarCache_##id; \
|
||||
\
|
||||
public: \
|
||||
static StripAtomic<cpp_type> id() { \
|
||||
MOZ_ASSERT(IsAtomic<cpp_type>::value || NS_IsMainThread(), \
|
||||
"Non-atomic static pref '" str \
|
||||
"' being accessed on background thread by getter"); \
|
||||
return sVarCache_##id; \
|
||||
} \
|
||||
static void Set##id(StripAtomic<cpp_type> aValue) { \
|
||||
MOZ_ASSERT(IsAtomic<cpp_type>::value || NS_IsMainThread(), \
|
||||
"Non-atomic static set pref '" str \
|
||||
"' being accessed on background thread by setter"); \
|
||||
sVarCache_##id = aValue; \
|
||||
}
|
||||
#include "mozilla/StaticPrefList.h"
|
||||
#undef PREF
|
||||
|
|
Загрузка…
Ссылка в новой задаче