Index: lib/downloader.js |
=================================================================== |
--- a/lib/downloader.js |
+++ b/lib/downloader.js |
@@ -43,28 +43,29 @@ |
{ |
this.dataSource = dataSource; |
this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); |
this._timer.initWithCallback(() => |
{ |
this._timer.delay = checkInterval; |
this._doCheck(); |
}, initialDelay, Ci.nsITimer.TYPE_REPEATING_SLACK); |
- this._downloading = Object.create(null); |
+ this._downloading = new Set(); |
}; |
Downloader.prototype = |
{ |
/** |
* Timer triggering the downloads. |
* @type {nsITimer} |
*/ |
_timer: null, |
/** |
- * Map containing the URLs of objects currently being downloaded as its keys. |
+ * Set containing the URLs of objects currently being downloaded. |
+ * @type {Set.<string>} |
*/ |
_downloading: null, |
/** |
* Function that will yield downloadable objects on each check. |
* @type {Function} |
*/ |
dataSource: null, |
@@ -177,17 +178,17 @@ |
/** |
* Checks whether an address is currently being downloaded. |
* @param {string} url |
* @return {boolean} |
*/ |
isDownloading(url) |
{ |
- return url in this._downloading; |
+ return this._downloading.has(url); |
}, |
/** |
* Starts downloading for an object. |
* @param {Downloadable} downloadable |
*/ |
download(downloadable) |
{ |
@@ -296,26 +297,26 @@ |
Cu.reportError(e); |
} |
request.addEventListener("error", event => |
{ |
if (onShutdown.done) |
return; |
- delete this._downloading[downloadable.url]; |
+ this._downloading.delete(downloadable.url); |
errorCallback("synchronize_connection_error"); |
}, false); |
request.addEventListener("load", event => |
{ |
if (onShutdown.done) |
return; |
- delete this._downloading[downloadable.url]; |
+ this._downloading.delete(downloadable.url); |
// Status will be 0 for non-HTTP requests |
if (request.status && request.status != 200) |
{ |
errorCallback("synchronize_connection_error"); |
return; |
} |
@@ -333,17 +334,17 @@ |
this._download(downloadable, redirects + 1); |
} |
} |
); |
}); |
request.send(null); |
- this._downloading[downloadable.url] = true; |
+ this._downloading.add(downloadable.url); |
if (this.onDownloadStarted) |
this.onDownloadStarted(downloadable); |
}, |
/** |
* Produces a soft and a hard expiration interval for a given supplied |
* expiration interval. |
* @param {number} interval |