Bug 745342 - Use more lazy services from Services.jsm [r=dietrich]

This commit is contained in:
Paul O’Shannessy 2012-04-16 14:26:10 -07:00
parent 50631b0bae
commit e86dac60a4

View File

@ -140,17 +140,11 @@ XPCOMUtils.defineLazyModuleGetter(this, "ScratchpadManager",
XPCOMUtils.defineLazyModuleGetter(this, "XPathGenerator",
"resource:///modules/sessionstore/XPathGenerator.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "CookieSvc",
"@mozilla.org/cookiemanager;1", "nsICookieManager2");
#ifdef MOZ_CRASHREPORTER
XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter",
"@mozilla.org/xre/app-info;1", "nsICrashReporter");
#endif
XPCOMUtils.defineLazyServiceGetter(this, "SecuritySvc",
"@mozilla.org/scriptsecuritymanager;1", "nsIScriptSecurityManager");
function debug(aMsg) {
aMsg = ("SessionStore: " + aMsg).replace(/\S{80}/g, "$&\n");
Services.console.logStringMessage(aMsg);
@ -160,8 +154,7 @@ function debug(aMsg) {
function SessionStoreService() {
XPCOMUtils.defineLazyGetter(this, "_prefBranch", function () {
return Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService).getBranch("browser.");
return Services.prefs.getBranch("browser.");
});
// minimal interval between two save operations (in milliseconds)
@ -2133,7 +2126,7 @@ SessionStoreService.prototype = {
let storage, storageItemCount = 0;
try {
var principal = SecuritySvc.getCodebasePrincipal(uri);
var principal = Services.scriptSecurityManager.getCodebasePrincipal(uri);
// Using getSessionStorageForPrincipal instead of getSessionStorageForURI
// just to be able to pass aCreate = false, that avoids creation of the
@ -2507,7 +2500,7 @@ SessionStoreService.prototype = {
for (var [host, isPinned] in Iterator(internalWindow.hosts)) {
let list;
try {
list = CookieSvc.getCookiesFromHost(host);
list = Services.cookies.getCookiesFromHost(host);
}
catch (ex) {
debug("getCookiesFromHost failed. Host: " + host);
@ -3703,9 +3696,9 @@ SessionStoreService.prototype = {
for (let i = 0; i < aCookies.length; i++) {
var cookie = aCookies[i];
try {
CookieSvc.add(cookie.host, cookie.path || "", cookie.name || "",
cookie.value, !!cookie.secure, !!cookie.httponly, true,
"expiry" in cookie ? cookie.expiry : MAX_EXPIRY);
Services.cookies.add(cookie.host, cookie.path || "", cookie.name || "",
cookie.value, !!cookie.secure, !!cookie.httponly, true,
"expiry" in cookie ? cookie.expiry : MAX_EXPIRY);
}
catch (ex) { Cu.reportError(ex); } // don't let a single cookie stop recovering
}