Bug 1416094 - Backoff
MozReview-Commit-ID: 25Mxao83nco
--- a/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
+++ b/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
@@ -221,19 +221,21 @@ HashCompleter.prototype = {
if (!this._backoffs[aGethashUrl]) {
// Initialize request backoffs separately, since requests are deleted
// after they are dispatched.
var jslib = Cc["@mozilla.org/url-classifier/jslib;1"]
.getService().wrappedJSObject;
// Using the V4 backoff algorithm for both V2 and V4. See bug 1273398.
- this._backoffs[aGethashUrl] = new jslib.RequestBackoffV4(
- 10 /* keep track of max requests */,
- 0 /* don't throttle on successful requests per time period */);
+ this._backoffs[aGethashUrl] = provider === "test" ?
+ new jslib.RequestBackoffTest() :
+ new jslib.RequestBackoffV4(
+ 10 /* keep track of max requests */,
+ 0 /* don't throttle on successful requests per time period */);
}
if (!this._nextGethashTimeMs[aGethashUrl]) {
this._nextGethashTimeMs[aGethashUrl] = 0;
}
// Start off this request. Without dispatching to a thread, every call to
// complete makes an individual HTTP request.
--- a/toolkit/components/url-classifier/nsUrlClassifierLib.js
+++ b/toolkit/components/url-classifier/nsUrlClassifierLib.js
@@ -184,16 +184,24 @@ function RequestBackoffV4(maxRequests, r
retryInterval /* retry interval, 15~30 min */,
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 */);
}
+function RequestBackoffTest() {
+ let obj = new RequestBackoffV4(0, 0);
+ obj.canMakeRequest = function () {
+ return true;
+ }
+ return obj;
+}
+
// Expose this whole component.
var lib = this;
function UrlClassifierLib() {
this.wrappedJSObject = lib;
}
UrlClassifierLib.prototype.classID = Components.ID("{26a4a019-2827-4a89-a85c-5931a678823a}");
UrlClassifierLib.prototype.QueryInterface = XPCOMUtils.generateQI([]);
--- a/toolkit/components/url-classifier/nsUrlClassifierListManager.js
+++ b/toolkit/components/url-classifier/nsUrlClassifierListManager.js
@@ -94,19 +94,21 @@ PROT_ListManager.prototype.registerTable
this.tablesData[tableName].gethashUrl = gethashUrl;
this.tablesData[tableName].provider = providerName;
// Keep track of all of our update URLs.
if (!this.needsUpdate_[updateUrl]) {
this.needsUpdate_[updateUrl] = {};
// Using the V4 backoff algorithm for both V2 and V4. See bug 1273398.
- this.requestBackoffs_[updateUrl] = new RequestBackoffV4(
- 4 /* num requests */,
- 60 * 60 * 1000 /* request time, 60 min */);
+ this.requestBackoffs_[updateUrl] = providerName == "test" ?
+ new RequestBackoffTest() :
+ new RequestBackoffV4(
+ 4 /* num requests */,
+ 60 * 60 * 1000 /* request time, 60 min */);
}
this.needsUpdate_[updateUrl][tableName] = false;
return true;
};
/**
* Unregister a table table from list
@@ -690,16 +692,17 @@ PROT_ListManager.prototype.QueryInterfac
var modScope = this;
function Init() {
// Pull the library in.
var jslib = Cc["@mozilla.org/url-classifier/jslib;1"]
.getService().wrappedJSObject;
/* global BindToObject, RequestBackoffV4 */
modScope.BindToObject = jslib.BindToObject;
modScope.RequestBackoffV4 = jslib.RequestBackoffV4;
+ modScope.RequestBackoffTest = jslib.RequestBackoffTest;
// We only need to call Init once.
modScope.Init = function() {};
}
function RegistrationData() {
}
RegistrationData.prototype = {