Bug 1162899 - Use sync message for in-process mozHasPendingMessage. r=fabrice

This commit is contained in:
Kan-Ru Chen 2015-05-11 15:18:45 +08:00
Родитель 7d7c2e5ca3
Коммит 24103c02e5
2 изменённых файлов: 29 добавлений и 0 удалений

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

@ -40,6 +40,7 @@ try {
}
const kMessages =["SystemMessageManager:GetPendingMessages",
"SystemMessageManager:HasPendingMessages",
"SystemMessageManager:Register",
"SystemMessageManager:Unregister",
"SystemMessageManager:Message:Return:OK",
@ -419,6 +420,7 @@ SystemMessageInternal.prototype = {
// TODO: fix bug 988142 to re-enable.
// "SystemMessageManager:Unregister",
"SystemMessageManager:GetPendingMessages",
"SystemMessageManager:HasPendingMessages",
"SystemMessageManager:Message:Return:OK",
"SystemMessageManager:HandleMessagesDone",
"SystemMessageManager:HandleMessageDone"].indexOf(aMessage.name) != -1) {
@ -519,6 +521,25 @@ SystemMessageInternal.prototype = {
this._refreshCacheInternal(aMessage.target, msg.manifestURL);
break;
}
case "SystemMessageManager:HasPendingMessages":
{
debug("received SystemMessageManager:HasPendingMessages " + msg.type +
" for " + msg.pageURL + " @ " + msg.manifestURL);
// NB: Sync message SystemMessageManager:HasPendingMessages
// should only be used by in-process app. For out-of-process
// app, SystemMessageCache should be used.
// This is a sync call used to return if a page has pending messages.
// Find the right page to get its corresponding pending messages.
let page = this._findPage(msg.type, msg.pageURL, msg.manifestURL);
if (!page) {
return false;
}
return page.pendingMessages.length != 0;
break;
}
case "SystemMessageManager:Message:Return:OK":
{
debug("received SystemMessageManager:Message:Return:OK " + msg.type +

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

@ -194,6 +194,14 @@ SystemMessageManager.prototype = {
}
// Use SystemMessageManager directly when we are in the same process.
if (Services.appinfo.processType === Services.appinfo.PROCESS_TYPE_DEFAULT) {
return cpmm.sendSyncMessage("SystemMessageManager:HasPendingMessages",
{ type: aType,
pageURL: this._pageURL,
manifestURL: this._manifestURL })[0];
}
/*
* NB: If the system message is fired after we received the cache
* and before we registered the pageURL we will get false