Bug 1363482: Part 7 - Preload XULStore.json off-thread during startup. r=chutten
MozReview-Commit-ID: JOlMHw8SAfg
--- a/toolkit/components/xulstore/XULStore.js
+++ b/toolkit/components/xulstore/XULStore.js
@@ -80,31 +80,22 @@ XULStore.prototype = {
log(message) {
if (!debugMode)
return;
dump("XULStore: " + message + "\n");
Services.console.logStringMessage("XULStore: " + message);
},
readFile() {
- const MODE_RDONLY = 0x01;
- const FILE_PERMS = 0o600;
-
- let stream = Cc["@mozilla.org/network/file-input-stream;1"].
- createInstance(Ci.nsIFileInputStream);
- let json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
try {
- stream.init(this._storeFile, MODE_RDONLY, FILE_PERMS, 0);
- this._data = json.decodeFromStream(stream, stream.available());
+ this._data = JSON.parse(Cu.readFile(this._storeFile));
} catch (e) {
this.log("Error reading JSON: " + e);
// This exception could mean that the file didn't exist.
// We'll just ignore the error and start with a blank slate.
- } finally {
- stream.close();
}
},
async writeFile() {
if (!this._needsSaving)
return;
this._needsSaving = false;