Bug 1533679 - Make content process domains to inherit from specialized ContentProcessDomain class. r=ato
authorAlexandre Poirot <poirot.alex@gmail.com>
Sun, 10 Mar 2019 12:51:01 +0000
changeset 521281 f46ddc90587c
parent 521280 1dc639610f3b
child 521282 600543aa900a
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1533679
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533679 - Make content process domains to inherit from specialized ContentProcessDomain class. r=ato Remove content, docShell and chromeEventHandler attribute from base Domain class as these fields only work for domains implemented in the content process and attached to a browsing context/document. For "global" domains like Target or Browser, that are not bound to any document, these properties won't work. Depends on D22687 Differential Revision: https://phabricator.services.mozilla.com/D22688
remote/domains/ContentProcessDomain.jsm
remote/domains/Domain.jsm
remote/domains/content/Log.jsm
remote/domains/content/Page.jsm
remote/jar.mn
copy from remote/domains/Domain.jsm
copy to remote/domains/ContentProcessDomain.jsm
--- a/remote/domains/Domain.jsm
+++ b/remote/domains/ContentProcessDomain.jsm
@@ -1,65 +1,25 @@
 /* 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/. */
 
 "use strict";
 
-var EXPORTED_SYMBOLS = ["Domain"];
-
-class Domain {
-  constructor(session) {
-    this.session = session;
-    this.name = this.constructor.name;
-
-    this.eventListeners_ = new Set();
-  }
-
-  destructor() {}
+var EXPORTED_SYMBOLS = ["ContentProcessDomain"];
 
-  emit(eventName, params = {}) {
-    for (const listener of this.eventListeners_) {
-      try {
-        if (isEventHandler(listener)) {
-          listener.onEvent(eventName, params);
-        } else {
-          listener.call(this, eventName, params);
-        }
-      } catch (e) {
-        Cu.reportError(e);
-      }
-    }
-  }
+const {Domain} = ChromeUtils.import("chrome://remote/content/domains/Domain.jsm");
 
-  addEventListener(listener) {
-    if (typeof listener != "function" && !isEventHandler(listener)) {
-      throw new TypeError();
-    }
-    this.eventListeners_.add(listener);
-  }
-
+class ContentProcessDomain extends Domain {
   // helpers
 
   get content() {
     return this.session.content;
   }
 
   get docShell() {
     return this.session.docShell;
   }
 
   get chromeEventHandler() {
     return this.docShell.chromeEventHandler;
   }
-
-  // static
-
-  static implements(methodName) {
-    return typeof this.prototype[methodName] == "function";
-  }
 }
-
-function isEventHandler(listener) {
-  return listener &&
-      "onEvent" in listener &&
-      typeof listener.onEvent == "function";
-}
--- a/remote/domains/Domain.jsm
+++ b/remote/domains/Domain.jsm
@@ -32,30 +32,16 @@ class Domain {
 
   addEventListener(listener) {
     if (typeof listener != "function" && !isEventHandler(listener)) {
       throw new TypeError();
     }
     this.eventListeners_.add(listener);
   }
 
-  // helpers
-
-  get content() {
-    return this.session.content;
-  }
-
-  get docShell() {
-    return this.session.docShell;
-  }
-
-  get chromeEventHandler() {
-    return this.docShell.chromeEventHandler;
-  }
-
   // static
 
   static implements(methodName) {
     return typeof this.prototype[methodName] == "function";
   }
 }
 
 function isEventHandler(listener) {
--- a/remote/domains/content/Log.jsm
+++ b/remote/domains/content/Log.jsm
@@ -1,20 +1,20 @@
 /* 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/. */
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["Log"];
 
-const {Domain} = ChromeUtils.import("chrome://remote/content/domains/Domain.jsm");
+const {ContentProcessDomain} = ChromeUtils.import("chrome://remote/content/domains/ContentProcessDomain.jsm");
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
-class Log extends Domain {
+class Log extends ContentProcessDomain {
   constructor(session) {
     super(session);
     this.enabled = false;
   }
 
   destructor() {
     this.disable();
   }
--- a/remote/domains/content/Page.jsm
+++ b/remote/domains/content/Page.jsm
@@ -1,21 +1,21 @@
 /* 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/. */
 
 "use strict";
 
 var EXPORTED_SYMBOLS = ["Page"];
 
-const {Domain} = ChromeUtils.import("chrome://remote/content/domains/Domain.jsm");
+const {ContentProcessDomain} = ChromeUtils.import("chrome://remote/content/domains/ContentProcessDomain.jsm");
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {UnsupportedError} = ChromeUtils.import("chrome://remote/content/Error.jsm");
 
-class Page extends Domain {
+class Page extends ContentProcessDomain {
   constructor(session) {
     super(session);
     this.enabled = false;
   }
 
   destructor() {
     this.disable();
   }
--- a/remote/jar.mn
+++ b/remote/jar.mn
@@ -21,16 +21,17 @@ remote.jar:
 
   # targets
   content/targets/Target.jsm (targets/Target.jsm)
   content/targets/Targets.jsm (targets/Targets.jsm)
 
   # domains
   content/domains/Domain.jsm (domains/Domain.jsm)
   content/domains/Domains.jsm (domains/Domains.jsm)
+  content/domains/ContentProcessDomain.jsm (domains/ContentProcessDomain.jsm)
   content/domains/ContentProcessDomains.jsm (domains/ContentProcessDomains.jsm)
   content/domains/ParentProcessDomains.jsm (domains/ParentProcessDomains.jsm)
   content/domains/content/Log.jsm (domains/content/Log.jsm)
   content/domains/content/Page.jsm (domains/content/Page.jsm)
   content/domains/parent/Browser.jsm (domains/parent/Browser.jsm)
 
   # transport layer
   content/server/HTTPD.jsm (../netwerk/test/httpserver/httpd.js)