summaryrefslogtreecommitdiffstats
path: root/dom/base/PlacesObservers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/PlacesObservers.cpp')
-rw-r--r--dom/base/PlacesObservers.cpp22
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