Bug 1394580 - 3. Lazy-load AndroidLog.jsm; r=droeh
Lazily load AndroidLog.jsm since we only need it for debug logging, and
logging is normally turned off in GeckoView code.
MozReview-Commit-ID: 5HNzYTwujMS
--- a/mobile/android/chrome/geckoview/GeckoViewContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewContent.js
@@ -1,18 +1,21 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/GeckoViewContentModule.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-var dump = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog.d.bind(null, "ViewContent");
+XPCOMUtils.defineLazyGetter(this, "dump", () =>
+ Cu.import("resource://gre/modules/AndroidLog.jsm",
+ {}).AndroidLog.d.bind(null, "ViewContent"));
function debug(aMsg) {
// dump(aMsg);
}
class GeckoViewContent extends GeckoViewContentModule {
register() {
debug("register");
--- a/mobile/android/chrome/geckoview/GeckoViewScrollContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewScrollContent.js
@@ -1,19 +1,21 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/GeckoViewContentModule.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-var dump = Cu.import("resource://gre/modules/AndroidLog.jsm", {})
- .AndroidLog.d.bind(null, "ViewScrollContent");
+XPCOMUtils.defineLazyGetter(this, "dump", () =>
+ Cu.import("resource://gre/modules/AndroidLog.jsm",
+ {}).AndroidLog.d.bind(null, "ViewScrollContent"));
function debug(aMsg) {
// dump(aMsg);
}
class GeckoViewScrollContent extends GeckoViewContentModule {
register() {
debug("register");
--- a/mobile/android/chrome/geckoview/geckoview.js
+++ b/mobile/android/chrome/geckoview/geckoview.js
@@ -9,18 +9,19 @@ const { classes: Cc, interfaces: Ci, uti
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "EventDispatcher",
"resource://gre/modules/Messaging.jsm");
XPCOMUtils.defineLazyGetter(this, "WindowEventDispatcher",
() => EventDispatcher.for(window));
-var dump = Cu.import("resource://gre/modules/AndroidLog.jsm", {})
- .AndroidLog.d.bind(null, "View");
+XPCOMUtils.defineLazyGetter(this, "dump", () =>
+ Cu.import("resource://gre/modules/AndroidLog.jsm",
+ {}).AndroidLog.d.bind(null, "View"));
// Creates and manages GeckoView modules.
// A module must extend GeckoViewModule.
// Instantiate a module by calling
// add(<resource path>, <type name>)
// and remove by calling
// remove(<type name>)
var ModuleManager = {
--- a/mobile/android/modules/geckoview/GeckoViewContent.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewContent.jsm
@@ -4,19 +4,21 @@
"use strict";
this.EXPORTED_SYMBOLS = ["GeckoViewContent"];
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/GeckoViewModule.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-var dump = Cu.import("resource://gre/modules/AndroidLog.jsm", {})
- .AndroidLog.d.bind(null, "ViewContent");
+XPCOMUtils.defineLazyGetter(this, "dump", () =>
+ Cu.import("resource://gre/modules/AndroidLog.jsm",
+ {}).AndroidLog.d.bind(null, "ViewContent"));
function debug(aMsg) {
// dump(aMsg);
}
class GeckoViewContent extends GeckoViewModule {
init() {
this.frameScriptLoaded = false;
--- a/mobile/android/modules/geckoview/GeckoViewContentModule.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewContentModule.jsm
@@ -8,18 +8,19 @@ this.EXPORTED_SYMBOLS = ["GeckoViewConte
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "EventDispatcher",
"resource://gre/modules/Messaging.jsm");
-var dump = Cu.import("resource://gre/modules/AndroidLog.jsm", {})
- .AndroidLog.d.bind(null, "ViewContentModule");
+XPCOMUtils.defineLazyGetter(this, "dump", () =>
+ Cu.import("resource://gre/modules/AndroidLog.jsm",
+ {}).AndroidLog.d.bind(null, "ViewContentModule"));
function debug(aMsg) {
// dump(aMsg);
}
class GeckoViewContentModule {
constructor(aModuleName, aMessageManager) {
this.moduleName = aModuleName;
--- a/mobile/android/modules/geckoview/GeckoViewModule.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewModule.jsm
@@ -3,18 +3,21 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
this.EXPORTED_SYMBOLS = ["GeckoViewModule"];
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-var dump = Cu.import("resource://gre/modules/AndroidLog.jsm", {})
- .AndroidLog.d.bind(null, "ViewModule");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyGetter(this, "dump", () =>
+ Cu.import("resource://gre/modules/AndroidLog.jsm",
+ {}).AndroidLog.d.bind(null, "ViewModule"));
function debug(aMsg) {
// dump(aMsg);
}
class GeckoViewModule {
constructor(aModuleName, aWindow, aBrowser, aEventDispatcher) {
this.window = aWindow;
--- a/mobile/android/modules/geckoview/GeckoViewNavigation.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewNavigation.jsm
@@ -11,18 +11,19 @@ const { classes: Cc, interfaces: Ci, uti
Cu.import("resource://gre/modules/GeckoViewModule.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "EventDispatcher",
"resource://gre/modules/Messaging.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
-var dump = Cu.import("resource://gre/modules/AndroidLog.jsm", {})
- .AndroidLog.d.bind(null, "ViewNavigation");
+XPCOMUtils.defineLazyGetter(this, "dump", () =>
+ Cu.import("resource://gre/modules/AndroidLog.jsm",
+ {}).AndroidLog.d.bind(null, "ViewNavigation"));
function debug(aMsg) {
// dump(aMsg);
}
// Handles navigation requests between Gecko and a GeckoView.
// Implements GeckoView.loadUri via openURI.
// Handles GeckoView:GoBack and :GoForward requests dispatched by
--- a/mobile/android/modules/geckoview/GeckoViewProgress.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewProgress.jsm
@@ -10,18 +10,19 @@ const { classes: Cc, interfaces: Ci, uti
Cu.import("resource://gre/modules/GeckoViewModule.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "EventDispatcher",
"resource://gre/modules/Messaging.jsm");
-var dump = Cu.import("resource://gre/modules/AndroidLog.jsm", {})
- .AndroidLog.d.bind(null, "ViewProgress");
+XPCOMUtils.defineLazyGetter(this, "dump", () =>
+ Cu.import("resource://gre/modules/AndroidLog.jsm",
+ {}).AndroidLog.d.bind(null, "ViewProgress"));
function debug(aMsg) {
// dump(aMsg);
}
var IdentityHandler = {
// No trusted identity information. No site identity icon is shown.
IDENTITY_MODE_UNKNOWN: "unknown",
--- a/mobile/android/modules/geckoview/GeckoViewScroll.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewScroll.jsm
@@ -4,19 +4,21 @@
"use strict";
this.EXPORTED_SYMBOLS = ["GeckoViewScroll"];
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/GeckoViewModule.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-var dump = Cu.import("resource://gre/modules/AndroidLog.jsm", {})
- .AndroidLog.d.bind(null, "ViewScroll");
+XPCOMUtils.defineLazyGetter(this, "dump", () =>
+ Cu.import("resource://gre/modules/AndroidLog.jsm",
+ {}).AndroidLog.d.bind(null, "ViewScroll"));
function debug(aMsg) {
// dump(aMsg);
}
class GeckoViewScroll extends GeckoViewModule {
init() {
debug("init");
--- a/mobile/android/modules/geckoview/GeckoViewSettings.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewSettings.jsm
@@ -9,18 +9,19 @@ this.EXPORTED_SYMBOLS = ["GeckoViewSetti
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/GeckoViewModule.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SafeBrowsing",
"resource://gre/modules/SafeBrowsing.jsm");
-var dump = Cu.import("resource://gre/modules/AndroidLog.jsm", {})
- .AndroidLog.d.bind(null, "ViewSettings");
+XPCOMUtils.defineLazyGetter(this, "dump", () =>
+ Cu.import("resource://gre/modules/AndroidLog.jsm",
+ {}).AndroidLog.d.bind(null, "ViewSettings"));
function debug(aMsg) {
// dump(aMsg);
}
// Handles GeckoView settings including:
// * tracking protection
// * multiprocess