Bug 1473631: Part 0a - Make preference callbacks typesafe. r=njn

I initially tried to avoid this, but decided it was necessary given the number
of times I had to repeat the same pattern of casting a variable to void*, and
then casting it back in a part of code far distant from the original type.

This changes our preference callback registration functions to match the type
of the callback's closure argument to the actual type of the closure pointer
passed, and then casting it to the type of our generic callback function. This
ensures that the callback function always gets an argument of the type it's
actually expecting without adding any additional runtime memory or
QueryInterface overhead for tracking it.

MozReview-Commit-ID: 9tLKBe10ddP

--HG--
extra : rebase_source : 7524fa8dcd5585f5a31fdeb37d95714f1bb94922
This commit is contained in:
Kris Maglione 2018-07-06 12:24:41 -07:00
parent 4fa87dd304
commit 0bfdb4329f
22 changed files with 184 additions and 137 deletions

View File

@ -12612,9 +12612,9 @@ struct PrefStore
Preferences::GetCString("urlclassifier.flashSubDocExceptTable", mSubDocDenyExceptionsTables);
}
static void UpdateStringPrefs(const char*, void* aClosure)
static void UpdateStringPrefs(const char*, PrefStore* aSelf)
{
static_cast<PrefStore*>(aClosure)->UpdateStringPrefs();
aSelf->UpdateStringPrefs();
}
bool mFlashBlockEnabled;

View File

@ -153,8 +153,7 @@ FallbackEncoding::Initialize()
"Initializing pre-existing fallback cache.");
FallbackEncoding::sInstance = new FallbackEncoding;
Preferences::RegisterCallback(FallbackEncoding::PrefChanged,
"intl.charset.fallback.override",
nullptr);
"intl.charset.fallback.override");
Preferences::AddBoolVarCache(&sGuessFallbackFromTopLevelDomain,
"intl.charset.fallback.tld");
Preferences::AddBoolVarCache(&sFallbackToUTF8ForFile,

View File

@ -247,12 +247,12 @@ private:
};
void
AtomicBoolPrefChangedCallback(const char* aPrefName, void* aClosure)
AtomicBoolPrefChangedCallback(const char* aPrefName, Atomic<bool>* aClosure)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aClosure);
*static_cast<Atomic<bool>*>(aClosure) = Preferences::GetBool(aPrefName);
*aClosure = Preferences::GetBool(aPrefName);
}
void

View File

