| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * @fileOverview Manages synchronization of filter subscriptions. | 21 * @fileOverview Manages synchronization of filter subscriptions. |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 const {Downloader, Downloadable, | 24 const {Downloader, Downloadable, |
| 25 MILLIS_IN_SECOND, MILLIS_IN_MINUTE, | 25 MILLIS_IN_SECOND, MILLIS_IN_MINUTE, |
| 26 MILLIS_IN_HOUR, MILLIS_IN_DAY} = require("./downloader"); | 26 MILLIS_IN_HOUR, MILLIS_IN_DAY} = require("./downloader"); |
| 27 const {Filter} = require("./filterClasses"); | 27 const {Filter} = require("./filterClasses"); |
| 28 const {FilterStorage} = require("./filterStorage"); | 28 const {FilterStorage} = require("./filterStorage"); |
| 29 const {FilterNotifier} = require("./filterNotifier"); | 29 const {filterNotifier} = require("./filterNotifier"); |
| 30 const {Prefs} = require("prefs"); | 30 const {Prefs} = require("prefs"); |
| 31 const {Subscription, | 31 const {Subscription, |
| 32 DownloadableSubscription} = require("./subscriptionClasses"); | 32 DownloadableSubscription} = require("./subscriptionClasses"); |
| 33 | 33 |
| 34 const INITIAL_DELAY = 1 * MILLIS_IN_MINUTE; | 34 const INITIAL_DELAY = 1 * MILLIS_IN_MINUTE; |
| 35 const CHECK_INTERVAL = 1 * MILLIS_IN_HOUR; | 35 const CHECK_INTERVAL = 1 * MILLIS_IN_HOUR; |
| 36 const DEFAULT_EXPIRATION_INTERVAL = 5 * MILLIS_IN_DAY; | 36 const DEFAULT_EXPIRATION_INTERVAL = 5 * MILLIS_IN_DAY; |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * The object providing actual downloading functionality. | 39 * The object providing actual downloading functionality. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 downloadable.softExpiration / MILLIS_IN_SECOND | 134 downloadable.softExpiration / MILLIS_IN_SECOND |
| 135 ); | 135 ); |
| 136 subscription.expires = Math.round( | 136 subscription.expires = Math.round( |
| 137 downloadable.hardExpiration / MILLIS_IN_SECOND | 137 downloadable.hardExpiration / MILLIS_IN_SECOND |
| 138 ); | 138 ); |
| 139 }, | 139 }, |
| 140 | 140 |
| 141 _onDownloadStarted(downloadable) | 141 _onDownloadStarted(downloadable) |
| 142 { | 142 { |
| 143 let subscription = Subscription.fromURL(downloadable.url); | 143 let subscription = Subscription.fromURL(downloadable.url); |
| 144 FilterNotifier.emit("subscription.downloading", subscription); | 144 filterNotifier.emit("subscription.downloading", subscription); |
| 145 }, | 145 }, |
| 146 | 146 |
| 147 _onDownloadSuccess(downloadable, responseText, errorCallback, | 147 _onDownloadSuccess(downloadable, responseText, errorCallback, |
| 148 redirectCallback) | 148 redirectCallback) |
| 149 { | 149 { |
| 150 let lines = responseText.split(/[\r\n]+/); | 150 let lines = responseText.split(/[\r\n]+/); |
| 151 let headerMatch = /\[Adblock(?:\s*Plus\s*([\d.]+)?)?\]/i.exec(lines[0]); | 151 let headerMatch = /\[Adblock(?:\s*Plus\s*([\d.]+)?)?\]/i.exec(lines[0]); |
| 152 if (!headerMatch) | 152 if (!headerMatch) |
| 153 return errorCallback("synchronize_invalid_data"); | 153 return errorCallback("synchronize_invalid_data"); |
| 154 let minVersion = headerMatch[1]; | 154 let minVersion = headerMatch[1]; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 subscription.filters.map(f => f.text).join("\n"); | 333 subscription.filters.map(f => f.text).join("\n"); |
| 334 redirectCallback("data:text/plain," + encodeURIComponent(data)); | 334 redirectCallback("data:text/plain," + encodeURIComponent(data)); |
| 335 } | 335 } |
| 336 }, false); | 336 }, false); |
| 337 request.send(null); | 337 request.send(null); |
| 338 } | 338 } |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 }; | 341 }; |
| 342 Synchronizer.init(); | 342 Synchronizer.init(); |
| OLD | NEW |