зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1569526 - Remove return values from `Add*VarCache()`. r=KrisWright
They're infallible in practice and always `NS_OK`. (This stems from `AddVarCacheNoAssignment()` always returning `NS_OK`.) As a result, the commit removes lots of unnecessary checks. Differential Revision: https://phabricator.services.mozilla.com/D39804 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
670a5bfd26
Коммит
cd426e3ad2
|
@ -6329,16 +6329,12 @@ void EventStateManager::Prefs::Init() {
|
|||
return;
|
||||
}
|
||||
|
||||
DebugOnly<nsresult> rv = Preferences::AddBoolVarCache(
|
||||
&sKeyCausesActivation, "accessibility.accesskeycausesactivation",
|
||||
sKeyCausesActivation);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv),
|
||||
"Failed to observe \"accessibility.accesskeycausesactivation\"");
|
||||
rv = Preferences::AddBoolVarCache(&sClickHoldContextMenu,
|
||||
"ui.click_hold_context_menus",
|
||||
sClickHoldContextMenu);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv),
|
||||
"Failed to observe \"ui.click_hold_context_menus\"");
|
||||
Preferences::AddBoolVarCache(&sKeyCausesActivation,
|
||||
"accessibility.accesskeycausesactivation",
|
||||
sKeyCausesActivation);
|
||||
Preferences::AddBoolVarCache(&sClickHoldContextMenu,
|
||||
"ui.click_hold_context_menus",
|
||||
sClickHoldContextMenu);
|
||||
sPrefsAlreadyCached = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -3268,15 +3268,10 @@ void InitializeLocalStorage() {
|
|||
NS_WARNING("Failed to initialize quota client!");
|
||||
}
|
||||
|
||||
if (NS_FAILED(Preferences::AddAtomicBoolVarCache(&gNextGen, kNextGenPref,
|
||||
kDefaultNextGen))) {
|
||||
NS_WARNING("Unable to respond to next gen pref changes!");
|
||||
}
|
||||
Preferences::AddAtomicBoolVarCache(&gNextGen, kNextGenPref, kDefaultNextGen);
|
||||
|
||||
if (NS_FAILED(Preferences::AddAtomicUintVarCache(
|
||||
&gOriginLimitKB, kDefaultQuotaPref, kDefaultOriginLimitKB))) {
|
||||
NS_WARNING("Unable to respond to default quota pref changes!");
|
||||
}
|
||||
Preferences::AddAtomicUintVarCache(&gOriginLimitKB, kDefaultQuotaPref,
|
||||
kDefaultOriginLimitKB);
|
||||
|
||||
Preferences::RegisterCallbackAndCall(ShadowWritesPrefChangedCallback,
|
||||
kShadowWritesPref);
|
||||
|
|
|
@ -2348,17 +2348,13 @@ void InitializeQuotaManager() {
|
|||
NS_WARNING("Failed to initialize quota manager!");
|
||||
}
|
||||
|
||||
if (NS_FAILED(Preferences::AddAtomicIntVarCache(
|
||||
&gFixedLimitKB, PREF_FIXED_LIMIT, kDefaultFixedLimitKB)) ||
|
||||
NS_FAILED(Preferences::AddAtomicUintVarCache(
|
||||
&gChunkSizeKB, PREF_CHUNK_SIZE, kDefaultChunkSizeKB))) {
|
||||
NS_WARNING("Unable to respond to temp storage pref changes!");
|
||||
}
|
||||
Preferences::AddAtomicIntVarCache(&gFixedLimitKB, PREF_FIXED_LIMIT,
|
||||
kDefaultFixedLimitKB);
|
||||
Preferences::AddAtomicUintVarCache(&gChunkSizeKB, PREF_CHUNK_SIZE,
|
||||
kDefaultChunkSizeKB);
|
||||
|
||||
if (NS_FAILED(Preferences::AddAtomicBoolVarCache(
|
||||
&gTestingEnabled, PREF_TESTING_FEATURES, false))) {
|
||||
NS_WARNING("Unable to respond to testing pref changes!");
|
||||
}
|
||||
Preferences::AddAtomicBoolVarCache(&gTestingEnabled, PREF_TESTING_FEATURES,
|
||||
false);
|
||||
|
||||
#ifdef DEBUG
|
||||
gQuotaManagerInitialized = true;
|
||||
|
|
|
@ -1609,14 +1609,11 @@ nsresult RuntimeService::Init() {
|
|||
// We assume atomic 32bit reads/writes. If this assumption doesn't hold on
|
||||
// some wacky platform then the worst that could happen is that the close
|
||||
// handler will run for a slightly different amount of time.
|
||||
if (NS_FAILED(Preferences::AddIntVarCache(
|
||||
&sDefaultJSSettings.content.maxScriptRuntime,
|
||||
PREF_MAX_SCRIPT_RUN_TIME_CONTENT, MAX_SCRIPT_RUN_TIME_SEC)) ||
|
||||
NS_FAILED(Preferences::AddIntVarCache(
|
||||
&sDefaultJSSettings.chrome.maxScriptRuntime,
|
||||
PREF_MAX_SCRIPT_RUN_TIME_CHROME, -1))) {
|
||||
NS_WARNING("Failed to register timeout cache!");
|
||||
}
|
||||
Preferences::AddIntVarCache(&sDefaultJSSettings.content.maxScriptRuntime,
|
||||
PREF_MAX_SCRIPT_RUN_TIME_CONTENT,
|
||||
MAX_SCRIPT_RUN_TIME_SEC);
|
||||
Preferences::AddIntVarCache(&sDefaultJSSettings.chrome.maxScriptRuntime,
|
||||
PREF_MAX_SCRIPT_RUN_TIME_CHROME, -1);
|
||||
|
||||
int32_t maxPerDomain =
|
||||
Preferences::GetInt(PREF_WORKERS_MAX_PER_DOMAIN, MAX_WORKERS_PER_DOMAIN);
|
||||
|
|
|
@ -272,14 +272,10 @@ MediaPipeline::MediaPipeline(const std::string& aPc,
|
|||
}
|
||||
if (!sPrefsRegistered.exchange(true)) {
|
||||
MOZ_ASSERT(Preferences::IsServiceAvailable());
|
||||
bool ok =
|
||||
Preferences::AddAtomicBoolVarCache(&sForceDisableRtcpReceptionPref,
|
||||
kQuashRtcpRxPref, false) == NS_OK;
|
||||
MOZ_LOG(gMediaPipelineLog, ok ? LogLevel::Info : LogLevel::Error,
|
||||
("Creating pref cache: %s%s", kQuashRtcpRxPref.get(),
|
||||
ok ? " succeded." : " FAILED!"));
|
||||
// If we failed to register allow us try again
|
||||
sPrefsRegistered.exchange(ok);
|
||||
Preferences::AddAtomicBoolVarCache(&sForceDisableRtcpReceptionPref,
|
||||
kQuashRtcpRxPref, false);
|
||||
MOZ_LOG(gMediaPipelineLog, LogLevel::Info,
|
||||
("Creating pref cache: %s succeeded", kQuashRtcpRxPref.get()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5202,109 +5202,107 @@ static void CacheDataAppendElement(CacheData* aData) {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
static nsresult AddVarCacheNoAssignment(T* aCache, const nsACString& aPref,
|
||||
StripAtomic<T> aDefault) {
|
||||
static void AddVarCacheNoAssignment(T* aCache, const nsACString& aPref,
|
||||
StripAtomic<T> aDefault) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
CacheData* data = new CacheData(aCache, aDefault);
|
||||
CacheDataAppendElement(data);
|
||||
Internals::RegisterCallback<T>(data, aPref);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static nsresult AddVarCache(T* aCache, const nsACString& aPref,
|
||||
StripAtomic<T> aDefault) {
|
||||
static void AddVarCache(T* aCache, const nsACString& aPref,
|
||||
StripAtomic<T> aDefault) {
|
||||
*aCache = Internals::GetPref(PromiseFlatCString(aPref).get(), aDefault);
|
||||
return AddVarCacheNoAssignment(aCache, aPref, aDefault);
|
||||
AddVarCacheNoAssignment(aCache, aPref, aDefault);
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsresult Preferences::AddBoolVarCache(bool* aCache, const nsACString& aPref,
|
||||
bool aDefault) {
|
||||
void Preferences::AddBoolVarCache(bool* aCache, const nsACString& aPref,
|
||||
bool aDefault) {
|
||||
AssertNotAlreadyCached("bool", aPref, aCache);
|
||||
return AddVarCache(aCache, aPref, aDefault);
|
||||
AddVarCache(aCache, aPref, aDefault);
|
||||
}
|
||||
|
||||
template <MemoryOrdering Order>
|
||||
/* static */
|
||||
nsresult Preferences::AddAtomicBoolVarCache(Atomic<bool, Order>* aCache,
|
||||
const nsACString& aPref,
|
||||
bool aDefault) {
|
||||
void Preferences::AddAtomicBoolVarCache(Atomic<bool, Order>* aCache,
|
||||
const nsACString& aPref,
|
||||
bool aDefault) {
|
||||
AssertNotAlreadyCached("bool", aPref, aCache);
|
||||
return AddVarCache(aCache, aPref, aDefault);
|
||||
AddVarCache(aCache, aPref, aDefault);
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsresult Preferences::AddIntVarCache(int32_t* aCache, const nsACString& aPref,
|
||||
int32_t aDefault) {
|
||||
void Preferences::AddIntVarCache(int32_t* aCache, const nsACString& aPref,
|
||||
int32_t aDefault) {
|
||||
AssertNotAlreadyCached("int", aPref, aCache);
|
||||
return AddVarCache(aCache, aPref, aDefault);
|
||||
AddVarCache(aCache, aPref, aDefault);
|
||||
}
|
||||
|
||||
template <MemoryOrdering Order>
|
||||
/* static */
|
||||
nsresult Preferences::AddAtomicIntVarCache(Atomic<int32_t, Order>* aCache,
|
||||
const nsACString& aPref,
|
||||
int32_t aDefault) {
|
||||
void Preferences::AddAtomicIntVarCache(Atomic<int32_t, Order>* aCache,
|
||||
const nsACString& aPref,
|
||||
int32_t aDefault) {
|
||||
AssertNotAlreadyCached("int", aPref, aCache);
|
||||
return AddVarCache(aCache, aPref, aDefault);
|
||||
AddVarCache(aCache, aPref, aDefault);
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsresult Preferences::AddUintVarCache(uint32_t* aCache, const nsACString& aPref,
|
||||
uint32_t aDefault) {
|
||||
void Preferences::AddUintVarCache(uint32_t* aCache, const nsACString& aPref,
|
||||
uint32_t aDefault) {
|
||||
AssertNotAlreadyCached("uint", aPref, aCache);
|
||||
return AddVarCache(aCache, aPref, aDefault);
|
||||
AddVarCache(aCache, aPref, aDefault);
|
||||
}
|
||||
|
||||
template <MemoryOrdering Order>
|
||||
/* static */
|
||||
nsresult Preferences::AddAtomicUintVarCache(Atomic<uint32_t, Order>* aCache,
|
||||
const nsACString& aPref,
|
||||
uint32_t aDefault) {
|
||||
void Preferences::AddAtomicUintVarCache(Atomic<uint32_t, Order>* aCache,
|
||||
const nsACString& aPref,
|
||||
uint32_t aDefault) {
|
||||
AssertNotAlreadyCached("uint", aPref, aCache);
|
||||
return AddVarCache(aCache, aPref, aDefault);
|
||||
AddVarCache(aCache, aPref, aDefault);
|
||||
}
|
||||
|
||||
// Since the definition of template functions is not in a header file, we
|
||||
// need to explicitly specify the instantiations that are required. Currently
|
||||
// limited orders are needed and therefore implemented.
|
||||
template nsresult Preferences::AddAtomicBoolVarCache(Atomic<bool, Relaxed>*,
|
||||
const nsACString&, bool);
|
||||
template void Preferences::AddAtomicBoolVarCache(Atomic<bool, Relaxed>*,
|
||||
const nsACString&, bool);
|
||||
|
||||
template nsresult Preferences::AddAtomicBoolVarCache(
|
||||
Atomic<bool, ReleaseAcquire>*, const nsACString&, bool);
|
||||
template void Preferences::AddAtomicBoolVarCache(Atomic<bool, ReleaseAcquire>*,
|
||||
const nsACString&, bool);
|
||||
|
||||
template nsresult Preferences::AddAtomicBoolVarCache(
|
||||
template void Preferences::AddAtomicBoolVarCache(
|
||||
Atomic<bool, SequentiallyConsistent>*, const nsACString&, bool);
|
||||
|
||||
template nsresult Preferences::AddAtomicIntVarCache(Atomic<int32_t, Relaxed>*,
|
||||
const nsACString&, int32_t);
|
||||
template void Preferences::AddAtomicIntVarCache(Atomic<int32_t, Relaxed>*,
|
||||
const nsACString&, int32_t);
|
||||
|
||||
template nsresult Preferences::AddAtomicUintVarCache(Atomic<uint32_t, Relaxed>*,
|
||||
const nsACString&,
|
||||
uint32_t);
|
||||
template void Preferences::AddAtomicUintVarCache(Atomic<uint32_t, Relaxed>*,
|
||||
const nsACString&, uint32_t);
|
||||
|
||||
template nsresult Preferences::AddAtomicUintVarCache(
|
||||
template void Preferences::AddAtomicUintVarCache(
|
||||
Atomic<uint32_t, ReleaseAcquire>*, const nsACString&, uint32_t);
|
||||
|
||||
template nsresult Preferences::AddAtomicUintVarCache(
|
||||
template void Preferences::AddAtomicUintVarCache(
|
||||
Atomic<uint32_t, SequentiallyConsistent>*, const nsACString&, uint32_t);
|
||||
|
||||
/* static */
|
||||
nsresult Preferences::AddFloatVarCache(float* aCache, const nsACString& aPref,
|
||||
float aDefault) {
|
||||
void Preferences::AddFloatVarCache(float* aCache, const nsACString& aPref,
|
||||
float aDefault) {
|
||||
AssertNotAlreadyCached("float", aPref, aCache);
|
||||
return AddVarCache(aCache, aPref, aDefault);
|
||||
AddVarCache(aCache, aPref, aDefault);
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsresult Preferences::AddAtomicFloatVarCache(std::atomic<float>* aCache,
|
||||
const nsACString& aPref,
|
||||
float aDefault) {
|
||||
void Preferences::AddAtomicFloatVarCache(std::atomic<float>* aCache,
|
||||
const nsACString& aPref,
|
||||
float aDefault) {
|
||||
AssertNotAlreadyCached("float", aPref, aCache);
|
||||
return AddVarCache(aCache, aPref, aDefault);
|
||||
AddVarCache(aCache, aPref, aDefault);
|
||||
}
|
||||
|
||||
// The InitPref_*() functions below end in a `_<type>` suffix because they are
|
||||
|
|
|
@ -464,77 +464,77 @@ class Preferences final : public nsIPrefService,
|
|||
// static variable. The value will be modified when the pref value is changed
|
||||
// but note that even if you modified it, the value isn't assigned to the
|
||||
// pref.
|
||||
static nsresult AddBoolVarCache(bool* aVariable, const nsACString& aPref,
|
||||
bool aDefault = false);
|
||||
static void AddBoolVarCache(bool* aVariable, const nsACString& aPref,
|
||||
bool aDefault = false);
|
||||
template <MemoryOrdering Order>
|
||||
static nsresult AddAtomicBoolVarCache(Atomic<bool, Order>* aVariable,
|
||||
const nsACString& aPref,
|
||||
bool aDefault = false);
|
||||
static nsresult AddIntVarCache(int32_t* aVariable, const nsACString& aPref,
|
||||
int32_t aDefault = 0);
|
||||
static void AddAtomicBoolVarCache(Atomic<bool, Order>* aVariable,
|
||||
const nsACString& aPref,
|
||||
bool aDefault = false);
|
||||
static void AddIntVarCache(int32_t* aVariable, const nsACString& aPref,
|
||||
int32_t aDefault = 0);
|
||||
template <MemoryOrdering Order>
|
||||
static nsresult AddAtomicIntVarCache(Atomic<int32_t, Order>* aVariable,
|
||||
const nsACString& aPref,
|
||||
int32_t aDefault = 0);
|
||||
static nsresult AddUintVarCache(uint32_t* aVariable, const nsACString& aPref,
|
||||
uint32_t aDefault = 0);
|
||||
static void AddAtomicIntVarCache(Atomic<int32_t, Order>* aVariable,
|
||||
const nsACString& aPref,
|
||||
int32_t aDefault = 0);
|
||||
static void AddUintVarCache(uint32_t* aVariable, const nsACString& aPref,
|
||||
uint32_t aDefault = 0);
|
||||
template <MemoryOrdering Order>
|
||||
static nsresult AddAtomicUintVarCache(Atomic<uint32_t, Order>* aVariable,
|
||||
const nsACString& aPref,
|
||||
uint32_t aDefault = 0);
|
||||
static nsresult AddFloatVarCache(float* aVariable, const nsACString& aPref,
|
||||
float aDefault = 0.0f);
|
||||
static void AddAtomicUintVarCache(Atomic<uint32_t, Order>* aVariable,
|
||||
const nsACString& aPref,
|
||||
uint32_t aDefault = 0);
|
||||
static void AddFloatVarCache(float* aVariable, const nsACString& aPref,
|
||||
float aDefault = 0.0f);
|
||||
|
||||
static nsresult AddAtomicFloatVarCache(std::atomic<float>* aVariable,
|
||||
const nsACString& aPref,
|
||||
float aDefault = 0.0f);
|
||||
static void AddAtomicFloatVarCache(std::atomic<float>* aVariable,
|
||||
const nsACString& aPref,
|
||||
float aDefault = 0.0f);
|
||||
|
||||
template <int N>
|
||||
static nsresult AddBoolVarCache(bool* aVariable, const char (&aPref)[N],
|
||||
bool aDefault = false) {
|
||||
static void AddBoolVarCache(bool* aVariable, const char (&aPref)[N],
|
||||
bool aDefault = false) {
|
||||
return AddBoolVarCache(aVariable, nsLiteralCString(aPref), aDefault);
|
||||
}
|
||||
template <MemoryOrdering Order, int N>
|
||||
static nsresult AddAtomicBoolVarCache(Atomic<bool, Order>* aVariable,
|
||||
const char (&aPref)[N],
|
||||
bool aDefault = false) {
|
||||
static void AddAtomicBoolVarCache(Atomic<bool, Order>* aVariable,
|
||||
const char (&aPref)[N],
|
||||
bool aDefault = false) {
|
||||
return AddAtomicBoolVarCache<Order>(aVariable, nsLiteralCString(aPref),
|
||||
aDefault);
|
||||
}
|
||||
template <int N>
|
||||
static nsresult AddIntVarCache(int32_t* aVariable, const char (&aPref)[N],
|
||||
int32_t aDefault = 0) {
|
||||
static void AddIntVarCache(int32_t* aVariable, const char (&aPref)[N],
|
||||
int32_t aDefault = 0) {
|
||||
return AddIntVarCache(aVariable, nsLiteralCString(aPref), aDefault);
|
||||
}
|
||||
template <MemoryOrdering Order, int N>
|
||||
static nsresult AddAtomicIntVarCache(Atomic<int32_t, Order>* aVariable,
|
||||
const char (&aPref)[N],
|
||||
int32_t aDefault = 0) {
|
||||
static void AddAtomicIntVarCache(Atomic<int32_t, Order>* aVariable,
|
||||
const char (&aPref)[N],
|
||||
int32_t aDefault = 0) {
|
||||
return AddAtomicIntVarCache<Order>(aVariable, nsLiteralCString(aPref),
|
||||
aDefault);
|
||||
}
|
||||
template <int N>
|
||||
static nsresult AddUintVarCache(uint32_t* aVariable, const char (&aPref)[N],
|
||||
uint32_t aDefault = 0) {
|
||||
static void AddUintVarCache(uint32_t* aVariable, const char (&aPref)[N],
|
||||
uint32_t aDefault = 0) {
|
||||
return AddUintVarCache(aVariable, nsLiteralCString(aPref), aDefault);
|
||||
}
|
||||
template <MemoryOrdering Order, int N>
|
||||
static nsresult AddAtomicUintVarCache(Atomic<uint32_t, Order>* aVariable,
|
||||
const char (&aPref)[N],
|
||||
uint32_t aDefault = 0) {
|
||||
static void AddAtomicUintVarCache(Atomic<uint32_t, Order>* aVariable,
|
||||
const char (&aPref)[N],
|
||||
uint32_t aDefault = 0) {
|
||||
return AddAtomicUintVarCache<Order>(aVariable, nsLiteralCString(aPref),
|
||||
aDefault);
|
||||
}
|
||||
template <int N>
|
||||
static nsresult AddFloatVarCache(float* aVariable, const char (&aPref)[N],
|
||||
float aDefault = 0.0f) {
|
||||
static void AddFloatVarCache(float* aVariable, const char (&aPref)[N],
|
||||
float aDefault = 0.0f) {
|
||||
return AddFloatVarCache(aVariable, nsLiteralCString(aPref), aDefault);
|
||||
}
|
||||
|
||||
template <int N>
|
||||
static nsresult AddAtomicFloatVarCache(std::atomic<float>* aVariable,
|
||||
const char (&aPref)[N],
|
||||
float aDefault = 0.0f) {
|
||||
static void AddAtomicFloatVarCache(std::atomic<float>* aVariable,
|
||||
const char (&aPref)[N],
|
||||
float aDefault = 0.0f) {
|
||||
return AddAtomicFloatVarCache(aVariable, nsLiteralCString(aPref), aDefault);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,57 +46,47 @@ void SetFunc(const nsCString& aPrefName, float aValue) {
|
|||
}
|
||||
|
||||
void AddVarCacheFunc(bool* aVar, const nsCString& aPrefName) {
|
||||
nsresult rv = Preferences::AddBoolVarCache(aVar, aPrefName);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
Preferences::AddBoolVarCache(aVar, aPrefName);
|
||||
}
|
||||
|
||||
void AddVarCacheFunc(Atomic<bool, Relaxed>* aVar, const nsCString& aPrefName) {
|
||||
nsresult rv = Preferences::AddAtomicBoolVarCache(aVar, aPrefName);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
Preferences::AddAtomicBoolVarCache(aVar, aPrefName);
|
||||
}
|
||||
|
||||
void AddVarCacheFunc(Atomic<bool, ReleaseAcquire>* aVar,
|
||||
const nsCString& aPrefName) {
|
||||
nsresult rv = Preferences::AddAtomicBoolVarCache(aVar, aPrefName);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
Preferences::AddAtomicBoolVarCache(aVar, aPrefName);
|
||||
}
|
||||
|
||||
void AddVarCacheFunc(int32_t* aVar, const nsCString& aPrefName) {
|
||||
nsresult rv = Preferences::AddIntVarCache(aVar, aPrefName);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
Preferences::AddIntVarCache(aVar, aPrefName);
|
||||
}
|
||||
|
||||
void AddVarCacheFunc(Atomic<int32_t, Relaxed>* aVar,
|
||||
const nsCString& aPrefName) {
|
||||
nsresult rv = Preferences::AddAtomicIntVarCache(aVar, aPrefName);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
Preferences::AddAtomicIntVarCache(aVar, aPrefName);
|
||||
}
|
||||
|
||||
void AddVarCacheFunc(uint32_t* aVar, const nsCString& aPrefName) {
|
||||
nsresult rv = Preferences::AddUintVarCache(aVar, aPrefName);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
Preferences::AddUintVarCache(aVar, aPrefName);
|
||||
}
|
||||
|
||||
void AddVarCacheFunc(Atomic<uint32_t, Relaxed>* aVar,
|
||||
const nsCString& aPrefName) {
|
||||
nsresult rv = Preferences::AddAtomicUintVarCache(aVar, aPrefName);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
Preferences::AddAtomicUintVarCache(aVar, aPrefName);
|
||||
}
|
||||
|
||||
void AddVarCacheFunc(Atomic<uint32_t, ReleaseAcquire>* aVar,
|
||||
const nsCString& aPrefName) {
|
||||
nsresult rv = Preferences::AddAtomicUintVarCache(aVar, aPrefName);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
Preferences::AddAtomicUintVarCache(aVar, aPrefName);
|
||||
}
|
||||
|
||||
void AddVarCacheFunc(float* aVar, const nsCString& aPrefName) {
|
||||
nsresult rv = Preferences::AddFloatVarCache(aVar, aPrefName);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
Preferences::AddFloatVarCache(aVar, aPrefName);
|
||||
}
|
||||
|
||||
void AddVarCacheFunc(std::atomic<float>* aVar, const nsCString& aPrefName) {
|
||||
nsresult rv = Preferences::AddAtomicFloatVarCache(aVar, aPrefName);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
Preferences::AddAtomicFloatVarCache(aVar, aPrefName);
|
||||
}
|
||||
|
||||
template <typename T, typename U = T>
|
||||
|
|
|
@ -807,18 +807,25 @@ void LogCallingScriptLocation(void* instance) {
|
|||
col));
|
||||
}
|
||||
|
||||
static bool sSanitize = true;
|
||||
|
||||
static bool InitPreferences() {
|
||||
Preferences::AddBoolVarCache(&sSanitize,
|
||||
"network.http.sanitize-headers-in-logs", true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void LogHeaders(const char* lineStart) {
|
||||
static bool sanitize = true;
|
||||
static nsresult once = Preferences::AddBoolVarCache(
|
||||
&sanitize, "network.http.sanitize-headers-in-logs", true);
|
||||
// The static bool assignment means that AddBoolVarCache is called just once.
|
||||
static bool once = InitPreferences();
|
||||
Unused << once;
|
||||
|
||||
nsAutoCString buf;
|
||||
char* endOfLine;
|
||||
while ((endOfLine = PL_strstr(lineStart, "\r\n"))) {
|
||||
buf.Assign(lineStart, endOfLine - lineStart);
|
||||
if (sanitize && (PL_strcasestr(buf.get(), "authorization: ") ||
|
||||
PL_strcasestr(buf.get(), "proxy-authorization: "))) {
|
||||
if (sSanitize && (PL_strcasestr(buf.get(), "authorization: ") ||
|
||||
PL_strcasestr(buf.get(), "proxy-authorization: "))) {
|
||||
char* p = PL_strchr(buf.get(), ' ');
|
||||
while (p && *++p) {
|
||||
*p = '*';
|
||||
|
|
|
@ -66,9 +66,9 @@ mozilla::LazyLogModule nsURILoader::mLog("URILoader");
|
|||
static uint32_t sConvertDataLimit = 20;
|
||||
|
||||
static bool InitPreferences() {
|
||||
nsresult rv = mozilla::Preferences::AddUintVarCache(
|
||||
mozilla::Preferences::AddUintVarCache(
|
||||
&sConvertDataLimit, "general.document_open_conversion_depth_limit", 20);
|
||||
return NS_SUCCEEDED(rv);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1041,10 +1041,8 @@ int32_t WidgetKeyboardEvent::GenericAccessModifierKeyPref() {
|
|||
static bool sInitialized = false;
|
||||
static int32_t sValue = -1;
|
||||
if (!sInitialized) {
|
||||
nsresult rv =
|
||||
Preferences::AddIntVarCache(&sValue, "ui.key.generalAccessKey", sValue);
|
||||
sInitialized = NS_SUCCEEDED(rv);
|
||||
MOZ_ASSERT(sInitialized);
|
||||
Preferences::AddIntVarCache(&sValue, "ui.key.generalAccessKey", sValue);
|
||||
sInitialized = true;
|
||||
}
|
||||
return sValue;
|
||||
}
|
||||
|
@ -1054,10 +1052,8 @@ int32_t WidgetKeyboardEvent::ChromeAccessModifierMaskPref() {
|
|||
static bool sInitialized = false;
|
||||
static int32_t sValue = 0;
|
||||
if (!sInitialized) {
|
||||
nsresult rv =
|
||||
Preferences::AddIntVarCache(&sValue, "ui.key.chromeAccess", sValue);
|
||||
sInitialized = NS_SUCCEEDED(rv);
|
||||
MOZ_ASSERT(sInitialized);
|
||||
Preferences::AddIntVarCache(&sValue, "ui.key.chromeAccess", sValue);
|
||||
sInitialized = true;
|
||||
}
|
||||
return sValue;
|
||||
}
|
||||
|
@ -1067,10 +1063,8 @@ int32_t WidgetKeyboardEvent::ContentAccessModifierMaskPref() {
|
|||
static bool sInitialized = false;
|
||||
static int32_t sValue = 0;
|
||||
if (!sInitialized) {
|
||||
nsresult rv =
|
||||
Preferences::AddIntVarCache(&sValue, "ui.key.contentAccess", sValue);
|
||||
sInitialized = NS_SUCCEEDED(rv);
|
||||
MOZ_ASSERT(sInitialized);
|
||||
Preferences::AddIntVarCache(&sValue, "ui.key.contentAccess", sValue);
|
||||
sInitialized = true;
|
||||
}
|
||||
return sValue;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче