Bug 930901 - Rename _SessionFile to SessionFile r=billm

From 88d1ec2f1c54fe85b5a79292562762f1e616310e Mon Sep 17 00:00:00 2001

--HG--
rename : browser/components/sessionstore/src/_SessionFile.jsm => browser/components/sessionstore/src/SessionFile.jsm
This commit is contained in:
Tim Taubert 2013-10-25 11:52:42 +02:00
Родитель 19cf3994a2
Коммит a24d5e7884
10 изменённых файлов: 44 добавлений и 44 удалений

Просмотреть файл

@ -4,7 +4,7 @@
"use strict";
this.EXPORTED_SYMBOLS = ["_SessionFile"];
this.EXPORTED_SYMBOLS = ["SessionFile"];
/**
* Implementation of all the disk I/O required by the session store.
@ -49,7 +49,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "Telemetry",
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
"resource://gre/modules/Deprecated.jsm");
this._SessionFile = {
this.SessionFile = {
/**
* Read the contents of the session file, asynchronously.
*/
@ -100,7 +100,7 @@ this._SessionFile = {
}
};
Object.freeze(_SessionFile);
Object.freeze(SessionFile);
/**
* Utilities for dealing with promises and Task.jsm
@ -224,7 +224,7 @@ let SessionFileInternal = {
write: function (aData) {
if (this._isClosed) {
return Promise.reject(new Error("_SessionFile is closed"));
return Promise.reject(new Error("SessionFile is closed"));
}
let refObj = {};
@ -311,5 +311,5 @@ let SessionWorker = (function () {
AsyncShutdown.profileBeforeChange.addBlocker(
"SessionFile: Finish writing the latest sessionstore.js",
function() {
return _SessionFile._latestWrite;
return SessionFile._latestWrite;
});

Просмотреть файл

@ -109,7 +109,7 @@ let SessionMigration = {
return Task.spawn(function() {
let inState = yield SessionMigrationInternal.readState(aFromPath);
let outState = SessionMigrationInternal.convertState(inState);
// Unfortunately, we can't use SessionStore's own _SessionFile to
// Unfortunately, we can't use SessionStore's own SessionFile to
// write out the data because it has a dependency on the profile dir
// being known. When the migration runs, there is no guarantee that
// that's true.

Просмотреть файл

@ -18,8 +18,8 @@ Cu.import("resource://gre/modules/TelemetryStopwatch.jsm", this);
XPCOMUtils.defineLazyModuleGetter(this, "SessionStore",
"resource:///modules/sessionstore/SessionStore.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "_SessionFile",
"resource:///modules/sessionstore/_SessionFile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SessionFile",
"resource:///modules/sessionstore/SessionFile.jsm");
// Minimal interval between two save operations (in milliseconds).
XPCOMUtils.defineLazyGetter(this, "gInterval", function () {
@ -290,7 +290,7 @@ let SessionSaverInternal = {
// Write (atomically) to a session file, using a tmp file. Once the session
// file is successfully updated, save the time stamp of the last save and
// notify the observers.
_SessionFile.write(data).then(() => {
SessionFile.write(data).then(() => {
this.updateLastSaveTime();
notify(null, "sessionstore-state-write-complete");
}, Cu.reportError);

Просмотреть файл

@ -115,8 +115,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "SessionCookies",
"resource:///modules/sessionstore/SessionCookies.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TextAndScrollData",
"resource:///modules/sessionstore/TextAndScrollData.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "_SessionFile",
"resource:///modules/sessionstore/_SessionFile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SessionFile",
"resource:///modules/sessionstore/SessionFile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TabAttributes",
"resource:///modules/sessionstore/TabAttributes.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TabState",
@ -490,12 +490,12 @@ let SessionStoreInternal = {
return Task.spawn(function task() {
try {
// Perform background backup
yield _SessionFile.createBackupCopy("-" + buildID);
yield SessionFile.createBackupCopy("-" + buildID);
this._prefBranch.setCharPref(PREF_UPGRADE, buildID);
// In case of success, remove previous backup.
yield _SessionFile.removeBackupCopy("-" + latestBackup);
yield SessionFile.removeBackupCopy("-" + latestBackup);
} catch (ex) {
debug("Could not perform upgrade backup " + ex);
debug(ex.stack);
@ -737,7 +737,7 @@ let SessionStoreInternal = {
// _loadState changed from "stopped" to "running". Save the session's
// load state immediately so that crashes happening during startup
// are correctly counted.
_SessionFile.writeLoadStateOnceAfterStartup(STATE_RUNNING_STR);
SessionFile.writeLoadStateOnceAfterStartup(STATE_RUNNING_STR);
}
}
else {
@ -1073,7 +1073,7 @@ let SessionStoreInternal = {
* On purge of session history
*/
onPurgeSessionHistory: function ssi_onPurgeSessionHistory() {
_SessionFile.wipe();
SessionFile.wipe();
// If the browser is shutting down, simply return after clearing the
// session data on disk as this notification fires after the
// quit-application notification so the browser is about to exit.

Просмотреть файл

@ -74,14 +74,14 @@ let Agent = {
backupPath: OS.Path.join(OS.Constants.Path.profileDir, "sessionstore.bak"),
/**
* This method is only intended to be called by _SessionFile.syncRead() and
* This method is only intended to be called by SessionFile.syncRead() and
* can be removed when we're not supporting synchronous SessionStore
* initialization anymore. When sessionstore.js is read from disk
* synchronously the state string must be supplied to the worker manually by
* calling this method.
*/
setInitialState: function (aState) {
// _SessionFile.syncRead() should not be called after startup has finished.
// SessionFile.syncRead() should not be called after startup has finished.
// Thus we also don't support any setInitialState() calls after we already
// wrote the loadState to disk.
if (this.hasWrittenLoadStateOnce) {
@ -89,7 +89,7 @@ let Agent = {
}
// Initial state might have been filled by read() already but yet we might
// be called by _SessionFile.syncRead() before SessionStore.jsm had a chance
// be called by SessionFile.syncRead() before SessionStore.jsm had a chance
// to call writeLoadStateOnceAfterStartup(). It's safe to ignore
// setInitialState() calls if this happens.
if (!this.initialState) {

Просмотреть файл

@ -13,7 +13,6 @@ EXTRA_COMPONENTS += [
JS_MODULES_PATH = 'modules/sessionstore'
EXTRA_JS_MODULES = [
'_SessionFile.jsm',
'DocShellCapabilities.jsm',
'DocumentUtils.jsm',
'Messenger.jsm',
@ -21,6 +20,7 @@ EXTRA_JS_MODULES = [
'PrivacyLevel.jsm',
'RecentlyClosedTabsAndWindowsMenuUtils.jsm',
'SessionCookies.jsm',
'SessionFile.jsm',
'SessionHistory.jsm',
'SessionMigration.jsm',
'SessionStorage.jsm',

Просмотреть файл

@ -43,8 +43,8 @@ Cu.import("resource://gre/modules/TelemetryStopwatch.jsm");
Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
Cu.import("resource://gre/modules/Promise.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "_SessionFile",
"resource:///modules/sessionstore/_SessionFile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SessionFile",
"resource:///modules/sessionstore/SessionFile.jsm");
const STATE_RUNNING_STR = "running";
@ -80,7 +80,7 @@ SessionStartup.prototype = {
return;
}
_SessionFile.read().then(
SessionFile.read().then(
this._onSessionFileRead.bind(this),
Cu.reportError
);
@ -284,7 +284,7 @@ SessionStartup.prototype = {
// Initialization is complete, nothing else to do
return;
}
let contents = _SessionFile.syncRead();
let contents = SessionFile.syncRead();
this._onSessionFileRead(contents);
} catch(ex) {
debug("ensureInitialized: could not read session " + ex + ", " + ex.stack);

Просмотреть файл

@ -7,9 +7,9 @@
let tmp = {};
Cu.import("resource://gre/modules/osfile.jsm", tmp);
Cu.import("resource:///modules/sessionstore/_SessionFile.jsm", tmp);
Cu.import("resource:///modules/sessionstore/SessionFile.jsm", tmp);
const {OS, _SessionFile} = tmp;
const {OS, SessionFile} = tmp;
const PREF_SS_INTERVAL = "browser.sessionstore.interval";
// Full paths for sessionstore.js and sessionstore.bak.
@ -100,29 +100,29 @@ function testReadBackup() {
array = yield OS.File.read(path);
gSSData = gDecoder.decode(array);
// Read sessionstore.js with _SessionFile.read.
let ssDataRead = yield _SessionFile.read();
is(ssDataRead, gSSData, "_SessionFile.read read sessionstore.js correctly.");
// Read sessionstore.js with SessionFile.read.
let ssDataRead = yield SessionFile.read();
is(ssDataRead, gSSData, "SessionFile.read read sessionstore.js correctly.");
// Read sessionstore.js with _SessionFile.syncRead.
ssDataRead = _SessionFile.syncRead();
// Read sessionstore.js with SessionFile.syncRead.
ssDataRead = SessionFile.syncRead();
is(ssDataRead, gSSData,
"_SessionFile.syncRead read sessionstore.js correctly.");
"SessionFile.syncRead read sessionstore.js correctly.");
// Remove sessionstore.js to test fallback onto sessionstore.bak.
yield OS.File.remove(path);
ssExists = yield OS.File.exists(path);
ok(!ssExists, "sessionstore.js should be removed now.");
// Read sessionstore.bak with _SessionFile.read.
ssDataRead = yield _SessionFile.read();
// Read sessionstore.bak with SessionFile.read.
ssDataRead = yield SessionFile.read();
is(ssDataRead, gSSBakData,
"_SessionFile.read read sessionstore.bak correctly.");
"SessionFile.read read sessionstore.bak correctly.");
// Read sessionstore.bak with _SessionFile.syncRead.
ssDataRead = _SessionFile.syncRead();
// Read sessionstore.bak with SessionFile.syncRead.
ssDataRead = SessionFile.syncRead();
is(ssDataRead, gSSBakData,
"_SessionFile.syncRead read sessionstore.bak correctly.");
"SessionFile.syncRead read sessionstore.bak correctly.");
nextTest(testBackupUnchanged);
}

Просмотреть файл

@ -7,7 +7,7 @@ Cu.import("resource://gre/modules/osfile.jsm");
function run_test() {
do_get_profile();
Cu.import("resource:///modules/sessionstore/_SessionFile.jsm", toplevel);
Cu.import("resource:///modules/sessionstore/SessionFile.jsm", toplevel);
pathStore = OS.Path.join(OS.Constants.Path.profileDir, "sessionstore.js");
run_next_test();
}
@ -19,7 +19,7 @@ function pathBackup(ext) {
// Ensure that things proceed smoothly if there is no file to back up
add_task(function test_nothing_to_backup() {
yield _SessionFile.createBackupCopy("");
yield SessionFile.createBackupCopy("");
});
// Create a file, back it up, remove it
@ -29,14 +29,14 @@ add_task(function test_do_backup() {
yield OS.File.writeAtomic(pathStore, content, {tmpPath: pathStore + ".tmp"});
do_print("Ensuring that the backup is created");
yield _SessionFile.createBackupCopy(ext);
yield SessionFile.createBackupCopy(ext);
do_check_true((yield OS.File.exists(pathBackup(ext))));
let data = yield OS.File.read(pathBackup(ext));
do_check_eq((new TextDecoder()).decode(data), content);
do_print("Ensuring that we can remove the backup");
yield _SessionFile.removeBackupCopy(ext);
yield SessionFile.removeBackupCopy(ext);
do_check_false((yield OS.File.exists(pathBackup(ext))));
});

Просмотреть файл

@ -6,7 +6,7 @@ Cu.import("resource://gre/modules/osfile.jsm");
function run_test() {
let profd = do_get_profile();
Cu.import("resource:///modules/sessionstore/_SessionFile.jsm", toplevel);
Cu.import("resource:///modules/sessionstore/SessionFile.jsm", toplevel);
decoder = new TextDecoder();
pathStore = OS.Path.join(OS.Constants.Path.profileDir, "sessionstore.js");
pathBackup = OS.Path.join(OS.Constants.Path.profileDir, "sessionstore.bak");
@ -25,7 +25,7 @@ add_task(function test_first_write_backup() {
let initial_content = decoder.decode(yield OS.File.read(pathStore));
do_check_true(!(yield OS.File.exists(pathBackup)));
yield _SessionFile.write(content);
yield SessionFile.write(content);
do_check_true(yield OS.File.exists(pathBackup));
let backup_content = decoder.decode(yield OS.File.read(pathBackup));
@ -38,7 +38,7 @@ add_task(function test_second_write_no_backup() {
let initial_content = decoder.decode(yield OS.File.read(pathStore));
let initial_backup_content = decoder.decode(yield OS.File.read(pathBackup));
yield _SessionFile.write(content);
yield SessionFile.write(content);
let written_content = decoder.decode(yield OS.File.read(pathStore));
do_check_eq(content, written_content);