mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 810097 - B2G MMS: Retry retrieval on error. r=vyang
This commit is contained in:
parent
414a4fc6f8
commit
7cd2bee960
@ -34,12 +34,14 @@ const CONFIG_SEND_REPORT_ALWAYS = 3;
|
||||
const TIME_TO_BUFFER_MMS_REQUESTS = 30000;
|
||||
const TIME_TO_RELEASE_MMS_CONNECTION = 30000;
|
||||
|
||||
|
||||
const PREF_RETRIEVAL_MODE = 'dom.mms.retrieval_mode';
|
||||
const RETRIEVAL_MODE_MANUAL = "manual";
|
||||
const RETRIEVAL_MODE_AUTOMATIC = "automatic";
|
||||
const RETRIEVAL_MODE_NEVER = "never";
|
||||
|
||||
const MAX_RETRY_COUNT = Services.prefs.getIntPref("dom.mms.retrievalRetryCount");
|
||||
const DELAY_TIME_TO_RETRY = Services.prefs.getIntPref("dom.mms.retrievalRetryInterval");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gpps",
|
||||
"@mozilla.org/network/protocol-proxy-service;1",
|
||||
"nsIProtocolProxyService");
|
||||
@ -482,22 +484,42 @@ RetrieveTransaction.prototype = {
|
||||
* the other for the parsed M-Retrieve.conf message.
|
||||
*/
|
||||
run: function run(callback) {
|
||||
let callbackIfValid = function callbackIfValid(status, msg) {
|
||||
this.retryCount = 0;
|
||||
let that = this;
|
||||
this.retrieve((function retryCallback(mmsStatus, msg) {
|
||||
if (MMS.MMS_PDU_STATUS_DEFERRED == mmsStatus &&
|
||||
that.retryCount < MAX_RETRY_COUNT) {
|
||||
that.retryCount++;
|
||||
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
timer.initWithCallback((function (){
|
||||
this.retrieve(retryCallback);
|
||||
}).bind(that),
|
||||
DELAY_TIME_TO_RETRY,
|
||||
Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
return;
|
||||
}
|
||||
if (callback) {
|
||||
callback(status, msg);
|
||||
}
|
||||
callback(mmsStatus, msg);
|
||||
}
|
||||
}).bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* @param callback
|
||||
* A callback function that takes two arguments: one for X-Mms-Status,
|
||||
* the other for the parsed M-Retrieve.conf message.
|
||||
*/
|
||||
retrieve: function retrieve(callback) {
|
||||
gMmsTransactionHelper.sendRequest("GET", this.contentLocation, null,
|
||||
(function (httpStatus, data) {
|
||||
if ((httpStatus != HTTP_STATUS_OK) || !data) {
|
||||
callbackIfValid(MMS.MMS_PDU_STATUS_DEFERRED, null);
|
||||
callback(MMS.MMS_PDU_STATUS_DEFERRED, null);
|
||||
return;
|
||||
}
|
||||
|
||||
let retrieved = MMS.PduHelper.parse(data, null);
|
||||
if (!retrieved || (retrieved.type != MMS.MMS_PDU_TYPE_RETRIEVE_CONF)) {
|
||||
callbackIfValid(MMS.MMS_PDU_STATUS_UNRECOGNISED, null);
|
||||
callback(MMS.MMS_PDU_STATUS_UNRECOGNISED, null);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -509,12 +531,12 @@ RetrieveTransaction.prototype = {
|
||||
let retrieveStatus = retrieved.headers["x-mms-retrieve-status"];
|
||||
if ((retrieveStatus != null) &&
|
||||
(retrieveStatus != MMS.MMS_PDU_ERROR_OK)) {
|
||||
callbackIfValid(MMS.translatePduErrorToStatus(retrieveStatus),
|
||||
callback(MMS.translatePduErrorToStatus(retrieveStatus),
|
||||
retrieved);
|
||||
return;
|
||||
}
|
||||
|
||||
callbackIfValid(MMS.MMS_PDU_STATUS_RETRIEVED, retrieved);
|
||||
callback(MMS.MMS_PDU_STATUS_RETRIEVED, retrieved);
|
||||
}).bind(this));
|
||||
}
|
||||
};
|
||||
@ -787,7 +809,6 @@ MmsService.prototype = {
|
||||
retrieveMessage: function retrieveMessage(contentLocation, callback) {
|
||||
// TODO: bug 839436 - make DB be able to save MMS messages
|
||||
// TODO: bug 810099 - support onretrieving event
|
||||
// TODO: bug 810097 - Retry retrieval on error
|
||||
// TODO: bug 809832 - support customizable max incoming/outgoing message
|
||||
// size.
|
||||
|
||||
|
@ -4114,6 +4114,8 @@ pref("wap.UAProf.tagname", "x-wap-profile");
|
||||
//automatic: Automatic retrieval mode.
|
||||
//never: Never retrieval mode.
|
||||
pref("dom.mms.retrieval_mode", "manual");
|
||||
pref("dom.mms.retrievalRetryCount", 3);
|
||||
pref("dom.mms.retrievalRetryInterval", 300000);
|
||||
|
||||
// If the user puts a finger down on an element and we think the user
|
||||
// might be executing a pan gesture, how long do we wait before
|
||||
|
Loading…
Reference in New Issue
Block a user