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, {
|
||||
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) {
|
||||
|
||||
@@ -59,17 +59,9 @@ export const backgroundTaskTimeoutSec = Services.prefs.getIntPref(
|
||||
async function _attemptBackgroundUpdate() {
|
||||
let SLUG = "_attemptBackgroundUpdate";
|
||||
|
||||
// Here's where we do `post-update-processing`. Creating the stub invokes the
|
||||
// `UpdateServiceStub()` constructor, which handles various migrations (which should not be
|
||||
// necessary, but we want to run for consistency and any migrations added in the future) and then
|
||||
// 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
|
||||
);
|
||||
// Most likely we will implicitly initialize update at some point, but make
|
||||
// sure post update processing gets run, just in case.
|
||||
await lazy.UpdateService.init();
|
||||
|
||||
lazy.log.debug(
|
||||
`${SLUG}: checking for preconditions necessary to update this installation`
|
||||
|
||||
@@ -182,9 +182,10 @@ async function testPostUpdateProcessing() {
|
||||
|
||||
/* Initializes the update service stub */
|
||||
async function initUpdateServiceStub() {
|
||||
Cc["@mozilla.org/updates/update-service-stub;1"].createInstance(
|
||||
Ci.nsISupports
|
||||
);
|
||||
const updateServiceStub = Cc[
|
||||
"@mozilla.org/updates/update-service-stub;1"
|
||||
].getService(Ci.nsIApplicationUpdateServiceStub);
|
||||
await updateServiceStub.init();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user