Closed
Bug 753862
Opened 11 years ago
Closed 11 years ago
Settings API: electrolysis support
Categories
(Core :: DOM: Device Interfaces, defect)
Tracking
()
RESOLVED
FIXED
mozilla16
People
(Reporter: gwagner, Assigned: ckerschb)
References
Details
Attachments
(2 files, 7 obsolete files)
8.64 KB,
patch
|
Details | Diff | Splinter Review | |
9.08 KB,
patch
|
fabrice
:
review+
|
Details | Diff | Splinter Review |
We need to send setting-changes across processes.
Reporter | ||
Updated•11 years ago
|
Assignee: nobody → mozilla
Updated•11 years ago
|
Blocks: e10s-device-apis
Reporter | ||
Comment 1•11 years ago
|
||
Some basic setups and basic control flow. now working version.
Assignee | ||
Comment 2•11 years ago
|
||
Assignee | ||
Comment 3•11 years ago
|
||
Reporter | ||
Comment 4•11 years ago
|
||
Comment on attachment 628380 [details] [diff] [review] WiP: implementation to send setting changes across processes >+ >+ receiveMessage: function(aMessage) { >+ debug("receiveMessage " + aMessage.name); >+ let msg = aMessage.json; >+ switch (aMessage.name) { >+ case "Settings:Changed": >+ debug("Settings:Changed!"); >+ ppmm.sendAsyncMessage("Settings:Change:Return:OK", {key: msg.key, value: msg.value}); We also have to inform listeners in the parent process. So we need the Services.obs.... >+ break; >+ default: >+ debug("Wrong message: " + aMessage.name); >+ } >+ } >+} >+ >+SettingsChangeNotifier.init(); >diff -r 65fb8b9ea0b7 dom/settings/SettingsManager.js >--- a/dom/settings/SettingsManager.js Wed May 16 12:03:18 2012 -0700 >+++ b/dom/settings/SettingsManager.js Wed May 30 10:32:04 2012 -0700 > > Cu.import("resource://gre/modules/SettingsQueue.jsm"); > Cu.import("resource://gre/modules/SettingsDB.jsm"); > Cu.import("resource://gre/modules/XPCOMUtils.jsm"); > Cu.import("resource://gre/modules/Services.jsm"); > >+XPCOMUtils.defineLazyGetter(Services, "DOMRequest", function() { >+ return Cc["@mozilla.org/dom/dom-request-service;1"].getService(Ci.nsIDOMRequestService); >+}); Is this needed? >@@ -215,21 +226,45 @@ SettingsManager.prototype = { > this._settingsDB.ensureDB( > function() { lock.createTransactionAndProcess(); }, > function() { dump("ensureDB error cb!\n"); }, > myGlobal ); > this.nextTick(function() { this._open = false; }, lock); > return lock; > }, > >+ receiveMessage: function(aMessage) { >+ debug("Settings::receiveMessage: " + aMessage.name); >+ let msg = aMessage.json; >+ let contacts = msg.contacts; ^ remove :) Otherwise looks good. Time to remove the debug code.
Reporter | ||
Comment 5•11 years ago
|
||
Alright we figured out the c++ chrome code notification broadcast. cjones and mrbkap think that's enough to just do observer-service notification in the parent process.
Assignee | ||
Comment 6•11 years ago
|
||
Attachment #628237 -
Attachment is obsolete: true
Attachment #628380 -
Attachment is obsolete: true
Reporter | ||
Comment 7•11 years ago
|
||
Comment on attachment 628591 [details] [diff] [review] updated the patch following advice from the last comment >+ >+Cu.import("resource://gre/modules/XPCOMUtils.jsm"); >+Cu.import("resource://gre/modules/Services.jsm"); >+ >+XPCOMUtils.defineLazyGetter(this, "ppmm", function() { >+ return Cc["@mozilla.org/parentprocessmessagemanager;1"].getService(Ci.nsIFrameMessageManager); >+}); >+ >+let myGlobal = this; ^ remove >@@ -66,16 +70,17 @@ SettingsLock.prototype = { > > req.onsuccess = function() { > lock._open = true; > Services.DOMRequest.fireSuccess(request, 0); > Services.obs.notifyObservers(lock, "mozsettings-changed", JSON.stringify({ > key: key, > value: info.settings[key] > })); >+ cpmm.sendAsyncMessage("Settings:Changed", {key: key, value: info.settings[key]}); > lock._open = false; > }; > > req.onerror = function() { Services.DOMRequest.fireError(request, 0) }; > } > break; > case "get": > if (info.name == "*") { You also need to remove the registered messages for the child. Hopefully the leak goes away with that. And Services.obs.notifyObservers should be removed from the child.
Assignee | ||
Comment 8•11 years ago
|
||
Attachment #628591 -
Attachment is obsolete: true
Assignee | ||
Comment 9•11 years ago
|
||
Attachment #628830 -
Attachment is obsolete: true
Reporter | ||
Comment 10•11 years ago
|
||
Comment on attachment 628834 [details] [diff] [review] uploaded the wrong diff in last comment >+let SettingsChangeNotifier = { >+ init: function() { >+ this._messages = ["Settings:Changed"]; >+ this._messages.forEach((function(msgName) { >+ ppmm.addMessageListener(msgName, this); >+ }).bind(this)); >+ >+ Services.obs.addObserver(this, "profile-before-change", false); >+ }, >+ >+ observe: function(aSubject, aTopic, aData) { >+ myGlobal = null; ^ remove >- let data = JSON.parse(aData); >- debug('data:' + data.key + ':' + data.value + '\n'); >- >- let event = new this._window.MozSettingsEvent("settingchanged", { >- settingName: data.key, >- settingValue: data.value >- }); >- >- this._onsettingchange.handleEvent(event); >- } >+ } ^ whitespace Looks good to me but I shouldn't review this because I submitted the first version.
Assignee | ||
Comment 11•11 years ago
|
||
Attachment #628834 -
Attachment is obsolete: true
Attachment #628881 -
Flags: review?(fabrice)
Reporter | ||
Comment 13•11 years ago
|
||
Comment on attachment 628881 [details] [diff] [review] updated patch following advice from last comment There was some misunderstanding. Christoph deleted too many lines :)
Attachment #628881 -
Flags: review?(fabrice)
Assignee | ||
Comment 14•11 years ago
|
||
Attachment #628881 -
Attachment is obsolete: true
Assignee | ||
Updated•11 years ago
|
Attachment #629216 -
Flags: review?(fabrice)
Comment 15•11 years ago
|
||
Comment on attachment 629216 [details] [diff] [review] put the accidentally deleted lines of code back in the patch Review of attachment 629216 [details] [diff] [review]: ----------------------------------------------------------------- That's almost ready! The remaining issue is setting the message listener in SettingsManager.js (unless I missed the obvious) ::: dom/settings/SettingsChangeNotifier.jsm @@ +8,5 @@ > +let DEBUG = false; > +if (DEBUG) > + debug = function (s) { dump("-*- SettingsManager: " + s + "\n"); }; > +else > + debug = function (s) {}; just do : function debug() { dump(...); } and comment the dump line if needed. Do that also in .js @@ +29,5 @@ > + this._messages = ["Settings:Changed"]; > + this._messages.forEach((function(msgName) { > + ppmm.addMessageListener(msgName, this); > + }).bind(this)); > + If you don't plan to add other messages to listen to, just do |ppm.addMessageListener("Settings:Changed", this)| @@ +30,5 @@ > + this._messages.forEach((function(msgName) { > + ppmm.addMessageListener(msgName, this); > + }).bind(this)); > + > + Services.obs.addObserver(this, "profile-before-change", false); can you comment why you're listening for profile-before-change? Since you use it to cleanup, we usually use xpcom-shutdown. @@ +36,5 @@ > + > + observe: function(aSubject, aTopic, aData) { > + this._messages.forEach((function(msgName) { > + ppmm.removeMessageListener(msgName, this); > + }).bind(this)); idem. @@ +46,5 @@ > + receiveMessage: function(aMessage) { > + let msg = aMessage.json; > + switch (aMessage.name) { > + case "Settings:Changed": > + ppmm.sendAsyncMessage("Settings:Change:Return:OK", {key: msg.key, value: msg.value}); nit: spaces around the json braces. ::: dom/settings/SettingsManager.js @@ +70,5 @@ > > req.onsuccess = function() { > lock._open = true; > Services.DOMRequest.fireSuccess(request, 0); > + cpmm.sendAsyncMessage("Settings:Changed", {key: key, value: info.settings[key]}); Nit: spaces in the json object: { key:... [key] } @@ +232,5 @@ > + debug("Settings::receiveMessage: " + aMessage.name); > + let msg = aMessage.json; > + > + switch (aMessage.name) { > + case "Settings:Change:Return:OK": where are you setting the listener for this message? @@ +280,5 @@ > this._requests = null; > this._window = null; > this._innerWindowID = null; > this._onsettingchange = null; > this._settingsDB.close(); add |cpmm = null;|
Attachment #629216 -
Flags: review?(fabrice) → review-
Assignee | ||
Comment 16•11 years ago
|
||
Attachment #629216 -
Attachment is obsolete: true
Assignee | ||
Updated•11 years ago
|
Attachment #629624 -
Flags: review?(fabrice)
Assignee | ||
Comment 17•11 years ago
|
||
(In reply to Fabrice Desré [:fabrice] from comment #15) > Comment on attachment 629216 [details] [diff] [review] > put the accidentally deleted lines of code back in the patch > > Review of attachment 629216 [details] [diff] [review]: > ----------------------------------------------------------------- > > That's almost ready! The remaining issue is setting the message listener in > SettingsManager.js (unless I missed the obvious) > > ::: dom/settings/SettingsChangeNotifier.jsm > @@ +8,5 @@ > > +let DEBUG = false; > > +if (DEBUG) > > + debug = function (s) { dump("-*- SettingsManager: " + s + "\n"); }; > > +else > > + debug = function (s) {}; > > just do : > function debug() { > dump(...); > } > > and comment the dump line if needed. Do that also in .js > > @@ +29,5 @@ > > + this._messages = ["Settings:Changed"]; > > + this._messages.forEach((function(msgName) { > > + ppmm.addMessageListener(msgName, this); > > + }).bind(this)); > > + > > If you don't plan to add other messages to listen to, just do > |ppm.addMessageListener("Settings:Changed", this)| good point - changed that. > @@ +30,5 @@ > > + this._messages.forEach((function(msgName) { > > + ppmm.addMessageListener(msgName, this); > > + }).bind(this)); > > + > > + Services.obs.addObserver(this, "profile-before-change", false); > > can you comment why you're listening for profile-before-change? Since you > use it to cleanup, we usually use xpcom-shutdown. changed it. > @@ +36,5 @@ > > + > > + observe: function(aSubject, aTopic, aData) { > > + this._messages.forEach((function(msgName) { > > + ppmm.removeMessageListener(msgName, this); > > + }).bind(this)); > > idem. > > @@ +46,5 @@ > > + receiveMessage: function(aMessage) { > > + let msg = aMessage.json; > > + switch (aMessage.name) { > > + case "Settings:Changed": > > + ppmm.sendAsyncMessage("Settings:Change:Return:OK", {key: msg.key, value: msg.value}); > > nit: spaces around the json braces. > > ::: dom/settings/SettingsManager.js > @@ +70,5 @@ > > > > req.onsuccess = function() { > > lock._open = true; > > Services.DOMRequest.fireSuccess(request, 0); > > + cpmm.sendAsyncMessage("Settings:Changed", {key: key, value: info.settings[key]}); > > Nit: spaces in the json object: > { key:... [key] } > > @@ +232,5 @@ > > + debug("Settings::receiveMessage: " + aMessage.name); > > + let msg = aMessage.json; > > + > > + switch (aMessage.name) { > > + case "Settings:Change:Return:OK": > > where are you setting the listener for this message? that was one of the lines I accidentally removed the other day. > > @@ +280,5 @@ > > this._requests = null; > > this._window = null; > > this._innerWindowID = null; > > this._onsettingchange = null; > > this._settingsDB.close(); > > add |cpmm = null;|
Updated•11 years ago
|
Attachment #629624 -
Flags: review?(fabrice) → review+
Reporter | ||
Comment 18•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/a7cbb6716a5b
Reporter | ||
Comment 19•11 years ago
|
||
Oh I forgot. Great work :)
Updated•11 years ago
|
Target Milestone: --- → mozilla16
Comment 20•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/a7cbb6716a5b
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•