Bug 1526981 - [2.4] Simplify JSM module logger initialization and ensure compatibility with ES6. r=geckoview-reviewers,agi

Differential Revision: https://phabricator.services.mozilla.com/D19580

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Eugen Sawin 2019-02-20 16:11:57 +00:00
Родитель 01058ecf82
Коммит 1fc5f0ebdc
27 изменённых файлов: 47 добавлений и 29 удалений

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

@ -7,8 +7,7 @@ const {GeckoViewUtils} = ChromeUtils.import("resource://gre/modules/GeckoViewUti
var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); var {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
/* global debug:false, warn:false */ const {debug, warn} = GeckoViewUtils.initLogging("ErrorPageEventHandler"); // eslint-disable-line no-unused-vars
GeckoViewUtils.initLogging("ErrorPageEventHandler", this);
ChromeUtils.defineModuleGetter(this, "SSLExceptions", ChromeUtils.defineModuleGetter(this, "SSLExceptions",
"resource://gre/modules/SSLExceptions.jsm"); "resource://gre/modules/SSLExceptions.jsm");

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

@ -451,5 +451,5 @@ class GeckoViewContentChild extends GeckoViewChildModule {
} }
} }
let {debug, warn} = GeckoViewContentChild.initLogging("GeckoViewContent"); const {debug, warn} = GeckoViewContentChild.initLogging("GeckoViewContent"); // eslint-disable-line no-unused-vars
let module = GeckoViewContentChild.create(this); const module = GeckoViewContentChild.create(this);

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

@ -428,5 +428,5 @@ class GeckoViewMediaChild extends GeckoViewChildModule {
} }
} }
const {debug, warn} = GeckoViewMediaChild.initLogging("GeckoViewMedia"); const {debug, warn} = GeckoViewMediaChild.initLogging("GeckoViewMedia"); // eslint-disable-line no-unused-vars
const module = GeckoViewMediaChild.create(this); const module = GeckoViewMediaChild.create(this);

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

@ -137,5 +137,5 @@ class GeckoViewNavigationChild extends GeckoViewChildModule {
} }
} }
let {debug, warn} = GeckoViewNavigationChild.initLogging("GeckoViewNavigation"); const {debug, warn} = GeckoViewNavigationChild.initLogging("GeckoViewNavigation"); // eslint-disable-line no-unused-vars
let module = GeckoViewNavigationChild.create(this); const module = GeckoViewNavigationChild.create(this);

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

@ -333,5 +333,5 @@ const ProgressTracker = {
}; };
let {debug, warn} = GeckoViewProgressChild.initLogging("GeckoViewProgress"); const {debug, warn} = GeckoViewProgressChild.initLogging("GeckoViewProgress"); // eslint-disable-line no-unused-vars
let module = GeckoViewProgressChild.create(this); const module = GeckoViewProgressChild.create(this);

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

@ -37,5 +37,5 @@ class GeckoViewScrollChild extends GeckoViewChildModule {
} }
} }
let {debug, warn} = GeckoViewScrollChild.initLogging("GeckoViewScroll"); const {debug, warn} = GeckoViewScrollChild.initLogging("GeckoViewScroll"); // eslint-disable-line no-unused-vars
let module = GeckoViewScrollChild.create(this); const module = GeckoViewScrollChild.create(this);

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

@ -238,6 +238,5 @@ class GeckoViewSelectionActionChild extends GeckoViewChildModule {
} }
} }
let {debug, warn} = const {debug, warn} = GeckoViewSelectionActionChild.initLogging("GeckoViewSelectionAction"); // eslint-disable-line no-unused-vars
GeckoViewSelectionActionChild.initLogging("GeckoViewSelectionAction"); const module = GeckoViewSelectionActionChild.create(this);
let module = GeckoViewSelectionActionChild.create(this);

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

@ -152,5 +152,5 @@ class GeckoViewSettingsChild extends GeckoViewChildModule {
} }
} }
let {debug, warn} = GeckoViewSettingsChild.initLogging("GeckoViewSettings"); const {debug, warn} = GeckoViewSettingsChild.initLogging("GeckoViewSettings"); // eslint-disable-line no-unused-vars
let module = GeckoViewSettingsChild.create(this); const module = GeckoViewSettingsChild.create(this);

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

