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

Side by Side Diff: lib/prefs.js

Issue 29760565: Issue 6599 - Detect data corruption of storage.local (Closed)
Patch Set: Created April 24, 2018, 11:02 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/subscriptionInit.js » ('j') | lib/subscriptionInit.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 }, 320 },
321 enumerable: true 321 enumerable: true
322 }); 322 });
323 } 323 }
324 324
325 function init() 325 function init()
326 { 326 {
327 let prefs = Object.keys(defaults); 327 let prefs = Object.keys(defaults);
328 prefs.forEach(addPreference); 328 prefs.forEach(addPreference);
329 329
330 let localLoaded = new Promise(resolve => 330 let localLoaded = new Promise((resolve, reject) =>
331 { 331 {
332 ext.storage.get(prefs.map(prefToKey), items => 332 ext.storage.get(prefs.map(prefToKey)).then(items =>
333 { 333 {
334 for (let key in items) 334 for (let key in items)
335 overrides[keyToPref(key)] = items[key]; 335 overrides[keyToPref(key)] = items[key];
336 336
337 resolve(); 337 resolve();
338 }); 338 }, reject);
339 }); 339 });
340 340
341 let managedLoaded = new Promise(resolve => 341 let managedLoaded = new Promise(resolve =>
342 { 342 {
343 if ("managed" in browser.storage) 343 if ("managed" in browser.storage)
344 { 344 {
345 browser.storage.managed.get(null, items => 345 browser.storage.managed.get(null, items =>
346 { 346 {
347 // Opera doesn't support browser.storage.managed, but instead simply 347 // Opera doesn't support browser.storage.managed, but instead simply
348 // removing the API, Opera sets browser.runtime.lastError when using it. 348 // removing the API, Opera sets browser.runtime.lastError when using it.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 eventEmitter.emit(pref); 380 eventEmitter.emit(pref);
381 } 381 }
382 } 382 }
383 }); 383 });
384 } 384 }
385 385
386 Prefs.untilLoaded = Promise.all([localLoaded, managedLoaded]).then(onLoaded); 386 Prefs.untilLoaded = Promise.all([localLoaded, managedLoaded]).then(onLoaded);
387 } 387 }
388 388
389 init(); 389 init();
OLDNEW
« no previous file with comments | « no previous file | lib/subscriptionInit.js » ('j') | lib/subscriptionInit.js » ('J')

Powered by Google App Engine
This is Rietveld