Commit Graph

251 Commits

Author SHA1 Message Date
Nicholas Nethercote
5b80c7cb65 Bug 1394578 - Pass pref locked status to content processes. r=glandium
This makes the IPC messages a little bigger, but that's unavoidable.

MozReview-Commit-ID: 1oPz2Yjjd9y

--HG--
extra : rebase_source : 0cff8cf5b25f66b73f6864ce50c1e5f575026ec3
2017-11-29 09:29:07 +11:00
Nicholas Nethercote
e7207b6fd8 Bug 1394578 - Rewrite Preferences::SetPreference(). r=glandium
Preferences::SetPreference() is used when setting prefs in the content process
from dom::Pref values that are passed from the parent process. Currently we
use the high-level Set*InAnyProcess() methods to do this -- basically the same
code path as sets done via the API -- but this has several problems.

- It is subtly broken. If the content process already has a pref of type T with
  a default value and then we get a SetPreference() call that tries to change
  it to type U, it will erroneously fail. In practice this never(?) happens,
  but it shows that things aren't arranged very well.

- SetPreference() also looks up the hashtable twice to get the same pref if
  both a default value and a user value are present in the dom::Pref.

- This happens in content processes, while all other pref set operations occur
  in the parent process. This is the main reason we have the Set*InAnyProcess()
  functions.

In short, the setting of prefs via IPC is quite different to the setting of
prefs via other means -- because it happens in content processes, and it's more
of a clobber that can set both values at once -- and so should be handled
differently.

The solution is to make Preferences::SetPreference() use lower-level operations
to do the update. It now does the hash table lookup/add itself, and then calls
the new Pref::FromDomPref() method. That method then possibly calls the new
PrefValue::FromDomPrefValue() method for both kinds of value, and overwrites
them as necessary. SetValueFromDom() is no longer used and the patch removes it.

MozReview-Commit-ID: 2Rg8VMOc0Cl

--HG--
extra : rebase_source : 0eddc3a4b694a79af3e173aefa7758f8e2ae776b
2017-11-23 18:03:02 +11:00
Nicholas Nethercote
9ce6c0ebf9 Bug 1394578 - Introduce PrefType::None. r=glandium
And remove the type argument from PrefValue's constructor. This is needed
for the next patch.

MozReview-Commit-ID: Ls8hEU2uRQQ

--HG--
extra : rebase_source : 115828e219f6bbe04677ffc106068a662458481a
2017-11-23 16:35:38 +11:00
Nicholas Nethercote
2c1bcd3a21 Bug 1394578 - Move Pref::AssignPrefValueToDomPrefVAlue() to PrefValue::ToDomPrefValue(). r=glandium
It's a bit nicer that way.

MozReview-Commit-ID: HpVaxje7XIP

--HG--
extra : rebase_source : 23a9bf251225992652e33bce84135840c2566d86
2017-11-23 16:35:35 +11:00
Nicholas Nethercote
dcfe881ca1 Bug 1394578 - Move more operations into PrefValue. r=glandium
The nice thing about this is that the memory management of the strings
(moz_xstrdup() and free()) is now entirely within PrefValue.

MozReview-Commit-ID: KJjnURpmgfE

--HG--
extra : rebase_source : 39c058cddf5ebf9e19f9151f40fd507f6909a289
2017-11-23 16:34:42 +11:00
Nicholas Nethercote
5208f7436b Bug 1394578 - Remove the kPref* enum. r=glandium
It's something of an obfuscation, and it forces together various bool values
that don't necessarily have to be together (and won't be together after future
refactorings).

The patch also reorders some function arguments for consistency: PrefType, then
PrefValueKind, then PrefValue.

MozReview-Commit-ID: KNY0Pxo0Nxf

