Skip to content
Snippets Groups Projects
Verified Commit 0dec6f40 authored by Alex Catarineu's avatar Alex Catarineu Committed by Pier Angelo Vendrame
Browse files

Bug 31740: Remove some unnecessary RemoteSettings instances

More concretely, SearchService.jsm 'hijack-blocklists' and
url-classifier-skip-urls.

Avoid creating instance for 'anti-tracking-url-decoration'.

If prefs are disabling their usage, avoid creating instances for
'cert-revocations' and 'intermediates'.

Do not ship JSON dumps for collections we do not expect to need. For
the ones in the 'main' bucket, this prevents them from being synced
unnecessarily (the code in remote-settings does so for collections
in the main bucket for which a dump or local data exists). For the
collections in the other buckets, we just save some size by not
shipping their dumps.

We also clear the collections database on the v2 -> v3 migration.
parent aa78dfa3
Branches
Tags
1 merge request!636Bug 41757: Rebased Tor Browser alpha to 102.11.0esr
Showing
with 58 additions and 50 deletions
......@@ -96,13 +96,7 @@ class TelemetryHandler {
return;
}
this._telemetrySettings = RemoteSettings(TELEMETRY_SETTINGS_KEY);
let rawProviderInfo = [];
try {
rawProviderInfo = await this._telemetrySettings.get();
} catch (ex) {
logConsole.error("Could not get settings:", ex);
}
// Send the provider info to the child handler.
this._contentHandler.init(rawProviderInfo);
......
......@@ -165,8 +165,10 @@ static const RedirEntry kRedirMap[] = {
#endif
{"telemetry", "chrome://global/content/aboutTelemetry.xhtml",
nsIAboutModule::ALLOW_SCRIPT | nsIAboutModule::IS_SECURE_CHROME_UI},
#ifndef BASE_BROWSER_VERSION
{"url-classifier", "chrome://global/content/aboutUrlClassifier.xhtml",
nsIAboutModule::ALLOW_SCRIPT},
#endif
{"webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.html",
nsIAboutModule::ALLOW_SCRIPT},
{"crashparent", "about:blank", nsIAboutModule::HIDE_FROM_ABOUTABOUT},
......
......@@ -78,7 +78,7 @@ void UrlClassifierFeatureBase::InitializePreferences() {
nsCOMPtr<nsIUrlClassifierExceptionListService> exceptionListService =
do_GetService("@mozilla.org/url-classifier/exception-list-service;1");
if (NS_WARN_IF(!exceptionListService)) {
if (!exceptionListService) {
return;
}
......
......@@ -13,10 +13,4 @@ Classes = [
'constructor': 'mozilla::net::ChannelClassifierService::GetSingleton',
'headers': ['mozilla/net/ChannelClassifierService.h'],
},
{
'cid': '{b9f4fd03-9d87-4bfd-9958-85a821750ddc}',
'contract_ids': ['@mozilla.org/url-classifier/exception-list-service;1'],
'jsm': 'resource://gre/modules/UrlClassifierExceptionListService.jsm',
'constructor': 'UrlClassifierExceptionListService',
},
]
......@@ -249,6 +249,16 @@ var RemoteSecuritySettings = {
class IntermediatePreloads {
constructor() {
this.maybeInit();
}
maybeInit() {
if (
this.client ||
!Services.prefs.getBoolPref(INTERMEDIATES_ENABLED_PREF, true)
) {
return;
}
this.client = RemoteSettings("intermediates", {
bucketName: SECURITY_STATE_BUCKET,
signerName: SECURITY_STATE_SIGNER,
......@@ -274,6 +284,7 @@ class IntermediatePreloads {
);
return;
}
this.maybeInit();
// Download attachments that are awaiting download, up to a max.
const maxDownloadsPerRun = Services.prefs.getIntPref(
......@@ -481,6 +492,16 @@ function compareFilters(filterA, filterB) {
class CRLiteFilters {
constructor() {
this.maybeInit();
}
maybeInit() {
if (
this.client ||
!Services.prefs.getBoolPref(CRLITE_FILTERS_ENABLED_PREF, true)
) {
return;
}
this.client = RemoteSettings("cert-revocations", {
bucketName: SECURITY_STATE_BUCKET,
signerName: SECURITY_STATE_SIGNER,
......@@ -504,6 +525,8 @@ class CRLiteFilters {
return;
}
this.maybeInit();
let hasPriorFilter = await hasPriorData(
Ci.nsICertStorage.DATA_TYPE_CRLITE_FILTER_FULL
);
......
......@@ -188,6 +188,10 @@ async function openIDB(allowUpgrades = true) {
});
}
if (event.oldVersion < 3) {
// Clear existing stores for a fresh start
transaction.objectStore("records").clear();
transaction.objectStore("timestamps").clear();
transaction.objectStore("collections").clear();
// Attachment store
db.createObjectStore("attachments", {
keyPath: ["cid", "attachmentId"],
......
......@@ -8,10 +8,6 @@ with Files("**"):
BUG_COMPONENT = ("Toolkit", "Blocklist Implementation")
# The addons blocklist is also in mobile/android/installer/package-manifest.in
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
# Remove this once bug 1639050 is resolved.
FINAL_TARGET_FILES.defaults.settings.blocklists += ["addons.json"]
else:
FINAL_TARGET_FILES.defaults.settings.blocklists += [
"addons-bloomfilters.json",
"gfx.json",
......
......@@ -3,19 +3,11 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
FINAL_TARGET_FILES.defaults.settings.main += [
"anti-tracking-url-decoration.json",
"devtools-compatibility-browsers.json",
"example.json",
"hijack-blocklists.json",
"language-dictionaries.json",
"password-recipes.json",
"password-rules.json",
"search-config.json",
"search-default-override-allowlist.json",
"search-telemetry-v2.json",
"sites-classification.json",
"top-sites.json",
"url-classifier-skip-urls.json",
"websites-with-shared-credential-backends.json",
]
......
......@@ -3,7 +3,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
FINAL_TARGET_FILES.defaults.settings["security-state"] += [
"intermediates.json",
"onecrl.json",
]
......
......@@ -200,12 +200,17 @@ function remoteSettingsFunction() {
full = false,
} = {}) => {
// When running in full mode, we ignore last polling status.
if (full) {
if (full || AppConstants.BASE_BROWSER_VERSION) {
gPrefs.clearUserPref(PREF_SETTINGS_SERVER_BACKOFF);
gPrefs.clearUserPref(PREF_SETTINGS_LAST_UPDATE);
gPrefs.clearUserPref(PREF_SETTINGS_LAST_ETAG);
}
if (AppConstants.BASE_BROWSER_VERSION) {
// tor-browser#41704: pollChanges is always online, so do not allow it.
return;
}
let pollTelemetryArgs = {
source: TELEMETRY_SOURCE_POLL,
trigger,
......
......@@ -4,4 +4,4 @@ resource services-settings resource://gre/modules/services-settings/
# Schedule polling of remote settings changes
# (default 24H, max 72H)
# see syntax https://searchfox.org/mozilla-central/rev/cc280c4be94ff8cf64a27cc9b3d6831ffa49fa45/toolkit/components/timermanager/UpdateTimerManager.jsm#155
category update-timer RemoteSettingsComponents @mozilla.org/services/settings;1,getService,services-settings-poll-changes,services.settings.poll_interval,86400,259200
# category update-timer RemoteSettingsComponents @mozilla.org/services/settings;1,getService,services-settings-poll-changes,services.settings.poll_interval,86400,259200
category profile-after-change URLDecorationAnnotationsService @mozilla.org/tracking-url-decoration-service;1 process=main
# category profile-after-change URLDecorationAnnotationsService @mozilla.org/tracking-url-decoration-service;1 process=main
......@@ -11,13 +11,6 @@ Classes = [
'jsm': 'resource://gre/modules/TrackingDBService.jsm',
'constructor': 'TrackingDBService',
},
{
'cid': '{5874af6d-5719-4e1b-b155-ef4eae7fcb32}',
'contract_ids': ['@mozilla.org/tracking-url-decoration-service;1'],
'jsm': 'resource://gre/modules/URLDecorationAnnotationsService.jsm',
'constructor': 'URLDecorationAnnotationsService',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
{
'cid': '{90d1fd17-2018-4e16-b73c-a04a26fa6dd4}',
'contract_ids': ['@mozilla.org/purge-tracker-service;1'],
......
......@@ -247,8 +247,6 @@ SearchService.prototype = {
// See if we have a settings file so we don't have to parse a bunch of XML.
let settings = await this._settings.get();
this._setupRemoteSettings().catch(Cu.reportError);
await this._loadEngines(settings);
// If we've got this far, but the application is now shutting down,
......
......@@ -8,19 +8,19 @@ const { XPCOMUtils } = ChromeUtils.import(
);
XPCOMUtils.defineLazyModuleGetters(this, {
RemoteSettings: "resource://services-settings/remote-settings.js",
RemoteSettingsClient: "resource://services-settings/RemoteSettingsClient.jsm",
});
var EXPORTED_SYMBOLS = ["IgnoreLists"];
Cu.importGlobalProperties(["fetch"]);
const SETTINGS_IGNORELIST_KEY = "hijack-blocklists";
var EXPORTED_SYMBOLS = ["IgnoreLists"];
class IgnoreListsManager {
_ignoreListSettings = null;
async init() {
if (!this._ignoreListSettings) {
this._ignoreListSettings = RemoteSettings(SETTINGS_IGNORELIST_KEY);
}
// TODO: Restore the initialization, once we use only the local dumps for
// the remote settings.
}
async getAndSubscribe(listener) {
......@@ -30,7 +30,7 @@ class IgnoreListsManager {
const settings = await this._getIgnoreList();
// Listen for future updates after we first get the values.
this._ignoreListSettings.on("sync", listener);
this._ignoreListSettings?.on("sync", listener);
return settings;
}
......@@ -70,6 +70,14 @@ class IgnoreListsManager {
* could be obtained.
*/
async _getIgnoreListSettings(firstTime = true) {
if (!this._ignoreListSettings) {
const dump = await fetch(
"resource:///defaults/settings/main/hijack-blocklists.json"
);
const { data } = await dump.json();
return data;
}
let result = [];
try {
result = await this._ignoreListSettings.get({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment