Bug 1550131 - Expose an iterator for AboutLoginsParent subscribers. r=jaws
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Tue, 21 May 2019 13:15:44 +0000
changeset 474733 d84f90dcd58473413b5600543c6781aff060118c
parent 474732 c03edb23edaa0f8e8fc5585838dc58e7a96e1cb0
child 474734 9dbb7bb20ca334f6eaf8925a48df005006c745eb
push id36046
push useraiakab@mozilla.com
push dateTue, 21 May 2019 21:45:52 +0000
treeherdermozilla-central@257f2c96cef5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1550131
milestone69.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 1550131 - Expose an iterator for AboutLoginsParent subscribers. r=jaws Differential Revision: https://phabricator.services.mozilla.com/D31698
browser/components/aboutlogins/AboutLoginsParent.jsm
--- a/browser/components/aboutlogins/AboutLoginsParent.jsm
+++ b/browser/components/aboutlogins/AboutLoginsParent.jsm
@@ -136,25 +136,31 @@ var AboutLoginsParent = {
         this.messageSubscribers("AboutLogins:LoginRemoved", login);
       }
       default: {
         break;
       }
     }
   },
 
-  messageSubscribers(name, details) {
+  * _subscriberIterator() {
     let subscribers = ChromeUtils.nondeterministicGetWeakSetKeys(this._subscribers);
     for (let subscriber of subscribers) {
       if (subscriber.remoteType != EXPECTED_ABOUTLOGINS_REMOTE_TYPE ||
           !subscriber.contentPrincipal ||
           subscriber.contentPrincipal.originNoSuffix != ABOUT_LOGINS_ORIGIN) {
         this._subscribers.delete(subscriber);
         continue;
       }
+      yield subscriber;
+    }
+  },
+
+  messageSubscribers(name, details) {
+    for (let subscriber of this._subscriberIterator()) {
       try {
         subscriber.messageManager.sendAsyncMessage(name, details);
       } catch (ex) {}
     }
   },
 
   getAllLogins() {
     return Services.logins