Commit 5eb344bb 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 b83ac777
Loading
Loading
Loading
Loading
+0 −10
Original line number Original line Diff line number Diff line
@@ -8,7 +8,6 @@ const lazy = {};


ChromeUtils.defineESModuleGetters(lazy, {
ChromeUtils.defineESModuleGetters(lazy, {
  BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
  BrowserSearchTelemetry: "resource:///modules/BrowserSearchTelemetry.sys.mjs",
  RemoteSettings: "resource://services-settings/remote-settings.sys.mjs",
  SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
  SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
});
});


@@ -19,9 +18,6 @@ const SEARCH_AD_CLICKS_SCALAR_BASE = "browser.search.adclicks.";
const SEARCH_DATA_TRANSFERRED_SCALAR = "browser.search.data_transferred";
const SEARCH_DATA_TRANSFERRED_SCALAR = "browser.search.data_transferred";
const SEARCH_TELEMETRY_PRIVATE_BROWSING_KEY_SUFFIX = "pb";
const SEARCH_TELEMETRY_PRIVATE_BROWSING_KEY_SUFFIX = "pb";


// Exported for tests.
export const TELEMETRY_SETTINGS_KEY = "search-telemetry-v2";

const impressionIdsWithoutEngagementsSet = new Set();
const impressionIdsWithoutEngagementsSet = new Set();


XPCOMUtils.defineLazyGetter(lazy, "logConsole", () => {
XPCOMUtils.defineLazyGetter(lazy, "logConsole", () => {
@@ -154,13 +150,7 @@ class TelemetryHandler {
      return;
      return;
    }
    }


    this._telemetrySettings = lazy.RemoteSettings(TELEMETRY_SETTINGS_KEY);
    let rawProviderInfo = [];
    let rawProviderInfo = [];
    try {
      rawProviderInfo = await this._telemetrySettings.get();
    } catch (ex) {
      lazy.logConsole.error("Could not get settings:", ex);
    }


    // Send the provider info to the child handler.
    // Send the provider info to the child handler.
    this._contentHandler.init(rawProviderInfo);
    this._contentHandler.init(rawProviderInfo);
+2 −0
Original line number Original line Diff line number Diff line
@@ -174,8 +174,10 @@ static const RedirEntry kRedirMap[] = {
         nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
         nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
         nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
         nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
         nsIAboutModule::HIDE_FROM_ABOUTABOUT},
         nsIAboutModule::HIDE_FROM_ABOUTABOUT},
#ifndef BASE_BROWSER_VERSION
    {"url-classifier", "chrome://global/content/aboutUrlClassifier.xhtml",
    {"url-classifier", "chrome://global/content/aboutUrlClassifier.xhtml",
     nsIAboutModule::ALLOW_SCRIPT},
     nsIAboutModule::ALLOW_SCRIPT},
#endif
    {"webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.html",
    {"webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.html",
     nsIAboutModule::ALLOW_SCRIPT},
     nsIAboutModule::ALLOW_SCRIPT},
    {"crashparent", "about:blank", nsIAboutModule::HIDE_FROM_ABOUTABOUT},
    {"crashparent", "about:blank", nsIAboutModule::HIDE_FROM_ABOUTABOUT},
+1 −1
Original line number Original line Diff line number Diff line
@@ -78,7 +78,7 @@ void UrlClassifierFeatureBase::InitializePreferences() {


  nsCOMPtr<nsIUrlClassifierExceptionListService> exceptionListService =
  nsCOMPtr<nsIUrlClassifierExceptionListService> exceptionListService =
      do_GetService("@mozilla.org/url-classifier/exception-list-service;1");
      do_GetService("@mozilla.org/url-classifier/exception-list-service;1");
  if (NS_WARN_IF(!exceptionListService)) {
  if (!exceptionListService) {
    return;
    return;
  }
  }


+0 −6
Original line number Original line Diff line number Diff line
@@ -13,10 +13,4 @@ Classes = [
        'constructor': 'mozilla::net::ChannelClassifierService::GetSingleton',
        'constructor': 'mozilla::net::ChannelClassifierService::GetSingleton',
        'headers': ['mozilla/net/ChannelClassifierService.h'],
        'headers': ['mozilla/net/ChannelClassifierService.h'],
    },
    },
    {
        'cid': '{b9f4fd03-9d87-4bfd-9958-85a821750ddc}',
        'contract_ids': ['@mozilla.org/url-classifier/exception-list-service;1'],
        'esModule': 'resource://gre/modules/UrlClassifierExceptionListService.sys.mjs',
        'constructor': 'UrlClassifierExceptionListService',
    },
]
]
+27 −0
Original line number Original line Diff line number Diff line
@@ -252,6 +252,16 @@ export var RemoteSecuritySettings = {


class IntermediatePreloads {
class IntermediatePreloads {
  constructor() {
  constructor() {
    this.maybeInit();
  }

  maybeInit() {
    if (
      this.client ||
      !Services.prefs.getBoolPref(INTERMEDIATES_ENABLED_PREF, true)
    ) {
      return;
    }
    this.client = RemoteSettings("intermediates", {
    this.client = RemoteSettings("intermediates", {
      bucketName: SECURITY_STATE_BUCKET,
      bucketName: SECURITY_STATE_BUCKET,
      signerName: SECURITY_STATE_SIGNER,
      signerName: SECURITY_STATE_SIGNER,
@@ -277,6 +287,7 @@ class IntermediatePreloads {
      );
      );
      return;
      return;
    }
    }
    this.maybeInit();


    // Download attachments that are awaiting download, up to a max.
    // Download attachments that are awaiting download, up to a max.
    const maxDownloadsPerRun = Services.prefs.getIntPref(
    const maxDownloadsPerRun = Services.prefs.getIntPref(
@@ -495,6 +506,16 @@ function compareFilters(filterA, filterB) {


class CRLiteFilters {
class CRLiteFilters {
  constructor() {
  constructor() {
    this.maybeInit();
  }

  maybeInit() {
    if (
      this.client ||
      !Services.prefs.getBoolPref(CRLITE_FILTERS_ENABLED_PREF, true)
    ) {
      return;
    }
    this.client = RemoteSettings("cert-revocations", {
    this.client = RemoteSettings("cert-revocations", {
      bucketName: SECURITY_STATE_BUCKET,
      bucketName: SECURITY_STATE_BUCKET,
      signerName: SECURITY_STATE_SIGNER,
      signerName: SECURITY_STATE_SIGNER,
@@ -508,6 +529,10 @@ class CRLiteFilters {
  }
  }


  async cleanAttachmentCache() {
  async cleanAttachmentCache() {
    if (!this.client) {
      return;
    }

    // Bug 1795710 - misuse of Remote Settings `downloadToDisk` caused us to
    // Bug 1795710 - misuse of Remote Settings `downloadToDisk` caused us to
    // keep filters and stashes on disk indefinitely. We're no longer caching
    // keep filters and stashes on disk indefinitely. We're no longer caching
    // these downloads, so if there are any filters still in the cache they can
    // these downloads, so if there are any filters still in the cache they can
@@ -550,6 +575,8 @@ class CRLiteFilters {
      return;
      return;
    }
    }


    this.maybeInit();

    let hasPriorFilter = await hasPriorData(
    let hasPriorFilter = await hasPriorData(
      Ci.nsICertStorage.DATA_TYPE_CRLITE_FILTER_FULL
      Ci.nsICertStorage.DATA_TYPE_CRLITE_FILTER_FULL
    );
    );
Loading