Bug 1394580 - 7. Follow-up to unpack fields in function signature; r=me

Unpack fields from the parameter object in the function signature
itself. r=me for trivial patch.

MozReview-Commit-ID: BeMPOlLgNcQ
This commit is contained in:
Jim Chen 2017-09-06 14:26:18 -04:00
Родитель 6ab1a5a3fc
Коммит 68c0a8b2fb
1 изменённых файлов: 7 добавлений и 8 удалений

Просмотреть файл

@ -17,16 +17,16 @@ GeckoViewStartup.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
addLazyGetter: function(aOptions) { addLazyGetter: function({name, script, service, module,
let {name, script, service, module, observers, ppmm, mm} = aOptions; observers, ppmm, mm, init, once}) {
if (script) { if (script) {
XPCOMUtils.defineLazyScriptGetter(this, name, script); XPCOMUtils.defineLazyScriptGetter(this, name, script);
} else if (module) { } else if (module) {
XPCOMUtils.defineLazyGetter(this, name, _ => { XPCOMUtils.defineLazyGetter(this, name, _ => {
let sandbox = {}; let sandbox = {};
Cu.import(module, sandbox); Cu.import(module, sandbox);
if (aOptions.init) { if (init) {
aOptions.init.call(this, sandbox[name]); init.call(this, sandbox[name]);
} }
return sandbox[name]; return sandbox[name];
}); });
@ -38,7 +38,7 @@ GeckoViewStartup.prototype = {
if (observers) { if (observers) {
let observer = (subject, topic, data) => { let observer = (subject, topic, data) => {
Services.obs.removeObserver(observer, topic); Services.obs.removeObserver(observer, topic);
if (!aOptions.once) { if (!once) {
Services.obs.addObserver(this[name], topic); Services.obs.addObserver(this[name], topic);
} }
this[name].observe(subject, topic, data); // Explicitly notify new observer this[name].observe(subject, topic, data); // Explicitly notify new observer
@ -50,7 +50,7 @@ GeckoViewStartup.prototype = {
let target = ppmm ? Services.ppmm : Services.mm; let target = ppmm ? Services.ppmm : Services.mm;
let listener = msg => { let listener = msg => {
target.removeMessageListener(msg.name, listener); target.removeMessageListener(msg.name, listener);
if (!aOptions.once) { if (!once) {
target.addMessageListener(msg.name, this[name]); target.addMessageListener(msg.name, this[name]);
} }
this[name].receiveMessage(msg); this[name].receiveMessage(msg);
@ -59,8 +59,7 @@ GeckoViewStartup.prototype = {
} }
}, },
addLazyEventListener: function(aOptions) { addLazyEventListener: function({name, target, events, options}) {
let {name, target, events, options} = aOptions;
let listener = event => { let listener = event => {
if (!options || !options.once) { if (!options || !options.once) {
target.removeEventListener(event.type, listener, options); target.removeEventListener(event.type, listener, options);