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