mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-19 05:37:30 +09:00
Issue #21 - Remove Telemetry accumulation/structures from toolkit js.
This fixes toolkit modules and prevents toolkit component breakage. Also removes about:telemetry
This commit is contained in:
parent
8d800b1cb0
commit
44388b01a3
42 changed files with 22 additions and 3581 deletions
|
|
@ -169,7 +169,6 @@ function safeCall(aCallback, ...aArgs) {
|
|||
*/
|
||||
function reportProviderError(aProvider, aMethod, aError) {
|
||||
let method = `provider ${providerName(aProvider)}.${aMethod}`;
|
||||
AddonManagerPrivate.recordException("AMI", method, aError);
|
||||
logger.error("Exception calling " + method, aError);
|
||||
}
|
||||
|
||||
|
|
@ -632,12 +631,6 @@ var AddonManagerInternal = {
|
|||
providerShutdowns: new Map(),
|
||||
types: {},
|
||||
startupChanges: {},
|
||||
// Store telemetry details per addon provider
|
||||
telemetryDetails: {},
|
||||
|
||||
recordTimestamp: function(name, value) {
|
||||
this.TelemetryTimestamps.add(name, value);
|
||||
},
|
||||
|
||||
validateBlocklist: function() {
|
||||
let appBlocklist = FileUtils.getFile(KEY_APPDIR, [FILE_BLOCKLIST]);
|
||||
|
|
@ -749,7 +742,6 @@ var AddonManagerInternal = {
|
|||
})
|
||||
.catch(err => {
|
||||
logger.warn("Failure during shutdown of " + name, err);
|
||||
AddonManagerPrivate.recordException("AMI", "Async shutdown of " + name, err);
|
||||
});
|
||||
};
|
||||
logger.debug("Registering shutdown blocker for " + name);
|
||||
|
|
@ -771,12 +763,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;
|
||||
|
|
@ -823,7 +809,6 @@ var AddonManagerInternal = {
|
|||
Services.prefs.addObserver(PREF_EM_AUTOUPDATE_DEFAULT, this, false);
|
||||
|
||||
let defaultProvidersEnabled = Services.prefs.getBoolPref(PREF_DEFAULT_PROVIDERS_ENABLED, true);
|
||||
AddonManagerPrivate.recordSimpleMeasure("default_providers", defaultProvidersEnabled);
|
||||
|
||||
// Ensure all default providers have had a chance to register themselves
|
||||
if (defaultProvidersEnabled) {
|
||||
|
|
@ -837,12 +822,10 @@ var AddonManagerInternal = {
|
|||
if ((syms.length < 1) ||
|
||||
(typeof scope[syms[0]].startup != "function")) {
|
||||
logger.warn("Provider " + url + " has no startup()");
|
||||
AddonManagerPrivate.recordException("AMI", "provider " + url, "no startup()");
|
||||
}
|
||||
logger.debug("Loaded provider scope for " + url + ": " + Object.keys(scope).toSource());
|
||||
}
|
||||
catch (e) {
|
||||
AddonManagerPrivate.recordException("AMI", "provider " + url + " load failed", e);
|
||||
logger.error("Exception loading default provider \"" + url + "\"", e);
|
||||
}
|
||||
};
|
||||
|
|
@ -861,7 +844,6 @@ var AddonManagerInternal = {
|
|||
logger.debug(`Loaded provider scope for ${url}`);
|
||||
}
|
||||
catch (e) {
|
||||
AddonManagerPrivate.recordException("AMI", "provider " + url + " load failed", e);
|
||||
logger.error("Exception loading provider " + entry + " from category \"" +
|
||||
url + "\"", e);
|
||||
}
|
||||
|
|
@ -887,11 +869,9 @@ var AddonManagerInternal = {
|
|||
}
|
||||
|
||||
gStartupComplete = true;
|
||||
this.recordTimestamp("AMI_startup_end");
|
||||
}
|
||||
catch (e) {
|
||||
logger.error("startup failed", e);
|
||||
AddonManagerPrivate.recordException("AMI", "startup failed", e);
|
||||
}
|
||||
|
||||
logger.debug("Completed startup sequence");
|
||||
|
|
@ -1106,7 +1086,6 @@ var AddonManagerInternal = {
|
|||
catch(err) {
|
||||
savedError = err;
|
||||
logger.error("Failure during wait for shutdown barrier", err);
|
||||
AddonManagerPrivate.recordException("AMI", "Async shutdown of AddonManager providers", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1119,7 +1098,6 @@ var AddonManagerInternal = {
|
|||
catch(err) {
|
||||
savedError = err;
|
||||
logger.error("Failure during AddonRepository shutdown", err);
|
||||
AddonManagerPrivate.recordException("AMI", "Async shutdown of AddonRepository", err);
|
||||
}
|
||||
|
||||
logger.debug("Async provider shutdown done");
|
||||
|
|
@ -2519,56 +2497,6 @@ this.AddonManagerPrivate = {
|
|||
|
||||
AddonType: AddonType,
|
||||
|
||||
recordTimestamp: function(name, value) {
|
||||
AddonManagerInternal.recordTimestamp(name, value);
|
||||
},
|
||||
|
||||
_simpleMeasures: {},
|
||||
recordSimpleMeasure: function(name, value) {
|
||||
this._simpleMeasures[name] = value;
|
||||
},
|
||||
|
||||
recordException: function(aModule, aContext, aException) {
|
||||
let report = {
|
||||
module: aModule,
|
||||
context: aContext
|
||||
};
|
||||
|
||||
if (typeof aException == "number") {
|
||||
report.message = Components.Exception("", aException).name;
|
||||
}
|
||||
else {
|
||||
report.message = aException.toString();
|
||||
if (aException.fileName) {
|
||||
report.file = aException.fileName;
|
||||
report.line = aException.lineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
this._simpleMeasures.exception = report;
|
||||
},
|
||||
|
||||
getSimpleMeasures: function() {
|
||||
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) {
|
||||
let startTime = Cu.now();
|
||||
return {
|
||||
done: () => this.recordSimpleMeasure(aName, Math.round(Cu.now() - startTime))
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper to call update listeners when no update is available.
|
||||
*
|
||||
|
|
@ -2970,7 +2898,6 @@ this.AddonManager = {
|
|||
};
|
||||
|
||||
// load the timestamps module into AddonManagerInternal
|
||||
Cu.import("resource://gre/modules/TelemetryTimestamps.jsm", AddonManagerInternal);
|
||||
Object.freeze(AddonManagerInternal);
|
||||
Object.freeze(AddonManagerPrivate);
|
||||
Object.freeze(AddonManager);
|
||||
|
|
|
|||
|
|
@ -243,17 +243,6 @@ var gVersionInfoPage = {
|
|||
|
||||
onAllUpdatesFinished: function gVersionInfoPage_onAllUpdatesFinished() {
|
||||
AddonManager.removeAddonListener(listener);
|
||||
AddonManagerPrivate.recordSimpleMeasure("appUpdate_disabled",
|
||||
gUpdateWizard.disabled);
|
||||
AddonManagerPrivate.recordSimpleMeasure("appUpdate_metadata_enabled",
|
||||
gUpdateWizard.metadataEnabled);
|
||||
AddonManagerPrivate.recordSimpleMeasure("appUpdate_metadata_disabled",
|
||||
gUpdateWizard.metadataDisabled);
|
||||
// Record 0 for these here in case we exit early; values will be replaced
|
||||
// later if we actually upgrade any.
|
||||
AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgraded", 0);
|
||||
AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgradeFailed", 0);
|
||||
AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgradeDeclined", 0);
|
||||
// Filter out any add-ons that are now enabled.
|
||||
// Tycho:
|
||||
// logger.debug("VersionInfo updates finished: found " +
|
||||
|
|
@ -563,12 +552,6 @@ var gInstallingPage = {
|
|||
|
||||
if (this._installs.length == this._currentInstall) {
|
||||
Services.obs.notifyObservers(null, "TEST:all-updates-done", null);
|
||||
AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgraded",
|
||||
gUpdateWizard.upgraded);
|
||||
AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgradeFailed",
|
||||
gUpdateWizard.upgradeFailed);
|
||||
AddonManagerPrivate.recordSimpleMeasure("appUpdate_upgradeDeclined",
|
||||
gUpdateWizard.upgradeDeclined);
|
||||
this._installing = false;
|
||||
if (gUpdateWizard.shuttingDown) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -463,7 +463,6 @@ var GMPProvider = {
|
|||
configureLogging();
|
||||
this._log = Log.repository.getLoggerWithMessagePrefix("Toolkit.GMP",
|
||||
"GMPProvider.");
|
||||
let telemetry = {};
|
||||
this.buildPluginList();
|
||||
this.ensureProperCDMInstallState();
|
||||
|
||||
|
|
@ -485,14 +484,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)) {
|
||||
|
|
@ -509,8 +500,6 @@ var GMPProvider = {
|
|||
this._log.warn("startup - adding clearkey CDM failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
AddonManagerPrivate.setTelemetryDetails("GMP", telemetry);
|
||||
},
|
||||
|
||||
shutdown: function() {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue