webextensions: remove telemetry

This commit is contained in:
roytam1 2022-04-28 22:14:48 +08:00
commit 37fa205f24
3 changed files with 2 additions and 190 deletions

View file

@ -685,14 +685,8 @@ var AddonManagerInternal = {
providerShutdowns: new Map(),
types: {},
startupChanges: {},
// Store telemetry details per addon provider
telemetryDetails: {},
upgradeListeners: new Map(),
recordTimestamp: function(name, value) {
this.TelemetryTimestamps.add(name, value);
},
validateBlocklist: function() {
let appBlocklist = FileUtils.getFile(KEY_APPDIR, [FILE_BLOCKLIST]);
@ -833,12 +827,6 @@ var AddonManagerInternal = {
if (gStarted)
return;
this.recordTimestamp("AMI_startup_begin");
// clear this for xpcshell test restarts
for (let provider in this.telemetryDetails)
delete this.telemetryDetails[provider];
let appChanged = undefined;
let oldAppVersion = null;
@ -982,7 +970,6 @@ var AddonManagerInternal = {
gPluginPageListener.addMessageListener("RequestPlugins", this.requestPlugins);
gStartupComplete = true;
this.recordTimestamp("AMI_startup_end");
}
catch (e) {
logger.error("startup failed", e);
@ -3092,10 +3079,6 @@ this.AddonManagerPrivate = {
AddonType: AddonType,
recordTimestamp: function(name, value) {
AddonManagerInternal.recordTimestamp(name, value);
},
_simpleMeasures: {},
recordSimpleMeasure: function(name, value) {
this._simpleMeasures[name] = value;
@ -3125,14 +3108,6 @@ this.AddonManagerPrivate = {
return this._simpleMeasures;
},
getTelemetryDetails: function() {
return AddonManagerInternal.telemetryDetails;
},
setTelemetryDetails: function(aProvider, aDetails) {
AddonManagerInternal.telemetryDetails[aProvider] = aDetails;
},
// Start a timer, record a simple measure of the time interval when
// timer.done() is called
simpleTimer: function(aName) {
@ -3660,7 +3635,6 @@ this.AddonManager = {
this.AddonManager.init();
// load the timestamps module into AddonManagerInternal
Cu.import("resource://gre/modules/TelemetryTimestamps.jsm", AddonManagerInternal);
Object.freeze(AddonManagerInternal);
Object.freeze(AddonManagerPrivate);
Object.freeze(AddonManager);

View file

@ -268,14 +268,6 @@ function mustSign(aType) {
return REQUIRE_SIGNING || Preferences.get(PREF_XPI_SIGNATURES_REQUIRED, false);
}
// Keep track of where we are in startup for telemetry
// event happened during XPIDatabase.startup()
const XPI_STARTING = "XPIStarting";
// event happened after startup() but before the final-ui-startup event
const XPI_BEFORE_UI_STARTUP = "BeforeFinalUIStartup";
// event happened after final-ui-startup
const XPI_AFTER_UI_STARTUP = "AfterFinalUIStartup";
const COMPATIBLE_BY_DEFAULT_TYPES = {
extension: true,
dictionary: true
@ -320,7 +312,6 @@ function loadLazyObjects() {
XPIStates,
syncLoadManifestFromFile,
isUsableAddon,
recordAddonTelemetry,
applyBlocklistChanges,
flushChromeCaches,
canRunInSafeMode,
@ -738,11 +729,6 @@ function isUsableAddon(aAddon) {
if (aAddon.type == "theme" && aAddon.internalName == XPIProvider.defaultSkin)
return true;
if (mustSign(aAddon.type) && !aAddon.isCorrectlySigned) {
logger.warn(`Add-on ${aAddon.id} is not correctly signed.`);
return false;
}
if (aAddon.blocklistState == Blocklist.STATE_BLOCKED) {
logger.warn(`Add-on ${aAddon.id} is blocklisted.`);
return false;
@ -1762,25 +1748,6 @@ function getSignedStatus(aRv, aCert, aAddonID) {
}
}
function shouldVerifySignedState(aAddon) {
// Updated system add-ons should always have their signature checked
if (aAddon._installLocation.name == KEY_APP_SYSTEM_ADDONS)
return true;
// We don't care about signatures for default system add-ons
if (aAddon._installLocation.name == KEY_APP_SYSTEM_DEFAULTS)
return false;
// Hotfixes should always have their signature checked
let hotfixID = Preferences.get(PREF_EM_HOTFIX_ID, undefined);
if (hotfixID && aAddon.id == hotfixID)
return true;
// Otherwise only check signatures if signing is enabled and the add-on is one
// of the signed types.
return ADDON_SIGNING && SIGNED_TYPES.has(aAddon.type);
}
let gCertDB = Cc["@mozilla.org/security/x509certdb;1"]
.getService(Ci.nsIX509CertDB);
@ -1797,11 +1764,6 @@ let gCertDB = Cc["@mozilla.org/security/x509certdb;1"]
* cert: an nsIX509Cert
*/
function verifyZipSignedState(aFile, aAddon) {
if (!shouldVerifySignedState(aAddon))
return Promise.resolve({
signedState: AddonManager.SIGNEDSTATE_NOT_REQUIRED,
cert: null
});
let root = Ci.nsIX509CertDB.AddonsPublicRoot;
if (!REQUIRE_SIGNING && Preferences.get(PREF_XPI_SIGNATURES_DEV_ROOT, false))
@ -1839,11 +1801,6 @@ function verifyZipSignedState(aFile, aAddon) {
* cert: an nsIX509Cert
*/
function verifyDirSignedState(aDir, aAddon) {
if (!shouldVerifySignedState(aAddon))
return Promise.resolve({
signedState: AddonManager.SIGNEDSTATE_NOT_REQUIRED,
cert: null,
});
let root = Ci.nsIX509CertDB.AddonsPublicRoot;
if (!REQUIRE_SIGNING && Preferences.get(PREF_XPI_SIGNATURES_DEV_ROOT, false))
@ -2075,20 +2032,6 @@ function getDirectoryEntries(aDir, aSortEntries) {
}
}
/**
* Record a bit of per-addon telemetry
* @param aAddon the addon to record
*/
function recordAddonTelemetry(aAddon) {
let locale = aAddon.defaultLocale;
if (locale) {
if (locale.name)
XPIProvider.setTelemetry(aAddon.id, "name", locale.name);
if (locale.creator)
XPIProvider.setTelemetry(aAddon.id, "creator", locale.creator);
}
}
/**
* The on-disk state of an individual XPI, created from an Object
* as stored in the 'extensions.xpiState' pref.
@ -2140,8 +2083,6 @@ XPIState.prototype = {
if (!('scanTime' in this) || this.enabled) {
logger.debug('getModTime: Recursive scan of ' + aId);
let [modFile, modTime, items] = recursiveLastModifiedTime(aFile);
XPIProvider._mostRecentlyModifiedFile[aId] = modFile;
XPIProvider.setTelemetry(aId, "scan_items", items);
if (modTime != this.scanTime) {
this.scanTime = modTime;
changed = true;
@ -2153,9 +2094,6 @@ XPIState.prototype = {
try {
// Get the install manifest update time, if any.
let maniFile = getManifestFileForDir(aFile);
if (!(aId in XPIProvider._mostRecentlyModifiedFile)) {
XPIProvider._mostRecentlyModifiedFile[aId] = maniFile.leafName;
}
let maniTime = maniFile.lastModifiedTime;
if (maniTime != this.manifestTime) {
this.manifestTime = maniTime;
@ -2176,9 +2114,6 @@ XPIState.prototype = {
this.scanTime = 0;
}
}
// Record duration of file-modified check
XPIProvider.setTelemetry(aId, "scan_MS", Math.round(Cu.now() - scanStarted));
return changed;
},
@ -2311,7 +2246,6 @@ this.XPIStates = {
}
foundAddons.set(id, xpiState);
}
XPIProvider.setTelemetry(id, "location", location.name);
}
// Anything left behind in oldState was removed from the file system.
@ -2394,7 +2328,6 @@ this.XPIStates = {
let xpiState = new XPIState({d: aAddon.descriptor});
location.set(aAddon.id, xpiState);
xpiState.syncWithDB(aAddon, true);
XPIProvider.setTelemetry(aAddon.id, "location", aAddon.location);
},
/**
@ -2459,13 +2392,6 @@ this.XPIProvider = {
allAppGlobal: true,
// A string listing the enabled add-ons for annotating crash reports
enabledAddons: null,
// Keep track of startup phases for telemetry
runPhase: XPI_STARTING,
// Keep track of the newest file in each add-on, in case we want to
// report it to telemetry.
_mostRecentlyModifiedFile: {},
// Per-addon telemetry information
_telemetryDetails: {},
// A Map from an add-on install to its ID
_addonFileMap: new Map(),
// Flag to know if ToolboxProcess.jsm has already been loaded by someone or not
@ -2512,15 +2438,6 @@ this.XPIProvider = {
return Array.from(res, id => addons[id]);
},
/*
* Set a value in the telemetry hash for a given ID
*/
setTelemetry: function(aId, aName, aValue) {
if (!this._telemetryDetails[aId])
this._telemetryDetails[aId] = {};
this._telemetryDetails[aId][aName] = aValue;
},
// Keep track of in-progress operations that support cancel()
_inProgress: [],
@ -2702,19 +2619,12 @@ this.XPIProvider = {
}
try {
AddonManagerPrivate.recordTimestamp("XPI_startup_begin");
logger.debug("startup");
this.runPhase = XPI_STARTING;
this.installs = new Set();
this.installLocations = [];
this.installLocationsByName = {};
// Hook for tests to detect when saving database at shutdown time fails
this._shutdownError = null;
// Clear this at startup for xpcshell test restarts
this._telemetryDetails = {};
// Register our details structure with AddonManager
AddonManagerPrivate.setTelemetryDetails("XPI", this._telemetryDetails);
let hasRegistry = ("nsIWindowsRegKey" in Ci);
@ -2847,8 +2757,6 @@ this.XPIProvider = {
}
try {
AddonManagerPrivate.recordTimestamp("XPI_bootstrap_addons_begin");
for (let addon of this.sortBootstrappedAddons()) {
try {
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
@ -2867,7 +2775,6 @@ this.XPIProvider = {
addon.descriptor, e);
}
}
AddonManagerPrivate.recordTimestamp("XPI_bootstrap_addons_end");
}
catch (e) {
logger.error("bootstrap startup failed", e);
@ -2906,19 +2813,7 @@ this.XPIProvider = {
}
}, "quit-application-granted", false);
// Detect final-ui-startup for telemetry reporting
Services.obs.addObserver({
observe: function(aSubject, aTopic, aData) {
AddonManagerPrivate.recordTimestamp("XPI_finalUIStartup");
XPIProvider.runPhase = XPI_AFTER_UI_STARTUP;
Services.obs.removeObserver(this, "final-ui-startup");
}
}, "final-ui-startup", false);
AddonManagerPrivate.recordTimestamp("XPI_startup_end");
this.extensionsActive = true;
this.runPhase = XPI_BEFORE_UI_STARTUP;
let timerManager = Cc["@mozilla.org/updates/timer-manager;1"].
getService(Ci.nsIUpdateTimerManager);
@ -3057,7 +2952,6 @@ this.XPIProvider = {
*/
showUpgradeUI: function(aAddonIDs) {
logger.debug("XPI_showUpgradeUI: " + aAddonIDs.toSource());
Services.telemetry.getHistogramById("ADDON_MANAGER_UPGRADE_UI_SHOWN").add(1);
// Flip a flag to indicate that we interrupted startup with an interactive prompt
Services.startup.interrupted = true;
@ -3293,10 +3187,6 @@ this.XPIProvider = {
Services.appinfo.annotateCrashReport("Add-ons", data);
}
catch (e) { }
let TelemetrySession =
Cu.import("resource://gre/modules/TelemetrySession.jsm", {}).TelemetrySession;
TelemetrySession.setAddOns(data);
},
/**
@ -3741,11 +3631,7 @@ this.XPIProvider = {
}
}
// Telemetry probe added around getInstallState() to check perf
let telemetryCaptureTime = Cu.now();
let installChanged = XPIStates.getInstallState();
let telemetry = Services.telemetry;
telemetry.getHistogramById("CHECK_ADDONS_MODIFIED_MS").add(Math.round(Cu.now() - telemetryCaptureTime));
if (installChanged) {
updateReasons.push("directoryState");
}
@ -4895,7 +4781,6 @@ this.XPIProvider = {
}
}
}
this.setTelemetry(aAddon.id, aMethod + "_MS", new Date() - timeStart);
}
},
@ -5840,8 +5725,6 @@ class AddonInstall {
XPIProvider.unloadBootstrapScope(this.addon.id);
}
}
XPIProvider.setTelemetry(this.addon.id, "unpacked", installedUnpacked);
recordAddonTelemetry(this.addon);
}
}).bind(this)).then(null, (e) => {
logger.warn(`Failed to install ${this.file.path} from ${this.sourceURI.spec} to ${stagedAddon.path}`, e);
@ -7039,32 +6922,6 @@ AddonInternal.prototype = {
this.updateURL.substring(0, 6) == "https:");
},
get isCorrectlySigned() {
switch (this._installLocation.name) {
case KEY_APP_SYSTEM_ADDONS:
// System add-ons must be signed by the system key.
return this.signedState == AddonManager.SIGNEDSTATE_SYSTEM
case KEY_APP_SYSTEM_DEFAULTS:
case KEY_APP_TEMPORARY:
// Temporary and built-in system add-ons do not require signing.
return true;
case KEY_APP_SYSTEM_SHARE:
case KEY_APP_SYSTEM_LOCAL:
// On UNIX platforms except OSX, an additional location for system
// add-ons exists in /usr/{lib,share}/mozilla/extensions. Add-ons
// installed there do not require signing.
if (Services.appinfo.OS != "Darwin")
return true;
break;
}
if (this.signedState === AddonManager.SIGNEDSTATE_NOT_REQUIRED)
return true;
return this.signedState > AddonManager.SIGNEDSTATE_MISSING;
},
get isCompatible() {
return this.isCompatibleWith();
},
@ -7909,8 +7766,7 @@ function defineAddonWrapperProperty(name, getter) {
"providesUpdatesSecurely", "blocklistState", "blocklistURL", "appDisabled",
"softDisabled", "skinnable", "size", "foreignInstall", "hasBinaryComponents",
"strictCompatibility", "compatibilityOverrides", "updateURL", "dependencies",
"getDataDirectory", "multiprocessCompatible", "signedState", "mpcOptedOut",
"isCorrectlySigned"].forEach(function(aProp) {
"getDataDirectory", "multiprocessCompatible", "signedState", "mpcOptedOut"].forEach(function(aProp) {
defineAddonWrapperProperty(aProp, function() {
let addon = addonFor(this);
return (aProp in addon) ? addon[aProp] : undefined;

View file

@ -7,7 +7,7 @@
// These are injected from XPIProvider.jsm
/* globals ADDON_SIGNING, SIGNED_TYPES, BOOTSTRAP_REASONS, DB_SCHEMA,
AddonInternal, XPIProvider, XPIStates, syncLoadManifestFromFile,
isUsableAddon, recordAddonTelemetry, applyBlocklistChanges,
isUsableAddon, applyBlocklistChanges,
flushChromeCaches, canRunInSafeMode*/
var Cc = Components.classes;
@ -1962,24 +1962,6 @@ this.XPIDatabaseReconcile = {
// Check if the add-on is still installed
let xpiState = states && states.get(id);
if (xpiState) {
// Here the add-on was present in the database and on disk
recordAddonTelemetry(oldAddon);
// Check if the add-on has been changed outside the XPI provider
if (oldAddon.updateDate != xpiState.mtime) {
// Did time change in the wrong direction?
if (xpiState.mtime < oldAddon.updateDate) {
XPIProvider.setTelemetry(oldAddon.id, "olderFile", {
name: XPIProvider._mostRecentlyModifiedFile[id],
mtime: xpiState.mtime,
oldtime: oldAddon.updateDate
});
} else {
XPIProvider.setTelemetry(oldAddon.id, "modifiedFile",
XPIProvider._mostRecentlyModifiedFile[id]);
}
}
// The add-on has changed if the modification time has changed, if
// we have an updated manifest for it, or if the schema version has
// changed.