@ -7,8 +7,7 @@
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {GeckoViewUtils} = ChromeUtils.import("resource://gre/modules/GeckoViewUtils.jsm"); const {GeckoViewUtils} = ChromeUtils.import("resource://gre/modules/GeckoViewUtils.jsm");
/* global debug:false, warn:false */ const {debug, warn} = GeckoViewUtils.initLogging("ExternalAppService"); // eslint-disable-line no-unused-vars
GeckoViewUtils.initLogging("ExternalAppService", this);
ChromeUtils.defineModuleGetter(this, "EventDispatcher", ChromeUtils.defineModuleGetter(this, "EventDispatcher",
"resource://gre/modules/Messaging.jsm"); "resource://gre/modules/Messaging.jsm");

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

@ -15,8 +15,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm", Services: "resource://gre/modules/Services.jsm",
}); });
/* global debug:false, warn:false */ const {debug, warn} = GeckoViewUtils.initLogging("Startup"); // eslint-disable-line no-unused-vars
GeckoViewUtils.initLogging("Startup", this);
function GeckoViewStartup() { function GeckoViewStartup() {
} }

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

@ -18,7 +18,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
ChromeUtils.defineModuleGetter(this, "OS", ChromeUtils.defineModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm"); "resource://gre/modules/osfile.jsm");
GeckoViewUtils.initLogging("ContentCrashHandler", this); const {debug, warn} = GeckoViewUtils.initLogging("ContentCrashHandler"); // eslint-disable-line no-unused-vars
function getDir(name) { function getDir(name) {
let uAppDataPath = Services.dirsvc.get("UAppData", Ci.nsIFile).path; let uAppDataPath = Services.dirsvc.get("UAppData", Ci.nsIFile).path;

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

@ -25,3 +25,5 @@ class GeckoViewAccessibility extends GeckoViewModule {
}, "GeckoView:AccessibilitySettings"); }, "GeckoView:AccessibilitySettings");
} }
} }
const {debug, warn} = GeckoViewAccessibility.initLogging("GeckoViewAccessibility"); // eslint-disable-line no-unused-vars

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

@ -15,7 +15,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
LoginManagerContent: "resource://gre/modules/LoginManagerContent.jsm", LoginManagerContent: "resource://gre/modules/LoginManagerContent.jsm",
}); });
GeckoViewUtils.initLogging("AutoFill", this); const {debug, warn} = GeckoViewUtils.initLogging("AutoFill"); // eslint-disable-line no-unused-vars
class GeckoViewAutoFill { class GeckoViewAutoFill {
constructor(aEventDispatcher) { constructor(aEventDispatcher) {

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

@ -8,13 +8,13 @@ var EXPORTED_SYMBOLS = ["GeckoViewChildModule"];
const {GeckoViewUtils} = ChromeUtils.import("resource://gre/modules/GeckoViewUtils.jsm"); const {GeckoViewUtils} = ChromeUtils.import("resource://gre/modules/GeckoViewUtils.jsm");
GeckoViewUtils.initLogging("Module[C]", this); const {debug, warn} = GeckoViewUtils.initLogging("Module[C]"); // eslint-disable-line no-unused-vars
class GeckoViewChildModule { class GeckoViewChildModule {
static initLogging(aModuleName) { static initLogging(aModuleName) {
this._moduleName = aModuleName; this._moduleName = aModuleName;
const tag = aModuleName.replace("GeckoView", "") + "[C]"; const tag = aModuleName.replace("GeckoView", "") + "[C]";
return GeckoViewUtils.initLogging(tag, {}); return GeckoViewUtils.initLogging(tag);
} }
static create(aGlobal, aModuleName) { static create(aGlobal, aModuleName) {

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

@ -12,7 +12,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm", Services: "resource://gre/modules/Services.jsm",
}); });
GeckoViewUtils.initLogging("Console", this); const {debug, warn} = GeckoViewUtils.initLogging("Console"); // eslint-disable-line no-unused-vars
const LOG_EVENT_TOPIC = "console-api-log-event"; const LOG_EVENT_TOPIC = "console-api-log-event";

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

@ -350,3 +350,5 @@ class GeckoViewContent extends GeckoViewModule {
finder.highlight(true, finder.searchString, linksOnly, !!aData.drawOutline); finder.highlight(true, finder.searchString, linksOnly, !!aData.drawOutline);
} }
} }
const {debug, warn} = GeckoViewContent.initLogging("GeckoViewContent"); // eslint-disable-line no-unused-vars

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

@ -54,3 +54,5 @@ class GeckoViewContentBlocking extends GeckoViewModule {
this.eventDispatcher.sendRequest(message); this.eventDispatcher.sendRequest(message);
} }
} }
const {debug, warn} = GeckoViewContentBlocking.initLogging("GeckoViewContentBlocking"); // eslint-disable-line no-unused-vars

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

