Bug 1416613 - Improve comments about pref IPC. r=glandium

These would have saved me some time last week when I was figuring out how this
stuff works.

MozReview-Commit-ID: DUhxGDht6xT
This commit is contained in:
Nicholas Nethercote 2017-11-13 09:19:43 +11:00
parent 03a781381b
commit 994d5726c4
2 changed files with 12 additions and 5 deletions

View File

@ -1296,7 +1296,11 @@ ContentParent::Init()
obs->AddObserver(this, sObserverTopics[i], false);
}
}
// Register ContentParent as an observer for changes to any pref whose prefix
// matches the empty string, i.e. all of them.
Preferences::AddStrongObserver(this, "");
if (obs) {
nsAutoString cpId;
cpId.AppendInt(static_cast<uint64_t>(this->ChildID()));
@ -2773,14 +2777,14 @@ ContentParent::Observe(nsISupports* aSubject,
NS_LITERAL_STRING("-no-forward"))) {
Unused << SendFlushMemory(nsDependentString(aData));
}
// listening for remotePrefs...
else if (!strcmp(aTopic, "nsPref:changed")) {
// Some prefs are not useful in the content process.
// A pref changed. If it's not on the blacklist, inform child processes.
#define BLACKLIST_ENTRY(s) { s, (sizeof(s)/sizeof(char16_t)) - 1 }
struct BlacklistEntry {
const char16_t* mPrefBranch;
size_t mLen;
};
// These prefs are not useful in child processes.
static const BlacklistEntry sContentPrefBranchBlacklist[] = {
BLACKLIST_ENTRY(u"app.update.lastUpdateTime."),
BLACKLIST_ENTRY(u"datareporting.policy."),

View File

@ -289,13 +289,16 @@ public:
const char* aPref,
float aDefault = 0.0f);
// Used to synchronise preferences between chrome and content processes.
// When a content process is created these methods are used to pass prefs in
// bulk from the parent process.
static void GetPreferences(InfallibleTArray<PrefSetting>* aPrefs);
static void SetInitPreferences(nsTArray<PrefSetting>* aPrefs);
// When a pref is changed in the parent process, these methods are used to
// pass the update to content processes.
static void GetPreference(PrefSetting* aPref);
static void SetPreference(const PrefSetting& aPref);
static void SetInitPreferences(nsTArray<PrefSetting>* aPrefs);
#ifdef DEBUG
static void SetInitPhase(pref_initPhase phase);
static pref_initPhase InitPhase();