Closed Bug 1567329 Opened 2 years ago Closed 2 years ago

Improve naming of static pref getter functions


(Core :: Preferences: Backend, task, P3)




Tracking Status
firefox70 --- fixed


(Reporter: n.nethercote, Assigned: n.nethercote)




(3 files)

Now that StaticPrefList.h is generated from StaticPrefList.yaml, we have more flexibility in how static pref getter functions are named, and we can do some useful things.

This better distinguishes it from the pref name part of the getter, which uses
snake case.

Depends on D38602

Currently it's completely unclear at use sites that the getters for once
static prefs return the pref value from startup, rather than the current pref
value. (Bugs have been caused by this.) This commit improves things by changing
the getter name to make it clear that the pref value obtained is from startup.

This required changing things within libpref so it distinguishes between the
"base id" (foo_bar) and the "full id" (foo_bar or
foo_bar_DoNotUseDirectly or foo_bar_AtStartup or
foo_bar_AtStartup_DoNotUseDirectly; the name used depends on the mirror and
do_not_use_directly values in the YAML definition.) The "full id" is used in
most places, while the "base id" is used for the GetPrefName_* and
GetPrefDefault_* functions.

(This is a nice demonstration of the benefits of the YAML file, bTW. Making
this change with the old code would have involved adding an entry to every
single pref in StaticPrefList.h.)

The patch also rejigs the comment at the top of StaticPrefList.yaml, to clarify
some things.

Depends on D38603

Pushed by
Change some mentions of StaticPrefList.h to StaticPrefList.yaml. r=erahm
Change `_do_not_use_directly` suffixes to `_DoNotUseDirectly`. r=erahm
Append `_AtStartup` to `once` static pref getters. r=erahm
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
Blocks: 1568059
You need to log in before you can comment on or make changes to this bug.