Skip to content

Commit

Permalink
Bug 835013 - AppProtocolHandler.js and related code taking ~50ms on t…
Browse files Browse the repository at this point in the history
…he critical startup path r=cjones
  • Loading branch information
Fabrice Desré committed Jan 31, 2013
1 parent f44ba49 commit fefe785
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
5 changes: 5 additions & 0 deletions dom/apps/src/AppsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand Down
11 changes: 10 additions & 1 deletion dom/apps/src/AppsServiceChild.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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();
19 changes: 10 additions & 9 deletions dom/apps/src/Webapps.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion dom/interfaces/apps/nsIAppsService.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -60,4 +60,6 @@ interface nsIAppsService : nsISupports
* Returns the basepath for regular packaged apps
*/
DOMString getWebAppsBasePath();

jsval getAppInfo(in DOMString appId);
};
9 changes: 4 additions & 5 deletions netwerk/protocol/app/AppProtocolHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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];
},
Expand Down

0 comments on commit fefe785

Please sign in to comment.