Closed Bug 941124 Opened 11 years ago Closed 9 years ago

Recombine all prefs into one file, and implement pref namespaces for all but a whitelist of prefs

Categories

(Core :: Preferences: Backend, defect)

x86_64
Windows 8.1
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: bbondy, Unassigned)

References

Details

(Whiteboard: [feature] p=5)

Attachments

(1 file)

We currently have toolkit/modules/WindowsPrefSync.jsm to do syncing of certain prefs in the front end.  This works nicely for a small number of preferences.

It works by pushing the whitelist of prefs to registry as they change, and pulling them in at startup.

However it becomes a problem when we want to sync a LOT of prefs like services.sync.*

This bug is to have the pref service handle a white list of prefs that should be loaded in by both Dektop and Metro.  And changes to those prefs would go in this new file.

p=3
Whiteboard: [release28]
The alternative would be to share ALL prefs, and bake in "if-metro checks", but that would probably open up a can of worms and affect a lot of code with ugly ifdef and metro checks.
Summary: Have a third prefs file which is loaded/saved for shared prefs between Desktop and Metro → Change - Have a third prefs file which is loaded/saved for shared prefs between Desktop and Metro
Whiteboard: [release28] → [release28] feature=change c=tbd u=tbd p=0
I expect that having a single prefs file with separate definitions of pref/desktop_pref/metro_pref might be easier to code and maintain that keeping three separate pref files.

But also, ugh. Prefservice sucks, this is going to be a pain.
I wonder if it may make sense to have it all in one prefs file and introduce the idea of a pref namespace. Which is basically just a prefix of "metro." in metro and nothing on Desktop. And have the ability to bypass the namespace.

It would work transparently to users knowing there is a pref namespace. 
Desktop could access the metro prefs by prefixing metro.

Thoughts?
Flags: needinfo?(benjamin)
Maybe that's what you were getting at in Comment 2, in any case just wanted to clarify.
That's also a possibility. You'd have to have a whitelist of "prefs that bypass the default namespace" or else modify every caller, and I expect modifying callers would be error-prone.

Of course, this whole thing feels a little error-prone.
Flags: needinfo?(benjamin)
k that sounds like the lesser of all evils. I'll do that but in a as-clean-as-possible way..
Summary: Change - Have a third prefs file which is loaded/saved for shared prefs between Desktop and Metro → Change - Recombine all prefs into one file, and implement pref namespaces for all but a whitelist of prefs
p=3 to be added later today.
Blocks: metrov1it20
No longer blocks: metrov1backlog
Status: NEW → ASSIGNED
Priority: -- → P2
QA Contact: jbecerra
Whiteboard: [release28] feature=change c=tbd u=tbd p=0 → [block28] feature=change c=tbd u=tbd p=0
Whiteboard: [block28] feature=change c=tbd u=tbd p=0 → [block28] feature=change c=tbd u=tbd p=3
Whiteboard: [block28] feature=change c=tbd u=tbd p=3 → [release28] feature=change c=tbd u=tbd p=3
Moving this out of it20 since I took some other higher priority bugs instead.
I'll take this in it21.
No longer blocks: metrov1it20
Whiteboard: [release28] feature=change c=tbd u=tbd p=3 → [beta28] feature=change c=tbd u=tbd p=3
Putting to p=5 because I think this is going to be a bit of a pain
Whiteboard: [beta28] feature=change c=tbd u=tbd p=3 → [beta28] feature=change c=tbd u=tbd p=5
Blocks: metrov1it21
No longer blocks: metrov1backlog
Blocks: metrov1it22
No longer blocks: metrov1it21
Summary: Change - Recombine all prefs into one file, and implement pref namespaces for all but a whitelist of prefs → Recombine all prefs into one file, and implement pref namespaces for all but a whitelist of prefs
Whiteboard: [beta28] feature=change c=tbd u=tbd p=5 → [beta28] [feature] p=5
Blocks: metrov1backlog
No longer blocks: metrov1it22
Before I spend more time perfecting the rest of this work, I just wanted to make sure the current implementation is OK or not.

Implementation details:
Prefs that are only used by metro have a prefix of: _metro_. 
Prefs that are only used by desktop have no prefix of _metro_. (***)
All of the prefs, _metro_ or not, are read in from both front ends so they are preserved on close.

It is expected that only _metro_ prefs change from a run of the Metro front end, and that only pref without _metro_ prefix is changed from the Desktop front end. (***).   Recall only 1 front end runs at a time.

The pref module maintains a user front end pref value and a metro pref value for each pref.  (See IPDL change)

