Bug 1434768 - Part 5: Add EvictLocalContentViewers to ChildSHistory, r=bz
authorNika Layzell <nika@thelayzells.com>
Mon, 12 Feb 2018 15:47:06 -0500
changeset 412757 7ae896b5ad633c584e7f2ad56013605c813adf72
parent 412756 0171a483cd7b062b797b1773812c8ce0a0e0ae3c
child 412758 0fd1326c744bbf71cce464674593683c81d7835b
push id33818
push userapavel@mozilla.com
push dateWed, 11 Apr 2018 14:36:40 +0000
treeherdermozilla-central@cfe6399e142c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1434768
milestone61.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 1434768 - Part 5: Add EvictLocalContentViewers to ChildSHistory, r=bz
docshell/base/nsDocShell.cpp
docshell/build/nsDocShellModule.cpp
docshell/shistory/ChildSHistory.cpp
docshell/shistory/ChildSHistory.h
docshell/shistory/nsISHistory.idl
docshell/shistory/nsISHistoryInternal.idl
dom/base/nsFrameLoader.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -5490,17 +5490,17 @@ nsDocShell::Destroy()
     mScriptGlobal->DetachFromDocShell();
     mScriptGlobal = nullptr;
   }
 
   if (mSessionHistory) {
     // We want to destroy these content viewers now rather than
     // letting their destruction wait for the session history
     // entries to get garbage collected.  (Bug 488394)
-    mSessionHistory->LegacySHistoryInternal()->EvictAllContentViewers();
+    mSessionHistory->EvictLocalContentViewers();
     mSessionHistory = nullptr;
   }
 
   SetTreeOwner(nullptr);
 
   mOnePermittedSandboxedNavigator = nullptr;
 
   // required to break ref cycle
--- a/docshell/build/nsDocShellModule.cpp
+++ b/docshell/build/nsDocShellModule.cpp
@@ -95,17 +95,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDBusHan
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalSharingAppService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalURLHandlerService)
 #endif
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ContentHandlerService, Init)
 
 // session history
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHEntry)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHTransaction)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHistory)
 
 #ifndef MOZ_PLACES
 // download history
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadHistory)
 #endif
 
 NS_DEFINE_NAMED_CID(NS_DOCSHELL_CID);
 NS_DEFINE_NAMED_CID(NS_DEFAULTURIFIXUP_CID);
@@ -123,18 +122,16 @@ NS_DEFINE_NAMED_CID(NS_LOCALHANDLERAPP_C
 NS_DEFINE_NAMED_CID(NS_DBUSHANDLERAPP_CID);
 #endif
 #if defined(MOZ_WIDGET_ANDROID)
 NS_DEFINE_NAMED_CID(NS_EXTERNALSHARINGAPPSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_EXTERNALURLHANDLERSERVICE_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_SHENTRY_CID);
 NS_DEFINE_NAMED_CID(NS_SHTRANSACTION_CID);
-NS_DEFINE_NAMED_CID(NS_SHISTORY_CID);
-NS_DEFINE_NAMED_CID(NS_SHISTORY_INTERNAL_CID);
 #ifndef MOZ_PLACES
 NS_DEFINE_NAMED_CID(NS_DOWNLOADHISTORY_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_CONTENTHANDLERSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_LOADCONTEXT_CID);
 NS_DEFINE_NAMED_CID(NS_PRIVATELOADCONTEXT_CID);
 
 const mozilla::Module::CIDEntry kDocShellCIDs[] = {
@@ -156,18 +153,16 @@ const mozilla::Module::CIDEntry kDocShel
   { &kNS_DBUSHANDLERAPP_CID, false, nullptr, nsDBusHandlerAppConstructor },
 #endif
 #if defined(MOZ_WIDGET_ANDROID)
   { &kNS_EXTERNALSHARINGAPPSERVICE_CID, false, nullptr, nsExternalSharingAppServiceConstructor },
   { &kNS_EXTERNALURLHANDLERSERVICE_CID, false, nullptr, nsExternalURLHandlerServiceConstructor },
 #endif
   { &kNS_SHENTRY_CID, false, nullptr, nsSHEntryConstructor },
   { &kNS_SHTRANSACTION_CID, false, nullptr, nsSHTransactionConstructor },
-  { &kNS_SHISTORY_CID, false, nullptr, nsSHistoryConstructor },
-  { &kNS_SHISTORY_INTERNAL_CID, false, nullptr, nsSHistoryConstructor },
 #ifndef MOZ_PLACES
   { &kNS_DOWNLOADHISTORY_CID, false, nullptr, nsDownloadHistoryConstructor },
 #endif
   { &kNS_LOADCONTEXT_CID, false, nullptr, mozilla::CreateTestLoadContext },
   { &kNS_PRIVATELOADCONTEXT_CID, false, nullptr, mozilla::CreatePrivateTestLoadContext },
   { nullptr }
 };
 
@@ -218,18 +213,16 @@ const mozilla::Module::ContractIDEntry k
   { NS_DBUSHANDLERAPP_CONTRACTID, &kNS_DBUSHANDLERAPP_CID },
 #endif
 #if defined(MOZ_WIDGET_ANDROID)
   { NS_EXTERNALSHARINGAPPSERVICE_CONTRACTID, &kNS_EXTERNALSHARINGAPPSERVICE_CID },
   { NS_EXTERNALURLHANDLERSERVICE_CONTRACTID, &kNS_EXTERNALURLHANDLERSERVICE_CID },
 #endif
   { NS_SHENTRY_CONTRACTID, &kNS_SHENTRY_CID },
   { NS_SHTRANSACTION_CONTRACTID, &kNS_SHTRANSACTION_CID },
-  { NS_SHISTORY_CONTRACTID, &kNS_SHISTORY_CID },
-  { NS_SHISTORY_INTERNAL_CONTRACTID, &kNS_SHISTORY_INTERNAL_CID },
 #ifndef MOZ_PLACES
   { NS_DOWNLOADHISTORY_CONTRACTID, &kNS_DOWNLOADHISTORY_CID },
 #endif
   { NS_LOADCONTEXT_CONTRACTID, &kNS_LOADCONTEXT_CID },
   { NS_PRIVATELOADCONTEXT_CONTRACTID, &kNS_PRIVATELOADCONTEXT_CID },
   { nullptr }
 };
 
