gecko-dev/modules/libpref
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
..
init Bug 1374574 - Remove the FlyWeb service and DOM interfaces. r=bz,djvj 2017-11-22 15:00:10 +01:00
test Merge inbound to central r=merge a=merge 2017-11-24 12:00:30 +02:00
greprefs.js Bug 1352497 - Remove about:healthreport. r=gfritzsche,nechen 2017-11-28 11:38:15 +01:00
moz.build Bug 1407112 (part 4) - Merge prefapi.{cpp,h} and prefapi_private_data.h into Preferences.cpp. r=glandium. 2017-10-11 21:02:03 +11:00
nsIPrefBranch.idl Bug 1414096 (attempt 2) - Remove support for nsISupportsString values in nsPrefBranch::{get,set}ComplexValue(). r=florian. 2017-11-10 09:07:48 +11:00
nsIPrefLocalizedString.idl Bug 1409635 (part 2) - Fix up nsIPrefLocalizedString. r=froydnj. 2017-10-18 16:51:56 +11:00
nsIPrefService.idl Bug 1413413 (part 2) - Remove support for extensions having their own prefs file. r=glandium,kmag. 2017-10-31 16:34:57 +11:00
nsIRelativeFilePref.idl
Preferences.cpp Bug 1394578 - Rewrite Preferences::SetPreference(). r=glandium 2017-11-23 18:03:02 +11:00
Preferences.h Bug 1394578 - Rewrite Preferences::SetPreference(). r=glandium 2017-11-23 18:03:02 +11:00