If both exist (the PREF_HAS_DUAL flag is set on the hash table item), then when they are written to disk 2 entries are written. One with the _metro_ prefix (for metro) and one without.

If you're using the metro front end, your prefs don't show up as _metro_ prefix. They are seen without it
If you're using the desktop front end, currently I don't even show the _metro_ prefix ones.

Definition: (***)
If a pref appears in a whitelist (an array of null terminated strings representing a pref branch), then it is used and written by metro.
No _metro_ prefix appears for the pref in those cases.
Basically this whitelist is only going to have services.sync.* for now.
It allows the sharing of the marked pref branch between desktop and metro.

Note:
- Patch isn't pefectly cleaned up yet
- Some edge cases and bugs probably still need to be tested/fixed 
- This feedback? is mainly for a 1) YES you're going in the right direction, or a 2) NO way in hell that I will ever r+ anything like this :)



Note2:
- I originally had implemented a metro_uer_pref function w/ parsing in the BNF state machine, but then realized that I can't do that because someone could have an old version installed that they share the same profile with. And that wouldn't understand those prefs and therefore not preserve them.
Attachment #8361797 - Flags: feedback?(benjamin)
Blocks: metrov1it23
No longer blocks: metrov1backlog
At first glance, it seems like a lot more implementation than necessary. Is there a reason we need to dig all the way into PrefHashEntry and store two values per pref?

I would have expected this to be entirely done as a translation layer for pref names, so e.g.:

* GetPref("something") would actually call pref_getPrefEntry("something") on desktop but would call GetPref("metro.something") in metro
* GetPref("services.sync.something") would use "services.sync.something" on all builds
 
I believe that this can be done entirely in the prefbranch code and doesn't need to touch the core hashtable/etc.

In this model, desktop builds would still have access to the metro prefs just by asking for the "metro.*" pref name. But the metro frontend wouldn't automatically have access to the desktop prefs. We could add access with some special "getDesktopPrefBranch" API if we cared, but I don't think we do.
Summarizing an IRC chat w/ bsmedberg and I: 

We do want the default prefs to be found on lookups, just not the user prefs

In the model you're suggesting I think that we would try to do a lookup and see no match, unless we double added the defaults with a _metro_ prefix

I think that was my main motivation for storing the metro+user prefs alongside the hash entry for the desktop default pref
Blocks: metrov1backlog
No longer blocks: metrov1it23
Whiteboard: [beta28] [feature] p=5 → release28] [feature] p=5
Whiteboard: release28] [feature] p=5 → [release28] [feature] p=5
That increases the complexity factor significantly :-(

I still think that it might be better to do this without changing the pref entry struct and instead doing two lookups in the case where the user pref is not available. That way you can localize the changes to just a couple functions:

* pref_HashTableLookup for gets: gets the "metro.*" prefbranch if present, or the plain prefbranch if not. You might need a little extra logic in PREF_ClearUserPref
* pref_HashPref for sets

Then the client code and IPC code can be blissfully unaware that there is this machinery going on behind the scenes.
Attachment #8361797 - Flags: feedback?(benjamin) → feedback-
Hey jimm and mbrubeck, I was just wondering if you thought this was needed or not in the short term? I'd prefer to unassign myself to work on the sandbox stuff, but if you think it's needed I'll spend more resources on it  with bsmedberg's suggestion.
Flags: needinfo?(mbrubeck)
Flags: needinfo?(jmathies)
(In reply to Brian R. Bondy [:bbondy] from comment #14)
> Hey jimm and mbrubeck, I was just wondering if you thought this was needed
> or not in the short term? I'd prefer to unassign myself to work on the
> sandbox stuff, but if you think it's needed I'll spend more resources on it 
> with bsmedberg's suggestion.

I guess it depends where fxaccounts falls in our priority list. Doesn't look like that work is targeted for fx30.
Flags: needinfo?(jmathies)
I agree.  WindowsPrefSync.jsm is still fine in the near term.
Flags: needinfo?(mbrubeck)
OK thanks, if this becomes a priority again shorter term let me know.
It's clear to me what to do based on Comment 13.
Assignee: netzen → nobody
Blocks: metrobacklog
No longer blocks: metrov1backlog
Status: ASSIGNED → NEW
Priority: P2 → --
Whiteboard: [release28] [feature] p=5 → [feature] p=5
Once this gets implemented we need to check to make sure the last blocklist ping related user prefs are getting stored for each browser.
Windows 10 doesn't have the new browser model so there's no need for this at this time.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: