Index: lib/downloader.js |
=================================================================== |
--- a/lib/downloader.js |
+++ b/lib/downloader.js |
@@ -31,11 +31,13 @@ |
* @param {Function} dataSource Function that will yield downloadable objects on each check |
* @param {Integer} initialDelay Number of milliseconds to wait before the first check |
* @param {Integer} checkInterval Interval between the checks |
+ * @param {function} downloadCallback optional function that's being called when something needs to be downloaded |
* @constructor |
*/ |
-let Downloader = exports.Downloader = function Downloader(dataSource, initialDelay, checkInterval) |
+let Downloader = exports.Downloader = function Downloader(dataSource, initialDelay, checkInterval, downloadCallback) |
{ |
this.dataSource = dataSource; |
+ this.downloadCallback = downloadCallback || this._download; |
this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); |
this._timer.initWithCallback(function() |
{ |
@@ -64,6 +66,12 @@ |
dataSource: null, |
/** |
+ * Function that's being called when something needs to be downloaded. |
+ * @type Function |
+ */ |
+ downloadCallback: null, |
+ |
+ /** |
* Maximal time interval that the checks can be left out until the soft |
* expiration interval increases. |
* @type Integer |
@@ -150,7 +158,7 @@ |
if (downloadable.lastError && now - downloadable.lastError < this.minRetryInterval) |
continue; |
- this._download(downloadable, 0); |
+ this.downloadCallback(downloadable, 0); |
} |
}, |