--HG--
extra : rebase_source : d46d228c3b13549b2159757dcdaf9583cca828f7
2017-11-23 13:07:04 +11:00
Nicholas Nethercote
53ec464e06 Bug 1394578 - PrefHashEntry as Pref. r=glandium
Although it is a subclass of PLDHashEntryHdr, it's the main representation of a
pref, so the name should reflect that.

MozReview-Commit-ID: 5qJNQtjbFmH

--HG--
extra : rebase_source : f2bd77a57c4e2a48e24ead736f15856fbeb9f718
2017-11-23 10:52:08 +11:00
Nicholas Nethercote
15bd051c45 Bug 1394578 - Use gHashTable->EntryCount() to size aDomPrefs, not aCapacity(). r=glandium
As is done in pref_SavePrefs().

The confusion here is because a Vector can fill 100% of its capacity, but a
hash table cannot go past 75% of its capacity.

MozReview-Commit-ID: 5JMbmtrxMGN

--HG--
extra : rebase_source : 5ce1ce9dd0259588a0df924c2b45c39497b1ce71
2017-11-22 21:21:19 +11:00
Nicholas Nethercote
a775a9afdb Bug 1394578 - Rename dom::PrefSetting as dom::Pref. r=glandium
It represents a pref, so `Pref` is a better name. Within Preferences.cpp the
patch uses domPref/aDomPref to distinguish it from PrefHashEntry values.

MozReview-Commit-ID: HXTl0GX4BtO

--HG--
extra : rebase_source : c1e0726c55e7577720f669f0ed2dbc38627d853e
2017-11-22 21:21:19 +11:00
Nicholas Nethercote
73b9138844 Bug 1394578 - Add PrefHashEntry::ValueMatches(). r=glandium
This factors out some common code from SetValue(), making it easier to read.
The patch also improves the comments in SetValue().

MozReview-Commit-ID: 60JnBlIS1q6

--HG--
extra : rebase_source : cc0e47eb556ab87549137777625856db12782702
2017-11-22 09:53:23 +11:00
Florian Quèze
c276dded0e Backed out changeset 1603e2488c32 as this patch for bug 1226616 didn't work 2017-11-25 00:01:07 +01:00
Nicholas Nethercote
09d19b6c47 Bug 1419654 - Prevent possible pref default/user value type mismatches. r=glandium
Currently, you can create a pref that only has a user value, and then later
give it a default value with a different type. The entire pref is then recorded
as having this second type. This causes problems later when interpreting the
user value.

This patch makes SetValue() fail if it tries to set a default value whose type
differs from an existing user value. It also expands an existing test to cover
this case and some similar ones.

MozReview-Commit-ID: 89tvISQ7RNT

--HG--
extra : rebase_source : 6cf34da0ff24f5b90a88003445a4a7c88b1f3907
2017-11-21 16:00:23 +11:00
Gabriele Svelto
6250b4ad47 Bug 1402519 - Remove MOZ_CRASHREPORTER directives from modules/libpref; r=njn
MozReview-Commit-ID: 3Jr4Cfe9Bn1

--HG--
extra : rebase_source : 5d151212da86676adf195921423e5826a818891e
2017-09-29 16:27:44 +02:00
Florian Quèze
723d70b38a Bug 1226616 - The presence of the general.config.filename preference should be reported on telemetry. r=njn, data-review=francois 2017-11-23 00:59:38 +01:00
Nicholas Nethercote
dccbe1fff8 Bug 1419648 - Remove and inline PREF_RegisterCallback(). r=glandium
This requires adding an aPriority argument (defaulting to false) to
Preferences::RegisterCallback(). And RegisterVarCacheCallback() is no longer
necessary.

MozReview-Commit-ID: BMDk3HuaQVV

--HG--
extra : rebase_source : 17a61cfd9a82f24854162fc993223691041ea46d
2017-11-21 12:57:53 +11:00
Nicholas Nethercote
1ea97b46f1 Bug 1419648 - Inline and remove PREF_UnregisterCallback(). r=glandium
MozReview-Commit-ID: GLUdbRjxDLR

