diff --git a/docshell/base/BrowsingContextWebProgress.cpp b/docshell/base/BrowsingContextWebProgress.cpp index 2c6baf4fa8512..7c915bd6669f9 100644 --- a/docshell/base/BrowsingContextWebProgress.cpp +++ b/docshell/base/BrowsingContextWebProgress.cpp @@ -3,6 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "BrowsingContextWebProgress.h" +#include "mozilla/AlreadyAddRefed.h" +#include "mozilla/BounceTrackingState.h" #include "mozilla/dom/CanonicalBrowsingContext.h" #include "mozilla/ErrorNames.h" #include "mozilla/Logging.h" @@ -12,6 +14,7 @@ #include "nsPrintfCString.h" #include "nsIChannel.h" #include "xptinfo.h" +#include "mozilla/RefPtr.h" namespace mozilla { namespace dom { @@ -164,6 +167,14 @@ void BrowsingContextWebProgress::ContextReplaced( mCurrentBrowsingContext = aNewContext; } +already_AddRefed +BrowsingContextWebProgress::GetBounceTrackingState() { + if (!mBounceTrackingState) { + mBounceTrackingState = BounceTrackingState::GetOrCreate(this); + } + return do_AddRef(mBounceTrackingState); +} + //////////////////////////////////////////////////////////////////////////////// // nsIWebProgressListener diff --git a/docshell/base/BrowsingContextWebProgress.h b/docshell/base/BrowsingContextWebProgress.h index b39fb2545d19e..81610886b9600 100644 --- a/docshell/base/BrowsingContextWebProgress.h +++ b/docshell/base/BrowsingContextWebProgress.h @@ -10,6 +10,7 @@ #include "nsTObserverArray.h" #include "nsWeakReference.h" #include "nsCycleCollectionParticipant.h" +#include "mozilla/BounceTrackingState.h" namespace mozilla::dom { @@ -61,6 +62,8 @@ class BrowsingContextWebProgress final : public nsIWebProgress, void SetLoadType(uint32_t aLoadType) { mLoadType = aLoadType; } + already_AddRefed GetBounceTrackingState(); + private: virtual ~BrowsingContextWebProgress(); @@ -91,6 +94,8 @@ class BrowsingContextWebProgress final : public nsIWebProgress, // discarded while loading a document to avoid noise caused by process // switches. bool mIsLoadingDocument = false; + + RefPtr mBounceTrackingState; }; } // namespace mozilla::dom diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp index 2fb81ec049d8f..31c97e2680530 100644 --- a/docshell/base/CanonicalBrowsingContext.cpp +++ b/docshell/base/CanonicalBrowsingContext.cpp @@ -3034,6 +3034,14 @@ CanonicalBrowsingContext::GetMostRecentLoadingSessionHistoryEntry() { return entry.forget(); } +already_AddRefed +CanonicalBrowsingContext::GetBounceTrackingState() { + if (!mWebProgress) { + return nullptr; + } + return mWebProgress->GetBounceTrackingState(); +} + NS_IMPL_CYCLE_COLLECTION_CLASS(CanonicalBrowsingContext) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(CanonicalBrowsingContext, diff --git a/docshell/base/CanonicalBrowsingContext.h b/docshell/base/CanonicalBrowsingContext.h index ff22edcbbcd33..244f95e36e8a5 100644 --- a/docshell/base/CanonicalBrowsingContext.h +++ b/docshell/base/CanonicalBrowsingContext.h @@ -37,6 +37,7 @@ class nsITimer; namespace mozilla { enum class CallState; +class BounceTrackingState; namespace embedding { class PrintData; @@ -381,6 +382,8 @@ class CanonicalBrowsingContext final : public BrowsingContext { already_AddRefed GetMostRecentLoadingSessionHistoryEntry(); + already_AddRefed GetBounceTrackingState(); + protected: // Called when the browsing context is being discarded. void CanonicalDiscard();