зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 14b4af261515 (bug 1385609) for eslint failures in nsUrlClassifierLib.js. r=backout
This commit is contained in:
Родитель
b687ca805e
Коммит
34e6bbd998
|
@ -77,20 +77,17 @@ this.HTTP_TEMPORARY_REDIRECT = 307;
|
|||
* @param timeoutIncrement Number time (ms) the starting timeout period
|
||||
* we double this time for consecutive errors
|
||||
* @param maxTimeout Number time (ms) maximum timeout period
|
||||
* @param tolerance Checking next request tolerance.
|
||||
*/
|
||||
this.RequestBackoff =
|
||||
function RequestBackoff(maxErrors, retryIncrement,
|
||||
maxRequests, requestPeriod,
|
||||
timeoutIncrement, maxTimeout,
|
||||
tolerance) {
|
||||
timeoutIncrement, maxTimeout) {
|
||||
this.MAX_ERRORS_ = maxErrors;
|
||||
this.RETRY_INCREMENT_ = retryIncrement;
|
||||
this.MAX_REQUESTS_ = maxRequests;
|
||||
this.REQUEST_PERIOD_ = requestPeriod;
|
||||
this.TIMEOUT_INCREMENT_ = timeoutIncrement;
|
||||
this.MAX_TIMEOUT_ = maxTimeout;
|
||||
this.TOLERANCE_ = tolerance;
|
||||
|
||||
// Queue of ints keeping the time of all requests
|
||||
this.requestTimes_ = [];
|
||||
|
@ -114,9 +111,7 @@ RequestBackoff.prototype.reset = function() {
|
|||
*/
|
||||
RequestBackoff.prototype.canMakeRequest = function() {
|
||||
var now = Date.now();
|
||||
//Note that nsITimer delay is approximate: the timer can be fired before the
|
||||
//requested time has elapsed. So, give it a tolerance
|
||||
if (now + this.TOLERANCE_ < this.nextRequestTime_) {
|
||||
if (now < this.nextRequestTime_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -185,8 +180,7 @@ function RequestBackoffV4(maxRequests, requestPeriod) {
|
|||
maxRequests /* num requests */,
|
||||
requestPeriod /* request time, 60 min */,
|
||||
backoffInterval /* backoff interval, 60 min */,
|
||||
24 * 60 * 60 * 1000 /* max backoff, 24hr */,
|
||||
1000 /* tolerance of 1 sec */);
|
||||
24 * 60 * 60 * 1000 /* max backoff, 24hr */);
|
||||
}
|
||||
|
||||
// Expose this whole component.
|
||||
|
|
|
@ -236,10 +236,7 @@ PROT_ListManager.prototype.setUpdateCheckTimer = function(updateUrl,
|
|||
.createInstance(Ci.nsITimer);
|
||||
this.updateCheckers_[updateUrl].initWithCallback(() => {
|
||||
this.updateCheckers_[updateUrl] = null;
|
||||
if (updateUrl && !this.checkForUpdates(updateUrl)) {
|
||||
// Make another attempt later.
|
||||
this.setUpdateCheckTimer(updateUrl, this.updateInterval);
|
||||
}
|
||||
this.checkForUpdates(updateUrl);
|
||||
}, delay, Ci.nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,7 @@ function setNow(time) {
|
|||
function run_test() {
|
||||
// 3 errors, 1ms retry period, max 3 requests per ten milliseconds,
|
||||
// 5ms backoff interval, 19ms max delay
|
||||
var rb = new jslib.RequestBackoff(3, 1, 3, 10, 5, 19, 0);
|
||||
var rb = new jslib.RequestBackoff(3, 1, 3, 10, 5, 19);
|
||||
setNow(1);
|
||||
rb.noteServerResponse(200);
|
||||
do_check_true(rb.canMakeRequest());
|
||||
|
|
Загрузка…
Ссылка в новой задаче