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:
@@ -111,6 +111,12 @@ if (AppConstants.MOZ_UPDATER) {
|
|||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
UpdateListener: "resource://gre/modules/UpdateListener.sys.mjs",
|
UpdateListener: "resource://gre/modules/UpdateListener.sys.mjs",
|
||||||
});
|
});
|
||||||
|
XPCOMUtils.defineLazyServiceGetters(lazy, {
|
||||||
|
UpdateServiceStub: [
|
||||||
|
"@mozilla.org/updates/update-service-stub;1",
|
||||||
|
"nsIApplicationUpdateServiceStub",
|
||||||
|
],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (AppConstants.MOZ_UPDATE_AGENT) {
|
if (AppConstants.MOZ_UPDATE_AGENT) {
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
@@ -3028,16 +3034,11 @@ BrowserGlue.prototype = {
|
|||||||
name: "BackgroundUpdate",
|
name: "BackgroundUpdate",
|
||||||
condition: AppConstants.MOZ_UPDATE_AGENT,
|
condition: AppConstants.MOZ_UPDATE_AGENT,
|
||||||
task: async () => {
|
task: async () => {
|
||||||
// Never in automation! This is close to
|
// Never in automation!
|
||||||
// `UpdateService.disabledForTesting`, but without creating the
|
if (
|
||||||
// service, which can perform a good deal of I/O in order to log its
|
AppConstants.MOZ_UPDATER &&
|
||||||
// state. Since this is in the startup path, we avoid all of that.
|
!lazy.UpdateServiceStub.updateDisabledForTesting
|
||||||
let disabledForTesting =
|
) {
|
||||||
(Cu.isInAutomation ||
|
|
||||||
lazy.Marionette.running ||
|
|
||||||
lazy.RemoteAgent.running) &&
|
|
||||||
Services.prefs.getBoolPref("app.update.disabledForTesting", false);
|
|
||||||
if (!disabledForTesting) {
|
|
||||||
try {
|
try {
|
||||||
await lazy.BackgroundUpdate.scheduleFirefoxMessagingSystemTargetingSnapshotting();
|
await lazy.BackgroundUpdate.scheduleFirefoxMessagingSystemTargetingSnapshotting();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -59,17 +59,9 @@ export const backgroundTaskTimeoutSec = Services.prefs.getIntPref(
|
|||||||
async function _attemptBackgroundUpdate() {
|
async function _attemptBackgroundUpdate() {
|
||||||
let SLUG = "_attemptBackgroundUpdate";
|
let SLUG = "_attemptBackgroundUpdate";
|
||||||
|
|
||||||
// Here's where we do `post-update-processing`. Creating the stub invokes the
|
// Most likely we will implicitly initialize update at some point, but make
|
||||||
// `UpdateServiceStub()` constructor, which handles various migrations (which should not be
|
// sure post update processing gets run, just in case.
|
||||||
// necessary, but we want to run for consistency and any migrations added in the future) and then
|
await lazy.UpdateService.init();
|
||||||
// dispatches `post-update-processing` (if appropriate). We want to do this very early, so that
|
|
||||||
// the real update service is in its fully initialized state before any usage.
|
|
||||||
lazy.log.debug(
|
|
||||||
`${SLUG}: creating UpdateServiceStub() for "post-update-processing"`
|
|
||||||
);
|
|
||||||
Cc["@mozilla.org/updates/update-service-stub;1"].createInstance(
|
|
||||||
Ci.nsISupports
|
|
||||||
);
|
|
||||||
|
|
||||||
lazy.log.debug(
|
lazy.log.debug(
|
||||||
`${SLUG}: checking for preconditions necessary to update this installation`
|
`${SLUG}: checking for preconditions necessary to update this installation`
|
||||||
|
|||||||
@@ -182,9 +182,10 @@ async function testPostUpdateProcessing() {
|
|||||||
|
|
||||||
/* Initializes the update service stub */
|
/* Initializes the update service stub */
|
||||||
async function initUpdateServiceStub() {
|
async function initUpdateServiceStub() {
|
||||||
Cc["@mozilla.org/updates/update-service-stub;1"].createInstance(
|
const updateServiceStub = Cc[
|
||||||
Ci.nsISupports
|
"@mozilla.org/updates/update-service-stub;1"
|
||||||
);
|
].getService(Ci.nsIApplicationUpdateServiceStub);
|
||||||
|
await updateServiceStub.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user