Bug 901992 - B2G MMS: Retry Mechanism for Downloading MMS is Buggy. r=vicamo a=leo+

This commit is contained in:
Gene Lian 2013-08-08 16:36:09 +08:00
parent e24465fc4b
commit e5cd57f08c

View File

@ -817,24 +817,25 @@ RetrieveTransaction.prototype = Object.create(CancellableTransaction.prototype,
this.registerRunCallback(callback);
this.retryCount = 0;
let that = this;
this.retrieve((function retryCallback(mmsStatus, msg) {
let retryCallback = (function (mmsStatus, msg) {
if (MMS.MMS_PDU_STATUS_DEFERRED == mmsStatus &&
that.retryCount < PREF_RETRIEVAL_RETRY_COUNT) {
if (that.timer == null) {
that.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this.retryCount < PREF_RETRIEVAL_RETRY_COUNT) {
let time = PREF_RETRIEVAL_RETRY_INTERVALS[this.retryCount];
if (DEBUG) debug("Fail to retrieve. Will retry after: " + time);
if (this.timer == null) {
this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
}
that.timer.initWithCallback((function (){
this.retrieve(retryCallback);
}).bind(that),
PREF_RETRIEVAL_RETRY_INTERVALS[that.retryCount],
Ci.nsITimer.TYPE_ONE_SHOT);
that.retryCount++;
this.timer.initWithCallback(this.retrieve.bind(this, retryCallback),
time, Ci.nsITimer.TYPE_ONE_SHOT);
this.retryCount++;
return;
}
this.runCallbackIfValid(mmsStatus, msg);
}).bind(this));
}).bind(this);
this.retrieve(retryCallback);
},
enumerable: true,
configurable: true,
@ -1043,6 +1044,10 @@ SendTransaction.prototype = Object.create(CancellableTransaction.prototype, {
if ((MMS.MMS_PDU_ERROR_TRANSIENT_FAILURE == mmsStatus ||
MMS.MMS_PDU_ERROR_PERMANENT_FAILURE == mmsStatus) &&
this.retryCount < PREF_SEND_RETRY_COUNT) {
if (DEBUG) {
debug("Fail to send. Will retry after: " + PREF_SEND_RETRY_INTERVAL);
}
if (this.timer == null) {
this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
}
@ -1400,7 +1405,7 @@ MmsService.prototype = {
// Retrieved fail after retry, so we update the delivery status in DB and
// notify this domMessage that error happen.
gMobileMessageDatabaseService
.setMessageDeliveryByMessageId(id,
.setMessageDeliveryByMessageId(savableMessage.id,
null,
null,
DELIVERY_STATUS_ERROR,