--HG--
extra : rebase_source : df713f8f242618f8624640bf94bebcc996362b1f
2017-11-21 12:57:53 +11:00
Nicholas Nethercote
b4b208fe70 Bug 1419648 - Remove and inline PREF_{LockPref,UnlockPref,PrefIsLocked}(). r=glandium
MozReview-Commit-ID: 7HatftTQwHr

--HG--
extra : rebase_source : 686cec1ece58dafb2227819db308c17f6d30cacd
2017-11-16 09:05:43 +11:00
Nicholas Nethercote
1bd63d481b Bug 1419648 - Inline and remove PREF_HasUserPref(). r=glandium
MozReview-Commit-ID: Dz2IgjrfEjQ

--HG--
extra : rebase_source : f0cc02751263b1a04f49b06115e407ab96dc8e69
2017-11-15 17:01:15 +11:00
Nicholas Nethercote
439ed6b332 Bug 1419648 - Inline and remove PREF_ClearUserPref(). r=glandium
MozReview-Commit-ID: EBb9hxtIwPz

--HG--
extra : rebase_source : b7944677bf72e7e891551e81775659dd46b59fab
2017-11-15 17:01:15 +11:00
Nicholas Nethercote
d03b40ebee Bug 1419648 - Inline and remove PREF_ClearAllUserPrefs(). r=glandium
MozReview-Commit-ID: Eud92V7qFS4

--HG--
extra : rebase_source : 9075832b2d0077a73e2268190e0a4a75aa89022c
2017-11-15 17:01:14 +11:00
shindli
fb855aa7ba Backed out 16 changesets (bug 1402519) for conflicts during merge r=backout on a CLOSED TREE
Backed out changeset 07fcf163241a (bug 1402519)
Backed out changeset c6d2ad45d8e2 (bug 1402519)
Backed out changeset 8a3caca61294 (bug 1402519)
Backed out changeset 01425eae2c48 (bug 1402519)
Backed out changeset cf298d3815de (bug 1402519)
Backed out changeset e1964f4389cd (bug 1402519)
Backed out changeset f405337f3569 (bug 1402519)
Backed out changeset a76356fd3359 (bug 1402519)
Backed out changeset d3bb350d1c34 (bug 1402519)
Backed out changeset 9d3bfd9f932c (bug 1402519)
Backed out changeset e3dd6e5b073f (bug 1402519)
Backed out changeset e801b0c00134 (bug 1402519)
Backed out changeset 8a4139fa5dca (bug 1402519)
Backed out changeset 8d01c14ac1ca (bug 1402519)
Backed out changeset 24e0dcd01898 (bug 1402519)
Backed out changeset f8fdf450613f (bug 1402519)
2017-11-23 00:11:44 +02:00
Gabriele Svelto
b32bdfa37b Bug 1402519 - Remove MOZ_CRASHREPORTER directives from modules/libpref; r=njn
MozReview-Commit-ID: 3Jr4Cfe9Bn1

--HG--
extra : rebase_source : 9584291478e44f988ace712e9fab0e97489c4693
2017-09-29 16:27:44 +02:00
Nicholas Nethercote
0d3f601004 Bug 1418847 - Move variable declarations within Parser::Parse(). r=glandium
MozReview-Commit-ID: FdgXKBKH4nr

--HG--
extra : rebase_source : 3433eb75f562c4d40aa32a2f617ffcbaebc9a1a7
2017-11-21 12:57:36 +11:00
Nicholas Nethercote
40c44bbf9d Bug 1418847 - Hardcode the value reader and error reporter in Parser. r=glandium
In practice we always use the same functions for these purposes.

MozReview-Commit-ID: 4Be9pRhUeff

