Bug 1454038 - 1. Share EventDispatcher among frame scripts; r?esawin
In order to be more efficient, use the same EventDispatcher instance
among different frame scripts for the same frame.
MozReview-Commit-ID: 1jZ3zW7NBeC
--- a/mobile/android/modules/geckoview/GeckoViewContentModule.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewContentModule.jsm
@@ -6,34 +6,36 @@
var EXPORTED_SYMBOLS = ["GeckoViewContentModule"];
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/GeckoViewUtils.jsm");
GeckoViewUtils.initLogging("GeckoView.Module.[C]", this);
-ChromeUtils.defineModuleGetter(this, "EventDispatcher",
- "resource://gre/modules/Messaging.jsm");
-
class GeckoViewContentModule {
static initLogging(aModuleName) {
this._moduleName = aModuleName;
const tag = aModuleName.replace("GeckoView", "GeckoView.") + ".[C]";
return GeckoViewUtils.initLogging(tag, {});
}
static create(aGlobal, aModuleName) {
return new this(aModuleName || this._moduleName, aGlobal);
}
- constructor(aModuleName, aMessageManager) {
+ constructor(aModuleName, aGlobal) {
this.moduleName = aModuleName;
- this.messageManager = aMessageManager;
- this.eventDispatcher = EventDispatcher.forMessageManager(aMessageManager);
+ this.messageManager = aGlobal;
+
+ if (!aGlobal._gvEventDispatcher) {
+ aGlobal._gvEventDispatcher =
+ GeckoViewUtils.getDispatcherForWindow(aGlobal.content);
+ }
+ this.eventDispatcher = aGlobal._gvEventDispatcher;
this.messageManager.addMessageListener(
"GeckoView:UpdateSettings",
aMsg => {
this.settings = aMsg.data;
this.onSettingsUpdate();
}
);