From 7af34a3085980977bd6f4a224e702eea2097d96a Mon Sep 17 00:00:00 2001 From: "wei.gao@spreadtrum.com" Date: Wed, 28 May 2014 10:33:22 -0400 Subject: [PATCH] Bug 1008812 - change dom.mms.retrievalRetryIntervals to shorten the mms wait time. r=vyang --- dom/mobilemessage/src/gonk/MmsService.js | 23 +++++++++++++++++------ modules/libpref/src/init/all.js | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/dom/mobilemessage/src/gonk/MmsService.js b/dom/mobilemessage/src/gonk/MmsService.js index 8d5f6d1b750..ca92c2e1547 100644 --- a/dom/mobilemessage/src/gonk/MmsService.js +++ b/dom/mobilemessage/src/gonk/MmsService.js @@ -98,8 +98,20 @@ const DELIVERY_STATUS_NOT_APPLICABLE = "not-applicable"; const PREF_SEND_RETRY_COUNT = Services.prefs.getIntPref("dom.mms.sendRetryCount"); -const PREF_SEND_RETRY_INTERVAL = - Services.prefs.getIntPref("dom.mms.sendRetryInterval"); +const PREF_SEND_RETRY_INTERVAL = (function () { + let intervals = + Services.prefs.getCharPref("dom.mms.sendRetryInterval").split(","); + for (let i = 0; i < PREF_SEND_RETRY_COUNT; ++i) { + intervals[i] = parseInt(intervals[i], 10); + // If one of the intervals isn't valid (e.g., 0 or NaN), + // assign a 1-minute interval to it as a default. + if (!intervals[i]) { + intervals[i] = 60000; + } + } + intervals.length = PREF_SEND_RETRY_COUNT; + return intervals; +})(); const PREF_RETRIEVAL_RETRY_COUNT = Services.prefs.getIntPref("dom.mms.retrievalRetryCount"); @@ -1266,15 +1278,13 @@ SendTransaction.prototype = Object.create(CancellableTransaction.prototype, { 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); + debug("Fail to send. Will retry after: " + PREF_SEND_RETRY_INTERVAL[this.retryCount]); } if (this.timer == null) { this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); } - this.retryCount++; - // the input stream may be read in the previous failure request so // we have to re-compose it. if (this.istreamSize == null || @@ -1283,8 +1293,9 @@ SendTransaction.prototype = Object.create(CancellableTransaction.prototype, { } this.timer.initWithCallback(this.send.bind(this, retryCallback), - PREF_SEND_RETRY_INTERVAL, + PREF_SEND_RETRY_INTERVAL[this.retryCount], Ci.nsITimer.TYPE_ONE_SHOT); + this.retryCount++; return; } diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index 0de624fc2bd..c0e6aa60edc 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -4052,7 +4052,7 @@ pref("dom.mms.requestStatusReport", true); pref("dom.mms.retrieval_mode", "manual"); pref("dom.mms.sendRetryCount", 3); -pref("dom.mms.sendRetryInterval", 300000); +pref("dom.mms.sendRetryInterval", "10000,60000,180000"); pref("dom.mms.retrievalRetryCount", 4); pref("dom.mms.retrievalRetryIntervals", "60000,300000,600000,1800000");