Bug 1401528 - replace __defineGetter__ on top-level objects in chat. r=florian
authoraceman <acelists@atlas.sk>
Sun, 26 Nov 2017 12:35:00 +0100
changeset 22780 1f76939382a1b6ec8a347379091c2ec5574cb261
parent 22779 5fa68c3f123f29c824d100ef4c856765b6f11c55
child 22781 c387f1f2e93e85eafa3e1536ceee229111b9ca69
push id13798
push usermozilla@jorgk.com
push dateWed, 29 Nov 2017 07:57:59 +0000
treeherdercomm-central@1f76939382a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1401528
Bug 1401528 - replace __defineGetter__ on top-level objects in chat. r=florian
chat/components/src/imContacts.js
chat/modules/imSmileys.jsm
chat/protocols/xmpp/xmpp-session.jsm
--- a/chat/components/src/imContacts.js
+++ b/chat/components/src/imContacts.js
@@ -91,37 +91,42 @@ function getDBConnection()
 
   return conn;
 }
 
 // Wrap all the usage of DBConn inside a transaction that will be
 // commited automatically at the end of the event loop spin so that
 // we flush buddy list data to disk only once per event loop spin.
 var gDBConnWithPendingTransaction = null;
-this.__defineGetter__("DBConn", function() {
-  if (gDBConnWithPendingTransaction)
-    return gDBConnWithPendingTransaction;
+Object.defineProperty(this, "DBConn", {
+  configurable: true,
+  enumerable: true,
+
+  get() {
+    if (gDBConnWithPendingTransaction)
+      return gDBConnWithPendingTransaction;
 
-  if (!gDBConnection) {
-    gDBConnection = getDBConnection();
-    Services.obs.addObserver(function dbClose(aSubject, aTopic, aData) {
-      Services.obs.removeObserver(dbClose, aTopic);
-      if (gDBConnection) {
-        gDBConnection.asyncClose();
-        gDBConnection = null;
-      }
-    }, "profile-before-change");
+    if (!gDBConnection) {
+      gDBConnection = getDBConnection();
+      Services.obs.addObserver(function dbClose(aSubject, aTopic, aData) {
+        Services.obs.removeObserver(dbClose, aTopic);
+        if (gDBConnection) {
+          gDBConnection.asyncClose();
+          gDBConnection = null;
+        }
+      }, "profile-before-change");
+    }
+    gDBConnWithPendingTransaction = gDBConnection;
+    gDBConnection.beginTransaction();
+    executeSoon(function() {
+      gDBConnWithPendingTransaction.commitTransaction();
+      gDBConnWithPendingTransaction = null;
+    });
+    return gDBConnection;
   }
-  gDBConnWithPendingTransaction = gDBConnection;
-  gDBConnection.beginTransaction();
-  executeSoon(function() {
-    gDBConnWithPendingTransaction.commitTransaction();
-    gDBConnWithPendingTransaction = null;
-  });
-  return gDBConnection;
 });
 
 function TagsService() { }
 TagsService.prototype = {
   get wrappedJSObject() { return this; },
   get defaultTag() { return this.createTag(_("defaultGroup")); },
   createTag: function(aName) {
     // If the tag already exists, we don't want to create a duplicate.
--- a/chat/modules/imSmileys.jsm
+++ b/chat/modules/imSmileys.jsm
@@ -18,20 +18,25 @@ this.EXPORTED_SYMBOLS = [
   "smileString", // used to add smile:// img tags into a string without parsing it as HTML. Be sure the string doesn't contain HTML tags.
   "getSmileRealURI", // used to retrive the chrome URI for a smile:// URI
   "getSmileyList" // used to display a list of smileys in the UI
 ];
 
 var kEmoticonsThemePref = "messenger.options.emoticonsTheme";
 var kThemeFile = "theme.js";
 
-this.__defineGetter__("gTheme", function() {
-  delete this.gTheme;
-  gPrefObserver.init();
-  return this.gTheme = getTheme();
+Object.defineProperty(this, "gTheme", {
+  configurable: true,
+  enumerable: true,
+
+  get() {
+    delete this.gTheme;
+    gPrefObserver.init();
+    return this.gTheme = getTheme();
+  }
 });
 
 var gPrefObserver = {
   init: function po_init() {
     Services.prefs.addObserver(kEmoticonsThemePref, gPrefObserver);
   },
 
   observe: function so_observe(aObject, aTopic, aMsg) {
--- a/chat/protocols/xmpp/xmpp-session.jsm
+++ b/chat/protocols/xmpp/xmpp-session.jsm
@@ -16,17 +16,23 @@ Cu.import("resource:///modules/xmpp-auth
 XPCOMUtils.defineLazyGetter(this, "_", () =>
   l10nHelper("chrome://chat/locale/xmpp.properties")
 );
 
 // Workaround because a lazy getter can't be exported.
 XPCOMUtils.defineLazyGetter(this, "_defaultResource", () =>
   l10nHelper("chrome://branding/locale/brand.properties")("brandShortName")
 );
-this.__defineGetter__("XMPPDefaultResource", () => _defaultResource);
+Object.defineProperty(this, "XMPPDefaultResource", {
+  configurable: true,
+  enumerable: true,
+  get() {
+    return _defaultResource;
+  }
+});
 
 function XMPPSession(aHost, aPort, aSecurity, aJID, aPassword, aAccount) {
   this._host = aHost;
   this._port = aPort;
 
   this._connectionSecurity = aSecurity;
   if (this._connectionSecurity == "old_ssl")
     this._security = ["ssl"];