tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 1ae86c8f91d84cbe6a84fa47626bb991d2974d95
parent f58b6480b80aaafdc44e48c63ca840cbc63f0843
Author: Jens Stutte <jstutte@mozilla.com>
Date:   Fri, 28 Nov 2025 09:42:00 +0000

Bug 2002527 - Have a dedicated observer object in BackupUIParent. r=mconley

Differential Revision: https://phabricator.services.mozilla.com/D274139

Diffstat:
Mbrowser/components/backup/actors/BackupUIParent.sys.mjs | 21++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/browser/components/backup/actors/BackupUIParent.sys.mjs b/browser/components/backup/actors/BackupUIParent.sys.mjs @@ -34,6 +34,13 @@ export class BackupUIParent extends JSWindowActorParent { #bs; /** + * Observer for "backup-service-status-updated" notifications. + * We want each BackupUIParent actor instance to be notified separately and + * to forward the state to its child. + */ + #obs; + + /** * Create a BackupUIParent instance. If a BackupUIParent is instantiated * before BrowserGlue has a chance to initialize the BackupService, this * constructor will cause it to initialize first. @@ -44,6 +51,13 @@ export class BackupUIParent extends JSWindowActorParent { // about:preferences before the service has had a chance to init itself // via BrowserGlue. this.#bs = lazy.BackupService.init(); + + // Define the observer function to capture our this. + this.#obs = (_subject, topic) => { + if (topic == "backup-service-status-updated") { + this.sendState(); + } + }; } /** @@ -51,7 +65,7 @@ export class BackupUIParent extends JSWindowActorParent { */ actorCreated() { this.#bs.addEventListener("BackupService:StateUpdate", this); - Services.obs.addObserver(this.sendState, "backup-service-status-updated"); + Services.obs.addObserver(this.#obs, "backup-service-status-updated"); // Note that loadEncryptionState is an async function. // This function is no-op if the encryption state was already loaded. this.#bs.loadEncryptionState(); @@ -62,10 +76,7 @@ export class BackupUIParent extends JSWindowActorParent { */ didDestroy() { this.#bs.removeEventListener("BackupService:StateUpdate", this); - Services.obs.removeObserver( - this.sendState, - "backup-service-status-updated" - ); + Services.obs.removeObserver(this.#obs, "backup-service-status-updated"); } /**