--HG--
extra : rebase_source : 3dfafd9479371d3a47ec263a66942ddbfbefdb46
2017-11-19 20:28:53 +11:00
Nicholas Nethercote
eaa4ad1134 Bug 1418847 - Move some constants into class Parser. r=glandium
MozReview-Commit-ID: 1eZiyrUWjFp

--HG--
extra : rebase_source : feea72ef3cae05616d5368bcc0170ec17736422c
2017-11-19 20:10:39 +11:00
Nicholas Nethercote
71c4d64d05 Bug 1418847 - Refactor the Parser's state enum. r=glandium
MozReview-Commit-ID: 7csnknAAEtH

--HG--
extra : rebase_source : 639fb5f148a119af93c99b5fe921bd9629f03520
2017-11-19 20:10:10 +11:00
Nicholas Nethercote
8098ada3c9 Bug 1418847 - Morph struct PrefParserState into class Parser. r=glandium
This patch makes it a proper class, and moves existing functions into it.

MozReview-Commit-ID: 5pbT3ljq44R

--HG--
extra : rebase_source : ac7ba98f9d39b3cd6f71498a5e108cb6757034e0
2017-11-19 20:10:07 +11:00
Nicholas Nethercote
30ee72e5bb Bug 1418846 - Give CallbackNode a constructor and destructor. r=glandium
And use new/delete for them. And make mDomain a unique pointer so it doesn't
need explicit deallocation.

MozReview-Commit-ID: E1jLccXaSwT

--HG--
extra : rebase_source : 5a64135d5471297ab98f8ec4557f66dac8b7eff9
2017-11-19 14:55:40 +11:00
Nicholas Nethercote
6207a59f90 Bug 1418846 - Remove PrefType::Invalid. r=glandium
Maybe<PrefType> is a better way of representing "no type".

MozReview-Commit-ID: Fnha5RxbNg4

--HG--
extra : rebase_source : 8e8322b0443305ab71acd6d98ea2607f626c5bce
2017-11-19 14:42:20 +11:00
Nicholas Nethercote
7e91e21a8a Bug 1418846 - Privatize GetRootLength(). r=glandium
MozReview-Commit-ID: JzZ2ot83YwJ

--HG--
extra : rebase_source : bd782baec39823fb6352110124cf851c184ad201
2017-11-18 20:36:56 +11:00
Nicholas Nethercote
b3a73b9721 Bug 1418846 - Rename ENSURE_MAIN_PROCESS as ENSURE_PARENT_PROCESS. r=glandium
So it matches XRE_IsParentProcess().

MozReview-Commit-ID: E5ARalJhttX

--HG--
extra : rebase_source : 8ff91a9f511c27837a4e6d5e79ce097e55e884d8
2017-11-18 20:32:20 +11:00
Nicholas Nethercote
3e0ae997ab Bug 1418846 - Give PrefHashEntry a destructor. r=glandium
MozReview-Commit-ID: 84IJ25ItUuY

--HG--
extra : rebase_source : 4fcecb3fc1ebdfc5efdda27e8adf6c8dc1776a55
2017-11-18 20:29:03 +11:00
Nicholas Nethercote
d65e40e1b8 Bug 1418846 - Remove PrefHashEntry::mIsSticky's getter and setter. r=glandium
This field isn't accessed outside PrefHashEntry.

MozReview-Commit-ID: IvwQe5UtjjJ

--HG--
extra : rebase_source : 5447d4e24bbf0d0637ee29377cc749b9b77b4e1e
2017-11-18 13:15:46 +11:00
Nicholas Nethercote
1ff309b5fb Bug 1418846 - Remove PrefHasEntry()::SetHas{Default,User}Value(). r=glandium
We can move the setting into ReplaceValue() and ClearValue(), and then those
methods aren't needed any more.

The patch also removes some getter calls within PrefHashEntry by directly using
field names.

MozReview-Commit-ID: 42EAx1Kh9Et

