Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2022-04-28 10:45:19 +08:00
commit 6de07653b9
368 changed files with 144 additions and 46366 deletions

View file

@ -465,7 +465,6 @@ var GMPProvider = {
configureLogging();
this._log = Log.repository.getLoggerWithMessagePrefix("Toolkit.GMP",
"GMPProvider.");
let telemetry = {};
this.buildPluginList();
this.ensureProperCDMInstallState();
@ -487,14 +486,6 @@ var GMPProvider = {
e.name + " - sandboxing not available?", e);
}
}
if (this.isEnabled) {
telemetry[id] = {
userDisabled: wrapper.userDisabled,
version: wrapper.version,
applyBackgroundUpdates: wrapper.applyBackgroundUpdates,
};
}
}
if (Preferences.get(GMPPrefs.KEY_EME_ENABLED, false)) {
@ -511,8 +502,6 @@ var GMPProvider = {
this._log.warn("startup - adding clearkey CDM failed", e);
}
}
AddonManagerPrivate.setTelemetryDetails("GMP", telemetry);
},
shutdown: function() {

View file

@ -206,7 +206,7 @@ const RESTARTLESS_TYPES = new Set([
"locale",
]);
// Keep track of where we are in startup for telemetry
// Keep track of where we are in startup.
// event happened during XPIDatabase.startup()
const XPI_STARTING = "XPIStarting";
// event happened after startup() but before the final-ui-startup event
@ -1833,13 +1833,11 @@ this.XPIProvider = {
allAppGlobal: true,
// A string listing the enabled add-ons for annotating crash reports
enabledAddons: null,
// Keep track of startup phases for telemetry
// Keep track of startup phases.
runPhase: XPI_STARTING,
// Keep track of the newest file in each add-on, in case we want to
// report it to telemetry.
// report it.
_mostRecentlyModifiedFile: {},
// Per-addon telemetry information
_telemetryDetails: {},
// Experiments are disabled by default. Track ones that are locally enabled.
_enabledExperiments: null,
// A Map from an add-on install to its ID
@ -2009,8 +2007,6 @@ this.XPIProvider = {
}
try {
AddonManagerPrivate.recordTimestamp("XPI_startup_begin");
logger.debug("startup");
this.runPhase = XPI_STARTING;
this.installs = [];
@ -2018,8 +2014,6 @@ this.XPIProvider = {
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 = {};
// Clear the set of enabled experiments (experiments disabled by default).
this._enabledExperiments = new Set();
@ -2144,21 +2138,7 @@ this.XPIProvider = {
this.enabledAddons = Preferences.get(PREF_EM_ENABLED_ADDONS, "");
if ("nsICrashReporter" in Ci &&
Services.appinfo instanceof Ci.nsICrashReporter) {
// Annotate the crash report with relevant add-on information.
try {
Services.appinfo.annotateCrashReport("Theme", this.currentSkin);
} catch (e) { }
try {
Services.appinfo.annotateCrashReport("EMCheckCompatibility",
AddonManager.checkCompatibility);
} catch (e) { }
this.addAddonsToCrashReporter();
}
try {
AddonManagerPrivate.recordTimestamp("XPI_bootstrap_addons_begin");
for (let id in this.bootstrappedAddons) {
try {
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
@ -2177,11 +2157,9 @@ this.XPIProvider = {
this.bootstrappedAddons[id].descriptor, e);
}
}
AddonManagerPrivate.recordTimestamp("XPI_bootstrap_addons_end");
}
catch (e) {
logger.error("bootstrap startup failed", e);
AddonManagerPrivate.recordException("XPI-BOOTSTRAP", "startup failed", e);
}
// Let these shutdown a little earlier when they still have access to most
@ -2200,23 +2178,11 @@ this.XPIProvider = {
}
}, "quit-application-granted", false);
// Detect final-ui-startup for telemetry reporting
Services.obs.addObserver({
observe: function uiStartupObserver(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;
}
catch (e) {
logger.error("startup failed", e);
AddonManagerPrivate.recordException("XPI", "startup failed", e);
}
},
@ -2240,7 +2206,6 @@ this.XPIProvider = {
// If there are pending operations then we must update the list of active
// add-ons
if (Preferences.get(PREF_PENDING_OPERATIONS, false)) {
AddonManagerPrivate.recordSimpleMeasure("XPIDB_pending_ops", 1);
XPIDatabase.updateActiveAddons();
Services.prefs.setBoolPref(PREF_PENDING_OPERATIONS,
!XPIDatabase.writeAddonsList());
@ -2307,11 +2272,8 @@ this.XPIProvider = {
* to be updated, but the metadata check needs to be performed.
*/
shouldForceUpdateCheck: function XPI_shouldForceUpdateCheck(aAppChanged) {
AddonManagerPrivate.recordSimpleMeasure("XPIDB_metadata_age", AddonRepository.metadataAge());
let startupChanges = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED);
logger.debug("shouldForceUpdateCheck startupChanges: " + startupChanges.toSource());
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startup_disabled", startupChanges.length);
let forceUpdate = [];
if (startupChanges.length > 0) {
@ -2405,10 +2367,6 @@ this.XPIProvider = {
Services.appinfo.annotateCrashReport("Add-ons", data);
}
catch (e) { }
let TelemetrySession =
Cu.import("resource://gre/modules/TelemetrySession.jsm", {}).TelemetrySession;
TelemetrySession.setAddOns(data);
},
/**
@ -3554,11 +3512,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");
}
@ -3610,7 +3564,6 @@ this.XPIProvider = {
// If the database needs to be updated then open it and then update it
// from the filesystem
if (updateReasons.length > 0) {
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startup_load_reasons", updateReasons);
XPIDatabase.syncLoadDB(false);
try {
extensionListChanged = this.processFileChanges(manifests,
@ -6431,7 +6384,6 @@ AddonInternal.prototype = {
let message = "Problem with addon " + this.id + " targetPlatforms "
+ JSON.stringify(this.targetPlatforms);
logger.error(message, e);
AddonManagerPrivate.recordException("XPI", message, e);
// don't trust this add-on
return false;
}

View file

@ -431,7 +431,6 @@ this.XPIDatabase = {
// use an Error here so we get a stack trace.
let err = new Error("XPI database modified after shutdown began");
logger.warn(err);
AddonManagerPrivate.recordSimpleMeasure("XPIDB_late_stack", Log.stackTrace(err));
}
if (!this._deferredSave) {
@ -539,7 +538,6 @@ this.XPIDatabase = {
let fstream = null;
let data = "";
try {
let readTimer = AddonManagerPrivate.simpleTimer("XPIDB_syncRead_MS");
logger.debug("Opening XPI database " + this.jsonFile.path);
fstream = Components.classes["@mozilla.org/network/file-input-stream;1"].
createInstance(Components.interfaces.nsIFileInputStream);
@ -557,14 +555,11 @@ this.XPIDatabase = {
data += str.value;
} while (read != 0);
readTimer.done();
this.parseDB(data, aRebuildOnError);
}
catch(e) {
logger.error("Failed to load XPI JSON data from profile", e);
let rebuildTimer = AddonManagerPrivate.simpleTimer("XPIDB_rebuildReadFailed_MS");
this.rebuildDatabase(aRebuildOnError);
rebuildTimer.done();
}
finally {
if (cstream)
@ -586,7 +581,6 @@ this.XPIDatabase = {
// If an async load was also in progress, resolve that promise with our DB;
// otherwise create a resolved promise
if (this._dbPromise) {
AddonManagerPrivate.recordSimpleMeasure("XPIDB_overlapped_load", 1);
this._dbPromise.resolve(this.addonDB);
}
else
@ -599,27 +593,20 @@ this.XPIDatabase = {
* If true, synchronously reconstruct the database from installed add-ons
*/
parseDB: function(aData, aRebuildOnError) {
let parseTimer = AddonManagerPrivate.simpleTimer("XPIDB_parseDB_MS");
try {
// dump("Loaded JSON:\n" + aData + "\n");
let inputAddons = JSON.parse(aData);
// Now do some sanity checks on our JSON db
if (!("schemaVersion" in inputAddons) || !("addons" in inputAddons)) {
parseTimer.done();
// Content of JSON file is bad, need to rebuild from scratch
logger.error("bad JSON file contents");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError", "badJSON");
let rebuildTimer = AddonManagerPrivate.simpleTimer("XPIDB_rebuildBadJSON_MS");
this.rebuildDatabase(aRebuildOnError);
rebuildTimer.done();
return;
}
if (inputAddons.schemaVersion != DB_SCHEMA) {
// Handle mismatched JSON schema version. For now, we assume
// compatibility for JSON data, though we throw away any fields we
// don't know about (bug 902956)
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError",
"schemaMismatch-" + inputAddons.schemaVersion);
logger.debug("JSON schema mismatch: expected " + DB_SCHEMA +
", actual " + inputAddons.schemaVersion);
// When we rev the schema of the JSON database, we need to make sure we
@ -633,7 +620,6 @@ this.XPIDatabase = {
let newAddon = new DBAddonInternal(loadedAddon);
addonDB.set(newAddon._key, newAddon);
};
parseTimer.done();
this.addonDB = addonDB;
logger.debug("Successfully read XPI database");
this.initialized = true;
@ -641,18 +627,13 @@ this.XPIDatabase = {
catch(e) {
// If we catch and log a SyntaxError from the JSON
// parser, the xpcshell test harness fails the test for us: bug 870828
parseTimer.done();
if (e.name == "SyntaxError") {
logger.error("Syntax error parsing saved XPI JSON data");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError", "syntax");
}
else {
logger.error("Failed to load XPI JSON data from profile", e);
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError", "other");
}
let rebuildTimer = AddonManagerPrivate.simpleTimer("XPIDB_rebuildReadFailed_MS");
this.rebuildDatabase(aRebuildOnError);
rebuildTimer.done();
}
},
@ -660,7 +641,6 @@ this.XPIDatabase = {
* Upgrade database from earlier (sqlite or RDF) version if available
*/
upgradeDB: function(aRebuildOnError) {
let upgradeTimer = AddonManagerPrivate.simpleTimer("XPIDB_upgradeDB_MS");
try {
let schemaVersion = Services.prefs.getIntPref(PREF_DB_SCHEMA);
if (schemaVersion <= LAST_SQLITE_DB_SCHEMA) {
@ -671,7 +651,6 @@ this.XPIDatabase = {
else {
// we've upgraded before but the JSON file is gone, fall through
// and rebuild from scratch
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError", "dbMissing");
}
}
catch(e) {
@ -681,7 +660,6 @@ this.XPIDatabase = {
}
this.rebuildDatabase(aRebuildOnError);
upgradeTimer.done();
},
/**
@ -689,15 +667,12 @@ this.XPIDatabase = {
* (for example because read permission is denied)
*/
rebuildUnreadableDB: function(aError, aRebuildOnError) {
let rebuildTimer = AddonManagerPrivate.simpleTimer("XPIDB_rebuildUnreadableDB_MS");
logger.warn("Extensions database " + this.jsonFile.path +
" exists but is not readable; rebuilding", aError);
// Remember the error message until we try and write at least once, so
// we know at shutdown time that there was a problem
this._loadError = aError;
AddonManagerPrivate.recordSimpleMeasure("XPIDB_startupError", "unreadable");
this.rebuildDatabase(aRebuildOnError);
rebuildTimer.done();
},
/**
@ -715,24 +690,19 @@ this.XPIDatabase = {
}
logger.debug("Starting async load of XPI database " + this.jsonFile.path);
AddonManagerPrivate.recordSimpleMeasure("XPIDB_async_load", XPIProvider.runPhase);
let readOptions = {
outExecutionDuration: 0
};
return this._dbPromise = OS.File.read(this.jsonFile.path, null, readOptions).then(
byteArray => {
logger.debug("Async JSON file read took " + readOptions.outExecutionDuration + " MS");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_asyncRead_MS",
readOptions.outExecutionDuration);
if (this._addonDB) {
logger.debug("Synchronous load completed while waiting for async load");
return this.addonDB;
}
logger.debug("Finished async read of XPI database, parsing...");
let decodeTimer = AddonManagerPrivate.simpleTimer("XPIDB_decode_MS");
let decoder = new TextDecoder();
let data = decoder.decode(byteArray);
decodeTimer.done();
this.parseDB(data, true);
return this.addonDB;
})
@ -1009,21 +979,11 @@ this.XPIDatabase = {
this.initialized = false;
if (this._deferredSave) {
AddonManagerPrivate.recordSimpleMeasure(
"XPIDB_saves_total", this._deferredSave.totalSaves);
AddonManagerPrivate.recordSimpleMeasure(
"XPIDB_saves_overlapped", this._deferredSave.overlappedSaves);
AddonManagerPrivate.recordSimpleMeasure(
"XPIDB_saves_late", this._deferredSave.dirty ? 1 : 0);
}
// Return a promise that any pending writes of the DB are complete and we
// are finished cleaning up
let flushPromise = this.flush();
flushPromise.then(null, error => {
logger.error("Flush of XPI database failed", error);
AddonManagerPrivate.recordSimpleMeasure("XPIDB_shutdownFlush_failed", 1);
// If our last attempt to read or write the DB failed, force a new
// extensions.ini to be written to disk on the next startup
Services.prefs.setBoolPref(PREF_PENDING_OPERATIONS, true);
@ -1142,7 +1102,6 @@ this.XPIDatabase = {
// an XPI theme to a lightweight theme before the DB has loaded,
// because we're called from sync XPIProvider.addonChanged
logger.warn("Synchronous load of XPI database due to getAddonsByType(" + aType + ")");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_lateOpen_byType", XPIProvider.runPhase);
this.syncLoadDB(true);
}
return _filterDB(this.addonDB, aAddon => (aAddon.type == aType));
@ -1159,8 +1118,6 @@ this.XPIDatabase = {
if (!this.addonDB) {
// This may be called when the DB hasn't otherwise been loaded
logger.warn("Synchronous load of XPI database due to getVisibleAddonForInternalName");
AddonManagerPrivate.recordSimpleMeasure("XPIDB_lateOpen_forInternalName",
XPIProvider.runPhase);
this.syncLoadDB(true);
}
@ -1231,8 +1188,6 @@ this.XPIDatabase = {
*/
addAddonMetadata: function XPIDB_addAddonMetadata(aAddon, aDescriptor) {
if (!this.addonDB) {
AddonManagerPrivate.recordSimpleMeasure("XPIDB_lateOpen_addMetadata",
XPIProvider.runPhase);
this.syncLoadDB(false);
}
@ -1361,8 +1316,6 @@ this.XPIDatabase = {
if (!this.addonDB) {
logger.warn("updateActiveAddons called when DB isn't loaded");
// force the DB to load
AddonManagerPrivate.recordSimpleMeasure("XPIDB_lateOpen_updateActive",
XPIProvider.runPhase);
this.syncLoadDB(true);
}
logger.debug("Updating add-on states");
@ -1382,8 +1335,6 @@ this.XPIDatabase = {
writeAddonsList: function XPIDB_writeAddonsList() {
if (!this.addonDB) {
// force the DB to load
AddonManagerPrivate.recordSimpleMeasure("XPIDB_lateOpen_writeList",
XPIProvider.runPhase);
this.syncLoadDB(true);
}
Services.appinfo.invalidateCachesOnRestart();