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

Delta Between Two Patch Sets: lib/io.js

Issue 29526591: Issue 5562 - Move Edge storage to IndexedDB (Closed)
Left Patch Set: Remove migration from localStorage logic Created Aug. 24, 2017, 2:42 p.m.
Right Patch Set: Remove accidental code Created Aug. 24, 2017, 5:15 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/localforage.min.js » ('j') | no next file with change/comment »
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
(...skipping 12 matching lines...) Expand all
23 { 23 {
24 return keyPrefix + fileName; 24 return keyPrefix + fileName;
25 } 25 }
26 26
27 function loadFile(fileName) 27 function loadFile(fileName)
28 { 28 {
29 return new Promise((resolve, reject) => 29 return new Promise((resolve, reject) =>
30 { 30 {
31 localforage.getItem(fileToKey(fileName), (err, value) => 31 localforage.getItem(fileToKey(fileName), (err, value) =>
32 { 32 {
33 if (err || !value) 33 if (err || value == null)
34 reject({type: "NoSuchFile"}); 34 reject({type: "NoSuchFile"});
35 else 35 else
36 resolve(value); 36 resolve(value);
37 }); 37 });
38 }); 38 });
39 } 39 }
40 40
41 function saveFile(fileName, data) 41 function saveFile(fileName, data)
42 { 42 {
43 let key = fileToKey(fileName); 43 let key = fileToKey(fileName);
(...skipping 25 matching lines...) Expand all
69 * Name of the file to be read 69 * Name of the file to be read
70 * @param {TextSink} listener 70 * @param {TextSink} listener
71 * Function that will be called for each line in the file 71 * Function that will be called for each line in the file
72 * @return {Promise} 72 * @return {Promise}
73 * Promise to be resolved or rejected once the operation is completed 73 * Promise to be resolved or rejected once the operation is completed
74 */ 74 */
75 readFromFile(fileName, listener) 75 readFromFile(fileName, listener)
76 { 76 {
77 return loadFile(fileName).then(entry => 77 return loadFile(fileName).then(entry =>
78 { 78 {
79 if ("content" in entry) 79 for (let line of entry.content)
80 { 80 listener(line);
81 for (let line of entry.content)
82 listener(line);
83 }
84 }); 81 });
85 }, 82 },
86 83
87 /** 84 /**
88 * Writes text lines to a file. 85 * Writes text lines to a file.
89 * @param {string} fileName 86 * @param {string} fileName
90 * Name of the file to be written 87 * Name of the file to be written
91 * @param {Iterable.<string>} data 88 * @param {Iterable.<string>} data
92 * An array-like or iterable object containing the lines (without line 89 * An array-like or iterable object containing the lines (without line
93 * endings) 90 * endings)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 lastModified: entry.lastModified 156 lastModified: entry.lastModified
160 }; 157 };
161 }).catch(error => 158 }).catch(error =>
162 { 159 {
163 if (error.type == "NoSuchFile") 160 if (error.type == "NoSuchFile")
164 return {exists: false}; 161 return {exists: false};
165 throw error; 162 throw error;
166 }); 163 });
167 } 164 }
168 }; 165 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld