tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

StaticPrefListBegin.h (2965B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 // This file does not make sense on its own. It must be #included along with
      8 // StaticPrefsListEnd.h in all headers that contribute prefs to the StaticPrefs
      9 // namespace.
     10 
     11 #include "StaticPrefsBase.h"
     12 #include "Preferences.h"
     13 #include "MainThreadUtils.h"  // for NS_IsMainThread()
     14 #include "nsXULAppAPI.h"      // for XRE_IsContentProcess()
     15 
     16 namespace mozilla {
     17 namespace StaticPrefs {
     18 
     19 // For mirrored prefs we generate an extern variable declaration and three
     20 // getter declarations/definitions.
     21 #define NEVER_PREF(name, cpp_type, default_value)
     22 #define ALWAYS_PREF(name, base_id, full_id, cpp_type, default_value)          \
     23  extern cpp_type sMirror_##full_id;                                          \
     24  inline StripAtomic<cpp_type> full_id() {                                    \
     25    MOZ_DIAGNOSTIC_ASSERT(IsAtomic<cpp_type>::value || NS_IsMainThread(),     \
     26                          "Non-atomic static pref '" name                     \
     27                          "' being accessed on background thread by getter"); \
     28    return sMirror_##full_id;                                                 \
     29  }                                                                           \
     30  inline const char* GetPrefName_##base_id() { return name; }                 \
     31  inline StripAtomic<cpp_type> GetPrefDefault_##base_id() {                   \
     32    return default_value;                                                     \
     33  }
     34 #define ALWAYS_DATAMUTEX_PREF(name, base_id, full_id, cpp_type, default_value) \
     35  extern cpp_type sMirror_##full_id;                                           \
     36  inline cpp_type::ConstAutoLock full_id() {                                   \
     37    return sMirror_##full_id.ConstLock();                                      \
     38  }                                                                            \
     39  inline const char* GetPrefName_##base_id() { return name; }                  \
     40  inline StripAtomic<cpp_type> GetPrefDefault_##base_id() {                    \
     41    return default_value;                                                      \
     42  }
     43 #define ONCE_PREF(name, base_id, full_id, cpp_type, default_value) \
     44  extern cpp_type sMirror_##full_id;                               \
     45  inline cpp_type full_id() {                                      \
     46    MaybeInitOncePrefs();                                          \
     47    return sMirror_##full_id;                                      \
     48  }                                                                \
     49  inline const char* GetPrefName_##base_id() { return name; }      \
     50  inline cpp_type GetPrefDefault_##base_id() { return default_value; }