summaryrefslogtreecommitdiffstats
path: root/dom/notification/new
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /dom/notification/new
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/notification/new')
-rw-r--r--dom/notification/new/NotificationDB.sys.mjs25
1 files changed, 24 insertions, 1 deletions
diff --git a/dom/notification/new/NotificationDB.sys.mjs b/dom/notification/new/NotificationDB.sys.mjs
index b607fdd234..d7e1d998c1 100644
--- a/dom/notification/new/NotificationDB.sys.mjs
+++ b/dom/notification/new/NotificationDB.sys.mjs
@@ -10,6 +10,7 @@ function debug(s) {
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
+ AsyncShutdown: "resource://gre/modules/AsyncShutdown.sys.mjs",
KeyValueService: "resource://gre/modules/kvstore.sys.mjs",
});
@@ -37,6 +38,11 @@ var NotificationDB = {
// of the load via its resolution.
_loadPromise: null,
+ // A promise that resolves once the ongoing task queue has been drained.
+ // The value will be reset when the queue starts again.
+ _queueDrainedPromise: null,
+ _queueDrainedPromiseResolve: null,
+
init() {
if (this._shutdownInProgress) {
return;
@@ -47,6 +53,13 @@ var NotificationDB = {
Services.obs.addObserver(this, "xpcom-shutdown");
this.registerListeners();
+
+ // This assumes that nothing will queue a new task at profile-change-teardown phase,
+ // potentially replacing the _queueDrainedPromise if there was no existing task run.
+ lazy.AsyncShutdown.profileChangeTeardown.addBlocker(
+ "NotificationDB: Need to make sure that all notification messages are processed",
+ () => this._queueDrainedPromise
+ );
},
registerListeners() {
@@ -61,7 +74,7 @@ var NotificationDB = {
}
},
- observe(aSubject, aTopic, aData) {
+ observe(aSubject, aTopic) {
if (DEBUG) {
debug("Topic: " + aTopic);
}
@@ -261,6 +274,9 @@ var NotificationDB = {
debug("Task queue was not running, starting now...");
}
this.runNextTask();
+ this._queueDrainedPromise = new Promise(resolve => {
+ this._queueDrainedPromiseResolve = resolve;
+ });
}
return promise;
@@ -272,6 +288,13 @@ var NotificationDB = {
debug("No more tasks to run, queue depleted");
}
this.runningTask = null;
+ if (this._queueDrainedPromiseResolve) {
+ this._queueDrainedPromiseResolve();
+ } else if (DEBUG) {
+ debug(
+ "_queueDrainedPromiseResolve was null somehow, no promise to resolve"
+ );
+ }
return;
}
this.runningTask = this.tasks.shift();