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(); return DOMApplicationRegistry.getWebAppsBasePath();
}, },
getAppInfo: function getAppInfo(aAppId) {
debug("getAppInfo()");
return DOMApplicationRegistry.getAppInfo(aAppId);
},
classID : APPS_SERVICE_CID, classID : APPS_SERVICE_CID,
QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService]) QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService])
} }

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

@ -111,7 +111,16 @@ this.DOMApplicationRegistry = {
getWebAppsBasePath: function getWebAppsBasePath() { getWebAppsBasePath: function getWebAppsBasePath() {
debug("getWebAppsBasePath() not yet supported on child!"); debug("getWebAppsBasePath() not yet supported on child!");
return null; 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(); DOMApplicationRegistry.init();

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

@ -75,7 +75,7 @@ this.DOMApplicationRegistry = {
"Webapps:GetSelf", "Webapps:CheckInstalled", "Webapps:GetSelf", "Webapps:CheckInstalled",
"Webapps:GetInstalled", "Webapps:GetNotInstalled", "Webapps:GetInstalled", "Webapps:GetNotInstalled",
"Webapps:Launch", "Webapps:GetAll", "Webapps:Launch", "Webapps:GetAll",
"Webapps:InstallPackage", "Webapps:GetAppInfo", "Webapps:InstallPackage",
"Webapps:GetList", "Webapps:RegisterForMessages", "Webapps:GetList", "Webapps:RegisterForMessages",
"Webapps:UnregisterForMessages", "Webapps:UnregisterForMessages",
"Webapps:CancelDownload", "Webapps:CheckForUpdate", "Webapps:CancelDownload", "Webapps:CheckForUpdate",
@ -798,14 +798,6 @@ this.DOMApplicationRegistry = {
case "Webapps:InstallPackage": case "Webapps:InstallPackage":
this.doInstallPackage(msg, mm); this.doInstallPackage(msg, mm);
break; 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": case "Webapps:RegisterForMessages":
this.addMessageListener(msg, mm); this.addMessageListener(msg, mm);
break; 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: // Some messages can be listened by several content processes:
// Webapps:AddApp // Webapps:AddApp
// Webapps:RemoveApp // Webapps:RemoveApp

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

@ -16,7 +16,7 @@ interface mozIApplication;
* This service allows accessing some DOMApplicationRegistry methods from * This service allows accessing some DOMApplicationRegistry methods from
* non-javascript code. * non-javascript code.
*/ */
[scriptable, uuid(e65f9397-e191-4273-aa5f-f13c185ce63b)] [scriptable, uuid(4ac27836-4d79-4d35-b105-d6fb7f4f8e41)]
interface nsIAppsService : nsISupports interface nsIAppsService : nsISupports
{ {
mozIDOMApplication getAppByManifestURL(in DOMString manifestURL); mozIDOMApplication getAppByManifestURL(in DOMString manifestURL);
@ -60,4 +60,6 @@ interface nsIAppsService : nsISupports
* Returns the basepath for regular packaged apps * Returns the basepath for regular packaged apps
*/ */
DOMString getWebAppsBasePath(); 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/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "cpmm", XPCOMUtils.defineLazyServiceGetter(this, "appsService",
"@mozilla.org/childprocessmessagemanager;1", "@mozilla.org/AppsService;1",
"nsISyncMessageSender"); "nsIAppsService");
function AppProtocolHandler() { function AppProtocolHandler() {
this._appInfo = []; this._appInfo = [];
@ -36,8 +36,7 @@ AppProtocolHandler.prototype = {
getAppInfo: function app_phGetAppInfo(aId) { getAppInfo: function app_phGetAppInfo(aId) {
if (!this._appInfo[aId]) { if (!this._appInfo[aId]) {
let reply = cpmm.sendSyncMessage("Webapps:GetAppInfo", { id: aId }); this._appInfo[aId] = appsService.getAppInfo(aId);
this._appInfo[aId] = reply[0];
} }
return this._appInfo[aId]; return this._appInfo[aId];
}, },