| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 updateUrl = updateUrl.replace(/%NAME%/g, encodeURIComponent(_appInfo.name)); | 22 updateUrl = updateUrl.replace(/%NAME%/g, encodeURIComponent(_appInfo.name)); |
| 23 | 23 |
| 24 let callback = null; | 24 let callback = null; |
| 25 | 25 |
| 26 const INITIAL_DELAY = 0.1 * MILLIS_IN_HOUR; | 26 const INITIAL_DELAY = 0.1 * MILLIS_IN_HOUR; |
| 27 const CHECK_INTERVAL = 1 * MILLIS_IN_HOUR; | 27 const CHECK_INTERVAL = 1 * MILLIS_IN_HOUR; |
| 28 const EXPIRATION_INTERVAL = 24 * MILLIS_IN_HOUR; | 28 const EXPIRATION_INTERVAL = 24 * MILLIS_IN_HOUR; |
| 29 const TYPE_AUTOMATIC = 0; | 29 const TYPE_AUTOMATIC = 0; |
| 30 const TYPE_MANUAL = 1; | 30 const TYPE_MANUAL = 1; |
| 31 | 31 |
| 32 let downloader = new Downloader(getDownloadables, INITIAL_DELAY, CHECK_INTERVAL) ; | 32 let downloader = new Downloader(getDownloadables, INITIAL_DELAY, CHECK_INTERVAL) ; |
|
Eric
2015/05/15 19:36:13
The actual timer is in the 'Downloader' prototype.
| |
| 33 downloader.onExpirationChange = onExpirationChange; | 33 downloader.onExpirationChange = onExpirationChange; |
| 34 downloader.onDownloadSuccess = onDownloadSuccess; | 34 downloader.onDownloadSuccess = onDownloadSuccess; |
| 35 downloader.onDownloadError = onDownloadError; | 35 downloader.onDownloadError = onDownloadError; |
| 36 | 36 |
| 37 function getDownloadable(forceCheck) | 37 function getDownloadable(forceCheck) |
|
sergei
2015/04/21 12:35:24
In downloader.js there is a function which is call
| |
| 38 { | 38 { |
| 39 let url = updateUrl.replace(/%TYPE%/g, forceCheck ? TYPE_MANUAL : TYPE_AUTOMAT IC); | 39 let url = updateUrl.replace(/%TYPE%/g, forceCheck ? TYPE_MANUAL : TYPE_AUTOMAT IC); |
| 40 let downloadable = new Downloadable(url); | 40 let downloadable = new Downloadable(url); |
| 41 downloadable.lastError = Prefs.update_last_error; | 41 downloadable.lastError = Prefs.update_last_error; |
| 42 downloadable.lastCheck = Prefs.update_last_check; | 42 downloadable.lastCheck = Prefs.update_last_check; |
| 43 downloadable.softExpiration = Prefs.update_soft_expiration; | 43 downloadable.softExpiration = Prefs.update_soft_expiration; |
| 44 downloadable.hardExpiration = Prefs.update_hard_expiration; | 44 downloadable.hardExpiration = Prefs.update_hard_expiration; |
| 45 return downloadable; | 45 return downloadable; |
| 46 } | 46 } |
| 47 | 47 |
| 48 function getDownloadables() | 48 function getDownloadables() |
| 49 { | 49 { |
| 50 yield getDownloadable(false); | 50 yield getDownloadable(!!autoupdatesDisabled); |
|
sergei
2015/04/21 12:35:24
I think we should not touch this line because it i
Eric
2015/05/15 19:36:13
Agreed.
| |
| 51 } | 51 } |
| 52 | 52 |
| 53 function onExpirationChange(downloadable) | 53 function onExpirationChange(downloadable) |
| 54 { | 54 { |
| 55 Prefs.update_last_check = downloadable.lastCheck; | 55 Prefs.update_last_check = downloadable.lastCheck; |
| 56 Prefs.update_soft_expiration = downloadable.softExpiration; | 56 Prefs.update_soft_expiration = downloadable.softExpiration; |
| 57 Prefs.update_hard_expiration = downloadable.hardExpiration; | 57 Prefs.update_hard_expiration = downloadable.hardExpiration; |
| 58 } | 58 } |
| 59 | 59 |
| 60 function onDownloadSuccess(downloadable, responseText, errorCallback, redirectCa llback) | 60 function onDownloadSuccess(downloadable, responseText, errorCallback, redirectCa llback) |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 91 } | 91 } |
| 92 | 92 |
| 93 function onDownloadError(downloadable, downloadURL, error, channelStatus, respon seStatus, redirectCallback) | 93 function onDownloadError(downloadable, downloadURL, error, channelStatus, respon seStatus, redirectCallback) |
| 94 { | 94 { |
| 95 Prefs.update_last_error = Date.now(); | 95 Prefs.update_last_error = Date.now(); |
| 96 if (callback) | 96 if (callback) |
| 97 callback(error); | 97 callback(error); |
| 98 callback = null; | 98 callback = null; |
| 99 } | 99 } |
| 100 | 100 |
| 101 let checkForUpdates = exports.checkForUpdates = function checkForUpdates(_callba ck) | 101 let checkForUpdates = exports.checkForUpdates = function checkForUpdates(_callba ck) |
|
Eric
2015/05/15 19:36:13
We also need to intervene here, since this is wher
| |
| 102 { | 102 { |
| 103 callback = _callback; | 103 callback = _callback; |
| 104 downloader.download(getDownloadable(true)); | 104 downloader.download(getDownloadable(true)); |
| 105 } | 105 } |
| OLD | NEW |