зеркало из https://github.com/mozilla/gecko-dev.git
Bug 806307 - Queue target messages before listener ready and resend after ready. r=vicamo, a=blocking-basecamp
This commit is contained in:
Родитель
b16b6ffb48
Коммит
e3e53e6f1d
|
@ -281,6 +281,8 @@ function RadioInterfaceLayer() {
|
|||
|
||||
this.portAddressedSmsApps = {};
|
||||
this.portAddressedSmsApps[WAP.WDP_PORT_PUSH] = this.handleSmsWdpPortPush.bind(this);
|
||||
|
||||
this._targetMessageQueue = [];
|
||||
}
|
||||
RadioInterfaceLayer.prototype = {
|
||||
|
||||
|
@ -657,6 +659,12 @@ RadioInterfaceLayer.prototype = {
|
|||
},
|
||||
|
||||
_sendTargetMessage: function _sendTargetMessage(permission, message, options) {
|
||||
|
||||
if (!this._sysMsgListenerReady) {
|
||||
this._enqueueTargetMessage(permission, message, options);
|
||||
return;
|
||||
}
|
||||
|
||||
let targets = this._messageManagerByPermission[permission];
|
||||
if (!targets) {
|
||||
return;
|
||||
|
@ -924,6 +932,36 @@ RadioInterfaceLayer.prototype = {
|
|||
this._ensureRadioState();
|
||||
},
|
||||
|
||||
_enqueueTargetMessage: function _enqueueTargetMessage(permission, message, options) {
|
||||
let msg = { permission : permission,
|
||||
message : message,
|
||||
options : options };
|
||||
// Remove previous queued message of same message type, only one message
|
||||
// per message type is allowed in queue.
|
||||
let messageQueue = this._targetMessageQueue;
|
||||
for(let i = 0; i < messageQueue.length; i++) {
|
||||
if (messageQueue[i].message === message) {
|
||||
messageQueue.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
messageQueue.push(msg);
|
||||
},
|
||||
|
||||
_resendQueuedTargetMessage: function _resendQueuedTargetMessage() {
|
||||
// Here uses this._sendTargetMessage() to resend message, which will
|
||||
// enqueue message if listener is not ready.
|
||||
// So only resend after listener is ready, or it will cause infinate loop and
|
||||
// hang the system.
|
||||
|
||||
// Dequeue and resend messages.
|
||||
for each (let msg in this._targetMessageQueue) {
|
||||
this._sendTargetMessage(msg.permission, msg.message, msg.options);
|
||||
}
|
||||
this._targetMessageQueue = null;
|
||||
},
|
||||
|
||||
_ensureRadioState: function _ensureRadioState() {
|
||||
debug("Reported radio state is " + this.rilContext.radioState +
|
||||
", desired radio enabled state is " + this._radioEnabled);
|
||||
|
@ -1490,6 +1528,7 @@ RadioInterfaceLayer.prototype = {
|
|||
case kSysMsgListenerReadyObserverTopic:
|
||||
Services.obs.removeObserver(this, kSysMsgListenerReadyObserverTopic);
|
||||
this._sysMsgListenerReady = true;
|
||||
this._resendQueuedTargetMessage();
|
||||
this._ensureRadioState();
|
||||
break;
|
||||
case kMozSettingsChangedObserverTopic:
|
||||
|
|
Загрузка…
Ссылка в новой задаче