Bug 1839916 - Update BrowsingContextWebProgress to hold BounceTrackingState objects. r=bvandersloot,nika

Differential Revision: https://phabricator.services.mozilla.com/D182342
This commit is contained in:
Paul Zuehlcke 2023-07-17 17:54:50 +00:00
Родитель eb2307620b
Коммит d26a3d493b
4 изменённых файлов: 27 добавлений и 0 удалений

Просмотреть файл

@ -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<BounceTrackingState>
BrowsingContextWebProgress::GetBounceTrackingState() {
if (!mBounceTrackingState) {
mBounceTrackingState = BounceTrackingState::GetOrCreate(this);
}
return do_AddRef(mBounceTrackingState);
}
////////////////////////////////////////////////////////////////////////////////
// nsIWebProgressListener

Просмотреть файл

@ -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<BounceTrackingState> 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<mozilla::BounceTrackingState> mBounceTrackingState;
};
} // namespace mozilla::dom

Просмотреть файл

@ -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,

Просмотреть файл

@ -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<nsISHEntry> GetMostRecentLoadingSessionHistoryEntry();
already_AddRefed<BounceTrackingState> GetBounceTrackingState();
protected:
// Called when the browsing context is being discarded.
void CanonicalDiscard();