Bug 1875502 - Update UpdateServiceStub consumers r=nalexander,application-update-reviewers,firefox-desktop-core-reviewers

The earlier patches in this stack (a) made it possible to await on the stub to complete and (b) ensured that the update system initiates properly regardless of when and if the update service stub is invoked. This allows us to remove explict stub invocations in some cases and to have the await on the results in others.

Differential Revision: https://phabricator.services.mozilla.com/D209129
This commit is contained in:
Robin Steuber
2024-05-16 20:01:54 +00:00
parent a084c0b8b0
commit e7cd6bcb76
3 changed files with 18 additions and 24 deletions

View File

@@ -111,6 +111,12 @@ if (AppConstants.MOZ_UPDATER) {
ChromeUtils.defineESModuleGetters(lazy, {
UpdateListener: "resource://gre/modules/UpdateListener.sys.mjs",
});
XPCOMUtils.defineLazyServiceGetters(lazy, {
UpdateServiceStub: [
"@mozilla.org/updates/update-service-stub;1",
"nsIApplicationUpdateServiceStub",
],
});
}
if (AppConstants.MOZ_UPDATE_AGENT) {
ChromeUtils.defineESModuleGetters(lazy, {
@@ -3028,16 +3034,11 @@ BrowserGlue.prototype = {
name: "BackgroundUpdate",
condition: AppConstants.MOZ_UPDATE_AGENT,
task: async () => {
// Never in automation! This is close to
// `UpdateService.disabledForTesting`, but without creating the
// service, which can perform a good deal of I/O in order to log its
// state. Since this is in the startup path, we avoid all of that.
let disabledForTesting =
(Cu.isInAutomation ||
lazy.Marionette.running ||
lazy.RemoteAgent.running) &&
Services.prefs.getBoolPref("app.update.disabledForTesting", false);
if (!disabledForTesting) {
// Never in automation!
if (
AppConstants.MOZ_UPDATER &&
!lazy.UpdateServiceStub.updateDisabledForTesting
) {
try {
await lazy.BackgroundUpdate.scheduleFirefoxMessagingSystemTargetingSnapshotting();
} catch (e) {