LEFT | RIGHT |
(no file at all) | |
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 const {filterNotifier} = require("../adblockpluscore/lib/filterNotifier"); | 20 const {filterNotifier} = require("../adblockpluscore/lib/filterNotifier"); |
21 const {FilterStorage} = require("../adblockpluscore/lib/filterStorage"); | 21 const {filterStorage} = require("../adblockpluscore/lib/filterStorage"); |
22 const {DownloadableSubscription, SpecialSubscription} = | 22 const {DownloadableSubscription, SpecialSubscription} = |
23 require("../adblockpluscore/lib/subscriptionClasses"); | 23 require("../adblockpluscore/lib/subscriptionClasses"); |
24 | 24 |
25 const BACKUP_NAME = "file:indexedDB-backup"; | 25 const BACKUP_NAME = "file:indexedDB-backup"; |
26 | 26 |
27 let backupDelay; | 27 let backupDelay; |
28 let pendingBackup = false; | 28 let pendingBackup = false; |
29 | 29 |
30 function setBackupInterval(backupInterval = 60 * 1000) | 30 function setBackupInterval(backupInterval = 60 * 1000) |
31 { | 31 { |
(...skipping 26 matching lines...) Expand all Loading... |
58 content: serialize(), | 58 content: serialize(), |
59 lastModified: Date.now() | 59 lastModified: Date.now() |
60 } | 60 } |
61 }); | 61 }); |
62 } | 62 } |
63 | 63 |
64 function serialize() | 64 function serialize() |
65 { | 65 { |
66 let buffer = []; | 66 let buffer = []; |
67 | 67 |
68 for (let subscription of FilterStorage.subscriptions) | 68 for (let subscription of filterStorage.subscriptions()) |
69 { | 69 { |
70 if (subscription instanceof SpecialSubscription) | 70 if (subscription instanceof SpecialSubscription) |
71 { | 71 { |
72 subscription.serialize(buffer); | 72 subscription.serialize(buffer); |
73 buffer.push("[Subscription filters]"); | 73 buffer.push("[Subscription filters]"); |
74 subscription.serializeFilters(buffer); | 74 subscription.serializeFilters(buffer); |
75 } | 75 } |
76 else if (subscription instanceof DownloadableSubscription) | 76 else if (subscription instanceof DownloadableSubscription) |
77 { | 77 { |
78 let {homepage, title, url, disabled} = subscription; | 78 let {homepage, title, url, disabled} = subscription; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 filterNotifier.on("filter.removed", scheduleBackup); | 110 filterNotifier.on("filter.removed", scheduleBackup); |
111 filterNotifier.on("filter.moved", scheduleBackup); | 111 filterNotifier.on("filter.moved", scheduleBackup); |
112 filterNotifier.on("filter.disabled", scheduleBackup); | 112 filterNotifier.on("filter.disabled", scheduleBackup); |
113 | 113 |
114 exports.IndexedDBBackup = | 114 exports.IndexedDBBackup = |
115 { | 115 { |
116 getBackupData, | 116 getBackupData, |
117 // Non-public API, just for tests. | 117 // Non-public API, just for tests. |
118 setBackupInterval | 118 setBackupInterval |
119 }; | 119 }; |
LEFT | RIGHT |