Bug 1484496: Part 2 - Add common base class for all nsISimpleEnumerator implementations. r=froydnj
authorKris Maglione <maglione.k@gmail.com>
Sat, 18 Aug 2018 14:22:47 -0700
changeset 490970 062e4138bfde6fb0f010d3fabb82b052b2a1b301
parent 490969 10d2e81f3c8a157151bf5cca7133e65458a859eb
child 490971 15a738855cb06dd495c14fde3c8b54dde513c098
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1484496
milestone63.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 1484496: Part 2 - Add common base class for all nsISimpleEnumerator implementations. r=froydnj In order to allow JS callers to use nsISimpleEnumerator instances with the JS iteration protocol, we'll need to additional methods to every instance. Since we currently have a large number of unrelated implementations, it would be best if they could share the same implementation for the JS portion of the protocol. This patch adds a stub nsSimpleEnumerator base class, and updates all existing implementations to inherit from it. A follow-up will add a new base interface to this class, and implement the additional functionality required for JS iteration. Differential Revision: https://phabricator.services.mozilla.com/D3725
browser/components/dirprovider/DirectoryProvider.cpp
browser/components/dirprovider/DirectoryProvider.h
browser/components/migration/nsIEHistoryEnumerator.cpp
browser/components/migration/nsIEHistoryEnumerator.h
docshell/base/nsDocShellEnumerator.cpp
docshell/base/nsDocShellEnumerator.h
docshell/shistory/nsSHistory.h
dom/commandhandler/nsCommandGroup.cpp
dom/indexedDB/ActorsParent.cpp
dom/media/gmp/GMPUtils.h
dom/payments/PaymentRequestService.cpp
dom/quota/ActorsParent.cpp
dom/workers/WorkerDebuggerManager.cpp
intl/strres/nsStringBundle.cpp
security/manager/ssl/nsNSSCertificate.cpp
security/manager/ssl/nsNSSCertificate.h
toolkit/components/windowwatcher/nsWindowWatcher.cpp
toolkit/profile/nsToolkitProfileService.cpp
widget/nsBaseFilePicker.cpp
widget/nsFilePickerProxy.cpp
xpcom/components/nsCategoryManager.cpp
xpcom/ds/moz.build
xpcom/ds/nsArrayEnumerator.cpp
xpcom/ds/nsEnumeratorUtils.cpp
xpcom/ds/nsObserverList.cpp
xpcom/ds/nsObserverList.h
xpcom/ds/nsSimpleEnumerator.cpp
xpcom/ds/nsSimpleEnumerator.h
xpcom/ds/nsStringEnumerator.cpp
xpcom/io/nsAppFileLocationProvider.cpp
xpcom/io/nsLocalFileUnix.cpp
xpcom/io/nsLocalFileWin.cpp
xpfe/appshell/nsAppShellWindowEnumerator.cpp
xpfe/appshell/nsAppShellWindowEnumerator.h
--- a/browser/components/dirprovider/DirectoryProvider.cpp
+++ b/browser/components/dirprovider/DirectoryProvider.cpp
@@ -141,18 +141,16 @@ DirectoryProvider::GetFiles(const char *
     AppendDistroSearchDirs(dirSvc, distroFiles);
 
     return NS_NewArrayEnumerator(aResult, distroFiles);
   }
 
   return NS_ERROR_FAILURE;
 }
 
