Backout 1f551298a760 (bug 697312) and b31507c8ca17 (bug 697246) for 25-30% Ts regression on multiple platforms

Except this time enter the changesets in the correct order in Mak's backout
script, so the changeset isn't empty :/
This commit is contained in:
Ed Morley 2011-11-04 10:50:16 +00:00
parent 83e90b8b97
commit b15379954e
4 changed files with 36 additions and 150 deletions

View File

@ -1759,7 +1759,7 @@ var XPIProvider = {
}
// Ensure any changes to the add-ons list are flushed to disk
XPIDatabase.writeAddonsList();
XPIDatabase.writeAddonsList([]);
Services.prefs.setBoolPref(PREF_PENDING_OPERATIONS, false);
},
@ -2942,18 +2942,16 @@ var XPIProvider = {
let state = this.getInstallLocationStates();
// If the database exists then the previous file cache can be trusted
// otherwise the database needs to be recreated
let dbFile = FileUtils.getFile(KEY_PROFILEDIR, [FILE_DATABASE], true);
updateDatabase |= !dbFile.exists();
if (!updateDatabase) {
// If the state has changed then we must update the database
let cache = Prefs.getCharPref(PREF_INSTALL_CACHE, null);
updateDatabase |= cache != JSON.stringify(state);
}
// If the database doesn't exist and there are add-ons installed then we
// must update the database however if there are no add-ons then there is
// no need to update the database.
if (!XPIDatabase.dbfile.exists())
updateDatabase = state.length > 0;
if (!updateDatabase) {
let bootstrapDescriptors = [this.bootstrappedAddons[b].descriptor
for (b in this.bootstrappedAddons)];
@ -2965,7 +2963,7 @@ var XPIProvider = {
bootstrapDescriptors.splice(pos, 1);
}
});
if (bootstrapDescriptors.length > 0) {
WARN("Bootstrap state is invalid (missing add-ons: " + bootstrapDescriptors.toSource() + ")");
updateDatabase = true;
@ -2979,7 +2977,7 @@ var XPIProvider = {
// If the database needs to be updated then open it and then update it
// from the filesystem
if (updateDatabase || hasPendingChanges) {
let migrateData = XPIDatabase.openConnection(false, true);
let migrateData = XPIDatabase.openConnection(false);
try {
extensionListChanged = this.processFileChanges(state, manifests,
@ -3034,8 +3032,8 @@ var XPIProvider = {
// Check that the add-ons list still exists
let addonsList = FileUtils.getFile(KEY_PROFILEDIR, [FILE_XPI_ADDONS_LIST],
true);
if (addonsList.exists() == (state.length == 0)) {
LOG("Add-ons list is invalid, rebuilding");
if (!addonsList.exists()) {
LOG("Add-ons list is missing, recreating");
XPIDatabase.writeAddonsList();
}
@ -4024,8 +4022,6 @@ var XPIDatabase = {
addonCache: [],
// The nested transaction count
transactionCount: 0,
// The database file
dbfile: FileUtils.getFile(KEY_PROFILEDIR, [FILE_DATABASE], true),
// The statements used by the database
statements: {
@ -4075,8 +4071,7 @@ var XPIDatabase = {
"type<>'theme' AND bootstrap=0",
getActiveTheme: "SELECT " + FIELDS_ADDON + " FROM addon WHERE " +
"internalName=:internalName AND type='theme'",
getThemes: "SELECT " + FIELDS_ADDON + " FROM addon WHERE type='theme' AND " +
"internalName<>:defaultSkin",
getThemes: "SELECT " + FIELDS_ADDON + " FROM addon WHERE type='theme'",
getAddonInLocation: "SELECT " + FIELDS_ADDON + " FROM addon WHERE id=:id " +
"AND location=:location",
@ -4218,17 +4213,12 @@ var XPIDatabase = {
* @return the migration data from the database if it was an old schema or
* null otherwise.
*/
openConnection: function XPIDB_openConnection(aRebuildOnError, aForceOpen) {
openConnection: function XPIDB_openConnection(aRebuildOnError) {
this.initialized = true;
let dbfile = FileUtils.getFile(KEY_PROFILEDIR, [FILE_DATABASE], true);
delete this.connection;
if (!aForceOpen && !this.dbfile.exists()) {
this.connection = null;
return {};
}
this.initialized = true;
this.connection = this.openDatabaseFile(this.dbfile);
this.connection = this.openDatabaseFile(dbfile);
let migrateData = null;
// If the database was corrupt or missing then the new blank database will
@ -4245,11 +4235,11 @@ var XPIDatabase = {
// Delete the existing database
this.connection.close();
try {
if (this.dbfile.exists())
this.dbfile.remove(true);
if (dbfile.exists())
dbfile.remove(true);
// Reopen an empty database
this.connection = this.openDatabaseFile(this.dbfile);
this.connection = this.openDatabaseFile(dbfile);
}
catch (e) {
ERROR("Failed to remove old database", e);
@ -4260,6 +4250,7 @@ var XPIDatabase = {
}
else if (Prefs.getIntPref(PREF_DB_SCHEMA, 0) == 0) {
// Only migrate data from the RDF if we haven't done it before
LOG("Migrating data from extensions.rdf");
migrateData = this.getMigrateDataFromRDF();
}
@ -4359,7 +4350,6 @@ var XPIDatabase = {
// Migrate data from extensions.rdf
let rdffile = FileUtils.getFile(KEY_PROFILEDIR, [FILE_OLD_DATABASE], true);
if (rdffile.exists()) {
LOG("Migrating data from extensions.rdf");
let ds = gRDF.GetDataSourceBlocking(Services.io.newFileURI(rdffile).spec);
let root = Cc["@mozilla.org/rdf/container;1"].
createInstance(Ci.nsIRDFContainer);
@ -4973,9 +4963,6 @@ var XPIDatabase = {
* @return an array of names of install locations
*/
getInstallLocations: function XPIDB_getInstallLocations() {
if (!this.connection)
return [];
let stmt = this.getStatement("getInstallLocations");
return [row.location for each (row in resultRows(stmt))];
@ -4989,9 +4976,6 @@ var XPIDatabase = {
* @return an array of DBAddonInternals
*/
getAddonsInLocation: function XPIDB_getAddonsInLocation(aLocation) {
if (!this.connection)
return [];
let stmt = this.getStatement("getAddonsInLocation");
stmt.params.location = aLocation;
@ -5010,11 +4994,6 @@ var XPIDatabase = {
* A callback to pass the DBAddonInternal to
*/
getAddonInLocation: function XPIDB_getAddonInLocation(aId, aLocation, aCallback) {
if (!this.connection) {
aCallback(null);
return;
}
let stmt = this.getStatement("getAddonInLocation");
stmt.params.id = aId;
@ -5041,11 +5020,6 @@ var XPIDatabase = {
* A callback to pass the DBAddonInternal to
*/
getVisibleAddonForID: function XPIDB_getVisibleAddonForID(aId, aCallback) {
if (!this.connection) {
aCallback(null);
return;
}
let stmt = this.getStatement("getVisibleAddonForID");
stmt.params.id = aId;
@ -5071,11 +5045,6 @@ var XPIDatabase = {
* A callback to pass the array of DBAddonInternals to
*/
getVisibleAddons: function XPIDB_getVisibleAddons(aTypes, aCallback) {
if (!this.connection) {
aCallback([]);
return;
}
let stmt = null;
if (!aTypes || aTypes.length == 0) {
stmt = this.getStatement("getVisibleAddons");
@ -5107,9 +5076,6 @@ var XPIDatabase = {
* @return an array of DBAddonInternals
*/
getAddonsByType: function XPIDB_getAddonsByType(aType) {
if (!this.connection)
return [];
let stmt = this.getStatement("getAddonsByType");
stmt.params.type = aType;
@ -5124,9 +5090,6 @@ var XPIDatabase = {
* @return a DBAddonInternal
*/
getVisibleAddonForInternalName: function XPIDB_getVisibleAddonForInternalName(aInternalName) {
if (!this.connection)
return null;
let stmt = this.getStatement("getVisibleAddonForInternalName");
let addon = null;
@ -5149,11 +5112,6 @@ var XPIDatabase = {
*/
getVisibleAddonsWithPendingOperations:
function XPIDB_getVisibleAddonsWithPendingOperations(aTypes, aCallback) {
if (!this.connection) {
aCallback([]);
return;
}
let stmt = null;
if (!aTypes || aTypes.length == 0) {
stmt = this.getStatement("getVisibleAddonsWithPendingOperations");
@ -5185,9 +5143,6 @@ var XPIDatabase = {
* @return an array of DBAddonInternals
*/
getAddons: function XPIDB_getAddons() {
if (!this.connection)
return [];
let stmt = this.getStatement("getAddons");
return [this.makeAddonFromRow(row) for each (row in resultRows(stmt))];;
@ -5202,10 +5157,6 @@ var XPIDatabase = {
* The file descriptor of the add-on
*/
addAddonMetadata: function XPIDB_addAddonMetadata(aAddon, aDescriptor) {
// If there is no DB yet then forcibly create one
if (!this.connection)
this.openConnection(false, true);
this.beginTransaction();
var self = this;
@ -5471,24 +5422,14 @@ var XPIDatabase = {
* Writes out the XPI add-ons list for the platform to read.
*/
writeAddonsList: function XPIDB_writeAddonsList() {
LOG("Writing add-ons list");
Services.appinfo.invalidateCachesOnRestart();
let addonsList = FileUtils.getFile(KEY_PROFILEDIR, [FILE_XPI_ADDONS_LIST],
true);
if (!this.connection) {
if (addonsList.exists()) {
LOG("Deleting add-ons list");
addonsList.remove(false);
}
Services.prefs.clearUserPref(PREF_EM_ENABLED_ADDONS);
return;
}
let enabledAddons = [];
let text = "[ExtensionDirs]\r\n";
let count = 0;
let fullCount = 0;
let stmt = this.getStatement("getActiveAddons");
@ -5496,47 +5437,28 @@ var XPIDatabase = {
text += "Extension" + (count++) + "=" + row.descriptor + "\r\n";
enabledAddons.push(row.id + ":" + row.version);
}
fullCount += count;
// The selected skin may come from an inactive theme (the default theme
// when a lightweight theme is applied for example)
text += "\r\n[ThemeDirs]\r\n";
stmt = null;
if (Prefs.getBoolPref(PREF_EM_DSS_ENABLED)) {
stmt = this.getStatement("getThemes");
stmt.params.defaultSkin = XPIProvider.defaultSkin;
}
else if (XPIProvider.selectedSkin != XPIProvider.defaultSkin) {
else {
stmt = this.getStatement("getActiveTheme");
stmt.params.internalName = XPIProvider.selectedSkin;
}
if (stmt) {
count = 0;
for (let row in resultRows(stmt)) {
text += "Extension" + (count++) + "=" + row.descriptor + "\r\n";
enabledAddons.push(row.id + ":" + row.version);
}
fullCount += count;
count = 0;
for (let row in resultRows(stmt)) {
text += "Extension" + (count++) + "=" + row.descriptor + "\r\n";
enabledAddons.push(row.id + ":" + row.version);
}
if (fullCount > 0) {
LOG("Writing add-ons list");
var fos = FileUtils.openSafeFileOutputStream(addonsList);
fos.write(text, text.length);
FileUtils.closeSafeFileOutputStream(fos);
var fos = FileUtils.openSafeFileOutputStream(addonsList);
fos.write(text, text.length);
FileUtils.closeSafeFileOutputStream(fos);
Services.prefs.setCharPref(PREF_EM_ENABLED_ADDONS, enabledAddons.join(","));
}
else {
if (addonsList.exists()) {
LOG("Deleting add-ons list");
addonsList.remove(false);
}
Services.prefs.clearUserPref(PREF_EM_ENABLED_ADDONS);
}
Services.prefs.setCharPref(PREF_EM_ENABLED_ADDONS, enabledAddons.join(","));
}
};

View File

@ -125,13 +125,6 @@ function run_test() {
startupManager();
let file = gProfD.clone();
file.append("extensions.sqlite");
do_check_false(file.exists());
file.leafName = "extensions.ini";
do_check_false(file.exists());
run_test_1();
}
@ -174,13 +167,6 @@ function run_test_1() {
}
function check_test_1() {
let file = gProfD.clone();
file.append("extensions.sqlite");
do_check_true(file.exists());
file.leafName = "extensions.ini";
do_check_false(file.exists());
AddonManager.getAllInstalls(function(installs) {
// There should be no active installs now since the install completed and
// doesn't require a restart.
@ -261,10 +247,6 @@ function run_test_3() {
do_check_eq(getShutdownReason(), ADDON_DISABLE);
do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
let file = gProfD.clone();
file.append("extensions.ini");
do_check_false(file.exists());
AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");

View File

@ -48,7 +48,7 @@ function run_test() {
do_check_false(d.userDisabled);
do_check_false(d.appDisabled);
do_check_true(d.isActive);
do_check_false(isThemeInAddonsList(profileDir, d.id));
do_check_true(isThemeInAddonsList(profileDir, d.id));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
@ -76,7 +76,7 @@ function run_test_1(d, a) {
do_check_true(d.userDisabled);
do_check_false(d.appDisabled);
do_check_true(d.isActive);
do_check_false(isThemeInAddonsList(profileDir, d.id));
do_check_true(isThemeInAddonsList(profileDir, d.id));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
do_check_true(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
@ -94,7 +94,7 @@ function run_test_1(d, a) {
do_check_false(d.userDisabled);
do_check_false(d.appDisabled);
do_check_true(d.isActive);
do_check_false(isThemeInAddonsList(profileDir, d.id));
do_check_true(isThemeInAddonsList(profileDir, d.id));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
@ -121,7 +121,7 @@ function run_test_2() {
do_check_false(d.userDisabled);
do_check_false(d.appDisabled);
do_check_true(d.isActive);
do_check_false(isThemeInAddonsList(profileDir, d.id));
do_check_true(isThemeInAddonsList(profileDir, d.id));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
@ -140,7 +140,7 @@ function run_test_2() {
do_check_true(d.userDisabled);
do_check_false(d.appDisabled);
do_check_true(d.isActive);
do_check_false(isThemeInAddonsList(profileDir, d.id));
do_check_true(isThemeInAddonsList(profileDir, d.id));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
do_check_true(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
@ -158,7 +158,7 @@ function run_test_2() {
do_check_false(d.userDisabled);
do_check_false(d.appDisabled);
do_check_true(d.isActive);
do_check_false(isThemeInAddonsList(profileDir, d.id));
do_check_true(isThemeInAddonsList(profileDir, d.id));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
@ -176,7 +176,7 @@ function run_test_2() {
do_check_true(d.userDisabled);
do_check_false(d.appDisabled);
do_check_true(d.isActive);
do_check_false(isThemeInAddonsList(profileDir, d.id));
do_check_true(isThemeInAddonsList(profileDir, d.id));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
do_check_true(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
@ -241,7 +241,7 @@ function check_test_2() {
do_check_false(d.userDisabled);
do_check_false(d.appDisabled);
do_check_true(d.isActive);
do_check_false(isThemeInAddonsList(profileDir, d.id));
do_check_true(isThemeInAddonsList(profileDir, d.id));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));

View File

@ -132,13 +132,6 @@ function run_test() {
check_startup_changes(AddonManager.STARTUP_CHANGE_DISABLED, []);
check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
let file = gProfD.clone();
file.append("extensions.sqlite");
do_check_false(file.exists());
file.leafName = "extensions.ini";
do_check_false(file.exists());
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
@ -190,13 +183,6 @@ function run_test_1() {
check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
do_check_true(gCachePurged);
let file = gProfD.clone();
file.append("extensions.sqlite");
do_check_true(file.exists());
file.leafName = "extensions.ini";
do_check_true(file.exists());
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
@ -298,10 +284,6 @@ function run_test_2() {
check_startup_changes(AddonManager.STARTUP_CHANGE_ENABLED, []);
do_check_true(gCachePurged);
var file = gProfD.clone();
file.append("extensions.ini");
do_check_true(file.exists());
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",