Bug 1524688: Part 16 - Convert push components to static registration. r=baku

--HG--
rename : dom/push/Push.js => dom/push/Push.jsm
rename : dom/push/PushComponents.js => dom/push/PushComponents.jsm
extra : source : 28670fdc418d846f6cd9fcfeeff5f54d86efd9f8
This commit is contained in:
Kris Maglione 2019-01-29 20:50:16 -08:00
Родитель 3aa22f3f17
Коммит 9bbd5b753d
8 изменённых файлов: 46 добавлений и 27 удалений

Просмотреть файл

@ -26,10 +26,6 @@ const startupPhases = {
// Consider loading your code after first paint instead,
// eg. from BrowserGlue.jsm' _onFirstWindowLoaded method).
"before profile selection": {whitelist: {
components: new Set([
// Bugs to fix: The following components shouldn't be initialized that early.
"PushComponents.js", // bug 1369436
]),
modules: new Set([
"resource:///modules/BrowserGlue.jsm",
"resource://gre/modules/AppConstants.jsm",
@ -39,6 +35,8 @@ const startupPhases = {
"resource://gre/modules/MainProcessSingleton.jsm",
"resource://gre/modules/XPCOMUtils.jsm",
"resource://gre/modules/Services.jsm",
// Bugs to fix: The following components shouldn't be initialized that early.
"resource://gre/modules/PushComponents.jsm", // bug 1369436
]),
}},

Просмотреть файл

@ -257,9 +257,7 @@
@RESPATH@/components/NotificationStorage.js
@RESPATH@/components/NotificationStorage.manifest
@RESPATH@/components/Push.js
@RESPATH@/components/Push.manifest
@RESPATH@/components/PushComponents.js
@RESPATH@/components/remotebrowserutils.manifest
@RESPATH@/components/RemoteWebNavigation.js

Просмотреть файл

@ -285,4 +285,4 @@ PushSubscriptionCallback.prototype = {
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([Push]);
var EXPORTED_SYMBOLS = ["Push"];

Просмотреть файл

@ -1,10 +1,3 @@
# DOM API
component {cde1d019-fad8-4044-b141-65fb4fb7a245} Push.js
contract @mozilla.org/push/PushManager;1 {cde1d019-fad8-4044-b141-65fb4fb7a245}
# XPCOM components.
component {daaa8d73-677e-4233-8acd-2c404bd01658} PushComponents.js
contract @mozilla.org/push/Service;1 {daaa8d73-677e-4233-8acd-2c404bd01658}
category app-startup PushServiceParent @mozilla.org/push/Service;1 process=main
# For immediate loading of PushService instead of delayed loading.

Просмотреть файл

@ -113,7 +113,13 @@ PushServiceBase.prototype = {
* `PushService.jsm` at startup and calls its methods directly. It also
* receives and responds to requests from the content process.
*/
let parentInstance;
function PushServiceParent() {
if (parentInstance) {
return parentInstance;
}
parentInstance = this;
PushServiceBase.call(this);
}
@ -123,8 +129,6 @@ XPCOMUtils.defineLazyServiceGetter(PushServiceParent.prototype, "_mm",
"@mozilla.org/parentprocessmessagemanager;1", "nsISupports");
Object.assign(PushServiceParent.prototype, {
_xpcom_factory: XPCOMUtils.generateSingletonFactory(PushServiceParent),
_messages: [
"Push:Register",
"Push:Registration",
@ -306,6 +310,7 @@ Object.defineProperty(PushServiceParent.prototype, "service", {
},
});
let contentInstance;
/**
* The content process implementation of `nsIPushService`. This version
* uses the child message manager to forward calls to the parent process.
@ -313,6 +318,11 @@ Object.defineProperty(PushServiceParent.prototype, "service", {
* message containing the result.
*/
function PushServiceContent() {
if (contentInstance) {
return contentInstance;
}
contentInstance = this;
PushServiceBase.apply(this, arguments);
this._requests = new Map();
this._requestId = 0;
@ -325,8 +335,6 @@ XPCOMUtils.defineLazyServiceGetter(PushServiceContent.prototype,
"nsISupports");
Object.assign(PushServiceContent.prototype, {
_xpcom_factory: XPCOMUtils.generateSingletonFactory(PushServiceContent),
_messages: [
"PushService:Register:OK",
"PushService:Register:KO",
@ -548,8 +556,8 @@ PushSubscription.prototype = {
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([
// Export the correct implementation depending on whether we're running in
// the parent or content process.
isParent ? PushServiceParent : PushServiceContent,
]);
// Export the correct implementation depending on whether we're running in
// the parent or content process.
let Service = isParent ? PushServiceParent : PushServiceContent;
var EXPORTED_SYMBOLS = ["Service"];

20
dom/push/components.conf Normal file
Просмотреть файл

@ -0,0 +1,20 @@
# -*- 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': '{cde1d019-fad8-4044-b141-65fb4fb7a245}',
'contract_ids': ['@mozilla.org/push/PushManager;1'],
'jsm': 'resource://gre/modules/Push.jsm',
'constructor': 'Push',
},
{
'cid': '{daaa8d73-677e-4233-8acd-2c404bd01658}',
'contract_ids': ['@mozilla.org/push/Service;1'],
'jsm': 'resource://gre/modules/PushComponents.jsm',
'constructor': 'Service',
},
]

Просмотреть файл

@ -7,13 +7,13 @@ with Files("**"):
BUG_COMPONENT = ("Core", "DOM: Push Notifications")
EXTRA_COMPONENTS += [
'Push.js',
'Push.manifest',
'PushComponents.js',
]
EXTRA_JS_MODULES += [
'Push.jsm',
'PushBroadcastService.jsm',
'PushComponents.jsm',
'PushCrypto.jsm',
'PushDB.jsm',
'PushRecord.jsm',
@ -32,6 +32,10 @@ else:
'PushServiceAndroidGCM.jsm',
]
XPCOM_MANIFESTS += [
'components.conf',
]
MOCHITEST_MANIFESTS += [
'test/mochitest.ini',
]

Просмотреть файл

@ -106,9 +106,7 @@
@BINPATH@/components/NotificationStorage.js
@BINPATH@/components/NotificationStorage.manifest
#ifdef MOZ_ANDROID_GCM
@BINPATH@/components/Push.js
@BINPATH@/components/Push.manifest
@BINPATH@/components/PushComponents.js
#endif
@BINPATH@/components/BrowserElementParent.manifest
@BINPATH@/components/BrowserElementParent.js