--HG--
extra : rebase_source : 3393a80a9c5d2d7c660171cdda8d3914c35e96ea
2017-11-18 13:13:27 +11:00
Nicholas Nethercote
ce60c37da0 Bug 1418846 - Fix string value leaks in libpref. r=glandium
There's an "XXX" comment suggesting a possible leak when string user values are
cleared. Turns out a lot of the time there won't be a leak, because the string
pointer isn't overwritten and ClearEntry() frees the string when the pref is
destroyed. However, if the user value is subsequently overwritten with a
different string, there will be a leak. Also, even in the non-leak case, we
currently hold onto the string for longer than necessary.

This patch introduces ClearUserValue() -- which frees the string when
appropriate -- and uses it in all the places where values are cleared.

MozReview-Commit-ID: ARuWUNzPTfy

--HG--
extra : rebase_source : 4567e37ba96ba3b4ae9b1972d887eeaed1257cb0
2017-11-18 13:05:02 +11:00
Nicholas Nethercote
34ba26b512 Bug 1418846 - Overhaul pref_DoCallback. r=glandium
Specifically:

- rename it as NotifyCallbacks();

- remove the return value, because it is always NS_OK;

- some minor naming and declaration clean-ups.

MozReview-Commit-ID: GcH81owPLsp

--HG--
extra : rebase_source : 501a85f76bb823cc45dba8e4601584f5218b1a9e
2017-11-18 12:34:25 +11:00
Tim Huang
f4abe5782a Bug 1417741 - Add support of Atmoic<> for Preferences::Add*VarCache(). r=baku,njn
MozReview-Commit-ID: 9aeLvgWdZxy

--HG--
extra : rebase_source : b6130610ad8f80257022cb6e103addfe58b96af2
2017-11-16 11:02:50 +08:00
Nicholas Nethercote
633725db69 Bug 1418467 - Privatize PrefHashEntry::m{Default,User}Value. r=glandium
MozReview-Commit-ID: 9Fzaf4ifF0N

--HG--
extra : rebase_source : 739933d801bfa7dc4580f5d1bd3c81e5d3f07c2e
2017-11-18 07:40:01 +11:00
Nicholas Nethercote
00d85378fb Bug 1418467 - Add PrefHashEntry::SetValue(). r=glandium
It's a horrible method, but the horribleness was pre-existing. I hope to make
it nicer in a follow-up bug.

MozReview-Commit-ID: 3tMTEeBNVax

--HG--
extra : rebase_source : b21d80ed6468b7c22689df64c1ae1bdda49a2a06
2017-11-18 07:38:24 +11:00
Nicholas Nethercote
48a1e0788f Bug 1418467 - Partly move value getting into PrefHashEntry. r=glandium
MozReview-Commit-ID: 4ouh3XFxPZr

--HG--
extra : rebase_source : d71c1db9a979bbd9fc8b1e0ed385e04b7cdb27cb
2017-11-18 07:28:29 +11:00
Nicholas Nethercote
ce0ad5b0c0 Bug 1418467 - Add PrefHashEntry::UserValueToStringForSaving(). r=glandium
This moves part of pref_savePrefs() into PrefHashEntry.

This requires moving StrEscape() higher up to avoid a forward declaration.

Note that clang-format insists on indenting an unrelated comment, I don't know
why.

MozReview-Commit-ID: 7gww3r7t9y4

--HG--
extra : rebase_source : 63f19bb2c556cc806cc6ce43e70ac6c95e6d67bc
2017-11-18 07:27:06 +11:00
Nicholas Nethercote
236478c605 Bug 1418467 - Move pref_ValueChanged() into PrefValue. r=glandium
And invert its sense, renaming as Equals(), because that is easier to think
about.

The patch also reorders some conditions so that
HasDefaultValue()/HasUserValue() is tested before Equals(). This isn't strictly
necessary, but it reads better.

MozReview-Commit-ID: JeGrevDwqKz

