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

Side by Side Diff: lib/io.js

Issue 29570614: Issue 5028 - Use browser namespace (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Use callback-based API for storage Created Oct. 9, 2017, 4:01 p.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 | « lib/icon.js ('k') | lib/notificationHelper.js » ('j') | no next file with comments »
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 ); 56 );
57 }); 57 });
58 } 58 }
59 59
60 function removeFile(fileName) 60 function removeFile(fileName)
61 { 61 {
62 return new Promise((resolve, reject) => 62 return new Promise((resolve, reject) =>
63 { 63 {
64 ext.storage.remove(fileToKey(fileName), () => 64 ext.storage.remove(fileToKey(fileName), () =>
65 { 65 {
66 if (chrome.runtime.lastError) 66 if (browser.runtime.lastError)
67 reject(chrome.runtime.lastError.message); 67 reject(browser.runtime.lastError.message);
68 else 68 else
69 resolve(); 69 resolve();
70 }); 70 });
71 }); 71 });
72 } 72 }
73 73
74 exports.IO = 74 exports.IO =
75 { 75 {
76 /** 76 /**
77 * Reads text lines from a file. 77 * Reads text lines from a file.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 * Promise to be resolved or rejected once the operation is completed 130 * Promise to be resolved or rejected once the operation is completed
131 */ 131 */
132 renameFile(fromFile, newName) 132 renameFile(fromFile, newName)
133 { 133 {
134 return loadFile(fromFile).then(entry => 134 return loadFile(fromFile).then(entry =>
135 { 135 {
136 return new Promise((resolve, reject) => 136 return new Promise((resolve, reject) =>
137 { 137 {
138 ext.storage.set(fileToKey(newName), entry, () => 138 ext.storage.set(fileToKey(newName), entry, () =>
139 { 139 {
140 if (chrome.runtime.lastError) 140 if (browser.runtime.lastError)
141 reject(chrome.runtime.lastError.message); 141 reject(browser.runtime.lastError.message);
142 else 142 else
143 resolve(); 143 resolve();
144 }); 144 });
145 }); 145 });
146 }).then(() => removeFile(fromFile)); 146 }).then(() => removeFile(fromFile));
147 }, 147 },
148 148
149 /** 149 /**
150 * Removes a file. 150 * Removes a file.
151 * @param {string} fileName 151 * @param {string} fileName
(...skipping 23 matching lines...) Expand all
175 lastModified: entry.lastModified 175 lastModified: entry.lastModified
176 }; 176 };
177 }).catch(error => 177 }).catch(error =>
178 { 178 {
179 if (error.type == "NoSuchFile") 179 if (error.type == "NoSuchFile")
180 return {exists: false}; 180 return {exists: false};
181 throw error; 181 throw error;
182 }); 182 });
183 } 183 }
184 }; 184 };
OLDNEW
« no previous file with comments | « lib/icon.js ('k') | lib/notificationHelper.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld