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

Unified Diff: lib/updater.js

Issue 29545700: Issue 5685 - Pass ESLint (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Address review comments Created Sept. 18, 2017, 12:42 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 | « lib/prefs.js ('k') | lib/utils.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/updater.js
===================================================================
--- a/lib/updater.js
+++ b/lib/updater.js
@@ -10,43 +10,48 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
+"use strict";
+
let {Prefs} = require("prefs");
let {Downloader, Downloadable, MILLIS_IN_HOUR} = require("downloader");
const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
-let updateUrl = (_appInfo.developmentBuild ? Prefs.update_url_devbuild : Prefs.update_url_release);
+let updateUrl = (_appInfo.developmentBuild ?
+ Prefs.update_url_devbuild : Prefs.update_url_release);
updateUrl = updateUrl.replace(/%NAME%/g, encodeURIComponent(_appInfo.name));
let callback = null;
const INITIAL_DELAY = 0.1 * MILLIS_IN_HOUR;
const CHECK_INTERVAL = 1 * MILLIS_IN_HOUR;
const EXPIRATION_INTERVAL = 24 * MILLIS_IN_HOUR;
const TYPE_AUTOMATIC = 0;
const TYPE_MANUAL = 1;
-let downloader = new Downloader(getDownloadables, INITIAL_DELAY, CHECK_INTERVAL);
+let downloader = new Downloader(
+ getDownloadables, INITIAL_DELAY, CHECK_INTERVAL);
downloader.onExpirationChange = onExpirationChange;
downloader.onDownloadSuccess = onDownloadSuccess;
downloader.onDownloadError = onDownloadError;
function getDownloadable(forceCheck)
{
if (!forceCheck && Prefs.disable_auto_updates)
{
return null;
}
- let url = updateUrl.replace(/%TYPE%/g, forceCheck ? TYPE_MANUAL : TYPE_AUTOMATIC);
+ let url = updateUrl.replace(/%TYPE%/g,
+ forceCheck ? TYPE_MANUAL : TYPE_AUTOMATIC);
let downloadable = new Downloadable(url);
downloadable.lastError = Prefs.update_last_error;
downloadable.lastCheck = Prefs.update_last_check;
downloadable.softExpiration = Prefs.update_soft_expiration;
downloadable.hardExpiration = Prefs.update_hard_expiration;
return downloadable;
}
@@ -57,20 +62,22 @@
function onExpirationChange(downloadable)
{
Prefs.update_last_check = downloadable.lastCheck;
Prefs.update_soft_expiration = downloadable.softExpiration;
Prefs.update_hard_expiration = downloadable.hardExpiration;
}
-function onDownloadSuccess(downloadable, responseText, errorCallback, redirectCallback)
+function onDownloadSuccess(downloadable, responseText, errorCallback,
+ redirectCallback)
{
Prefs.update_last_error = 0;
- [Prefs.update_soft_expiration, Prefs.update_hard_expiration] = downloader.processExpirationInterval(EXPIRATION_INTERVAL);
+ [Prefs.update_soft_expiration, Prefs.update_hard_expiration] =
+ downloader.processExpirationInterval(EXPIRATION_INTERVAL);
try
{
let data = JSON.parse(responseText);
let updateInfo = null;
if (_appInfo.name in data)
updateInfo = data[_appInfo.name];
else if (_appInfo.name + "/" + _appInfo.application in data)
@@ -90,21 +97,24 @@
{
Cu.reportError(e);
errorCallback(e);
}
callback = null;
}
-function onDownloadError(downloadable, downloadURL, error, channelStatus, responseStatus, redirectCallback)
+function onDownloadError(downloadable, downloadURL, error,
+ channelStatus, responseStatus, redirectCallback)
{
Prefs.update_last_error = Date.now();
if (callback)
callback(error);
callback = null;
}
-let checkForUpdates = exports.checkForUpdates = function checkForUpdates(_callback)
+let checkForUpdates = function(_callback)
{
callback = _callback;
downloader.download(getDownloadable(true));
-}
+};
+
+exports.checkForUpdates = checkForUpdates;
« no previous file with comments | « lib/prefs.js ('k') | lib/utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld