Bug 834911 - Remove support of nsIEnumerator from mailnews/base/util/iteratorUtils.jsm - adapt /mailnews. r=asuth
authoraceman <acelists@atlas.sk>
Sat, 09 Feb 2013 16:31:18 -0500
changeset 14838 baabd0228d4167688c896ce269eb2bba8588dcb4
parent 14837 76972e8b8432a219dea02614e35c263c80f22f77
child 14839 b66b5fafc36d265a58475ad9fc5e8c620d7ca169
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs834911
Bug 834911 - Remove support of nsIEnumerator from mailnews/base/util/iteratorUtils.jsm - adapt /mailnews. r=asuth
mailnews/base/util/iteratorUtils.jsm
mailnews/db/gloda/modules/index_msg.js
mailnews/test/resources/folderEventLogHelper.js
--- a/mailnews/base/util/iteratorUtils.jsm
+++ b/mailnews/base/util/iteratorUtils.jsm
@@ -45,21 +45,21 @@ function toArray(aObj, aUseKeys) {
 
 /**
 * Given a JS array, JS iterator, or one of a variety of XPCOM collections or
  * iterators, return a JS iterator suitable for use in a for...in expression.
  *
  * Currently, we support the following types of xpcom iterators:
  *   nsIArray
  *   nsISupportsArray
- *   nsIEnumerator // We must support this until there are no uses of nsIEnumerator
- *                    in mozilla-central and comm-central. E.g. it can be created
- *                    via nsISupportsArray.enumerate().
  *   nsISimpleEnumerator
  *
+ *   This intentionally does not support nsIEnumerator as it is obsolete and
+ *   no longer used in the base code.
+ *
  *   @param aEnum  the enumerator to convert
  *   @param aIface (optional) an interface to QI each object to prior to
  *                 returning
  *
  *   @note This does *not* return an Array object.  It returns an object that
  *         can be used in for...in contexts only.  To create such an array, use
  *         var array = toArray(fixIterator(xpcomEnumerator));
  */
@@ -94,34 +94,18 @@ function fixIterator(aEnum, aIface) {
   if (aEnum instanceof Ci.nsISupportsArray) {
     let iter = function() {
       let count = aEnum.Count();
       for (let i = 0; i < count; i++)
         yield aEnum.QueryElementAt(i, face);
     }
     return { __iterator__: iter };
   }
-  
-  // Now try nsIEnumerator
-  if (aEnum instanceof Ci.nsIEnumerator) {
-    let done = false;
-    let iter = function() {
-      while (!done) {
-        try {
-          yield aEnum.currentItem().QueryInterface(face);
-          aEnum.next();
-        } catch(ex) {
-          done = true;
-        }
-      }
-    };
-    return { __iterator__: iter };
-  }
-  
-  // how about nsISimpleEnumerator? this one is nice and simple
+
+  // How about nsISimpleEnumerator? This one is nice and simple.
   if (aEnum instanceof Ci.nsISimpleEnumerator) {
     let iter = function () {
       while (aEnum.hasMoreElements())
         yield aEnum.getNext().QueryInterface(face);
     }
     return { __iterator__: iter };
   }
   return null;
--- a/mailnews/db/gloda/modules/index_msg.js
+++ b/mailnews/db/gloda/modules/index_msg.js
@@ -2326,18 +2326,17 @@ var GlodaMsgIndexer = {
           //  none of the gloda-id's are valid (and so we certainly don't want
           //  to try and use them as a basis for updating message keys.)
           let srcMsgFolder = aSrcMsgHdrs.queryElementAt(0, nsIMsgDBHdr).folder;
           if (!this.indexer.shouldIndexFolder(srcMsgFolder) ||
               (GlodaDatastore._mapFolder(srcMsgFolder).dirtyStatus ==
                  GlodaFolder.prototype.kFolderFilthy)) {
             // Local case, just modify the destination headers directly.
             if (aDestMsgHdrs) {
-              for each (let destMsgHdr in fixIterator(aDestMsgHdrs.enumerate(),
-                                                      nsIMsgDBHdr)) {
+              for (let destMsgHdr in fixIterator(aDestMsgHdrs, nsIMsgDBHdr)) {
                 // zero it out if it exists
                 // (no need to deal with pending commit issues here; a filthy
                 //  folder by definition has nothing indexed in it.)
                 let glodaId = destMsgHdr.getUint32Property(
                                 GLODA_MESSAGE_ID_PROPERTY);
                 if (glodaId)
                   destMsgHdr.setUint32Property(GLODA_MESSAGE_ID_PROPERTY,
                                                0);
@@ -2359,18 +2358,17 @@ var GlodaMsgIndexer = {
                 destDb = aDestFolder.msgDatabase;
               } catch (ex) {
                 this.indexer._log.warn("Destination database for " +
                                        aDestFolder.prettiestName +
                                        " not ready on IMAP move." +
                                        " Gloda corruption possible.");
                 return;
               }
-              for each (let srcMsgHdr in fixIterator(aSrcMsgHdrs.enumerate(),
-                                                     nsIMsgDBHdr)) {
+              for (let srcMsgHdr in fixIterator(aSrcMsgHdrs, nsIMsgDBHdr)) {
                 // zero it out if it exists
                 // (no need to deal with pending commit issues here; a filthy
                 //  folder by definition has nothing indexed in it.)
                 let glodaId = srcMsgHdr.getUint32Property(
                                 GLODA_MESSAGE_ID_PROPERTY);
                 if (glodaId)
                   destDb.setUint32AttributeOnPendingHdr(
                     srcMsgHdr, GLODA_MESSAGE_ID_PROPERTY, 0);
@@ -2475,18 +2473,17 @@ var GlodaMsgIndexer = {
             //  message added events will cause that to happen.
           }
         }
         // ---- Copy case
         else {
           // -- Do not propagate gloda-id's for copies
           // (Only applies if we have the destination header, which means local)
           if (aDestMsgHdrs) {
-            for each (let destMsgHdr in fixIterator(aDestMsgHdrs.enumerate(),
-                                                    nsIMsgDBHdr)) {
+            for (let destMsgHdr in fixIterator(aDestMsgHdrs, nsIMsgDBHdr)) {
               let glodaId = destMsgHdr.getUint32Property(
                 GLODA_MESSAGE_ID_PROPERTY);
               if (glodaId)
                 destMsgHdr.setUint32Property(GLODA_MESSAGE_ID_PROPERTY, 0);
             }
           }
 
           // mark the folder as dirty; we'll get to it later.
--- a/mailnews/test/resources/folderEventLogHelper.js
+++ b/mailnews/test/resources/folderEventLogHelper.js
@@ -47,46 +47,42 @@ let _folderEventLogHelper_msgFolderListe
   },
 
   msgsClassified: function felh_msgsClassified(aMsgs, aJunkProcessed,
                                                aTraitProcessed) {
     let args = [
       aJunkProcessed ? "junk processed" : "did not junk process",
       aTraitProcessed ? "trait processed" : "did not trait process"
     ];
-    for each (let msgHdr in fixIterator(aMsgs.enumerate(),
-                                        Components.interfaces.nsIMsgDBHdr)) {
+    for (let msgHdr in fixIterator(aMsgs, Components.interfaces.nsIMsgDBHdr)) {
       args.push(msgHdr);
     }
     mark_action("msgEvent", "msgsClassified", args);
   },
 
   msgsDeleted: function felh_msgsDeleted(aMsgs) {
     let args = [];
-    for each (let msgHdr in fixIterator(aMsgs.enumerate(),
-                                        Components.interfaces.nsIMsgDBHdr)) {
+    for (let msgHdr in fixIterator(aMsgs, Components.interfaces.nsIMsgDBHdr)) {
       args.push(msgHdr);
     }
     mark_action("msgEvent", "msgsDeleted", args);
   },
 
   msgsMoveCopyCompleted: function felh_msgsMoveCopyCompleted(aMove, aSrcMsgs,
                                                              aDestFolder,
                                                              aDestMsgs) {
     let args = [aMove ? "moved" : "copied"];
-    for each (let msgHdr in fixIterator(aSrcMsgs.enumerate(),
-                                        Components.interfaces.nsIMsgDBHdr)) {
+    for (let msgHdr in fixIterator(aSrcMsgs, Components.interfaces.nsIMsgDBHdr)) {
       args.push(msgHdr);
     }
     args.push("to");
     args.push(aDestFolder);
     if (aDestMsgs) {
       args.push("dest headers:");
-      for each (let msgHdr in fixIterator(aDestMsgs.enumerate(),
-                                          Components.interfaces.nsIMsgDBHdr)) {
+      for (let msgHdr in fixIterator(aDestMsgs, Components.interfaces.nsIMsgDBHdr)) {
         args.push(msgHdr);
       }
     }
     mark_action("msgEvent", "msgsMoveCopyCompleted", args);
   },
 
   msgKeyChanged: function felh_msgKeyChanged(aOldMsgKey, aNewMsgHdr) {
     let args = ["old key", aOldMsgKey, "new header", aNewMsgHdr];