Bug 1448219 Comment 3 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

KrisWright: If you are interested in doing some conversions, a good place to start would be `TimoutManager::Initialize()` in `dom/base/TimeoutManager.cpp`. There are 13 VarCache prefs there that look straightforward.

The following steps should work for most (but not all) VarCache prefs.
- Find an existing VarCache pref to convert, by searching for `Add*VarCache` calls.
- Find the pref's entry in a prefs data file, usually `modules/libpref/init/all.js`.
- Add a new entry to `modules/libpref/init/StaticPrefList.yaml`, based on what you found in the above two steps.
  - Note that sometimes the default value given in those two locations won't agree, in which case you probably should use the `all.js` one.
- Remove the entry from `all.js`.
- Remove the `Add*VarCache` call, along with the mirror variable it used, and any accompanying stuff such as:
  - any constant for the default value;
  - any static bool being used to prevent `Add*VarCache` from being called more than once.
- Also look for any entries in other prefs files, particularly `mobile/android/app/mobile.js` or `browser/app/profile/firefox.js`. If they are equivalent to the `StaticPrefList.yaml` entry, then remove them. This is surprisingly common.

It's usually best to do one pref per commit, because it makes reviewing and bisecting any regressions easier. Sometimes you might have two or three tightly-coupled prefs, in which case doing them in a single commit might be better.

You can look at commits in bugs blocking this bug for examples of previous conversions. They all predate the introduction of `StaticPrefList.yaml`, and therefore add the new static pref to `StaticPrefList.h` instead, but otherwise they'll match the steps above.
KrisWright: If you are interested in doing some conversions, a good place to start would be `TimoutManager::Initialize()` in `dom/base/TimeoutManager.cpp`. There are 13 VarCache prefs there that look straightforward.

The following steps should work for most (but not all) VarCache prefs.
- Find an existing VarCache pref to convert, by searching for `Add*VarCache` calls.
- Find the pref's entry in a prefs data file, usually `modules/libpref/init/all.js`.
- Add a new entry to `modules/libpref/init/StaticPrefList.yaml`, based on what you found in the above two steps.
  - Note that sometimes the default value given in those two locations won't agree, in which case you probably should use the `all.js` one.
- Remove the entry from `all.js`.
- Remove the `Add*VarCache` call, along with the mirror variable it used, and any accompanying stuff such as:
  - any constant for the default value;
  - any static bool being used to prevent `Add*VarCache` from being called more than once.
- Replace uses of the mirror variable with `StaticPrefs::foo_bar_baz()`.
- Also look for any entries in other prefs files, particularly `mobile/android/app/mobile.js` or `browser/app/profile/firefox.js`. If they are equivalent to the `StaticPrefList.yaml` entry, then remove them. This is surprisingly common.

It's usually best to do one pref per commit, because it makes reviewing and bisecting any regressions easier. Sometimes you might have two or three tightly-coupled prefs, in which case doing them in a single commit might be better.

You can look at commits in bugs blocking this bug for examples of previous conversions. They all predate the introduction of `StaticPrefList.yaml`, and therefore add the new static pref to `StaticPrefList.h` instead, but otherwise they'll match the steps above.
KrisWright: If you are interested in doing some conversions, a good place to start would be `TimoutManager::Initialize()` in `dom/base/TimeoutManager.cpp`. There are 13 VarCache prefs there that look straightforward.

The following steps should work for most (but not all) VarCache prefs.
- Find an existing VarCache pref to convert, by searching for `Add*VarCache` calls.
- Find the pref's entry in a prefs data file, usually `modules/libpref/init/all.js`.
- Add a new entry to `modules/libpref/init/StaticPrefList.yaml`, based on what you found in the above two steps.
  - Note that sometimes the default value given in those two locations won't agree, in which case you probably should use the `all.js` one.
- Remove the entry from `all.js`.
- Remove the `Add*VarCache` call, along with the mirror variable it used, and any accompanying stuff such as:
  - any constant for the default value;
  - any static bool being used to prevent `Add*VarCache` from being called more than once.
- Replace uses of the mirror variable with `StaticPrefs::foo_bar_baz()`.
  - If there are no such uses, give it a `mirror` value of `never`.
  - Unless the pref is never used at all, in which case remove it!
- Also look for any entries in other prefs files, particularly `mobile/android/app/mobile.js` or `browser/app/profile/firefox.js`. If they are equivalent to the `StaticPrefList.yaml` entry, then remove them. This is surprisingly common.

It's usually best to do one pref per commit, because it makes reviewing and bisecting any regressions easier. Sometimes you might have two or three tightly-coupled prefs, in which case doing them in a single commit might be better.

You can look at commits in bugs blocking this bug for examples of previous conversions. They all predate the introduction of `StaticPrefList.yaml`, and therefore add the new static pref to `StaticPrefList.h` instead, but otherwise they'll match the steps above.
KrisWright: If you are interested in doing some conversions, a good place to start would be `TimoutManager::Initialize()` in `dom/base/TimeoutManager.cpp`. There are 13 VarCache prefs there that look straightforward.

The following steps should work for most (but not all) VarCache prefs.
- Find an existing VarCache pref to convert, by searching for `Add*VarCache` calls.
- Look for the pref's entry in a prefs data file, usually `modules/libpref/init/all.js`. (You won't always find one.)
- Add a new entry to `modules/libpref/init/StaticPrefList.yaml`, based on what you found in the above two steps.
  - Note that sometimes the default value given in those two locations won't agree, in which case you probably should use the `all.js` one.
- Remove the entry from `all.js`, if present.
- Remove the `Add*VarCache` call, along with the mirror variable it used, and any accompanying stuff such as:
  - any constant for the default value;
  - any static bool being used to prevent `Add*VarCache` from being called more than once.
- Replace uses of the mirror variable with `StaticPrefs::foo_bar_baz()`.
  - If there are no such uses, give it a `mirror` value of `never`.
  - Unless the pref is never used at all, in which case remove it!
- Also look for any entries in other prefs files, particularly `mobile/android/app/mobile.js` or `browser/app/profile/firefox.js`. If they are equivalent to the `StaticPrefList.yaml` entry, then remove them. (This is surprisingly common.) Or if they can be merged into the `StaticPrefList.yaml` entry (e.g. with `#ifdef ANDROID`), then do that.

It's usually best to do one pref per commit, because it makes reviewing and bisecting any regressions easier. Sometimes you might have two or three tightly-coupled prefs, in which case doing them in a single commit might be better.

You can look at commits in bugs blocking this bug for examples of previous conversions. They all predate the introduction of `StaticPrefList.yaml`, and therefore add the new static pref to `StaticPrefList.h` instead, but otherwise they'll match the steps above.

Back to Bug 1448219 Comment 3