зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1357517 - Remove Preferences.jsm usage from some dom/push/* files. r=kitcambridge
--HG-- extra : rebase_source : 77dce879e3ceb5352ea7a65673dffd53c9b9276f
This commit is contained in:
Родитель
dcf26d1a9a
Коммит
51d8b32912
|
@ -7,7 +7,6 @@
|
|||
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.importGlobalProperties(["indexedDB"]);
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ const Cu = Components.utils;
|
|||
const Cr = Components.results;
|
||||
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
|
@ -25,7 +24,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
|||
|
||||
this.EXPORTED_SYMBOLS = ["PushRecord"];
|
||||
|
||||
const prefs = new Preferences("dom.push.");
|
||||
const prefs = Services.prefs.getBranch("dom.push.");
|
||||
|
||||
/**
|
||||
* The push subscription record, stored in IndexedDB.
|
||||
|
@ -50,7 +49,7 @@ PushRecord.prototype = {
|
|||
setQuota(suggestedQuota) {
|
||||
if (this.quotaApplies()) {
|
||||
let quota = +suggestedQuota;
|
||||
this.quota = quota >= 0 ? quota : prefs.get("maxQuotaPerSubscription");
|
||||
this.quota = quota >= 0 ? quota : prefs.getIntPref("maxQuotaPerSubscription");
|
||||
} else {
|
||||
this.quota = Infinity;
|
||||
}
|
||||
|
@ -58,7 +57,7 @@ PushRecord.prototype = {
|
|||
|
||||
resetQuota() {
|
||||
this.quota = this.quotaApplies() ?
|
||||
prefs.get("maxQuotaPerSubscription") : Infinity;
|
||||
prefs.getIntPref("maxQuotaPerSubscription") : Infinity;
|
||||
},
|
||||
|
||||
updateQuota(lastVisit) {
|
||||
|
@ -81,7 +80,7 @@ PushRecord.prototype = {
|
|||
Math.max(0, (Date.now() - lastVisit) / 24 / 60 / 60 / 1000);
|
||||
this.quota = Math.min(
|
||||
Math.round(8 * Math.pow(daysElapsed, -0.8)),
|
||||
prefs.get("maxQuotaPerSubscription")
|
||||
prefs.getIntPref("maxQuotaPerSubscription")
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -106,7 +105,7 @@ PushRecord.prototype = {
|
|||
// Drop older message IDs from the end of the list.
|
||||
let maxRecentMessageIDs = Math.min(
|
||||
this.recentMessageIDs.length,
|
||||
Math.max(prefs.get("maxRecentMessageIDsPerSubscription"), 0)
|
||||
Math.max(prefs.getIntPref("maxRecentMessageIDsPerSubscription"), 0)
|
||||
);
|
||||
this.recentMessageIDs.length = maxRecentMessageIDs || 0;
|
||||
},
|
||||
|
@ -214,7 +213,7 @@ PushRecord.prototype = {
|
|||
* permission check.
|
||||
*/
|
||||
hasPermission() {
|
||||
if (this.systemRecord || prefs.get("testing.ignorePermission")) {
|
||||
if (this.systemRecord || prefs.getBoolPref("testing.ignorePermission", false)) {
|
||||
return true;
|
||||
}
|
||||
let permission = Services.perms.testExactPermissionFromPrincipal(
|
||||
|
|
|
@ -17,7 +17,6 @@ Cu.import("resource://gre/modules/Services.jsm");
|
|||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
Cu.import("resource://gre/modules/IndexedDBHelper.jsm");
|
||||
Cu.import("resource://gre/modules/Timer.jsm");
|
||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
const {
|
||||
PushCrypto,
|
||||
|
@ -34,7 +33,7 @@ XPCOMUtils.defineLazyGetter(this, "console", () => {
|
|||
});
|
||||
});
|
||||
|
||||
const prefs = new Preferences("dom.push.");
|
||||
const prefs = Services.prefs.getBranch("dom.push.");
|
||||
|
||||
const kPUSHHTTP2DB_DB_NAME = "pushHttp2";
|
||||
const kPUSHHTTP2DB_DB_VERSION = 5; // Change this if the IndexedDB format changes
|
||||
|
@ -257,7 +256,7 @@ SubscriptionListener.prototype = {
|
|||
var statusCode = aRequest.QueryInterface(Ci.nsIHttpChannel).responseStatus;
|
||||
|
||||
if (Math.floor(statusCode / 100) == 5) {
|
||||
if (this._subInfo.retries < prefs.get("http2.maxRetries")) {
|
||||
if (this._subInfo.retries < prefs.getIntPref("http2.maxRetries")) {
|
||||
this._subInfo.retries++;
|
||||
var retryAfter = retryAfterParser(aRequest);
|
||||
this._retryTimeoutID = setTimeout(_ =>
|
||||
|
@ -432,7 +431,7 @@ this.PushServiceHttp2 = {
|
|||
|
||||
validServerURI: function(serverURI) {
|
||||
if (serverURI.scheme == "http") {
|
||||
return !!prefs.get("testing.allowInsecureServerURL");
|
||||
return !!prefs.getBoolPref("testing.allowInsecureServerURL", false);
|
||||
}
|
||||
return serverURI.scheme == "https";
|
||||
},
|
||||
|
@ -582,14 +581,14 @@ this.PushServiceHttp2 = {
|
|||
_retryAfterBackoff: function(aSubscriptionUri, retryAfter) {
|
||||
console.debug("retryAfterBackoff()");
|
||||
|
||||
var resetRetryCount = prefs.get("http2.reset_retry_count_after_ms");
|
||||
var resetRetryCount = prefs.getIntPref("http2.reset_retry_count_after_ms");
|
||||
// If it was running for some time, reset retry counter.
|
||||
if ((Date.now() - this._conns[aSubscriptionUri].lastStartListening) >
|
||||
resetRetryCount) {
|
||||
this._conns[aSubscriptionUri].countUnableToConnect = 0;
|
||||
}
|
||||
|
||||
let maxRetries = prefs.get("http2.maxRetries");
|
||||
let maxRetries = prefs.getIntPref("http2.maxRetries");
|
||||
if (this._conns[aSubscriptionUri].countUnableToConnect >= maxRetries) {
|
||||
this._shutdownSubscription(aSubscriptionUri);
|
||||
this._resubscribe(aSubscriptionUri);
|
||||
|
@ -604,7 +603,7 @@ this.PushServiceHttp2 = {
|
|||
return;
|
||||
}
|
||||
|
||||
retryAfter = prefs.get("http2.retryInterval") *
|
||||
retryAfter = prefs.getIntPref("http2.retryInterval") *
|
||||
Math.pow(2, this._conns[aSubscriptionUri].countUnableToConnect);
|
||||
|
||||
retryAfter = retryAfter * (0.8 + Math.random() * 0.4); // add +/-20%.
|
||||
|
|
Загрузка…
Ссылка в новой задаче