Bug 1363482: Part 7 - Preload XULStore.json off-thread during startup. r=chutten
authorKris Maglione <maglione.k@gmail.com>
Wed, 10 May 2017 17:09:49 -0700
changeset 427916 191e7abe8ce4f4398b3a19b22e53a4ec34b84a09
parent 427915 1f5bed26622ab351107afa822a7218d6603deec6
child 427917 4b9237e1824060357c47315cc04700235bee6179
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1363482
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1363482: Part 7 - Preload XULStore.json off-thread during startup. r=chutten MozReview-Commit-ID: JOlMHw8SAfg
toolkit/components/xulstore/XULStore.js
--- 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;