@ -31,3 +31,5 @@ class GeckoViewMedia extends GeckoViewModule {
this.messageManager.sendAsyncMessage(aEvent, aData); this.messageManager.sendAsyncMessage(aEvent, aData);
} }
} }
const {debug, warn} = GeckoViewMedia.initLogging("GeckoViewMedia"); // eslint-disable-line no-unused-vars

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

@ -8,9 +8,14 @@ var EXPORTED_SYMBOLS = ["GeckoViewModule"];
const {GeckoViewUtils} = ChromeUtils.import("resource://gre/modules/GeckoViewUtils.jsm"); const {GeckoViewUtils} = ChromeUtils.import("resource://gre/modules/GeckoViewUtils.jsm");
GeckoViewUtils.initLogging("Module", this); const {debug, warn} = GeckoViewUtils.initLogging("Module"); // eslint-disable-line no-unused-vars
class GeckoViewModule { class GeckoViewModule {
static initLogging(aModuleName) {
const tag = aModuleName.replace("GeckoView", "");
return GeckoViewUtils.initLogging(tag);
}
constructor(aModuleInfo) { constructor(aModuleInfo) {
this._info = aModuleInfo; this._info = aModuleInfo;

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

@ -340,3 +340,5 @@ class GeckoViewNavigation extends GeckoViewModule {
this.eventDispatcher.sendRequest(message); this.eventDispatcher.sendRequest(message);
} }
} }
const {debug, warn} = GeckoViewNavigation.initLogging("GeckoViewNavigation"); // eslint-disable-line no-unused-vars

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

@ -259,3 +259,5 @@ class GeckoViewProgress extends GeckoViewModule {
} }
} }
} }
const {debug, warn} = GeckoViewProgress.initLogging("GeckoViewProgress"); // eslint-disable-line no-unused-vars

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

@ -28,7 +28,7 @@ XPCOMUtils.defineLazyGetter(this, "SocketListener", () => {
return SocketListener; return SocketListener;
}); });
GeckoViewUtils.initLogging("RemoteDebugger", this); const {debug, warn} = GeckoViewUtils.initLogging("RemoteDebugger"); // eslint-disable-line no-unused-vars
var GeckoViewRemoteDebugger = { var GeckoViewRemoteDebugger = {
observe(aSubject, aTopic, aData) { observe(aSubject, aTopic, aData) {

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

@ -119,3 +119,5 @@ class GeckoViewSettings extends GeckoViewModule {
this.window.docShell.displayMode = aMode; this.window.docShell.displayMode = aMode;
} }
} }
const {debug, warn} = GeckoViewSettings.initLogging("GeckoViewSettings"); // eslint-disable-line no-unused-vars

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

@ -60,3 +60,5 @@ class GeckoViewTab extends GeckoViewModule {
}; };
} }
} }
const {debug, warn} = GeckoViewTab.initLogging("GeckoViewTab"); // eslint-disable-line no-unused-vars

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

@ -375,6 +375,7 @@ var GeckoViewUtils = {
* @param aScope Scope to add the logging functions to. * @param aScope Scope to add the logging functions to.
*/ */
initLogging: function(aTag, aScope) { initLogging: function(aTag, aScope) {
aScope = aScope || {};
const tag = "GeckoView." + aTag.replace(/^GeckoView\.?/, ""); const tag = "GeckoView." + aTag.replace(/^GeckoView\.?/, "");
// Only provide two levels for simplicity. // Only provide two levels for simplicity.

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

@ -13,7 +13,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
Services: "resource://gre/modules/Services.jsm", Services: "resource://gre/modules/Services.jsm",
}); });
GeckoViewUtils.initLogging("LoadURIDelegate", this); const {debug, warn} = GeckoViewUtils.initLogging("LoadURIDelegate"); // eslint-disable-line no-unused-vars
const LoadURIDelegate = { const LoadURIDelegate = {
// Delegate URI loading to the app. // Delegate URI loading to the app.

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

@ -13,7 +13,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
TelemetryUtils: "resource://gre/modules/TelemetryUtils.jsm", TelemetryUtils: "resource://gre/modules/TelemetryUtils.jsm",
}); });
GeckoViewUtils.initLogging("GeckoView.TelemetryController", this); const {debug, warn} = GeckoViewUtils.initLogging("GeckoView.TelemetryController"); // eslint-disable-line no-unused-vars
var EXPORTED_SYMBOLS = ["GeckoViewTelemetryController"]; var EXPORTED_SYMBOLS = ["GeckoViewTelemetryController"];