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

Delta Between Two Patch Sets: lib/indexedDBBackup.js

Issue 29860578: Issue 6775 - Work around filter data stored in IndexedDB getting lost on Microsoft Edge (Closed)
Left Patch Set: Created Sept. 5, 2018, 2:02 p.m.
Right Patch Set: Created Sept. 5, 2018, 3:53 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | lib/ioIndexedDB.js » ('j') | qunit/tests/indexedDBBackup.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 minWriteInterval; 27 let backupDelay;
Sebastian Noack 2018/09/05 14:34:49 Nit: This is no longer a "min" but a fixed value.
geo 2018/09/05 15:59:08 Done. I've also changed the name of `writeInterval
28 let pendingBackup = false; 28 let pendingBackup = false;
29 29
30 function setBackupInterval(backupInterval = 60 * 1000) 30 function setBackupInterval(backupInterval = 60 * 1000)
31 { 31 {
32 minWriteInterval = backupInterval; 32 backupDelay = backupInterval;
33 } 33 }
34 34
35 setBackupInterval(); 35 setBackupInterval();
36 36
37 function scheduleBackup() 37 function scheduleBackup()
38 { 38 {
39 if (!pendingBackup) 39 if (!pendingBackup)
40 { 40 {
41 pendingBackup = true; 41 pendingBackup = true;
42 42
43 setTimeout( 43 setTimeout(
44 () => 44 () =>
45 { 45 {
46 saveToStorage(); 46 saveToStorage();
47 pendingBackup = false; 47 pendingBackup = false;
48 }, 48 },
49 minWriteInterval 49 backupDelay
50 ); 50 );
51 } 51 }
52 } 52 }
53 53
54 function saveToStorage() 54 function saveToStorage()
55 { 55 {
56 browser.storage.local.set({ 56 browser.storage.local.set({
57 [BACKUP_NAME]: { 57 [BACKUP_NAME]: {
58 content: serialize(), 58 content: serialize(),
59 lastModified: Date.now() 59 lastModified: Date.now()
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 };
LEFTRIGHT
« no previous file | lib/ioIndexedDB.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld