Class: Downloader

Downloader(dataSource, initialDelay, checkInterval)

new Downloader(dataSource, initialDelay, checkInterval)

Creates a new downloader instance.
Parameters:
Name Type Description
dataSource function Function that will yield downloadable objects on each check
initialDelay number Number of milliseconds to wait before the first check
checkInterval number Interval between the checks
Source:

Members

_downloading :Set.<string>

Set containing the URLs of objects currently being downloaded.
Type:
  • Set.<string>
Source:

_timer :nsITimer

Timer triggering the downloads.
Type:
  • nsITimer
Source:

dataSource :function

Function that will yield downloadable objects on each check.
Type:
  • function
Source:

maxAbsenceInterval :number

Maximal time interval that the checks can be left out until the soft expiration interval increases.
Type:
  • number
Source:

maxExpirationInterval :number

Maximal allowed expiration interval; larger expiration intervals will be corrected.
Type:
  • number
Source:

maxRedirects :number

Maximal number of redirects before the download is considered as failed.
Type:
  • number
Source:

minRetryInterval :number

Minimal time interval before retrying a download after an error.
Type:
  • number
Source:

(nullable) onDownloadError :function

Callback to be triggered whenever a download fails.
Type:
  • function
Source:

(nullable) onDownloadStarted :function

Callback to be triggered whenever a download starts.
Type:
  • function
Source:

(nullable) onDownloadSuccess :function

Callback to be triggered whenever a download finishes successfully. The callback can return an error code to indicate that the data is wrong.
Type:
  • function
Source:

(nullable) onExpirationChange :function

Called whenever expiration intervals for an object need to be adapted.
Type:
  • function
Source:

Methods

_doCheck()

Checks whether anything needs downloading.
Source:

download(downloadable)

Starts downloading for an object.
Parameters:
Name Type Description
downloadable Downloadable
Source:

getDownloadUrl(downloadable) → {string}

Generates the real download URL for an object by appending various parameters.
Parameters:
Name Type Description
downloadable Downloadable
Source:
Returns:
Type
string

isDownloading(url) → {boolean}

Checks whether an address is currently being downloaded.
Parameters:
Name Type Description
url string
Source:
Returns:
Type
boolean

processExpirationInterval(interval) → {Array.<number>}

Produces a soft and a hard expiration interval for a given supplied expiration interval.
Parameters:
Name Type Description
interval number
Source:
Returns:
soft and hard expiration interval
Type
Array.<number>