@ -512,6 +512,16 @@ PluginModuleChromeParent::LoadModule(const char* aFilePath, uint32_t aPluginId,
return parent.forget();
}
static const char* gCallbackPrefs[] = {
kChildTimeoutPref,
kParentTimeoutPref,
#ifdef XP_WIN
kHangUITimeoutPref,
kHangUIMinDisplayPref,
#endif
nullptr,
};
void
PluginModuleChromeParent::OnProcessLaunched(const bool aSucceeded)
{
@ -536,12 +546,8 @@ PluginModuleChromeParent::OnProcessLaunched(const bool aSucceeded)
TimeoutChanged(CHILD_TIMEOUT_PREF, this);
Preferences::RegisterCallback(TimeoutChanged, kChildTimeoutPref, this);
Preferences::RegisterCallback(TimeoutChanged, kParentTimeoutPref, this);
#ifdef XP_WIN
Preferences::RegisterCallback(TimeoutChanged, kHangUITimeoutPref, this);
Preferences::RegisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this);
#endif
Preferences::RegisterCallbacks(TimeoutChanged, gCallbackPrefs,
static_cast<PluginModuleParent*>(this));
RegisterSettingsCallbacks();
@ -626,12 +632,14 @@ PluginModuleContentParent::PluginModuleContentParent()
: PluginModuleParent(false)
, mPluginId(0)
{
Preferences::RegisterCallback(TimeoutChanged, kContentTimeoutPref, this);
Preferences::RegisterCallback(TimeoutChanged, kContentTimeoutPref,
static_cast<PluginModuleParent*>(this));
}
PluginModuleContentParent::~PluginModuleContentParent()
{
Preferences::UnregisterCallback(TimeoutChanged, kContentTimeoutPref, this);
Preferences::UnregisterCallback(TimeoutChanged, kContentTimeoutPref,
static_cast<PluginModuleParent*>(this));
}
PluginModuleChromeParent::PluginModuleChromeParent(const char* aFilePath,
@ -702,12 +710,10 @@ PluginModuleChromeParent::~PluginModuleChromeParent()
UnregisterSettingsCallbacks();
Preferences::UnregisterCallback(TimeoutChanged, kChildTimeoutPref, this);
Preferences::UnregisterCallback(TimeoutChanged, kParentTimeoutPref, this);
#ifdef XP_WIN
Preferences::UnregisterCallback(TimeoutChanged, kHangUITimeoutPref, this);
Preferences::UnregisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this);
Preferences::UnregisterCallbacks(TimeoutChanged, gCallbackPrefs,
static_cast<PluginModuleParent*>(this));
#ifdef XP_WIN
if (mHangUIParent) {
delete mHangUIParent;
mHangUIParent = nullptr;
@ -768,33 +774,31 @@ PluginModuleParent::SetChildTimeout(const int32_t aChildTimeout)
}
void
PluginModuleParent::TimeoutChanged(const char* aPref, void* aModule)
PluginModuleParent::TimeoutChanged(const char* aPref, PluginModuleParent* aModule)
{
PluginModuleParent* module = static_cast<PluginModuleParent*>(aModule);
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
#ifndef XP_WIN
if (!strcmp(aPref, kChildTimeoutPref)) {
MOZ_ASSERT(module->IsChrome());
MOZ_ASSERT(aModule->IsChrome());
// The timeout value used by the parent for children
int32_t timeoutSecs = Preferences::GetInt(kChildTimeoutPref, 0);
module->SetChildTimeout(timeoutSecs);
aModule->SetChildTimeout(timeoutSecs);
#else
if (!strcmp(aPref, kChildTimeoutPref) ||
!strcmp(aPref, kHangUIMinDisplayPref) ||
!strcmp(aPref, kHangUITimeoutPref)) {
MOZ_ASSERT(module->IsChrome());
static_cast<PluginModuleChromeParent*>(module)->EvaluateHangUIState(true);
MOZ_ASSERT(aModule->IsChrome());
static_cast<PluginModuleChromeParent*>(aModule)->EvaluateHangUIState(true);
#endif // XP_WIN
} else if (!strcmp(aPref, kParentTimeoutPref)) {
// The timeout value used by the child for its parent
MOZ_ASSERT(module->IsChrome());
MOZ_ASSERT(aModule->IsChrome());
int32_t timeoutSecs = Preferences::GetInt(kParentTimeoutPref, 0);
Unused << static_cast<PluginModuleChromeParent*>(module)->SendSetParentHangTimeout(timeoutSecs);
Unused << static_cast<PluginModuleChromeParent*>(aModule)->SendSetParentHangTimeout(timeoutSecs);
} else if (!strcmp(aPref, kContentTimeoutPref)) {
MOZ_ASSERT(!module->IsChrome());
MOZ_ASSERT(!aModule->IsChrome());
int32_t timeoutSecs = Preferences::GetInt(kContentTimeoutPref, 0);
module->SetChildTimeout(timeoutSecs);
aModule->SetChildTimeout(timeoutSecs);
}
}
@ -2078,10 +2082,9 @@ PluginModuleChromeParent::CachedSettingChanged()
}
/* static */ void
PluginModuleChromeParent::CachedSettingChanged(const char* aPref, void* aModule)
PluginModuleChromeParent::CachedSettingChanged(const char* aPref, PluginModuleChromeParent* aModule)
{
PluginModuleChromeParent *module = static_cast<PluginModuleChromeParent*>(aModule);
module->CachedSettingChanged();
aModule->CachedSettingChanged();
}
#if defined(XP_UNIX) && !defined(XP_MACOSX)

