Merge mozilla-central and birch

This commit is contained in:
Ed Morley 2013-06-24 13:41:17 +01:00
Родитель ec5c07ba45 68ff282d24
Коммит 2faba00f1b
5 изменённых файлов: 109 добавлений и 37 удалений

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

@ -1,4 +1,4 @@
{
"revision": "d816bb323b9c9d7e59b3c8dfc2c62d3901864b46",
"revision": "3b11c4cca57eec67a6a267dfcf2d0d83b5b87b76",
"repo_path": "/integration/gaia-central"
}

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

@ -508,7 +508,17 @@ this.AlarmService = {
case "webapps-clear-data":
let params =
aSubject.QueryInterface(Ci.mozIApplicationClearPrivateDataParams);
if (!params) {
debug("Error! Fail to remove alarms for an uninstalled app.");
return;
}
let manifestURL = appsService.getManifestURLByLocalId(params.appId);
if (!manifestURL) {
debug("Error! Fail to remove alarms for an uninstalled app.");
return;
}
this._db.getAll(
manifestURL,
function getAllSuccessCb(aAlarms) {

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

@ -27,9 +27,15 @@ function debug(aMsg) {
// Implementation of the DOM API for system messages
function SystemMessageManager() {
// Message handlers for this page.
// We can have only one handler per message type.
this._handlers = {};
// If we have a system message handler registered for messages of type
// |type|, this._dispatchers[type] equals {handler, messages, isHandling},
// where
// - |handler| is the message handler that the page registered,
// - |messages| is a list of messages which we've received while
// dispatching messages to the handler, but haven't yet sent, and
// - |isHandling| indicates whether we're currently dispatching messages
// to this handler.
this._dispatchers = {};
// Pending messages for this page, keyed by message type.
this._pendings = {};
@ -52,7 +58,21 @@ function SystemMessageManager() {
SystemMessageManager.prototype = {
__proto__: DOMRequestIpcHelper.prototype,
_dispatchMessage: function sysMessMgr_dispatchMessage(aType, aHandler, aMessage) {
_dispatchMessage: function sysMessMgr_dispatchMessage(aType, aDispatcher, aMessage) {
if (aDispatcher.isHandling) {
// Queue up the incomming message if we're currently dispatching a
// message; we'll send the message once we finish with the current one.
//
// _dispatchMethod is reentrant because a page can spin up a nested
// event loop from within a system message handler (e.g. via alert()),
// and we can then try to send the page another message while it's
// inside this nested event loop.
aDispatcher.messages.push(aMessage);
return;
}
aDispatcher.isHandling = true;
// We get a json blob, but in some cases we want another kind of object
// to be dispatched.
// To do so, we check if we have a with a contract ID of
@ -72,8 +92,22 @@ SystemMessageManager.prototype = {
}
}
aHandler.handleMessage(wrapped ? aMessage
: ObjectWrapper.wrap(aMessage, this._window));
aDispatcher.handler
.handleMessage(wrapped ? aMessage
: ObjectWrapper.wrap(aMessage, this._window));
// We need to notify the parent one of the system messages has been handled,
// so the parent can release the CPU wake lock it took on our behalf.
cpmm.sendAsyncMessage("SystemMessageManager:HandleMessagesDone",
{ type: aType,
manifest: this._manifest,
uri: this._uri,
handledCount: 1 });
aDispatcher.isHandling = false;
if (aDispatcher.messages.length > 0) {
this._dispatchMessage(aType, aDispatcher, aDispatcher.messages.shift());
}
},
mozSetMessageHandler: function sysMessMgr_setMessageHandler(aType, aHandler) {
@ -90,16 +124,16 @@ SystemMessageManager.prototype = {
return;
}
let handlers = this._handlers;
let dispatchers = this._dispatchers;
if (!aHandler) {
// Setting the handler to null means we don't want to receive messages
// of this type anymore.
delete handlers[aType];
// Setting the dispatcher to null means we don't want to handle messages
// for this type anymore.
delete dispatchers[aType];
return;
}
// Last registered handler wins.
handlers[aType] = aHandler;
dispatchers[aType] = { handler: aHandler, messages: [], isHandling: false };
// Ask for the list of currently pending messages.
cpmm.sendAsyncMessage("SystemMessageManager:GetPendingMessages",
@ -118,7 +152,7 @@ SystemMessageManager.prototype = {
}
// If we have a handler for this type, we can't have any pending message.
if (aType in this._handlers) {
if (aType in this._dispatchers) {
return false;
}
@ -129,7 +163,7 @@ SystemMessageManager.prototype = {
},
uninit: function sysMessMgr_uninit() {
this._handlers = null;
this._dispatchers = null;
this._pendings = null;
if (this._isParentProcess) {
@ -187,25 +221,28 @@ SystemMessageManager.prototype = {
: msg.msgQueue;
// We only dispatch messages when a handler is registered.
let handler = this._handlers[msg.type];
if (handler) {
let dispatcher = this._dispatchers[msg.type];
if (dispatcher) {
messages.forEach(function(aMsg) {
this._dispatchMessage(msg.type, handler, aMsg);
this._dispatchMessage(msg.type, dispatcher, aMsg);
}, this);
} else {
// We need to notify the parent that all the queued system messages have
// been handled (notice |handledCount: messages.length|), so the parent
// can release the CPU wake lock it took on our behalf.
cpmm.sendAsyncMessage("SystemMessageManager:HandleMessagesDone",
{ type: msg.type,
manifest: this._manifest,
uri: this._uri,
handledCount: messages.length });
}
// We need to notify the parent the system messages have been handled,
// even if there are no handlers registered for them, so the parent can
// release the CPU wake lock it took on our behalf.
cpmm.sendAsyncMessage("SystemMessageManager:HandleMessagesDone",
{ type: msg.type,
manifest: this._manifest,
uri: this._uri,
handledCount: messages.length });
Services.obs.notifyObservers(/* aSubject */ null,
"handle-system-messages-done",
/* aData */ null);
if (!dispatcher || !dispatcher.isHandling) {
// TODO: Bug 874353 - Remove SystemMessageHandledListener in ContentParent
Services.obs.notifyObservers(/* aSubject */ null,
"handle-system-messages-done",
/* aData */ null);
}
},
// nsIDOMGlobalPropertyInitializer implementation.
@ -272,11 +309,12 @@ SystemMessageManager.prototype = {
Ci.nsIDOMGlobalPropertyInitializer,
Ci.nsIObserver]),
classInfo: XPCOMUtils.generateCI({classID: Components.ID("{bc076ea0-609b-4d8f-83d7-5af7cbdc3bb2}"),
contractID: "@mozilla.org/system-message-manager;1",
interfaces: [Ci.nsIDOMNavigatorSystemMessages],
flags: Ci.nsIClassInfo.DOM_OBJECT,
classDescription: "System Messages"})
classInfo: XPCOMUtils.generateCI({
classID: Components.ID("{bc076ea0-609b-4d8f-83d7-5af7cbdc3bb2}"),
contractID: "@mozilla.org/system-message-manager;1",
interfaces: [Ci.nsIDOMNavigatorSystemMessages],
flags: Ci.nsIClassInfo.DOM_OBJECT,
classDescription: "System Messages"})
}
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SystemMessageManager]);

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

@ -1454,7 +1454,7 @@ MmsService.prototype = {
send: function send(aParams, aRequest) {
if (DEBUG) debug("send: aParams: " + JSON.stringify(aParams));
if (aParams.receivers.length == 0) {
aRequest.notifySendMmsMessageFailed(Ci.nsIMobileMessageCallback.INTERNAL_ERROR);
aRequest.notifySendMessageFailed(Ci.nsIMobileMessageCallback.INTERNAL_ERROR);
return;
}
@ -1497,14 +1497,14 @@ MmsService.prototype = {
if (DEBUG) debug("Saving sending message is done. Start to send.");
// For radio disabled error.
if(gMmsConnection.radioDisabled) {
if (gMmsConnection.radioDisabled) {
if (DEBUG) debug("Error! Radio is disabled when sending MMS.");
sendTransactionCb(aDomMessage.id, Ci.nsIMobileMessageCallback.RADIO_DISABLED_ERROR);
return;
}
// For SIM card is not ready.
if(gRIL.rilContext.cardState != "ready") {
if (gRIL.rilContext.cardState != "ready") {
if (DEBUG) debug("Error! SIM card is not ready when sending MMS.");
sendTransactionCb(aDomMessage.id, Ci.nsIMobileMessageCallback.NO_SIM_CARD_ERROR);
return;

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

@ -2840,6 +2840,30 @@ RadioInterfaceLayer.prototype = {
// TODO bug 832140 handle !Components.isSuccessCode(rv)
Services.obs.notifyObservers(domMessage, kSmsSendingObserverTopic, null);
// If the radio is disabled or the SIM card is not ready, just directly
// return with the corresponding error code.
let errorCode;
if (!this._radioEnabled) {
debug("Error! Radio is disabled when sending SMS.");
errorCode = Ci.nsIMobileMessageCallback.RADIO_DISABLED_ERROR;
} else if (this.rilContext.cardState != "ready") {
debug("Error! SIM card is not ready when sending SMS.");
errorCode = Ci.nsIMobileMessageCallback.NO_SIM_CARD_ERROR;
}
if (errorCode) {
gMobileMessageDatabaseService
.setMessageDelivery(domMessage.id,
null,
DOM_MOBILE_MESSAGE_DELIVERY_ERROR,
RIL.GECKO_SMS_DELIVERY_STATUS_ERROR,
function notifyResult(rv, domMessage) {
// TODO bug 832140 handle !Components.isSuccessCode(rv)
request.notifySendMessageFailed(errorCode);
Services.obs.notifyObservers(domMessage, kSmsFailedObserverTopic, null);
});
return;
}
// Keep current SMS message info for sent/delivered notifications
options.envelopeId = this.createSmsEnvelope({
request: request,