-NS_IMPL_ISUPPORTS(DirectoryProvider::AppendingEnumerator, nsISimpleEnumerator)
-
 NS_IMETHODIMP
 DirectoryProvider::AppendingEnumerator::HasMoreElements(bool *aResult)
 {
   *aResult = mNext ? true : false;
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/browser/components/dirprovider/DirectoryProvider.h
+++ b/browser/components/dirprovider/DirectoryProvider.h
@@ -2,18 +2,18 @@
  * 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/. */
 
 #ifndef DirectoryProvider_h__
 #define DirectoryProvider_h__
 
 #include "nsIDirectoryService.h"
 #include "nsComponentManagerUtils.h"
-#include "nsISimpleEnumerator.h"
 #include "nsIFile.h"
+#include "nsSimpleEnumerator.h"
 #include "mozilla/Attributes.h"
 
 #define NS_BROWSERDIRECTORYPROVIDER_CONTRACTID \
   "@mozilla.org/browser/directory-provider;1"
 
 namespace mozilla {
 namespace browser {
 
@@ -22,27 +22,26 @@ class DirectoryProvider final : public n
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDIRECTORYSERVICEPROVIDER
   NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
 
 private:
   ~DirectoryProvider() {}
 
-  class AppendingEnumerator final : public nsISimpleEnumerator
+  class AppendingEnumerator final : public nsSimpleEnumerator
   {
   public:
-    NS_DECL_ISUPPORTS
     NS_DECL_NSISIMPLEENUMERATOR
 
     AppendingEnumerator(nsISimpleEnumerator* aBase,
                         char const *const *aAppendList);
 
   private:
-    ~AppendingEnumerator() {}
+    ~AppendingEnumerator() override = default;
 
     nsCOMPtr<nsISimpleEnumerator> mBase;
     char const *const *const      mAppendList;
     nsCOMPtr<nsIFile>             mNext;
   };
 };
 
 } // namespace browser
--- a/browser/components/migration/nsIEHistoryEnumerator.cpp
+++ b/browser/components/migration/nsIEHistoryEnumerator.cpp
@@ -14,18 +14,16 @@
 #include "nsNetUtil.h"
 #include "nsString.h"
 #include "nsWindowsMigrationUtils.h"
 #include "prtime.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsIEHistoryEnumerator
 
-NS_IMPL_ISUPPORTS(nsIEHistoryEnumerator, nsISimpleEnumerator)
-
 nsIEHistoryEnumerator::nsIEHistoryEnumerator()
 {
   ::CoInitialize(nullptr);
 }
 
 nsIEHistoryEnumerator::~nsIEHistoryEnumerator()
 {
   ::CoUninitialize();
--- a/browser/components/migration/nsIEHistoryEnumerator.h
+++ b/browser/components/migration/nsIEHistoryEnumerator.h
@@ -4,29 +4,28 @@
 
 #ifndef iehistoryenumerator___h___
 #define iehistoryenumerator___h___
 
 #include <urlhist.h>
 
 #include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
-#include "nsISimpleEnumerator.h"
 #include "nsIWritablePropertyBag2.h"
+#include "nsSimpleEnumerator.h"
 
-class nsIEHistoryEnumerator final : public nsISimpleEnumerator
+class nsIEHistoryEnumerator final : public nsSimpleEnumerator
 {
 public:
-  NS_DECL_ISUPPORTS
   NS_DECL_NSISIMPLEENUMERATOR
 
   nsIEHistoryEnumerator();
 
 private:
-  ~nsIEHistoryEnumerator();
+  ~nsIEHistoryEnumerator() override;
 
   /**
    * Initializes the history reader, if needed.
    */
   void EnsureInitialized();
 
   RefPtr<IUrlHistoryStg2> mIEHistory;
   RefPtr<IEnumSTATURL> mURLEnumerator;
--- a/docshell/base/nsDocShellEnumerator.cpp
+++ b/docshell/base/nsDocShellEnumerator.cpp
@@ -16,18 +16,16 @@ nsDocShellEnumerator::nsDocShellEnumerat
   , mEnumerationDirection(aEnumerationDirection)
 {
 }
 
 nsDocShellEnumerator::~nsDocShellEnumerator()
 {
 }
 
-NS_IMPL_ISUPPORTS(nsDocShellEnumerator, nsISimpleEnumerator)
-
 NS_IMETHODIMP
 nsDocShellEnumerator::GetNext(nsISupports** aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = nullptr;
 
   nsresult rv = EnsureDocShellArray();
   if (NS_FAILED(rv)) {
--- a/docshell/base/nsDocShellEnumerator.h
+++ b/docshell/base/nsDocShellEnumerator.h
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #ifndef nsDocShellEnumerator_h___
 #define nsDocShellEnumerator_h___
 
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 #include "nsTArray.h"
 #include "nsIWeakReferenceUtils.h"
 
 class nsIDocShellTreeItem;
 
 /*
 // {13cbc281-35ae-11d5-be5b-bde0edece43c}
 #define NS_DOCSHELL_FORWARDS_ENUMERATOR_CID  \
@@ -24,33 +24,30 @@ class nsIDocShellTreeItem;
 // {13cbc282-35ae-11d5-be5b-bde0edece43c}
 #define NS_DOCSHELL_BACKWARDS_ENUMERATOR_CID  \
 { 0x13cbc282, 0x35ae, 0x11d5, { 0xbe, 0x5b, 0xbd, 0xe0, 0xed, 0xec, 0xe4, 0x3c } }
 
 #define NS_DOCSHELL_BACKWARDS_ENUMERATOR_CONTRACTID \
 "@mozilla.org/docshell/enumerator-backwards;1"
 */
 
-class nsDocShellEnumerator : public nsISimpleEnumerator
+class nsDocShellEnumerator : public nsSimpleEnumerator
 {
 protected:
   enum
   {
     enumerateForwards,
     enumerateBackwards
   };
 
   virtual ~nsDocShellEnumerator();
 
 public:
   explicit nsDocShellEnumerator(int32_t aEnumerationDirection);
 
-  // nsISupports
-  NS_DECL_ISUPPORTS
-
   // nsISimpleEnumerator
   NS_DECL_NSISIMPLEENUMERATOR
 
 public:
   nsresult GetEnumerationRootItem(nsIDocShellTreeItem** aEnumerationRootItem);
   nsresult SetEnumerationRootItem(nsIDocShellTreeItem* aEnumerationRootItem);
 
   nsresult GetEnumDocShellType(int32_t* aEnumerationItemType);
--- a/docshell/shistory/nsSHistory.h
+++ b/docshell/shistory/nsSHistory.h
@@ -6,19 +6,19 @@
 
 #ifndef nsSHistory_h
 #define nsSHistory_h
 
 #include "nsCOMPtr.h"
 #include "nsExpirationTracker.h"
 #include "nsISHistory.h"
 #include "nsISHistoryInternal.h"
-#include "nsISimpleEnumerator.h"
 #include "nsIWebNavigation.h"
 #include "nsSHEntryShared.h"
+#include "nsSimpleEnumerator.h"
 #include "nsTObserverArray.h"
 #include "nsWeakReference.h"
 
 #include "mozilla/LinkedList.h"
 #include "mozilla/UniquePtr.h"
 
 class nsIDocShell;
 class nsDocShell;
--- a/dom/commandhandler/nsCommandGroup.cpp
+++ b/dom/commandhandler/nsCommandGroup.cpp
@@ -2,48 +2,44 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsTArray.h"
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 #include "nsXPCOM.h"
 #include "nsSupportsPrimitives.h"
 #include "nsIComponentManager.h"
 #include "nsCommandGroup.h"
 #include "nsIControllerCommand.h"
 #include "nsCRT.h"
 
-class nsGroupsEnumerator : public nsISimpleEnumerator
+class nsGroupsEnumerator : public nsSimpleEnumerator
 {
 public:
   explicit nsGroupsEnumerator(
     nsControllerCommandGroup::GroupsHashtable& aInHashTable);
 
-  NS_DECL_ISUPPORTS
   NS_DECL_NSISIMPLEENUMERATOR
 
 protected:
-  virtual ~nsGroupsEnumerator();
+  ~nsGroupsEnumerator() override;
 
   nsresult Initialize();
 
 protected:
   nsControllerCommandGroup::GroupsHashtable& mHashTable;
   int32_t mIndex;
   const char** mGroupNames;  // array of pointers to char16_t* in the hash table
   bool mInitted;
 };
 
-/* Implementation file */
-NS_IMPL_ISUPPORTS(nsGroupsEnumerator, nsISimpleEnumerator)
-
 nsGroupsEnumerator::nsGroupsEnumerator(
       nsControllerCommandGroup::GroupsHashtable& aInHashTable)
   : mHashTable(aInHashTable)
   , mIndex(-1)
   , mGroupNames(nullptr)
   , mInitted(false)
 {
 }
@@ -120,43 +116,40 @@ nsGroupsEnumerator::Initialize()
     mIndex++;
   }
 
   mIndex = -1;
   mInitted = true;
   return NS_OK;
 }
 
-class nsNamedGroupEnumerator : public nsISimpleEnumerator
+class nsNamedGroupEnumerator : public nsSimpleEnumerator
 {
 public:
   explicit nsNamedGroupEnumerator(nsTArray<nsCString>* aInArray);
 
-  NS_DECL_ISUPPORTS
   NS_DECL_NSISIMPLEENUMERATOR
 
 protected:
-  virtual ~nsNamedGroupEnumerator();
+  ~nsNamedGroupEnumerator() override;
 
   nsTArray<nsCString>* mGroupArray;
   int32_t mIndex;
 };
 
 nsNamedGroupEnumerator::nsNamedGroupEnumerator(nsTArray<nsCString>* aInArray)
   : mGroupArray(aInArray)
   , mIndex(-1)
 {
 }
 
 nsNamedGroupEnumerator::~nsNamedGroupEnumerator()
 {
 }
 
-NS_IMPL_ISUPPORTS(nsNamedGroupEnumerator, nsISimpleEnumerator)
-
 NS_IMETHODIMP
 nsNamedGroupEnumerator::HasMoreElements(bool* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
 
   int32_t arrayLen = mGroupArray ? mGroupArray->Length() : 0;
   *aResult = (mIndex < arrayLen - 1);
   return NS_OK;
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -17119,17 +17119,17 @@ FileManager::InitDirectory(nsIFile* aDir
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     if (NS_WARN_IF(!isDirectory)) {
       return NS_ERROR_FAILURE;
     }
 
-    nsCOMPtr<nsISimpleEnumerator> entries;
+    nsCOMPtr<nsIDirectoryEnumerator> entries;
     rv = journalDirectory->GetDirectoryEntries(getter_AddRefs(entries));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
     bool hasElements;
     rv = entries->HasMoreElements(&hasElements);
     if (NS_WARN_IF(NS_FAILED(rv))) {
--- a/dom/media/gmp/GMPUtils.h
+++ b/dom/media/gmp/GMPUtils.h
@@ -13,17 +13,17 @@
 #include "nsTArray.h"
 #include "nsCOMPtr.h"
 #include "nsClassHashtable.h"
 
 #define CHROMIUM_CDM_API_BACKWARD_COMPAT "chromium-cdm8-host4"
 #define CHROMIUM_CDM_API "chromium-cdm9-host4"
 
 class nsIFile;
-class nsISimpleEnumerator;
+class nsIDirectoryEnumerator;
 
 namespace mozilla {
 
 template<typename T>
 struct DestroyPolicy
 {
   void operator()(T* aGMPObject) const {
     aGMPObject->Destroy();
@@ -57,17 +57,17 @@ public:
   };
 
   DirectoryEnumerator(nsIFile* aPath, Mode aMode);
 
   already_AddRefed<nsIFile> Next();
 
 private:
   Mode mMode;
-  nsCOMPtr<nsISimpleEnumerator> mIter;
+  nsCOMPtr<nsIDirectoryEnumerator> mIter;
 };
 
 class GMPInfoFileParser {
 public:
   bool Init(nsIFile* aFile);
   bool Contains(const nsCString& aKey) const;
   nsCString Get(const nsCString& aKey) const;
 private:
--- a/dom/payments/PaymentRequestService.cpp
+++ b/dom/payments/PaymentRequestService.cpp
@@ -3,40 +3,38 @@
 /* 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/. */
 
 #include "mozilla/ClearOnShutdown.h"
 #include "PaymentRequestData.h"
 #include "PaymentRequestService.h"
 #include "BasicCardPayment.h"
+#include "nsSimpleEnumerator.h"
 
 namespace mozilla {
 namespace dom {
 
 StaticRefPtr<PaymentRequestService> gPaymentService;
 
 namespace {
 
-class PaymentRequestEnumerator final : public nsISimpleEnumerator
+class PaymentRequestEnumerator final : public nsSimpleEnumerator
 {
 public:
-  NS_DECL_ISUPPORTS
   NS_DECL_NSISIMPLEENUMERATOR
 
   PaymentRequestEnumerator()
     : mIndex(0)
   {}
 private:
-  ~PaymentRequestEnumerator() = default;
+  ~PaymentRequestEnumerator() override = default;
   uint32_t mIndex;
 };
 
-NS_IMPL_ISUPPORTS(PaymentRequestEnumerator, nsISimpleEnumerator)
-
 NS_IMETHODIMP
 PaymentRequestEnumerator::HasMoreElements(bool* aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
   *aReturn = false;
   if (NS_WARN_IF(!gPaymentService)) {
     return NS_ERROR_FAILURE;
   }
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -4878,17 +4878,17 @@ QuotaManager::MaybeRemoveLocalStorageDir
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (!exists) {
     return NS_OK;
   }
 
-  nsCOMPtr<nsISimpleEnumerator> entries;
+  nsCOMPtr<nsIDirectoryEnumerator> entries;
   rv = defaultStorageDir->GetDirectoryEntries(getter_AddRefs(entries));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   if (!entries) {
     return NS_OK;
   }
--- a/dom/workers/WorkerDebuggerManager.cpp
+++ b/dom/workers/WorkerDebuggerManager.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include "WorkerDebuggerManager.h"
 
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/StaticPtr.h"
 
 #include "WorkerDebugger.h"
 #include "WorkerPrivate.h"
 
 namespace mozilla {
@@ -71,37 +71,34 @@ private:
     return NS_OK;
   }
 };
 
 static StaticRefPtr<WorkerDebuggerManager> gWorkerDebuggerManager;
 
 } /* anonymous namespace */
 
-class WorkerDebuggerEnumerator final : public nsISimpleEnumerator
+class WorkerDebuggerEnumerator final : public nsSimpleEnumerator
 {
   nsTArray<RefPtr<WorkerDebugger>> mDebuggers;
   uint32_t mIndex;
 
 public:
   explicit WorkerDebuggerEnumerator(
                              const nsTArray<RefPtr<WorkerDebugger>>& aDebuggers)
   : mDebuggers(aDebuggers), mIndex(0)
   {
   }
 
-  NS_DECL_ISUPPORTS
   NS_DECL_NSISIMPLEENUMERATOR
 
 private:
-  ~WorkerDebuggerEnumerator() {}
+  ~WorkerDebuggerEnumerator() override = default;
 };
 
-NS_IMPL_ISUPPORTS(WorkerDebuggerEnumerator, nsISimpleEnumerator);
-
 NS_IMETHODIMP
 WorkerDebuggerEnumerator::HasMoreElements(bool* aResult)
 {
   *aResult = mIndex < mDebuggers.Length();
   return NS_OK;
 };
 
 NS_IMETHODIMP
--- a/intl/strres/nsStringBundle.cpp
+++ b/intl/strres/nsStringBundle.cpp
@@ -21,16 +21,17 @@
 #include "nsIObserverService.h"
 #include "nsCOMArray.h"
 #include "nsTextFormatter.h"
 #include "nsIErrorService.h"
 #include "nsICategoryManager.h"
 #include "nsContentUtils.h"
 #include "nsPersistentProperties.h"
 #include "nsQueryObject.h"
+#include "nsSimpleEnumerator.h"
 #include "nsStringStream.h"
 #include "mozilla/BinarySearch.h"
 #include "mozilla/ResultExtensions.h"
 #include "mozilla/URLPreloader.h"
 #include "mozilla/ResultExtensions.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ipc/SharedStringMap.h"
 
@@ -256,36 +257,34 @@ private:
 
   Maybe<FileDescriptor> mMapFile;
   size_t mMapSize;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(SharedStringBundle, SHAREDSTRINGBUNDLE_IID)
 
 
-class StringMapEnumerator final : public nsISimpleEnumerator
+class StringMapEnumerator final : public nsSimpleEnumerator
 {
-  NS_DECL_ISUPPORTS
+public:
   NS_DECL_NSISIMPLEENUMERATOR
 
   explicit StringMapEnumerator(SharedStringMap* aStringMap)
     : mStringMap(aStringMap)
   {}
 
 protected:
   virtual ~StringMapEnumerator() = default;
 
 private:
   RefPtr<SharedStringMap> mStringMap;
 
   uint32_t mIndex = 0;
 };
 
-NS_IMPL_ISUPPORTS(StringMapEnumerator, nsISimpleEnumerator)
-
 template <typename T, typename... Args>
 already_AddRefed<T>
 MakeBundle(Args... args)
 {
   return nsStringBundleBase::Create<T>(args...);
 }
 
 template <typename T, typename... Args>
--- a/security/manager/ssl/nsNSSCertificate.cpp
+++ b/security/manager/ssl/nsNSSCertificate.cpp
@@ -1215,18 +1215,16 @@ nsNSSCertList::GetRootCertificate(/* out
   // Duplicates the certificate
   aRoot = nsNSSCertificate::Create(rootNode->cert);
   if (!aRoot) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
   return NS_OK;
 }
 
-NS_IMPL_ISUPPORTS(nsNSSCertListEnumerator, nsISimpleEnumerator)
-
 nsNSSCertListEnumerator::nsNSSCertListEnumerator(
   const UniqueCERTCertList& certList)
 {
   MOZ_ASSERT(certList);
   mCertList = nsNSSCertList::DupCertList(certList);
 }
 
 NS_IMETHODIMP
--- a/security/manager/ssl/nsNSSCertificate.h
+++ b/security/manager/ssl/nsNSSCertificate.h
@@ -10,20 +10,20 @@
 #include <vector>
 
 #include "ScopedNSSTypes.h"
 #include "certt.h"
 #include "nsCOMPtr.h"
 #include "nsIASN1Object.h"
 #include "nsIClassInfo.h"
 #include "nsISerializable.h"
-#include "nsISimpleEnumerator.h"
 #include "nsIX509Cert.h"
 #include "nsIX509CertDB.h"
 #include "nsIX509CertList.h"
+#include "nsSimpleEnumerator.h"
 #include "nsStringFwd.h"
 
 namespace mozilla { namespace pkix { class DERArray; } }
 
 class nsINSSComponent;
 class nsIASN1Sequence;
 
 class nsNSSCertificate final : public nsIX509Cert
@@ -118,20 +118,19 @@ private:
    virtual ~nsNSSCertList() {}
 
    mozilla::UniqueCERTCertList mCertList;
 
    nsNSSCertList(const nsNSSCertList&) = delete;
    void operator=(const nsNSSCertList&) = delete;
 };
 
-class nsNSSCertListEnumerator : public nsISimpleEnumerator
+class nsNSSCertListEnumerator : public nsSimpleEnumerator
 {
 public:
-   NS_DECL_THREADSAFE_ISUPPORTS
    NS_DECL_NSISIMPLEENUMERATOR
 
    explicit nsNSSCertListEnumerator(const mozilla::UniqueCERTCertList& certList);
 private:
    virtual ~nsNSSCertListEnumerator() {}
 
    mozilla::UniqueCERTCertList mCertList;
 
--- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
@@ -53,16 +53,17 @@
 #include "nsIWidget.h"
 #include "nsFocusManager.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsContentUtils.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsSandboxFlags.h"
+#include "nsSimpleEnumerator.h"
 #include "mozilla/CheckedInt.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Storage.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/dom/DocGroup.h"
 #include "mozilla/dom/TabGroup.h"
@@ -141,43 +142,37 @@ nsWatcherWindowEntry::ReferenceSelf()
   mYounger = this;
   mOlder = this;
 }
 
 /****************************************************************
  ****************** nsWatcherWindowEnumerator *******************
  ****************************************************************/
 
-class nsWatcherWindowEnumerator : public nsISimpleEnumerator
+class nsWatcherWindowEnumerator : public nsSimpleEnumerator
 {
 
 public:
   explicit nsWatcherWindowEnumerator(nsWindowWatcher* aWatcher);
   NS_IMETHOD HasMoreElements(bool* aResult) override;
   NS_IMETHOD GetNext(nsISupports** aResult) override;
 
-  NS_DECL_ISUPPORTS
-
 protected:
-  virtual ~nsWatcherWindowEnumerator();
+  ~nsWatcherWindowEnumerator() override;
 
 private:
   friend class nsWindowWatcher;
 
   nsWatcherWindowEntry* FindNext();
   void WindowRemoved(nsWatcherWindowEntry* aInfo);
 
   nsWindowWatcher* mWindowWatcher;
   nsWatcherWindowEntry* mCurrentPosition;
 };
 
-NS_IMPL_ADDREF(nsWatcherWindowEnumerator)
-NS_IMPL_RELEASE(nsWatcherWindowEnumerator)
-NS_IMPL_QUERY_INTERFACE(nsWatcherWindowEnumerator, nsISimpleEnumerator)
-
 nsWatcherWindowEnumerator::nsWatcherWindowEnumerator(nsWindowWatcher* aWatcher)
   : mWindowWatcher(aWatcher)
   , mCurrentPosition(aWatcher->mOldestWindow)
 {
   mWindowWatcher->AddEnumerator(this);
   mWindowWatcher->AddRef();
 }
 
--- a/toolkit/profile/nsToolkitProfileService.cpp
+++ b/toolkit/profile/nsToolkitProfileService.cpp
@@ -19,17 +19,17 @@
 #ifdef XP_UNIX
 #include <unistd.h>
 #endif
 
 #include "nsIToolkitProfileService.h"
 #include "nsIToolkitProfile.h"
 #include "nsIFactory.h"
 #include "nsIFile.h"
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 
 #ifdef XP_MACOSX
 #include <CoreFoundation/CoreFoundation.h>
 #include "nsILocalFileMac.h"
 #endif
 
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsNetCID.h"
@@ -139,26 +139,24 @@ private:
     nsCOMPtr<nsIFile>           mAppData;
     nsCOMPtr<nsIFile>           mTempData;
     nsCOMPtr<nsIFile>           mListFile;
     bool mStartWithLast;
     bool mStartOffline;
 
     static nsToolkitProfileService *gService;
 
-    class ProfileEnumerator final : public nsISimpleEnumerator
+    class ProfileEnumerator final : public nsSimpleEnumerator
     {
     public:
-        NS_DECL_ISUPPORTS
         NS_DECL_NSISIMPLEENUMERATOR
 
         explicit ProfileEnumerator(nsToolkitProfile *first)
           { mCurrent = first; }
     private:
-        ~ProfileEnumerator() { }
         RefPtr<nsToolkitProfile> mCurrent;
     };
 };
 
 nsToolkitProfile::nsToolkitProfile(const nsACString& aName,
                                    nsIFile* aRootDir,
                                    nsIFile* aLocalDir,
                                    nsToolkitProfile* aPrev) :
@@ -590,19 +588,16 @@ nsToolkitProfileService::GetProfiles(nsI
     *aResult = new ProfileEnumerator(this->mFirst);
     if (!*aResult)
         return NS_ERROR_OUT_OF_MEMORY;
 
     NS_ADDREF(*aResult);
     return NS_OK;
 }
 
-NS_IMPL_ISUPPORTS(nsToolkitProfileService::ProfileEnumerator,
-                  nsISimpleEnumerator)
-
 NS_IMETHODIMP
 nsToolkitProfileService::ProfileEnumerator::HasMoreElements(bool* aResult)
 {
     *aResult = mCurrent ? true : false;
     return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/widget/nsBaseFilePicker.cpp
+++ b/widget/nsBaseFilePicker.cpp
@@ -16,16 +16,17 @@
 #include "nsIServiceManager.h"
 #include "nsCOMArray.h"
 #include "nsIFile.h"
 #include "nsEnumeratorUtils.h"
 #include "mozilla/dom/Directory.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/Services.h"
 #include "WidgetUtils.h"
+#include "nsSimpleEnumerator.h"
 #include "nsThreadUtils.h"
 
 #include "nsBaseFilePicker.h"
 
 using namespace mozilla::widget;
 using namespace mozilla::dom;
 
 #define FILEPICKER_TITLES "chrome://global/locale/filepicker.properties"
@@ -95,21 +96,19 @@ public:
     return NS_OK;
   }
 
 private:
   RefPtr<nsBaseFilePicker> mFilePicker;
   RefPtr<nsIFilePickerShownCallback> mCallback;
 };
 
-class nsBaseFilePickerEnumerator : public nsISimpleEnumerator
+class nsBaseFilePickerEnumerator : public nsSimpleEnumerator
 {
 public:
-  NS_DECL_ISUPPORTS
-
   nsBaseFilePickerEnumerator(nsPIDOMWindowOuter* aParent,
                              nsISimpleEnumerator* iterator,
                              int16_t aMode)
     : mIterator(iterator)
     , mParent(aParent->GetCurrentInnerWindow())
     , mMode(aMode)
   {}
 
@@ -136,28 +135,22 @@ public:
   }
 
   NS_IMETHOD
   HasMoreElements(bool* aResult) override
   {
     return mIterator->HasMoreElements(aResult);
   }
 
-protected:
-  virtual ~nsBaseFilePickerEnumerator()
-  {}
-
 private:
   nsCOMPtr<nsISimpleEnumerator> mIterator;
   nsCOMPtr<nsPIDOMWindowInner> mParent;
   int16_t mMode;
 };
 
-NS_IMPL_ISUPPORTS(nsBaseFilePickerEnumerator, nsISimpleEnumerator)
-
 nsBaseFilePicker::nsBaseFilePicker()
   : mAddToRecentDocs(true)
   , mMode(nsIFilePicker::modeOpen)
 {
 
 }
 
 nsBaseFilePicker::~nsBaseFilePicker()
--- a/widget/nsFilePickerProxy.cpp
+++ b/widget/nsFilePickerProxy.cpp
@@ -2,16 +2,17 @@
  *
  * 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/. */
 
 #include "nsFilePickerProxy.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIFile.h"
+#include "nsSimpleEnumerator.h"
 #include "mozilla/dom/Directory.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/IPCBlobUtils.h"
 
 using namespace mozilla::dom;
 
 NS_IMPL_ISUPPORTS(nsFilePickerProxy, nsIFilePicker)
@@ -215,21 +216,19 @@ nsFilePickerProxy::GetDomFileOrDirectory
   MOZ_ASSERT(mFilesOrDirectories[0].IsDirectory());
   RefPtr<Directory> directory = mFilesOrDirectories[0].GetAsDirectory();
   directory.forget(aValue);
   return NS_OK;
 }
 
 namespace {
 
-class SimpleEnumerator final : public nsISimpleEnumerator
+class SimpleEnumerator final : public nsSimpleEnumerator
 {
 public:
-  NS_DECL_ISUPPORTS
-
   explicit
   SimpleEnumerator(const nsTArray<OwningFileOrDirectory>& aFilesOrDirectories)
     : mFilesOrDirectories(aFilesOrDirectories)
     , mIndex(0)
   {}
 
   NS_IMETHOD
   HasMoreElements(bool* aRetvalue) override
@@ -254,25 +253,20 @@ public:
 
     MOZ_ASSERT(mFilesOrDirectories[index].IsDirectory());
     RefPtr<Directory> directory = mFilesOrDirectories[index].GetAsDirectory();
     directory.forget(aValue);
     return NS_OK;
   }
 
 private:
-  ~SimpleEnumerator()
-  {}
-
   nsTArray<mozilla::dom::OwningFileOrDirectory> mFilesOrDirectories;
   uint32_t mIndex;
 };
 
-NS_IMPL_ISUPPORTS(SimpleEnumerator, nsISimpleEnumerator)
-
 } // namespace
 
 NS_IMETHODIMP
 nsFilePickerProxy::GetDomFileOrDirectoryEnumerator(nsISimpleEnumerator** aDomfiles)
 {
   RefPtr<SimpleEnumerator> enumerator =
     new SimpleEnumerator(mFilesOrDirectories);
   enumerator.forget(aDomfiles);
--- a/xpcom/components/nsCategoryManager.cpp
+++ b/xpcom/components/nsCategoryManager.cpp
@@ -24,17 +24,17 @@
 #include "nsQuickSort.h"
 #include "nsEnumeratorUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/ArenaAllocatorExtensions.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Services.h"
 
 #include "ManifestParser.h"
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 
 using namespace mozilla;
 class nsIComponentLoaderManager;
 
 /*
   CategoryDatabase
   contains 0 or more 1-1 mappings of string to Category
   each Category contains 0 or more 1-1 mappings of string keys to string values
@@ -46,21 +46,21 @@ class nsIComponentLoaderManager;
   going to change much ;)
 */
 
 //
 // BaseStringEnumerator is subclassed by EntryEnumerator and
 // CategoryEnumerator
 //
 class BaseStringEnumerator
-  : public nsISimpleEnumerator
+  : public nsSimpleEnumerator
   , private nsIUTF8StringEnumerator
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSISIMPLEENUMERATOR
   NS_DECL_NSIUTF8STRINGENUMERATOR
 
 protected:
   // Callback function for NS_QuickSort to sort mArray
   static int SortCallback(const void*, const void*, void*);
 
   BaseStringEnumerator()
@@ -82,18 +82,18 @@ protected:
   void Sort();
 
   const char** mArray;
   uint32_t mCount;
   uint32_t mSimpleCurItem;
   uint32_t mStringCurItem;
 };
 
-NS_IMPL_ISUPPORTS(BaseStringEnumerator, nsISimpleEnumerator,
-                  nsIUTF8StringEnumerator)
+NS_IMPL_ISUPPORTS_INHERITED(BaseStringEnumerator, nsSimpleEnumerator,
+                            nsIUTF8StringEnumerator)
 
 NS_IMETHODIMP
 BaseStringEnumerator::HasMoreElements(bool* aResult)
 {
   *aResult = (mSimpleCurItem < mCount);
 
   return NS_OK;
 }
--- a/xpcom/ds/moz.build
+++ b/xpcom/ds/moz.build
@@ -59,16 +59,17 @@ EXPORTS += [
     'nsHashKeys.h',
     'nsHashPropertyBag.h',
     'nsInterfaceHashtable.h',
     'nsJSThingHashtable.h',
     'nsMathUtils.h',
     'nsPointerHashKeys.h',
     'nsQuickSort.h',
     'nsRefPtrHashtable.h',
+    'nsSimpleEnumerator.h',
     'nsStaticAtomUtils.h',
     'nsStaticNameTable.h',
     'nsStringEnumerator.h',
     'nsSupportsPrimitives.h',
     'nsTArray-inl.h',
     'nsTArray.h',
     'nsTArrayForwardDeclare.h',
     'nsTHashtable.h',
@@ -105,16 +106,17 @@ UNIFIED_SOURCES += [
     'nsEnumeratorUtils.cpp',
     'nsHashPropertyBag.cpp',
     'nsINIParserImpl.cpp',
     'nsObserverList.cpp',
     'nsObserverService.cpp',
     'nsPersistentProperties.cpp',
     'nsProperties.cpp',
     'nsQuickSort.cpp',
+    'nsSimpleEnumerator.cpp',
     'nsStaticNameTable.cpp',
     'nsStringEnumerator.cpp',
     'nsSupportsPrimitives.cpp',
     'nsTArray.cpp',
     'nsTObserverArray.cpp',
     'nsVariant.cpp',
     'PLDHashTable.cpp',
     'Tokenizer.cpp',
--- a/xpcom/ds/nsArrayEnumerator.cpp
+++ b/xpcom/ds/nsArrayEnumerator.cpp
@@ -4,49 +4,44 @@
  * 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/. */
 
 #include "mozilla/Attributes.h"
 
 #include "nsArrayEnumerator.h"
 
 #include "nsIArray.h"
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 
 #include "nsCOMArray.h"
 #include "nsCOMPtr.h"
 #include "mozilla/OperatorNewExtensions.h"
 #include "mozilla/RefPtr.h"
 
-class nsSimpleArrayEnumerator final : public nsISimpleEnumerator
+class nsSimpleArrayEnumerator final : public nsSimpleEnumerator
 {
 public:
-  // nsISupports interface
-  NS_DECL_ISUPPORTS
-
   // nsISimpleEnumerator interface
   NS_DECL_NSISIMPLEENUMERATOR
 
   // nsSimpleArrayEnumerator methods
   explicit nsSimpleArrayEnumerator(nsIArray* aValueArray)
     : mValueArray(aValueArray)
     , mIndex(0)
   {
   }
 
 private:
-  ~nsSimpleArrayEnumerator() = default;
+  ~nsSimpleArrayEnumerator() override = default;
 
 protected:
   nsCOMPtr<nsIArray> mValueArray;
   uint32_t mIndex;
 };
 
-NS_IMPL_ISUPPORTS(nsSimpleArrayEnumerator, nsISimpleEnumerator)
-
 NS_IMETHODIMP
 nsSimpleArrayEnumerator::HasMoreElements(bool* aResult)
 {
   MOZ_ASSERT(aResult != 0, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
@@ -99,22 +94,19 @@ NS_NewArrayEnumerator(nsISimpleEnumerato
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 // enumerator implementation for nsCOMArray
 // creates a snapshot of the array in question
 // you MUST use NS_NewArrayEnumerator to create this, so that
 // allocation is done correctly
-class nsCOMArrayEnumerator final : public nsISimpleEnumerator
+class nsCOMArrayEnumerator final : public nsSimpleEnumerator
 {
 public:
-  // nsISupports interface
-  NS_DECL_ISUPPORTS
-
   // nsISimpleEnumerator interface
   NS_DECL_NSISIMPLEENUMERATOR
 
   // Use this instead of `new`.
   static nsCOMArrayEnumerator* Allocate(const nsCOMArray_base& aArray);
 
   // specialized operator to make sure we make room for mValues
   void operator delete(void* aPtr) { free(aPtr); }
@@ -123,28 +115,26 @@ private:
   // nsSimpleArrayEnumerator methods
   nsCOMArrayEnumerator()
     : mIndex(0)
     , mArraySize(0)
   {
     mValueArray[0] = nullptr;
   }
 
-  ~nsCOMArrayEnumerator(void);
+  ~nsCOMArrayEnumerator(void) override;
 
 protected:
   uint32_t mIndex;            // current position
   uint32_t mArraySize;        // size of the array
 
   // this is actually bigger
   nsISupports* mValueArray[1];
 };
 
-NS_IMPL_ISUPPORTS(nsCOMArrayEnumerator, nsISimpleEnumerator)
-
 nsCOMArrayEnumerator::~nsCOMArrayEnumerator()
 {
   // only release the entries that we haven't visited yet
   for (; mIndex < mArraySize; ++mIndex) {
     NS_IF_RELEASE(mValueArray[mIndex]);
   }
 }
 
--- a/xpcom/ds/nsEnumeratorUtils.cpp
+++ b/xpcom/ds/nsEnumeratorUtils.cpp
@@ -3,24 +3,24 @@
 /* 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/. */
 
 #include "mozilla/Attributes.h"
 
 #include "nsEnumeratorUtils.h"
 
-#include "nsISimpleEnumerator.h"
 #include "nsIStringEnumerator.h"
+#include "nsSimpleEnumerator.h"
 
 #include "nsCOMPtr.h"
 #include "mozilla/RefPtr.h"
 
 class EmptyEnumeratorImpl
-  : public nsISimpleEnumerator
+  : public nsSimpleEnumerator
   , public nsIUTF8StringEnumerator
   , public nsIStringEnumerator
 {
 public:
   EmptyEnumeratorImpl() {}
 
   // nsISupports interface
   NS_DECL_ISUPPORTS_INHERITED  // not really inherited, but no mRefCnt
@@ -47,17 +47,17 @@ EmptyEnumeratorImpl::AddRef(void)
 }
 
 NS_IMETHODIMP_(MozExternalRefCountType)
 EmptyEnumeratorImpl::Release(void)
 {
   return 1;
 }
 
-NS_IMPL_QUERY_INTERFACE(EmptyEnumeratorImpl, nsISimpleEnumerator,
+NS_IMPL_QUERY_INTERFACE_INHERITED(EmptyEnumeratorImpl, nsSimpleEnumerator,
                         nsIUTF8StringEnumerator, nsIStringEnumerator)
 
 // nsISimpleEnumerator interface
 NS_IMETHODIMP
 EmptyEnumeratorImpl::HasMoreElements(bool* aResult)
 {
   *aResult = false;
   return NS_OK;
@@ -92,45 +92,41 @@ nsresult
 NS_NewEmptyEnumerator(nsISimpleEnumerator** aResult)
 {
   *aResult = EmptyEnumeratorImpl::GetInstance();
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-class nsSingletonEnumerator final : public nsISimpleEnumerator
+class nsSingletonEnumerator final : public nsSimpleEnumerator
 {
 public:
-  NS_DECL_ISUPPORTS
-
   // nsISimpleEnumerator methods
   NS_IMETHOD HasMoreElements(bool* aResult) override;
   NS_IMETHOD GetNext(nsISupports** aResult) override;
 
   explicit nsSingletonEnumerator(nsISupports* aValue);
 
 private:
-  ~nsSingletonEnumerator();
+  ~nsSingletonEnumerator() override;
 
 protected:
   nsCOMPtr<nsISupports> mValue;
   bool mConsumed;
 };
 
 nsSingletonEnumerator::nsSingletonEnumerator(nsISupports* aValue)
   : mValue(aValue)
 {
   mConsumed = (mValue ? false : true);
 }
 
 nsSingletonEnumerator::~nsSingletonEnumerator() = default;
 
-NS_IMPL_ISUPPORTS(nsSingletonEnumerator, nsISimpleEnumerator)
-
 NS_IMETHODIMP
 nsSingletonEnumerator::HasMoreElements(bool* aResult)
 {
   MOZ_ASSERT(aResult != 0, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
@@ -164,30 +160,28 @@ NS_NewSingletonEnumerator(nsISimpleEnume
 {
   RefPtr<nsSingletonEnumerator> enumer = new nsSingletonEnumerator(aSingleton);
   enumer.forget(aResult);
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-class nsUnionEnumerator final : public nsISimpleEnumerator
+class nsUnionEnumerator final : public nsSimpleEnumerator
 {
 public:
-  NS_DECL_ISUPPORTS
-
   // nsISimpleEnumerator methods
   NS_IMETHOD HasMoreElements(bool* aResult) override;
   NS_IMETHOD GetNext(nsISupports** aResult) override;
 
   nsUnionEnumerator(nsISimpleEnumerator* aFirstEnumerator,
                     nsISimpleEnumerator* aSecondEnumerator);
 
 private:
-  ~nsUnionEnumerator();
+  ~nsUnionEnumerator() override;
 
 protected:
   nsCOMPtr<nsISimpleEnumerator> mFirstEnumerator, mSecondEnumerator;
   bool mConsumed;
   bool mAtSecond;
 };
 
 nsUnionEnumerator::nsUnionEnumerator(nsISimpleEnumerator* aFirstEnumerator,
@@ -196,18 +190,16 @@ nsUnionEnumerator::nsUnionEnumerator(nsI
   , mSecondEnumerator(aSecondEnumerator)
   , mConsumed(false)
   , mAtSecond(false)
 {
 }
 
 nsUnionEnumerator::~nsUnionEnumerator() = default;
 
-NS_IMPL_ISUPPORTS(nsUnionEnumerator, nsISimpleEnumerator)
-
 NS_IMETHODIMP
 nsUnionEnumerator::HasMoreElements(bool* aResult)
 {
   MOZ_ASSERT(aResult != 0, "null ptr");
   if (!aResult) {
     return NS_ERROR_NULL_POINTER;
   }
 
--- a/xpcom/ds/nsObserverList.cpp
+++ b/xpcom/ds/nsObserverList.cpp
@@ -3,17 +3,16 @@
 /* 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/. */
 
 #include "nsObserverList.h"
 
 #include "nsAutoPtr.h"
 #include "nsCOMArray.h"
-#include "nsISimpleEnumerator.h"
 #include "xpcpublic.h"
 
 nsresult
 nsObserverList::AddObserver(nsIObserver* anObserver, bool ownsWeak)
 {
   NS_ASSERTION(anObserver, "Null input");
 
   if (!ownsWeak) {
@@ -108,18 +107,16 @@ nsObserverList::NotifyObservers(nsISuppo
   nsCOMArray<nsIObserver> observers;
   FillObserverArray(observers);
 
   for (int32_t i = 0; i < observers.Count(); ++i) {
     observers[i]->Observe(aSubject, aTopic, someData);
   }
 }
 
-NS_IMPL_ISUPPORTS(nsObserverEnumerator, nsISimpleEnumerator)
-
 nsObserverEnumerator::nsObserverEnumerator(nsObserverList* aObserverList)
   : mIndex(0)
 {
   aObserverList->FillObserverArray(mObservers);
 }
 
 NS_IMETHODIMP
 nsObserverEnumerator::HasMoreElements(bool* aResult)
--- a/xpcom/ds/nsObserverList.h
+++ b/xpcom/ds/nsObserverList.h
@@ -9,17 +9,17 @@
 
 #include "nsISupports.h"
 #include "nsTArray.h"
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 #include "nsIObserver.h"
 #include "nsIWeakReference.h"
 #include "nsHashKeys.h"
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 #include "mozilla/Attributes.h"
 
 struct ObserverRef
 {
   ObserverRef(const ObserverRef& aO) : isWeakRef(aO.isWeakRef), ref(aO.ref) {}
   explicit ObserverRef(nsIObserver* aObserver) : isWeakRef(false), ref(aObserver) {}
   explicit ObserverRef(nsIWeakReference* aWeak) : isWeakRef(true), ref(aWeak) {}
 
@@ -70,24 +70,23 @@ public:
 
   // Like FillObserverArray(), but only for strongly held observers.
   void AppendStrongObservers(nsCOMArray<nsIObserver>& aArray);
 
 private:
   nsTArray<ObserverRef> mObservers;
 };
 
-class nsObserverEnumerator final : public nsISimpleEnumerator
+class nsObserverEnumerator final : public nsSimpleEnumerator
 {
 public:
-  NS_DECL_ISUPPORTS
   NS_DECL_NSISIMPLEENUMERATOR
 
   explicit nsObserverEnumerator(nsObserverList* aObserverList);
 
 private:
-  ~nsObserverEnumerator() {}
+  ~nsObserverEnumerator() override = default;
 
   int32_t mIndex; // Counts up from 0
   nsCOMArray<nsIObserver> mObservers;
 };
 
 #endif /* nsObserverList_h___ */
new file mode 100644
--- /dev/null
+++ b/xpcom/ds/nsSimpleEnumerator.cpp
@@ -0,0 +1,9 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#include "nsSimpleEnumerator.h"
+
+NS_IMPL_ISUPPORTS(nsSimpleEnumerator, nsISimpleEnumerator)
new file mode 100644
--- /dev/null
+++ b/xpcom/ds/nsSimpleEnumerator.h
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#ifndef nsSimpleEnumerator_h
+#define nsSimpleEnumerator_h
+
+#include "nsISimpleEnumerator.h"
+
+class nsSimpleEnumerator : public nsISimpleEnumerator
+{
+  NS_DECL_ISUPPORTS
+
+protected:
+  virtual ~nsSimpleEnumerator() = default;
+};
+
+#endif
--- a/xpcom/ds/nsStringEnumerator.cpp
+++ b/xpcom/ds/nsStringEnumerator.cpp
@@ -1,29 +1,29 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 
 #include "nsStringEnumerator.h"
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 #include "nsSupportsPrimitives.h"
 #include "mozilla/Attributes.h"
 #include "nsTArray.h"
 
 //
 // nsStringEnumerator
 //
 
 class nsStringEnumerator final
-  : public nsIStringEnumerator
+  : public nsSimpleEnumerator
+  , public nsIStringEnumerator
   , public nsIUTF8StringEnumerator
-  , public nsISimpleEnumerator
 {
 public:
   nsStringEnumerator(const nsTArray<nsString>* aArray, bool aOwnsArray)
     : mArray(aArray)
     , mIndex(0)
     , mOwnsArray(aOwnsArray)
     , mIsUnicode(true)
   {}
@@ -46,17 +46,17 @@ public:
   nsStringEnumerator(const nsTArray<nsCString>* aArray, nsISupports* aOwner)
     : mCArray(aArray)
     , mIndex(0)
     , mOwner(aOwner)
     , mOwnsArray(false)
     , mIsUnicode(false)
   {}
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIUTF8STRINGENUMERATOR
 
   // have to declare nsIStringEnumerator manually, because of
   // overlapping method names
   NS_IMETHOD GetNext(nsAString& aResult) override;
   NS_DECL_NSISIMPLEENUMERATOR
 
 private:
@@ -91,20 +91,20 @@ private:
   // that owns the array. Having a non-null value in mOwner implies
   // that mOwnsArray is false, because we rely on the real owner
   // to release the array
   nsCOMPtr<nsISupports> mOwner;
   bool mOwnsArray;
   bool mIsUnicode;
 };
 
-NS_IMPL_ISUPPORTS(nsStringEnumerator,
-                  nsIStringEnumerator,
-                  nsIUTF8StringEnumerator,
-                  nsISimpleEnumerator)
+NS_IMPL_ISUPPORTS_INHERITED(nsStringEnumerator,
+                            nsSimpleEnumerator,
+                            nsIStringEnumerator,
+                            nsIUTF8StringEnumerator)
 
 NS_IMETHODIMP
 nsStringEnumerator::HasMore(bool* aResult)
 {
   *aResult = mIndex < Count();
   return NS_OK;
 }
 
--- a/xpcom/io/nsAppFileLocationProvider.cpp
+++ b/xpcom/io/nsAppFileLocationProvider.cpp
@@ -6,17 +6,17 @@
 
 #include "nsAppFileLocationProvider.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsEnumeratorUtils.h"
 #include "nsAtom.h"
 #include "nsIFile.h"
 #include "nsString.h"
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 #include "prenv.h"
 #include "nsCRT.h"
 #if defined(MOZ_WIDGET_COCOA)
 #include <Carbon/Carbon.h>
 #include "nsILocalFileMac.h"
 #elif defined(XP_WIN)
 #include <windows.h>
 #include <shlobj.h>
@@ -370,20 +370,19 @@ nsAppFileLocationProvider::GetDefaultUse
 
   return rv;
 }
 
 //*****************************************************************************
 // nsAppFileLocationProvider::nsIDirectoryServiceProvider2
 //*****************************************************************************
 
-class nsAppDirectoryEnumerator : public nsISimpleEnumerator
+class nsAppDirectoryEnumerator : public nsSimpleEnumerator
 {
 public:
-  NS_DECL_ISUPPORTS
 
   /**
    * aKeyList is a null-terminated list of properties which are provided by aProvider
    * They do not need to be publicly defined keys.
    */
   nsAppDirectoryEnumerator(nsIDirectoryServiceProvider* aProvider,
                            const char* aKeyList[]) :
     mProvider(aProvider),
@@ -426,26 +425,18 @@ public:
 
     return *aResult ? NS_OK : NS_ERROR_FAILURE;
   }
 
 protected:
   nsCOMPtr<nsIDirectoryServiceProvider> mProvider;
   const char** mCurrentKey;
   nsCOMPtr<nsIFile> mNext;
-
-  // Virtual destructor since subclass nsPathsDirectoryEnumerator
-  // does not re-implement Release()
-  virtual ~nsAppDirectoryEnumerator()
-  {
-  }
 };
 
-NS_IMPL_ISUPPORTS(nsAppDirectoryEnumerator, nsISimpleEnumerator)
-
 /* nsPathsDirectoryEnumerator and PATH_SEPARATOR
  * are not used on MacOS/X. */
 
 #if defined(XP_WIN) /* Win32 */
 #define PATH_SEPARATOR ';'
 #else
 #define PATH_SEPARATOR ':'
 #endif
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -41,17 +41,17 @@
 #include "nsMemory.h"
 #include "nsIFile.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsLocalFile.h"
 #include "nsIComponentManager.h"
 #include "prproces.h"
 #include "nsIDirectoryEnumerator.h"
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 #include "private/pprio.h"
 #include "prlink.h"
 
 #ifdef MOZ_WIDGET_GTK
 #include "nsIGIOService.h"
 #endif
 
 #ifdef MOZ_WIDGET_COCOA
@@ -86,34 +86,35 @@ using namespace mozilla;
         if (mPath.IsEmpty())                    \
             return NS_ERROR_NOT_INITIALIZED;    \
         if (!FilePreferences::IsAllowedPath(mPath)) \
             return NS_ERROR_FILE_ACCESS_DENIED; \
     } while(0)
 
 /* directory enumerator */
 class nsDirEnumeratorUnix final
-  : public nsIDirectoryEnumerator
+  : public nsSimpleEnumerator
+  , public nsIDirectoryEnumerator
 {
 public:
   nsDirEnumeratorUnix();
 
   // nsISupports interface
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
 
   // nsISimpleEnumerator interface
   NS_DECL_NSISIMPLEENUMERATOR
 
   // nsIDirectoryEnumerator interface
   NS_DECL_NSIDIRECTORYENUMERATOR
 
   NS_IMETHOD Init(nsLocalFile* aParent, bool aIgnored);
 
 private:
-  ~nsDirEnumeratorUnix();
+  ~nsDirEnumeratorUnix() override;
 
 protected:
   NS_IMETHOD GetNextEntry();
 
   DIR*           mDir;
   struct dirent* mEntry;
   nsCString      mParentPath;
 };
@@ -124,18 +125,18 @@ nsDirEnumeratorUnix::nsDirEnumeratorUnix
 {
 }
 
 nsDirEnumeratorUnix::~nsDirEnumeratorUnix()
 {
   Close();
 }
 
-NS_IMPL_ISUPPORTS(nsDirEnumeratorUnix, nsISimpleEnumerator,
-                  nsIDirectoryEnumerator)
+NS_IMPL_ISUPPORTS_INHERITED(nsDirEnumeratorUnix, nsSimpleEnumerator,
+                            nsIDirectoryEnumerator)
 
 NS_IMETHODIMP
 nsDirEnumeratorUnix::Init(nsLocalFile* aParent,
                           bool aResolveSymlinks /*ignored*/)
 {
   nsAutoCString dirPath;
   if (NS_FAILED(aParent->GetNativePath(dirPath)) ||
       dirPath.IsEmpty()) {
@@ -1091,17 +1092,17 @@ nsLocalFile::Remove(bool aRecursive)
 
   if (isSymLink || !S_ISDIR(mCachedStat.st_mode)) {
     return NSRESULT_FOR_RETURN(unlink(mPath.get()));
   }
 
   if (aRecursive) {
     auto* dir = new nsDirEnumeratorUnix();
 
-    nsCOMPtr<nsISimpleEnumerator> dirRef(dir); // release on exit
+    RefPtr<nsSimpleEnumerator> dirRef(dir); // release on exit
 
     rv = dir->Init(this, false);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     bool more;
     while (NS_SUCCEEDED(dir->HasMoreElements(&more)) && more) {
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -12,17 +12,17 @@
 #include "nsAutoPtr.h"
 #include "nsMemory.h"
 #include "GeckoProfiler.h"
 
 #include "nsLocalFile.h"
 #include "nsIDirectoryEnumerator.h"
 #include "nsNativeCharsetUtils.h"
 
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 #include "nsIComponentManager.h"
 #include "prio.h"
 #include "private/pprio.h"  // To get PR_ImportFile
 #include "nsHashKeys.h"
 
 #include "nsString.h"
 #include "nsReadableUtils.h"
 
@@ -226,21 +226,22 @@ private:
 
     return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE;
   }
 
   // Stores the path to perform the operation on
   nsString mResolvedPath;
 };
 
-class nsDriveEnumerator : public nsIDirectoryEnumerator
+class nsDriveEnumerator : public nsSimpleEnumerator
+                        , public nsIDirectoryEnumerator
 {
 public:
   nsDriveEnumerator();
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSISIMPLEENUMERATOR
   nsresult Init();
 
   NS_IMETHOD GetNextFile(nsIFile** aResult) override
   {
     bool hasMore = false;
     nsresult rv = HasMoreElements(&hasMore);
     if (NS_FAILED(rv) || !hasMore) {
@@ -676,26 +677,27 @@ CloseDir(nsDir*& aDir)
   return isOk ? NS_OK : ConvertWinError(GetLastError());
 }
 
 //-----------------------------------------------------------------------------
 // nsDirEnumerator
 //-----------------------------------------------------------------------------
 
 class nsDirEnumerator final
-  : public nsIDirectoryEnumerator
+  : public nsSimpleEnumerator
+  , public nsIDirectoryEnumerator
 {
 private:
   ~nsDirEnumerator()
   {
     Close();
   }
 
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_ISUPPORTS_INHERITED
 
   nsDirEnumerator() : mDir(nullptr)
   {
   }
 
   nsresult Init(nsIFile* aParent)
   {
     nsAutoString filepath;
@@ -797,17 +799,17 @@ public:
   }
 
 protected:
   nsDir*             mDir;
   nsCOMPtr<nsIFile>  mParent;
   nsCOMPtr<nsIFile>  mNext;
 };
 
-NS_IMPL_ISUPPORTS(nsDirEnumerator, nsISimpleEnumerator, nsIDirectoryEnumerator)
+NS_IMPL_ISUPPORTS_INHERITED(nsDirEnumerator, nsSimpleEnumerator, nsIDirectoryEnumerator)
 
 
 //-----------------------------------------------------------------------------
 // nsLocalFile <public>
 //-----------------------------------------------------------------------------
 
 nsLocalFile::nsLocalFile()
   : mDirty(true)
@@ -3576,17 +3578,17 @@ nsLocalFile::GetHashCode(uint32_t* aResu
   // In order for short and long path names to hash to the same value we
   // always hash on the short pathname.
   EnsureShortPath();
 
   *aResult = HashString(mShortWorkingPath);
   return NS_OK;
 }
 
-NS_IMPL_ISUPPORTS(nsDriveEnumerator, nsIDirectoryEnumerator, nsISimpleEnumerator)
+NS_IMPL_ISUPPORTS_INHERITED(nsDriveEnumerator, nsSimpleEnumerator, nsIDirectoryEnumerator)
 
 nsDriveEnumerator::nsDriveEnumerator()
 {
 }
 
 nsDriveEnumerator::~nsDriveEnumerator()
 {
 }
--- a/xpfe/appshell/nsAppShellWindowEnumerator.cpp
+++ b/xpfe/appshell/nsAppShellWindowEnumerator.cpp
@@ -136,18 +136,16 @@ void nsWindowInfo::ReferenceSelf(bool in
     mHigher = this;
   }
 }
 
 //
 // nsAppShellWindowEnumerator
 //
 
-NS_IMPL_ISUPPORTS(nsAppShellWindowEnumerator, nsISimpleEnumerator)
-
 nsAppShellWindowEnumerator::nsAppShellWindowEnumerator(
     const char16_t* aTypeString,
     nsWindowMediator& aMediator) :
       mWindowMediator(&aMediator), mType(aTypeString), mCurrentPosition(nullptr)
 {
   mWindowMediator->AddEnumerator(this);
   NS_ADDREF(mWindowMediator);
 }
--- a/xpfe/appshell/nsAppShellWindowEnumerator.h
+++ b/xpfe/appshell/nsAppShellWindowEnumerator.h
@@ -4,17 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsAppShellWindowEnumerator_h
 #define nsAppShellWindowEnumerator_h
 
 #include "nsCOMPtr.h"
 #include "nsString.h"
 
-#include "nsISimpleEnumerator.h"
+#include "nsSimpleEnumerator.h"
 #include "nsIXULWindow.h"
 
 class nsWindowMediator;
 
 //
 // nsWindowInfo
 //
 
@@ -38,31 +38,29 @@ struct nsWindowInfo
   void   Unlink(bool inAge, bool inZ);
   void   ReferenceSelf(bool inAge, bool inZ);
 };
 
 //
 // virtual enumerators
 //
 
-class nsAppShellWindowEnumerator : public nsISimpleEnumerator {
+class nsAppShellWindowEnumerator : public nsSimpleEnumerator {
 
 friend class nsWindowMediator;
 
 public:
   nsAppShellWindowEnumerator(const char16_t* aTypeString,
                              nsWindowMediator& inMediator);
   NS_IMETHOD GetNext(nsISupports **retval) override = 0;
   NS_IMETHOD HasMoreElements(bool *retval) override;
 
-  NS_DECL_ISUPPORTS
-
 protected:
 
-  virtual ~nsAppShellWindowEnumerator();
+  ~nsAppShellWindowEnumerator() override;
 
   void AdjustInitialPosition();
   virtual nsWindowInfo *FindNext() = 0;
 
   void WindowRemoved(nsWindowInfo *inInfo);
 
   nsWindowMediator *mWindowMediator;
   nsString          mType;