--HG--
extra : rebase_source : 575758e11d7e66226fe196f92f2dd355b1444d1d
2017-11-18 07:19:42 +11:00
Nicholas Nethercote
3fe59e0566 Bug 1418156 - Remove unnecessary forward declaration of pref_SetPref(). r=glandium
MozReview-Commit-ID: KQHfpAKEEgt

--HG--
extra : rebase_source : 3c622413c72024889214c8ee5ff994fb6a0ad390
2017-11-17 16:29:18 +11:00
Nicholas Nethercote
9f8d2c21ff Bug 1418156 - Move pref_SetValue() into PrefHashEntry. r=glandium
MozReview-Commit-ID: LE7vQ8Iz5Dg

--HG--
extra : rebase_source : 563e2507cb1f4d74ec2f28f4644b4249605e3c81
2017-11-17 16:27:10 +11:00
Nicholas Nethercote
98e2a16031 Bug 1418156 - Rename PrefHashEntry::mKey as mName, and make it private. r=glandium
This requires adding a constructor, which is used in a placement new.

MozReview-Commit-ID: 3v6843D5DMu

--HG--
extra : rebase_source : 780902ae8e761bdf1141f24bf5594ce910ea32b4
2017-11-17 15:57:08 +11:00
Nicholas Nethercote
20dcc4a828 Bug 1418156 - Move pref_EntryHasAdvisablySizedValues() into PrefHashEntry. r=glandium
MozReview-Commit-ID: 4p0KnaOOi2j

--HG--
extra : rebase_source : 4f1513ca77efa42a44d818e9f3a2b44af0e15199
2017-11-17 15:29:30 +11:00
Nicholas Nethercote
32b0c9bb22 Bug 1418156 - Move pref_GetPrefFromEntry into PrefHashEntry. r=glandium
And rename it as ToSetting(). This requires also moving
AssignPrefValueToDomPrefValue into PrefHashEntry.

MozReview-Commit-ID: 8ntNZJt9rhv

--HG--
extra : rebase_source : 5dd5a2c570b2ceefb506b4051c414b06d27a95f2
2017-11-17 15:29:30 +11:00
Nicholas Nethercote
645fe6b3a0 Bug 1418156 - Overhaul GetPrefValueFromEntry. r=glandium
This patch:

- partially inlines GetPrefValueFromEntry() at its two call sites, to avoid
  repeating the kind check;

- renames it as AssignPrefValueToDomPrefValue().

MozReview-Commit-ID: BUBk3ML6h5O

--HG--
extra : rebase_source : eb12adf4af2ee05356af6b2b4f346aa3425ff438
2017-11-17 15:29:29 +11:00
Nicholas Nethercote
e7c913bc12 Bug 1418156 - Move the PLDHashTable ops into PrefHashEntry. r=glandium
MozReview-Commit-ID: HJfjz2PzW0I

--HG--
extra : rebase_source : 717a3d5121a33ca01da5c0b5298386f4c8345eae
2017-11-17 15:29:29 +11:00
Nicholas Nethercote
cb911105fb Bug 1418156 - Merge PrefTypeFlags into PrefHashEntry. r=glandium
PrefTypeFlags is a class with a lot of smarts (i.e. methods). PrefHashEntry is
a class with little smarts. This is silly, because PrefTypeFlags is essentially
an internal implementation detail of PrefHashEntry.

This patch merges PrefTypeFlags into PrefHashEntry, so that PrefHashEntry has
all the smarts. This means lots of `pref->mPrefFlags.Foo()` calls become
`pref->Foo()`.

The patch also changes the representation of the type and flags within
PrefHashEntry to use bitfields, which avoids the need for a Flags type and is
much simpler than the old approach.

MozReview-Commit-ID: 4Yt9OtBzh9e

--HG--
extra : rebase_source : 18fc01217aeaee7057b3d9a54b18cae45be5538f
2017-11-17 15:29:14 +11:00