Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/downloader.js

Issue 29336735: Issue 394 - hit statistics tool data collection (core) (Closed)
Patch Set: Rebase to changeset 593 Created April 6, 2016, 2:52 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/filterListener.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
},
« no previous file with comments | « no previous file | lib/filterListener.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld