Bug 1772101 - Part 46: Use plain object for lazy getter in toolkit/components/url-classifier/. r=gcp
Differential Revision: https://phabricator.services.mozilla.com/D147987
This commit is contained in:
@@ -18,15 +18,17 @@ const { XPCOMUtils } = ChromeUtils.import(
|
|||||||
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
const { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
|
||||||
|
|
||||||
|
const lazy = {};
|
||||||
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(
|
XPCOMUtils.defineLazyServiceGetter(
|
||||||
this,
|
lazy,
|
||||||
"gDbService",
|
"gDbService",
|
||||||
"@mozilla.org/url-classifier/dbservice;1",
|
"@mozilla.org/url-classifier/dbservice;1",
|
||||||
"nsIUrlClassifierDBService"
|
"nsIUrlClassifierDBService"
|
||||||
);
|
);
|
||||||
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(
|
XPCOMUtils.defineLazyServiceGetter(
|
||||||
this,
|
lazy,
|
||||||
"gUrlUtil",
|
"gUrlUtil",
|
||||||
"@mozilla.org/url-classifier/utils;1",
|
"@mozilla.org/url-classifier/utils;1",
|
||||||
"nsIUrlClassifierUtils"
|
"nsIUrlClassifierUtils"
|
||||||
@@ -261,7 +263,7 @@ HashCompleter.prototype = {
|
|||||||
this._backoffs[aGethashUrl] = new jslib.RequestBackoffV4(
|
this._backoffs[aGethashUrl] = new jslib.RequestBackoffV4(
|
||||||
10 /* keep track of max requests */,
|
10 /* keep track of max requests */,
|
||||||
0 /* don't throttle on successful requests per time period */,
|
0 /* don't throttle on successful requests per time period */,
|
||||||
gUrlUtil.getProvider(aTableName) /* used by testcase */
|
lazy.gUrlUtil.getProvider(aTableName) /* used by testcase */
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,11 +406,11 @@ HashCompleterRequest.prototype = {
|
|||||||
|
|
||||||
// Assuming all tables with the same gethash URL have the same provider
|
// Assuming all tables with the same gethash URL have the same provider
|
||||||
if (this.provider == "") {
|
if (this.provider == "") {
|
||||||
this.provider = gUrlUtil.getProvider(aTableName);
|
this.provider = lazy.gUrlUtil.getProvider(aTableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.telemetryProvider == "") {
|
if (this.telemetryProvider == "") {
|
||||||
this.telemetryProvider = gUrlUtil.getTelemetryProvider(aTableName);
|
this.telemetryProvider = lazy.gUrlUtil.getTelemetryProvider(aTableName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -424,7 +426,7 @@ HashCompleterRequest.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
fillTableStatesBase64: function HCR_fillTableStatesBase64(aCallback) {
|
fillTableStatesBase64: function HCR_fillTableStatesBase64(aCallback) {
|
||||||
gDbService.getTables(aTableData => {
|
lazy.gDbService.getTables(aTableData => {
|
||||||
aTableData.split("\n").forEach(line => {
|
aTableData.split("\n").forEach(line => {
|
||||||
let p = line.indexOf(";");
|
let p = line.indexOf(";");
|
||||||
if (-1 === p) {
|
if (-1 === p) {
|
||||||
@@ -574,7 +576,7 @@ HashCompleterRequest.prototype = {
|
|||||||
JSON.stringify(prefixArray)
|
JSON.stringify(prefixArray)
|
||||||
);
|
);
|
||||||
|
|
||||||
return gUrlUtil.makeFindFullHashRequestV4(
|
return lazy.gUrlUtil.makeFindFullHashRequestV4(
|
||||||
tableNameArray,
|
tableNameArray,
|
||||||
stateArray,
|
stateArray,
|
||||||
prefixArray
|
prefixArray
|
||||||
@@ -726,7 +728,7 @@ HashCompleterRequest.prototype = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
gUrlUtil.parseFindFullHashResponseV4(this._response, callback);
|
lazy.gUrlUtil.parseFindFullHashResponseV4(this._response, callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
// This parses a table entry in the response body and calls |handleItem|
|
// This parses a table entry in the response body and calls |handleItem|
|
||||||
@@ -774,7 +776,7 @@ HashCompleterRequest.prototype = {
|
|||||||
// This adds a complete hash to any entry in |this._requests| that matches
|
// This adds a complete hash to any entry in |this._requests| that matches
|
||||||
// the hash.
|
// the hash.
|
||||||
handleItem: function HCR_handleItem(aData) {
|
handleItem: function HCR_handleItem(aData) {
|
||||||
let provider = gUrlUtil.getProvider(aData.tableName);
|
let provider = lazy.gUrlUtil.getProvider(aData.tableName);
|
||||||
if (provider != this.provider) {
|
if (provider != this.provider) {
|
||||||
log(
|
log(
|
||||||
"Ignoring table " +
|
"Ignoring table " +
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ PROT_ListManager.prototype.checkForUpdates = function(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableTestNotifications) {
|
if (lazy.enableTestNotifications) {
|
||||||
Services.obs.notifyObservers(
|
Services.obs.notifyObservers(
|
||||||
null,
|
null,
|
||||||
"safebrowsing-update-attempt",
|
"safebrowsing-update-attempt",
|
||||||
@@ -824,8 +824,10 @@ function RegistrationData() {
|
|||||||
return new PROT_ListManager();
|
return new PROT_ListManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const lazy = {};
|
||||||
|
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
this,
|
lazy,
|
||||||
"enableTestNotifications",
|
"enableTestNotifications",
|
||||||
PREF_TEST_NOTIFICATIONS,
|
PREF_TEST_NOTIFICATIONS,
|
||||||
false
|
false
|
||||||
|
|||||||
Reference in New Issue
Block a user