Bug 1524688: Part 4 - Convert UpdateService to static registration r=mhowell

--HG--
rename : toolkit/mozapps/update/nsUpdateService.js => toolkit/mozapps/update/UpdateService.jsm
rename : toolkit/mozapps/update/nsUpdateServiceStub.js => toolkit/mozapps/update/UpdateServiceStub.jsm
extra : source : 6b3684e7d8f95c7d028fcf27d1570675a8ccbbef
This commit is contained in:
Kris Maglione 2019-01-29 17:46:17 -08:00
parent cda73836d1
commit 6ebfea8015
8 changed files with 49 additions and 25 deletions

View File

@ -14,8 +14,6 @@ const mockUpdateManager = {
_originalClassId: "",
_originalFactory: null,
QueryInterface: ChromeUtils.generateQI([Ci.nsIUpdateManager]),
createInstance(outer, iiD) {
@ -29,8 +27,6 @@ const mockUpdateManager = {
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
if (!registrar.isCIDRegistered(this._mockClassId)) {
this._originalClassId = registrar.contractIDToCID(this.contractId);
this._originalFactory = Cm.getClassObject(Cc[this.contractId], Ci.nsIFactory);
registrar.unregisterFactory(this._originalClassId, this._originalFactory);
registrar.registerFactory(this._mockClassId, "Unregister after testing", this.contractId, this);
}
},
@ -38,7 +34,7 @@ const mockUpdateManager = {
unregister() {
let registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(this._mockClassId, this);
registrar.registerFactory(this._originalClassId, "", this.contractId, this._originalFactory);
registrar.registerFactory(this._originalClassId, "", this.contractId, null);
},
get updateCount() {

View File

@ -225,8 +225,6 @@
@RESPATH@/components/amWebAPI.js
#ifdef MOZ_UPDATER
@RESPATH@/components/nsUpdateService.manifest
@RESPATH@/components/nsUpdateService.js
@RESPATH@/components/nsUpdateServiceStub.js
#endif
@RESPATH@/components/nsUpdateTimerManager.manifest
@RESPATH@/components/nsUpdateTimerManager.js

View File

@ -156,8 +156,6 @@
#ifndef MOZ_GECKOVIEW_JAR
#ifdef MOZ_UPDATER
@BINPATH@/components/nsUpdateService.manifest
@BINPATH@/components/nsUpdateService.js
@BINPATH@/components/nsUpdateServiceStub.js
#endif
#endif

View File

@ -4367,5 +4367,4 @@ UpdatePrompt.prototype = {
QueryInterface: ChromeUtils.generateQI([Ci.nsIUpdatePrompt]),
};
var components = [UpdateService, Checker, UpdatePrompt, UpdateManager];
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
var EXPORTED_SYMBOLS = ["UpdateService", "Checker", "UpdatePrompt", "UpdateManager"];

View File

@ -61,7 +61,7 @@ UpdateServiceStub.prototype = {
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver]),
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([UpdateServiceStub]);
var EXPORTED_SYMBOLS = ["UpdateServiceStub"];
/**
* This function should be called when there are files in the old update

View File

@ -0,0 +1,40 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Classes = [
{
'cid': '{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}',
'contract_ids': ['@mozilla.org/updates/update-service;1'],
'jsm': 'resource://gre/modules/UpdateService.jsm',
'constructor': 'UpdateService',
},
{
'cid': '{093C2356-4843-4C65-8709-D7DBCBBE7DFB}',
'contract_ids': ['@mozilla.org/updates/update-manager;1'],
'jsm': 'resource://gre/modules/UpdateService.jsm',
'constructor': 'UpdateManager',
},
{
'cid': '{898CDC9B-E43F-422F-9CC4-2F6291B415A3}',
'contract_ids': ['@mozilla.org/updates/update-checker;1'],
'jsm': 'resource://gre/modules/UpdateService.jsm',
'constructor': 'Checker',
},
{
'cid': '{27ABA825-35B5-4018-9FDD-F99250A0E722}',
'contract_ids': ['@mozilla.org/updates/update-prompt;1'],
'jsm': 'resource://gre/modules/UpdateService.jsm',
'constructor': 'UpdatePrompt',
},
{
'cid': '{e43b0010-04ba-4da6-b523-1f92580bc150}',
'contract_ids': ['@mozilla.org/updates/update-service-stub;1'],
'jsm': 'resource://gre/modules/UpdateServiceStub.jsm',
'constructor': 'UpdateServiceStub',
'categories': {'profile-after-change': 'nsUpdateServiceStub'},
},
]

View File

@ -17,16 +17,20 @@ XPIDL_SOURCES += [
TEST_DIRS += ['tests']
EXTRA_COMPONENTS += [
'nsUpdateService.js',
'nsUpdateService.manifest',
'nsUpdateServiceStub.js',
]
EXTRA_JS_MODULES += [
'UpdateListener.jsm',
'UpdateService.jsm',
'UpdateServiceStub.jsm',
'UpdateTelemetry.jsm',
]
XPCOM_MANIFESTS += [
'components.conf',
]
JAR_MANIFESTS += ['jar.mn']
with Files('**'):

View File

@ -1,12 +1 @@
component {B3C290A6-3943-4B89-8BBE-C01EB7B3B311} nsUpdateService.js
contract @mozilla.org/updates/update-service;1 {B3C290A6-3943-4B89-8BBE-C01EB7B3B311}
category update-timer nsUpdateService @mozilla.org/updates/update-service;1,getService,background-update-timer,app.update.interval,43200,86400
component {093C2356-4843-4C65-8709-D7DBCBBE7DFB} nsUpdateService.js
contract @mozilla.org/updates/update-manager;1 {093C2356-4843-4C65-8709-D7DBCBBE7DFB}
component {898CDC9B-E43F-422F-9CC4-2F6291B415A3} nsUpdateService.js
contract @mozilla.org/updates/update-checker;1 {898CDC9B-E43F-422F-9CC4-2F6291B415A3}
component {27ABA825-35B5-4018-9FDD-F99250A0E722} nsUpdateService.js
contract @mozilla.org/updates/update-prompt;1 {27ABA825-35B5-4018-9FDD-F99250A0E722}
component {e43b0010-04ba-4da6-b523-1f92580bc150} nsUpdateServiceStub.js
contract @mozilla.org/updates/update-service-stub;1 {e43b0010-04ba-4da6-b523-1f92580bc150}
category profile-after-change nsUpdateServiceStub @mozilla.org/updates/update-service-stub;1