Commit 98792f83 authored by Alex Catarineu's avatar Alex Catarineu Committed by brizental
Browse files

BB 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 08e10f9a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -913,6 +913,8 @@ class DomainToCategoriesMap {
   * reuse the store if the version in each record matches the store.
   */
  async #setupClientAndStore() {
    return;
    // eslint-disable-next-line no-unreachable
    if (this.#client && !this.empty) {
      return;
    }
+3 −2
Original line number Diff line number Diff line
@@ -310,7 +310,8 @@ class TelemetryHandler {
   * can be tracked.
   */
  async init() {
    if (this._initialized) {
    // eslint-disable-next-line no-constant-condition
    if (this._initialized || true) {
      return;
    }

@@ -1138,7 +1139,7 @@ class TelemetryHandler {
   *   Returns a provider or undefined if no provider was found for the url.
   */
  _getProviderInfoForURL(url) {
    return this._searchProviderInfo.find(info =>
    return this._searchProviderInfo?.find(info =>
      info.searchPageRegexp.test(url)
    );
  }
+0 −3
Original line number Diff line number Diff line
@@ -18,9 +18,6 @@ Classes = [
        'contract_ids': ['@mozilla.org/url-classifier/exception-list-service;1'],
        'esModule': 'resource://gre/modules/UrlClassifierExceptionListService.sys.mjs',
        'constructor': 'UrlClassifierExceptionListService',
        'categories': {
            'idle-daily': 'UrlClassifierExceptionListService'
        }
    },
    {
        'cid': '{8753A413-3ED6-4A61-A1DC-B31A7E69B796}',
+23 −0
Original line number Diff line number Diff line
@@ -245,6 +245,16 @@ export 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,
@@ -270,6 +280,7 @@ class IntermediatePreloads {
      );
      return;
    }
    this.maybeInit();

    // Download attachments that are awaiting download, up to a max.
    const maxDownloadsPerRun = Services.prefs.getIntPref(
@@ -507,6 +518,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,
@@ -573,6 +594,8 @@ class CRLiteFilters {
      return;
    }

    this.maybeInit();

    let hasPriorFilter = await hasPriorData(
      Ci.nsICertStorage.DATA_TYPE_CRLITE_FILTER_FULL
    );
+4 −0
Original line number Diff line number Diff line
@@ -180,6 +180,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"],
Loading