View File

@ -169,7 +169,7 @@ protected:
protected:
void SetChildTimeout(const int32_t aChildTimeout);
static void TimeoutChanged(const char* aPref, void* aModule);
static void TimeoutChanged(const char* aPref, PluginModuleParent* aModule);
virtual void UpdatePluginTimeout() {}
@ -519,7 +519,7 @@ private:
virtual mozilla::ipc::IPCResult RecvNotifyContentModuleDestroyed() override;
static void CachedSettingChanged(const char* aPref, void* aModule);
static void CachedSettingChanged(const char* aPref, PluginModuleChromeParent* aModule);
virtual mozilla::ipc::IPCResult
AnswerNPN_SetValue_NPPVpluginRequiresAudioDeviceChanges(

View File

@ -2927,12 +2927,11 @@ XULDocument::ResetDocumentDirection()
}
void
XULDocument::DirectionChanged(const char* aPrefName, void* aData)
XULDocument::DirectionChanged(const char* aPrefName, XULDocument* aDoc)
{
// Reset the direction and restyle the document if necessary.
XULDocument* doc = (XULDocument *)aData;
if (doc) {
doc->ResetDocumentDirection();
if (aDoc) {
aDoc->ResetDocumentDirection();
}
}

View File

@ -209,7 +209,7 @@ protected:
already_AddRefed<nsPIWindowRoot> GetWindowRoot();
static void DirectionChanged(const char* aPrefName, void* aData);
static void DirectionChanged(const char* aPrefName, XULDocument* aData);
// pseudo constants
static int32_t gRefCnt;

View File

@ -273,9 +273,9 @@ void gfxPrefs::PrefSet(const char* aPref, std::string aValue)
}
static void
OnGfxPrefChanged(const char* aPrefname, void* aClosure)
OnGfxPrefChanged(const char* aPrefname, gfxPrefs::Pref* aPref)
{
reinterpret_cast<gfxPrefs::Pref*>(aClosure)->OnChange();
aPref->OnChange();
}
void gfxPrefs::WatchChanges(const char* aPrefname, Pref* aPref)

View File

@ -733,9 +733,8 @@ bool
xpc::SharedMemoryEnabled() { return sSharedMemoryEnabled; }
static void
ReloadPrefsCallback(const char* pref, void* data)
ReloadPrefsCallback(const char* pref, XPCJSContext* xpccx)
{
XPCJSContext* xpccx = static_cast<XPCJSContext*>(data);
JSContext* cx = xpccx->Context();
bool useBaseline = Preferences::GetBool(JS_OPTIONS_DOT_STR "baselinejit");

View File

@ -150,15 +150,10 @@ nsPresContext::IsDOMPaintEventPending()
}
void
nsPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data)
nsPresContext::PrefChangedCallback(const char* aPrefName, nsPresContext* aPresContext)
{
RefPtr<nsPresContext> presContext =
static_cast<nsPresContext*>(instance_data);
NS_ASSERTION(presContext, "bad instance data");
if (presContext) {
presContext->PreferenceChanged(aPrefName);
}
NS_ASSERTION(aPresContext, "bad instance data");
aPresContext->PreferenceChanged(aPrefName);
}
void

View File

@ -1198,7 +1198,7 @@ protected:
void GetDocumentColorPreferences();
void PreferenceChanged(const char* aPrefName);
static void PrefChangedCallback(const char*, void*);
static void PrefChangedCallback(const char*, nsPresContext*);
void UpdateAfterPreferencesChanged();
void DispatchPrefChangedRunnableIfNeeded();

View File

@ -5470,9 +5470,9 @@ nsComputedDOMStyle::DummyGetter()
}
static void
MarkComputedStyleMapDirty(const char* aPref, void* aData)
MarkComputedStyleMapDirty(const char* aPref, ComputedStyleMap* aData)
{
static_cast<ComputedStyleMap*>(aData)->MarkDirty();
aData->MarkDirty();
}
void