--- a/docshell/shistory/ChildSHistory.cpp
+++ b/docshell/shistory/ChildSHistory.cpp
@@ -70,16 +70,22 @@ ChildSHistory::Go(int32_t aOffset, Error
   index += aOffset;
   if (!index.isValid()) {
     aRv.Throw(NS_ERROR_FAILURE);
     return;
   }
   aRv = mHistory->GotoIndex(index.value());
 }
 
+void
+ChildSHistory::EvictLocalContentViewers()
+{
+  mHistory->EvictAllContentViewers();
+}
+
 nsISHistory*
 ChildSHistory::LegacySHistory()
 {
   return mHistory;
 }
 
 nsISHistoryInternal*
 ChildSHistory::LegacySHistoryInternal()
--- a/docshell/shistory/ChildSHistory.h
+++ b/docshell/shistory/ChildSHistory.h
@@ -61,16 +61,21 @@ public:
   /**
    * The CanGo and Go methods are called with an offset from the current index.
    * Positive numbers go forward in history, while negative numbers go
    * backwards.
    */
   bool CanGo(int32_t aOffset);
   void Go(int32_t aOffset, ErrorResult& aRv);
 
+  /**
+   * Evicts all content viewers within the current process.
+   */
+  void EvictLocalContentViewers();
+
   nsISHistory* LegacySHistory();
   nsISHistoryInternal* LegacySHistoryInternal();
   nsIWebNavigation* LegacySHistoryWebNav();
 
   ParentSHistory* GetParentIfSameProcess();
 
 private:
   virtual ~ChildSHistory();
--- a/docshell/shistory/nsISHistory.idl
+++ b/docshell/shistory/nsISHistory.idl
@@ -14,24 +14,16 @@ interface nsISimpleEnumerator;
  * 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
  * it in the nsIWebNavigation object.
  * This interface is accessible from javascript.
  */
- 
-
-%{C++
-#define NS_SHISTORY_CID \
-{0x7b807041, 0xe60a, 0x4384, {0x93, 0x5f, 0xaf, 0x30, 0x61, 0xd8, 0xb8, 0x15}}
-
-#define NS_SHISTORY_CONTRACTID "@mozilla.org/browser/shistory;1"
-%}
 
 [scriptable, uuid(7b807041-e60a-4384-935f-af3061d8b815)]
 interface nsISHistory: nsISupports
 {
   /**
    * The size of the window of SHEntries which can have alive viewers in the
    * bfcache around the currently active SHEntry.
    *
--- a/docshell/shistory/nsISHistoryInternal.idl
+++ b/docshell/shistory/nsISHistoryInternal.idl
@@ -9,22 +9,16 @@ interface nsIBFCacheEntry;
 interface nsISHContainer;
 interface nsISHEntry;
 interface nsISHistoryListener;
 interface nsISHTransaction;
 interface nsIDocShell;
 interface nsIURI;
 
 %{C++
-#define NS_SHISTORY_INTERNAL_CID \
-{ 0x3dfb2f54, 0x378d, 0x4d3c, \
-  { 0xa9, 0xf9, 0x95, 0xdd, 0x26, 0x73, 0x24, 0x8c } }
-
-#define NS_SHISTORY_INTERNAL_CONTRACTID "@mozilla.org/browser/shistory-internal;1"
-
 #include "nsTArrayForwardDeclare.h"
 %}
 
 [ref] native nsDocshellIDArray(nsTArray<nsID>);
 
 [scriptable, uuid(3dfb2f54-378d-4d3c-a9f9-95dd2673248c)]
 interface nsISHistoryInternal: nsISupports
 {
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -1606,20 +1606,20 @@ nsFrameLoader::SwapWithOtherLoader(nsFra
   // to ourselves to make sure we don't die while we overwrite our reference to
   // ourself.
   RefPtr<nsFrameLoader> kungFuDeathGrip(this);
   aThisOwner->InternalSetFrameLoader(aOther);
   aOtherOwner->InternalSetFrameLoader(kungFuDeathGrip);
 
   // Drop any cached content viewers in the two session histories.
   if (ourHistory) {
-    ourHistory->LegacySHistoryInternal()->EvictAllContentViewers();
+    ourHistory->EvictLocalContentViewers();
   }
   if (otherHistory) {
-    otherHistory->LegacySHistoryInternal()->EvictAllContentViewers();
+    otherHistory->EvictLocalContentViewers();
   }
 
   NS_ASSERTION(ourFrame == ourContent->GetPrimaryFrame() &&
                otherFrame == otherContent->GetPrimaryFrame(),
                "changed primary frame");
 
   ourFrameFrame->EndSwapDocShells(otherFrame);