Closed Bug 1567329 Opened 3 months ago Closed 3 months ago

Improve naming of static pref getter functions

Categories

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

task

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: njn, Assigned: njn)

References

Details

Attachments

(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 nnethercote@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1cbe3ab8f7cd
Change some mentions of StaticPrefList.h to StaticPrefList.yaml. r=erahm
https://hg.mozilla.org/integration/autoland/rev/4d005e8db6cc
Change `_do_not_use_directly` suffixes to `_DoNotUseDirectly`. r=erahm
https://hg.mozilla.org/integration/autoland/rev/2cb4ffa920c6
Append `_AtStartup` to `once` static pref getters. r=erahm
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
Blocks: 1568059
You need to log in before you can comment on or make changes to this bug.