View File

@ -34,6 +34,39 @@ class nsPrefBranch;
namespace mozilla {
// A typesafe version of PrefChangeFunc, with its data argument type deduced
// from the type of the argument passed to RegisterCallback.
//
// Note: We specify this as a dependent type TypedPrefChangeFunc<T>::SelfType so
// that it does not participate in argument type deduction. This allows us to
// use its implicit conversion constructor, and also allows our Register and
// Unregister methods to accept non-capturing lambdas (which will not match
// void(*)(const char*, T*) when used in type deduction) as callback functions.
template<typename T>
struct TypedPrefChangeFunc
{
using Type = TypedPrefChangeFunc<T>;
using CallbackType = void (*)(const char*, T*);
MOZ_IMPLICIT TypedPrefChangeFunc(CallbackType aCallback)
: mCallback(aCallback)
{
}
template<typename F>
MOZ_IMPLICIT TypedPrefChangeFunc(F&& aLambda)
: mCallback(aLambda)
{
}
operator PrefChangedFunc() const
{
return reinterpret_cast<PrefChangedFunc>(mCallback);
}
CallbackType mCallback;
};
class PreferenceServiceReporter;
namespace dom {
@ -307,52 +340,64 @@ public:
static nsresult RemoveObservers(nsIObserver* aObserver, const char** aPrefs);
// Registers/Unregisters the callback function for the aPref.
static nsresult RegisterCallback(PrefChangedFunc aCallback,
const nsACString& aPref,
void* aClosure = nullptr)
template<typename T = void>
static nsresult RegisterCallback(
typename TypedPrefChangeFunc<T>::Type aCallback,
const nsACString& aPref,
T* aClosure = nullptr)
{
return RegisterCallback(aCallback, aPref, aClosure, ExactMatch);
}
static nsresult UnregisterCallback(PrefChangedFunc aCallback,
const nsACString& aPref,
void* aClosure = nullptr)
template<typename T = void>
static nsresult UnregisterCallback(
typename TypedPrefChangeFunc<T>::Type aCallback,
const nsACString& aPref,
T* aClosure = nullptr)
{
return UnregisterCallback(aCallback, aPref, aClosure, ExactMatch);
}
// Like RegisterCallback, but also calls the callback immediately for
// initialization.
static nsresult RegisterCallbackAndCall(PrefChangedFunc aCallback,
const nsACString& aPref,
void* aClosure = nullptr)
template<typename T = void>
static nsresult RegisterCallbackAndCall(
typename TypedPrefChangeFunc<T>::Type aCallback,
const nsACString& aPref,
T* aClosure = nullptr)
{
return RegisterCallbackAndCall(aCallback, aPref, aClosure, ExactMatch);
}
// Like RegisterCallback, but registers a callback for a prefix of multiple
// pref names, not a single pref name.
static nsresult RegisterPrefixCallback(PrefChangedFunc aCallback,
const nsACString& aPref,
void* aClosure = nullptr)
template<typename T = void>
static nsresult RegisterPrefixCallback(
typename TypedPrefChangeFunc<T>::Type aCallback,
const nsACString& aPref,
T* aClosure = nullptr)
{
return RegisterCallback(aCallback, aPref, aClosure, PrefixMatch);
}
// Like RegisterPrefixCallback, but also calls the callback immediately for
// initialization.
static nsresult RegisterPrefixCallbackAndCall(PrefChangedFunc aCallback,
const nsACString& aPref,
void* aClosure = nullptr)
template<typename T = void>
static nsresult RegisterPrefixCallbackAndCall(
typename TypedPrefChangeFunc<T>::Type aCallback,
const nsACString& aPref,
T* aClosure = nullptr)
{
return RegisterCallbackAndCall(aCallback, aPref, aClosure, PrefixMatch);
}
// Unregister a callback registered with RegisterPrefixCallback or
// RegisterPrefixCallbackAndCall.
static nsresult UnregisterPrefixCallback(PrefChangedFunc aCallback,
const nsACString& aPref,
void* aClosure = nullptr)
template<typename T = void>
static nsresult UnregisterPrefixCallback(
typename TypedPrefChangeFunc<T>::Type aCallback,
const nsACString& aPref,
T* aClosure = nullptr)
{
return UnregisterCallback(aCallback, aPref, aClosure, PrefixMatch);
}
@ -366,83 +411,97 @@ public:
//
// Also note that the exact same aPrefs pointer must be passed to the
// Unregister call as was passed to the Register call.
static nsresult RegisterCallbacks(PrefChangedFunc aCallback,
const char** aPrefs,
void* aClosure = nullptr)
template<typename T = void>
static nsresult RegisterCallbacks(
typename TypedPrefChangeFunc<T>::Type aCallback,
const char** aPrefs,
T* aClosure = nullptr)
{
return RegisterCallbacks(aCallback, aPrefs, aClosure, ExactMatch);
}
static nsresult RegisterCallbacksAndCall(PrefChangedFunc aCallback,
const char** aPrefs,
void* aClosure = nullptr);
static nsresult UnregisterCallbacks(PrefChangedFunc aCallback,
const char** aPrefs,
void* aClosure = nullptr)
template<typename T = void>
static nsresult UnregisterCallbacks(
typename TypedPrefChangeFunc<T>::Type aCallback,
const char** aPrefs,
T* aClosure = nullptr)
{
return UnregisterCallbacks(aCallback, aPrefs, aClosure, ExactMatch);
}
static nsresult RegisterPrefixCallbacks(PrefChangedFunc aCallback,
const char** aPrefs,
void* aClosure = nullptr)
template<typename T = void>
static nsresult RegisterPrefixCallbacks(
typename TypedPrefChangeFunc<T>::Type aCallback,
const char** aPrefs,
T* aClosure = nullptr)
{
return RegisterCallbacks(aCallback, aPrefs, aClosure, PrefixMatch);
}
static nsresult UnregisterPrefixCallbacks(PrefChangedFunc aCallback,
const char** aPrefs,
void* aClosure = nullptr)
template<typename T = void>
static nsresult UnregisterPrefixCallbacks(
typename TypedPrefChangeFunc<T>::Type aCallback,
const char** aPrefs,
T* aClosure = nullptr)
{
return UnregisterCallbacks(aCallback, aPrefs, aClosure, PrefixMatch);
}
template<int N>
static nsresult RegisterCallback(PrefChangedFunc aCallback,
const char (&aPref)[N],
void* aClosure = nullptr)
template<int N, typename T = void>
static nsresult RegisterCallback(
typename TypedPrefChangeFunc<T>::Type aCallback,
const char (&aPref)[N],
T* aClosure = nullptr)
{
return RegisterCallback(
aCallback, nsLiteralCString(aPref), aClosure, ExactMatch);
}
template<int N>
static nsresult UnregisterCallback(PrefChangedFunc aCallback,
const char (&aPref)[N],
void* aClosure = nullptr)
template<int N, typename T = void>
static nsresult UnregisterCallback(
typename TypedPrefChangeFunc<T>::Type aCallback,
const char (&aPref)[N],
T* aClosure = nullptr)
{
return UnregisterCallback(
aCallback, nsLiteralCString(aPref), aClosure, ExactMatch);
}
template<int N>
static nsresult RegisterCallbackAndCall(PrefChangedFunc aCallback,
const char (&aPref)[N],
void* aClosure = nullptr)
template<int N, typename T = void>
static nsresult RegisterCallbackAndCall(
typename TypedPrefChangeFunc<T>::Type aCallback,
const char (&aPref)[N],
T* aClosure = nullptr)
{
return RegisterCallbackAndCall(
aCallback, nsLiteralCString(aPref), aClosure, ExactMatch);
}
template<int N>
static nsresult RegisterPrefixCallback(PrefChangedFunc aCallback,
const char (&aPref)[N],
void* aClosure = nullptr)
template<int N, typename T = void>
static nsresult RegisterPrefixCallback(
typename TypedPrefChangeFunc<T>::Type aCallback,
const char (&aPref)[N],
T* aClosure = nullptr)
{
return RegisterCallback(
aCallback, nsLiteralCString(aPref), aClosure, PrefixMatch);
}
template<int N>
static nsresult RegisterPrefixCallbackAndCall(PrefChangedFunc aCallback,
const char (&aPref)[N],
void* aClosure = nullptr)
template<int N, typename T = void>
static nsresult RegisterPrefixCallbackAndCall(
typename TypedPrefChangeFunc<T>::Type aCallback,
const char (&aPref)[N],
T* aClosure = nullptr)
{
return RegisterCallbackAndCall(
aCallback, nsLiteralCString(aPref), aClosure, PrefixMatch);
}
template<int N>
static nsresult UnregisterPrefixCallback(PrefChangedFunc aCallback,
const char (&aPref)[N],
void* aClosure = nullptr)
template<int N, typename T = void>
static nsresult UnregisterPrefixCallback(
typename TypedPrefChangeFunc<T>::Type aCallback,
const char (&aPref)[N],
T* aClosure = nullptr)
{
return UnregisterCallback(
aCallback, nsLiteralCString(aPref), aClosure, PrefixMatch);

View File

@ -21,12 +21,11 @@ struct Closure
template<typename T, typename U>
void
VarChanged(const char* aPrefName, void* aData)
VarChanged(const char* aPrefName, Closure<T, U>* aClosure)
{
auto closure = static_cast<Closure<T, U>*>(aData);
ASSERT_EQ(*closure->mLocation, closure->mExpected);
ASSERT_FALSE(closure->mCalled);
closure->mCalled = true;
ASSERT_EQ(*aClosure->mLocation, aClosure->mExpected);
ASSERT_FALSE(aClosure->mCalled);
aClosure->mCalled = true;
}
void

View File

@ -94,7 +94,7 @@ private:
CachedPrefs();
~CachedPrefs();
static void OnPrefsChange(const char* aPrefName, void* );
static void OnPrefsChange(const char* aPrefName, CachedPrefs*);
// Whether channels should be annotated as being on the tracking protection
// list.
@ -119,24 +119,22 @@ StaticAutoPtr<CachedPrefs> CachedPrefs::sInstance;
// static
void
CachedPrefs::OnPrefsChange(const char* aPref, void* aClosure)
CachedPrefs::OnPrefsChange(const char* aPref, CachedPrefs* aPrefs)
{
CachedPrefs* prefs = static_cast<CachedPrefs*> (aClosure);
if (!strcmp(aPref, URLCLASSIFIER_SKIP_HOSTNAMES)) {
nsCString skipHostnames;
Preferences::GetCString(URLCLASSIFIER_SKIP_HOSTNAMES, skipHostnames);
ToLowerCase(skipHostnames);
prefs->SetSkipHostnames(skipHostnames);
aPrefs->SetSkipHostnames(skipHostnames);
} else if (!strcmp(aPref, URLCLASSIFIER_TRACKING_WHITELIST)) {
nsCString trackingWhitelist;
Preferences::GetCString(URLCLASSIFIER_TRACKING_WHITELIST,
trackingWhitelist);
prefs->SetTrackingWhiteList(trackingWhitelist);
aPrefs->SetTrackingWhiteList(trackingWhitelist);
} else if (!strcmp(aPref, URLCLASSIFIER_TRACKING_TABLE)) {
nsCString trackingBlacklist;
Preferences::GetCString(URLCLASSIFIER_TRACKING_TABLE, trackingBlacklist);
prefs->SetTrackingBlackList(trackingBlacklist);
aPrefs->SetTrackingBlackList(trackingBlacklist);
}
}

View File

@ -523,13 +523,12 @@ static const char kPrefThreadIdleTime[] = "network.dns.resolver-thread-extra-idl
static bool sGetTtlEnabled = false;
mozilla::Atomic<bool, mozilla::Relaxed> gNativeIsLocalhost;
static void DnsPrefChanged(const char* aPref, void* aClosure)
static void DnsPrefChanged(const char* aPref, nsHostResolver* aSelf)
{
MOZ_ASSERT(NS_IsMainThread(),
"Should be getting pref changed notification on main thread!");
DebugOnly<nsHostResolver*> self = static_cast<nsHostResolver*>(aClosure);
MOZ_ASSERT(self);
MOZ_ASSERT(aSelf);
if (!strcmp(aPref, kPrefGetTtl)) {
#ifdef DNSQUERY_AVAILABLE

View File

@ -628,11 +628,10 @@ CertBlocklist::IsBlocklistFresh(bool* _retval)
/* static */
void
CertBlocklist::PreferenceChanged(const char* aPref, void* aClosure)
CertBlocklist::PreferenceChanged(const char* aPref, CertBlocklist* aBlocklist)
{
auto blocklist = static_cast<CertBlocklist*>(aClosure);
MutexAutoLock lock(blocklist->mMutex);
MutexAutoLock lock(aBlocklist->mMutex);
MOZ_LOG(gCertBlockPRLog, LogLevel::Warning,
("CertBlocklist::PreferenceChanged %s changed", aPref));

View File

@ -79,7 +79,7 @@ private:
nsCOMPtr<nsIFile> mBackingFile;
protected:
static void PreferenceChanged(const char* aPref, void* aClosure);
static void PreferenceChanged(const char* aPref, CertBlocklist* aBlocklist);
static uint32_t sLastBlocklistUpdate;
static uint32_t sLastKintoUpdate;
static uint32_t sMaxStaleness;

View File

@ -4711,10 +4711,10 @@ nsNavHistoryResult::OnMobilePrefChanged()
void
nsNavHistoryResult::OnMobilePrefChangedCallback(const char *prefName,
void *closure)
nsNavHistoryResult *self)
{
MOZ_ASSERT(!strcmp(prefName, MOBILE_BOOKMARKS_PREF),
"We only expected Mobile Bookmarks pref change.");
static_cast<nsNavHistoryResult*>(closure)->OnMobilePrefChanged();
self->OnMobilePrefChanged();
}

View File

@ -177,7 +177,7 @@ public:
void OnMobilePrefChanged();
static void OnMobilePrefChangedCallback(const char* prefName, void* closure);
static void OnMobilePrefChangedCallback(const char* prefName, nsNavHistoryResult* self);
protected:
virtual ~nsNavHistoryResult();

View File

@ -380,9 +380,9 @@ private:
private:
void Init();
static void OnChange(const char* aPrefName, void* aClosure)
static void OnChange(const char* aPrefName, UserPrefs* aClosure)
{
static_cast<UserPrefs*>(aClosure)->MarkDirty();
aClosure->MarkDirty();
}
bool mInitialized;

View File

@ -262,8 +262,7 @@ OnFifoEnabledChange(const char* /*unused*/, void* /*unused*/)
LOG("%s changed", FifoWatcher::kPrefName);
if (SetupFifo()) {
Preferences::UnregisterCallback(OnFifoEnabledChange,
FifoWatcher::kPrefName,
nullptr);
FifoWatcher::kPrefName);
}
}
@ -304,8 +303,7 @@ nsMemoryInfoDumper::Initialize()
// to attempt to initialize if the fifo watcher becomes enabled by
// a user pref.
Preferences::RegisterCallback(OnFifoEnabledChange,
FifoWatcher::kPrefName,
nullptr);
FifoWatcher::kPrefName);
}
#endif
}