diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /dom/base/PlacesObservers.cpp | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dom/base/PlacesObservers.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/dom/base/PlacesObservers.cpp b/dom/base/PlacesObservers.cpp index bb92e4a072..b5211733ea 100644 --- a/dom/base/PlacesObservers.cpp +++ b/dom/base/PlacesObservers.cpp @@ -22,7 +22,7 @@ struct Flagged { Flagged(const Flagged& aOther) = default; ~Flagged() = default; - uint32_t flags; + uint32_t flags = 0; T value; }; @@ -123,6 +123,14 @@ MOZ_CAN_RUN_SCRIPT void CallListeners( } } +StaticRefPtr<PlacesEventCounts> PlacesObservers::sCounts; +static void EnsureCountsInitialized() { + if (!PlacesObservers::sCounts) { + PlacesObservers::sCounts = new PlacesEventCounts(); + ClearOnShutdown(&PlacesObservers::sCounts); + } +} + void PlacesObservers::AddListener(GlobalObject& aGlobal, const nsTArray<PlacesEventType>& aEventTypes, PlacesEventCallback& aCallback, @@ -304,7 +312,11 @@ void PlacesObservers::NotifyListeners( if (aEvents.Length() == 0) { return; } - + EnsureCountsInitialized(); + for (const auto& event : aEvents) { + DebugOnly<nsresult> rv = sCounts->Increment(event->Type()); + MOZ_ASSERT(NS_SUCCEEDED(rv)); + } #ifdef DEBUG if (!gNotificationQueue.IsEmpty()) { NS_WARNING( @@ -389,4 +401,10 @@ void PlacesObservers::NotifyNext() { } } +already_AddRefed<PlacesEventCounts> PlacesObservers::Counts( + const GlobalObject& global) { + EnsureCountsInitialized(); + return do_AddRef(sCounts); +}; + } // namespace mozilla::dom |