Bug 1484944 - Remove nsSHEnumerator. r=qdot
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 21 Aug 2018 19:52:19 +1000
changeset 487829 a24fde0f296e0351d6ce51354438bdbf8941bebb
parent 487828 7323a50a7eede38e729ae85658bbaa8bc53bbd6a
child 487830 737a89a8edb7d9b46215d8688ac18275e38dde34
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1484944
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 1484944 - Remove nsSHEnumerator. r=qdot
docshell/shistory/nsISHistory.idl
docshell/shistory/nsSHistory.cpp
docshell/shistory/nsSHistory.h
--- a/docshell/shistory/nsISHistory.idl
+++ b/docshell/shistory/nsISHistory.idl
@@ -2,17 +2,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 "nsISupports.idl"
 
 interface nsISHEntry;
 interface nsISHistoryListener;
-interface nsISimpleEnumerator;
 
 /**
  * An interface to the primary properties of the Session History
  * component. In an embedded browser environment, the nsIWebBrowser
  * object creates an instance of session history for each open window.
  * A handle to the session history object can be obtained from
  * nsIWebNavigation. In a non-embedded situation, the  owner of the
  * session history component must create a instance of it and set
@@ -127,39 +126,16 @@ interface nsISHistory: nsISupports
    *
    * @note                    A listener object must implement 
    *                          nsISHistoryListener and nsSupportsWeakReference
    * @see nsISHistoryListener
    * @see nsSupportsWeakReference
    */ 
    void removeSHistoryListener(in nsISHistoryListener aListener);
 
-  /**
-   * Called to obtain a enumerator for all the  documents stored in
-   * session history. The enumerator object thus returned by this method
-   * can be traversed using nsISimpleEnumerator. 
-   *
-   * @note  To access individual history entries of the enumerator, perform the
-   *        following steps:
-   *        1) Call nsISHistory->GetSHistoryEnumerator() to obtain handle 
-   *           the nsISimpleEnumerator object.
-   *        2) Use nsISimpleEnumerator->GetNext() on the object returned
-   *           by step #1 to obtain handle to the next object in the list. 
-   *           The object returned by this step is of type nsISupports.
-   *        3) Perform a QueryInterface on the object returned by step #2 
-   *           to nsISHEntry.
-   *        4) Use nsISHEntry to access properties of each history entry. 
-   *
-   * @see nsISimpleEnumerator
-   * @see nsISHEntry
-   * @see QueryInterface()
-   * @see do_QueryInterface()
-   */
-   readonly attribute nsISimpleEnumerator SHistoryEnumerator;
-
    void reloadCurrentEntry();
 
    /**
    * Called to obtain the index to a given history entry.
    *
    * @param aEntry            The entry to obtain the index of.
    *
    * @return                  <code>NS_OK</code> index for the history entry
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -2105,60 +2105,8 @@ nsSHistory::SetRootDocShell(nsIDocShell*
       this,
       mozilla::Preferences::GetUint(CONTENT_VIEWER_TIMEOUT_SECONDS,
                                     CONTENT_VIEWER_TIMEOUT_SECONDS_DEFAULT),
       global->EventTargetFor(mozilla::TaskCategory::Other));
   }
 
   return NS_OK;
 }
-
-NS_IMETHODIMP
-nsSHistory::GetSHistoryEnumerator(nsISimpleEnumerator** aEnumerator)
-{
-  NS_ENSURE_ARG_POINTER(aEnumerator);
-  RefPtr<nsSHEnumerator> iterator = new nsSHEnumerator(this);
-  iterator.forget(aEnumerator);
-  return NS_OK;
-}
-
-nsSHEnumerator::nsSHEnumerator(nsSHistory* aSHistory) : mIndex(-1)
-{
-  mSHistory = aSHistory;
-}
-
-nsSHEnumerator::~nsSHEnumerator()
-{
-  mSHistory = nullptr;
-}
-
-NS_IMPL_ISUPPORTS(nsSHEnumerator, nsISimpleEnumerator)
-
-NS_IMETHODIMP
-nsSHEnumerator::HasMoreElements(bool* aReturn)
-{
-  int32_t cnt;
-  *aReturn = false;
-  mSHistory->GetCount(&cnt);
-  if (mIndex >= -1 && mIndex < (cnt - 1)) {
-    *aReturn = true;
-  }
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsSHEnumerator::GetNext(nsISupports** aItem)
-{
-  NS_ENSURE_ARG_POINTER(aItem);
-  int32_t cnt = 0;
-
-  nsresult result = NS_ERROR_FAILURE;
-  mSHistory->GetCount(&cnt);
-  if (mIndex < (cnt - 1)) {
-    mIndex++;
-    nsCOMPtr<nsISHEntry> hEntry;
-    result = mSHistory->GetEntryAtIndex(mIndex, false, getter_AddRefs(hEntry));
-    if (hEntry) {
-      result = CallQueryInterface(hEntry, aItem);
-    }
-  }
-  return result;
-}
--- a/docshell/shistory/nsSHistory.h
+++ b/docshell/shistory/nsSHistory.h
@@ -17,17 +17,16 @@
 #include "nsTObserverArray.h"
 #include "nsWeakReference.h"
 
 #include "mozilla/LinkedList.h"
 #include "mozilla/UniquePtr.h"
 
 class nsIDocShell;
 class nsDocShell;
-class nsSHEnumerator;
 class nsSHistoryObserver;
 class nsISHEntry;
 class nsISHTransaction;
 
 class nsSHistory final : public mozilla::LinkedListElement<nsSHistory>,
                          public nsISHistory,
                          public nsISHistoryInternal,
                          public nsIWebNavigation,
@@ -128,17 +127,16 @@ public:
   // is passed to the callback.
   static nsresult WalkHistoryEntries(nsISHEntry* aRootEntry,
                                      nsDocShell* aRootShell,
                                      WalkHistoryEntriesFunc aCallback,
                                      void* aData);
 
 private:
   virtual ~nsSHistory();
-  friend class nsSHEnumerator;
   friend class nsSHistoryObserver;
 
   nsresult GetTransactionAtIndex(int32_t aIndex, nsISHTransaction** aResult);
   nsresult LoadDifferingEntries(nsISHEntry* aPrevEntry, nsISHEntry* aNextEntry,
                                 nsIDocShell* aRootDocShell, long aLoadType,
                                 bool& aDifferenceFound);
   nsresult InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
                         long aLoadType);
@@ -187,32 +185,15 @@ private:
 
   // Weak reference. Do not refcount this.
   nsIDocShell* mRootDocShell;
 
   // Max viewers allowed total, across all SHistory objects
   static int32_t sHistoryMaxTotalViewers;
 };
 
-class nsSHEnumerator : public nsISimpleEnumerator
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSISIMPLEENUMERATOR
-
-  explicit nsSHEnumerator(nsSHistory* aHistory);
-
-protected:
-  friend class nsSHistory;
-  virtual ~nsSHEnumerator();
-
-private:
-  int32_t mIndex;
-  nsSHistory* mSHistory;
-};
-
 inline nsISupports*
 ToSupports(nsSHistory* aObj)
 {
   return static_cast<nsISHistory*>(aObj);
 }
 
 #endif /* nsSHistory */