Bug 824021 - Use SessionSaver.run() to force disk writes r=yoric

From e47510ab938cba4f54d515c9e2397a08b0f4f87b Mon Sep 17 00:00:00 2001
This commit is contained in:
Tim Taubert 2014-04-02 15:08:48 +02:00
parent a9eca49755
commit 89abeea26d

View File

@ -40,7 +40,8 @@ registerCleanupFunction(() => {
let tmp = {};
Cu.import("resource://gre/modules/Promise.jsm", tmp);
Cu.import("resource:///modules/sessionstore/SessionStore.jsm", tmp);
let {Promise, SessionStore} = tmp;
Cu.import("resource:///modules/sessionstore/SessionSaver.jsm", tmp);
let {Promise, SessionStore, SessionSaver} = tmp;
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
@ -265,23 +266,7 @@ function promiseSaveState() {
return deferred.promise;
}
function forceSaveState() {
let promise = promiseSaveState();
const PREF = "browser.sessionstore.interval";
let original = Services.prefs.getIntPref(PREF);
// Set interval to an arbitrary non-0 duration
// to ensure that setting it to 0 will notify observers
Services.prefs.setIntPref(PREF, 1000);
Services.prefs.setIntPref(PREF, 0);
return promise.then(
function onSuccess(x) {
Services.prefs.setIntPref(PREF, original);
return x;
},
function onError(x) {
Services.prefs.setIntPref(PREF, original);
throw x;
}
);
return SessionSaver.run();
}
function promiseSaveFileContents() {