mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 22:37:50 +00:00

We busted browser_preferences_usage.js by looking up a preference too many times. The reason we are now exceeding the pref-reading limit for this pref is that inside ShouldSanitizePreference all of our calls to Preferences::Something(pref_name) are causing pref lookups. _Most_ of the time when we are in ShouldSanitizePreference, we got there from a place that has the actual pref object; so change the function to take in a Pref object. Unfortunately, there is a place we do need to look it up by name, and that's in Static Pref getters, so we need to keep that function around (and expose it in Preferences.h) To minimize code duplication (i.e. not having the exact same code for ShouldSanitizePreference(Pref) and ShouldSanitizePreference(PrefWrapper) we do some templating tricks because even though they expose the same API, they are not in a class hierarchy where we could just make one function for a base class. Depends on D141420 Differential Revision: https://phabricator.services.mozilla.com/D141421