Closed Bug 960257 Opened 10 years ago Closed 10 years ago

[AccessFu] Introduce SettingCache in Utils

Categories

(Core :: Disability Access APIs, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: eeejay, Assigned: eeejay)

References

Details

Attachments

(1 file, 2 obsolete files)

This would be similar to PrefCache, but for the Settings API. Useful for screen reader settings that can be adjusted by privileged apps (like the Gaia Settings app).
Attachment #8360635 - Flags: review?(yura.zenevich)
Comment on attachment 8360635 [details] [diff] [review]
[AccessFu] Introduce SettingCache in Utils.jsm

Review of attachment 8360635 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, r=me with some followup regarding the inline comment.

::: accessible/src/jsat/Utils.jsm
@@ +793,5 @@
> +
> +  req.addEventListener('success', () => {
> +    this.value = req.result[aName];
> +    if (this.callback && aRunCallbackNow) {
> +      this.callback(aName, this.value, this);

Nit: slightly uncomfortable about passing this in callback. I think we are only using it to delete callback in bug 960267. Perhaps we can have a constructor arg |aOnce| that is a flag that indicates that the callback needs to be applied only once (or we can aggregate things like aDefault and aOnce into an options arg to the constructor)?
Attachment #8360635 - Flags: review?(yzenevich) → review+
I did as you suggested. Carry over the r+?
Attachment #8360635 - Attachment is obsolete: true
Attachment #8363972 - Flags: review?(yzenevich)
Comment on attachment 8363972 [details] [diff] [review]
[AccessFu] Introduce SettingCache in Utils.jsm

Review of attachment 8363972 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with just one more change. Looks awesome!

::: accessible/src/jsat/Utils.jsm
@@ +780,5 @@
> +  let callback = aCallback;
> +
> +  let settings = Utils.win.navigator.mozSettings;
> +  if (!settings) {
> +    if (callback && aOptions.callbackNow) {

This block

if (callback) {
  callback(aName, this.value);
  if (aOptions.callbackOnce) {
    callback = null;
  }
}

is also used in addEventListener call and when adding an observer. If we define a function for that, we can just check for aOptions.callbackNow here and in addEventListener.
Attachment #8363972 - Flags: review?(yzenevich) → review+
Did it!
Attachment #8363972 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/fb3597db9e48
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla29
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: