Skip to content

Commit

Permalink
Bug 1839916 - Update BrowsingContextWebProgress to hold BounceTrackin…
Browse files Browse the repository at this point in the history
…gState objects. r=bvandersloot,nika

Differential Revision: https://phabricator.services.mozilla.com/D182342
  • Loading branch information
Trikolon committed Jul 18, 2023
1 parent 49ea39b commit 56ff601
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docshell/base/BrowsingContextWebProgress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -12,6 +14,7 @@
#include "nsPrintfCString.h"
#include "nsIChannel.h"
#include "xptinfo.h"
#include "mozilla/RefPtr.h"

namespace mozilla {
namespace dom {
Expand Down Expand Up @@ -164,6 +167,14 @@ void BrowsingContextWebProgress::ContextReplaced(
mCurrentBrowsingContext = aNewContext;
}

already_AddRefed<BounceTrackingState>
BrowsingContextWebProgress::GetBounceTrackingState() {
if (!mBounceTrackingState) {
mBounceTrackingState = BounceTrackingState::GetOrCreate(this);
}
return do_AddRef(mBounceTrackingState);
}

////////////////////////////////////////////////////////////////////////////////
// nsIWebProgressListener

Expand Down
5 changes: 5 additions & 0 deletions docshell/base/BrowsingContextWebProgress.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "nsTObserverArray.h"
#include "nsWeakReference.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/BounceTrackingState.h"

namespace mozilla::dom {

Expand Down Expand Up @@ -61,6 +62,8 @@ class BrowsingContextWebProgress final : public nsIWebProgress,

void SetLoadType(uint32_t aLoadType) { mLoadType = aLoadType; }

already_AddRefed<BounceTrackingState> GetBounceTrackingState();

private:
virtual ~BrowsingContextWebProgress();

Expand Down Expand Up @@ -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<mozilla::BounceTrackingState> mBounceTrackingState;
};

} // namespace mozilla::dom
Expand Down
8 changes: 8 additions & 0 deletions docshell/base/CanonicalBrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3034,6 +3034,14 @@ CanonicalBrowsingContext::GetMostRecentLoadingSessionHistoryEntry() {
return entry.forget();
}

already_AddRefed<BounceTrackingState>
CanonicalBrowsingContext::GetBounceTrackingState() {
if (!mWebProgress) {
return nullptr;
}
return mWebProgress->GetBounceTrackingState();
}

NS_IMPL_CYCLE_COLLECTION_CLASS(CanonicalBrowsingContext)

NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(CanonicalBrowsingContext,
Expand Down
3 changes: 3 additions & 0 deletions docshell/base/CanonicalBrowsingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class nsITimer;

namespace mozilla {
enum class CallState;
class BounceTrackingState;

namespace embedding {
class PrintData;
Expand Down Expand Up @@ -381,6 +382,8 @@ class CanonicalBrowsingContext final : public BrowsingContext {

already_AddRefed<nsISHEntry> GetMostRecentLoadingSessionHistoryEntry();

already_AddRefed<BounceTrackingState> GetBounceTrackingState();

protected:
// Called when the browsing context is being discarded.
void CanonicalDiscard();
Expand Down

0 comments on commit 56ff601

Please sign in to comment.