Bug 835013 - AppProtocolHandler.js and related code taking ~50ms on the critical startup path r=cjones

This commit is contained in:
Fabrice Desré 2013-01-31 13:35:13 -08:00
Родитель f44ba49ba0
Коммит fefe78557a
5 изменённых файлов: 32 добавлений и 16 удалений

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

@ -68,6 +68,11 @@ AppsService.prototype = {
return DOMApplicationRegistry.getWebAppsBasePath();
},
getAppInfo: function getAppInfo(aAppId) {
debug("getAppInfo()");
return DOMApplicationRegistry.getAppInfo(aAppId);
},
classID : APPS_SERVICE_CID,
QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService])
}

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

@ -111,7 +111,16 @@ this.DOMApplicationRegistry = {
getWebAppsBasePath: function getWebAppsBasePath() {
debug("getWebAppsBasePath() not yet supported on child!");
return null;
}
},
getAppInfo: function getAppInfo(aAppId) {
if (!this.webapps[aAppId]) {
debug("No webapp for " + aAppId);
return null;
}
return { "basePath": this.webapps[aAppId].basePath + "/",
"isCoreApp": !this.webapps[aAppId].removable };
},
}
DOMApplicationRegistry.init();

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

@ -75,7 +75,7 @@ this.DOMApplicationRegistry = {
"Webapps:GetSelf", "Webapps:CheckInstalled",
"Webapps:GetInstalled", "Webapps:GetNotInstalled",
"Webapps:Launch", "Webapps:GetAll",
"Webapps:InstallPackage", "Webapps:GetAppInfo",
"Webapps:InstallPackage",
"Webapps:GetList", "Webapps:RegisterForMessages",
"Webapps:UnregisterForMessages",
"Webapps:CancelDownload", "Webapps:CheckForUpdate",
@ -798,14 +798,6 @@ this.DOMApplicationRegistry = {
case "Webapps:InstallPackage":
this.doInstallPackage(msg, mm);
break;
case "Webapps:GetAppInfo":
if (!this.webapps[msg.id]) {
debug("No webapp for " + msg.id);
return null;
}
return { "basePath": this.webapps[msg.id].basePath + "/",
"isCoreApp": !this.webapps[msg.id].removable };
break;
case "Webapps:RegisterForMessages":
this.addMessageListener(msg, mm);
break;
@ -836,6 +828,15 @@ this.DOMApplicationRegistry = {
}
},
getAppInfo: function getAppInfo(aAppId) {
if (!this.webapps[aAppId]) {
debug("No webapp for " + aAppId);
return null;
}
return { "basePath": this.webapps[aAppId].basePath + "/",
"isCoreApp": !this.webapps[aAppId].removable };
},
// Some messages can be listened by several content processes:
// Webapps:AddApp
// Webapps:RemoveApp

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

@ -16,7 +16,7 @@ interface mozIApplication;
* This service allows accessing some DOMApplicationRegistry methods from
* non-javascript code.
*/
[scriptable, uuid(e65f9397-e191-4273-aa5f-f13c185ce63b)]
[scriptable, uuid(4ac27836-4d79-4d35-b105-d6fb7f4f8e41)]
interface nsIAppsService : nsISupports
{
mozIDOMApplication getAppByManifestURL(in DOMString manifestURL);
@ -60,4 +60,6 @@ interface nsIAppsService : nsISupports
* Returns the basepath for regular packaged apps
*/
DOMString getWebAppsBasePath();
jsval getAppInfo(in DOMString appId);
};

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

@ -11,9 +11,9 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
"@mozilla.org/childprocessmessagemanager;1",
"nsISyncMessageSender");
XPCOMUtils.defineLazyServiceGetter(this, "appsService",
"@mozilla.org/AppsService;1",
"nsIAppsService");
function AppProtocolHandler() {
this._appInfo = [];
@ -36,8 +36,7 @@ AppProtocolHandler.prototype = {
getAppInfo: function app_phGetAppInfo(aId) {
if (!this._appInfo[aId]) {
let reply = cpmm.sendSyncMessage("Webapps:GetAppInfo", { id: aId });
this._appInfo[aId] = reply[0];
this._appInfo[aId] = appsService.getAppInfo(aId);
}
return this._appInfo[aId];
},