Bug 756701 - Backout original patch. r=mfinkle

This commit is contained in:
Wes Johnston 2012-05-22 15:33:31 -07:00
parent a900813e5d
commit bd17386f20
2 changed files with 75 additions and 0 deletions

View File

@ -345,6 +345,7 @@ LoginManagerStorage_mozStorage.prototype = {
try {
stmt = this._dbCreateStatement(query, params);
stmt.execute();
this.storeDeletedLogin(storedLogin);
transaction.commit();
} catch (e) {
this.log("_removeLogin failed: " + e.name + " : " + e.message);
@ -650,6 +651,31 @@ LoginManagerStorage_mozStorage.prototype = {
return [logins, ids];
},
/* storeDeletedLogin
*
* Moves a login to the deleted logins table
*
*/
storeDeletedLogin : function(aLogin) {
#ifdef ANDROID
let stmt = null;
try {
this.log("Storing " + aLogin.guid + " in deleted passwords\n");
let query = "INSERT INTO moz_deleted_logins (guid, timeDeleted) VALUES (:guid, :timeDeleted)";
let params = { guid: aLogin.guid,
timeDeleted: Date.now() };
let stmt = this._dbCreateStatement(query, params);
stmt.execute();
} catch(ex) {
throw ex;
} finally {
if (stmt)
stmt.reset();
}
#endif
},
/*
* removeAllLogins
*
@ -667,6 +693,11 @@ LoginManagerStorage_mozStorage.prototype = {
// Disabled hosts kept, as one presumably doesn't want to erase those.
query = "DELETE FROM moz_logins";
try {
let logins = this.getAllLogins();
for each (let login in logins) {
let [id, storedLogin] = this._getIdForLogin(login);
this.storeDeletedLogin(storedLogin);
}
stmt = this._dbCreateStatement(query);
stmt.execute();
transaction.commit();

View File

@ -222,6 +222,10 @@ FormHistory.prototype = {
existingTransactionInProgress = this.dbConnection.transactionInProgress;
if (!existingTransactionInProgress)
this.dbConnection.beginTransaction();
this.moveToDeletedTable("VALUES (:guid, :timeDeleted)", {
guid: guid,
timeDeleted: Date.now()
});
// remove from the formhistory database
stmt = this.dbCreateStatement(query, params);
@ -257,6 +261,12 @@ FormHistory.prototype = {
existingTransactionInProgress = this.dbConnection.transactionInProgress;
if (!existingTransactionInProgress)
this.dbConnection.beginTransaction();
this.moveToDeletedTable(
"SELECT guid, :timeDeleted FROM moz_formhistory " +
"WHERE fieldname = :fieldname", {
fieldname: name,
timeDeleted: Date.now()
});
stmt = this.dbCreateStatement(query, params);
stmt.execute();
@ -290,6 +300,11 @@ FormHistory.prototype = {
existingTransactionInProgress = this.dbConnection.transactionInProgress;
if (!existingTransactionInProgress)
this.dbConnection.beginTransaction();
this.moveToDeletedTable(
"SELECT guid, :timeDeleted FROM moz_formhistory", {
timeDeleted: Date.now()
});
stmt = this.dbCreateStatement(query);
stmt.execute();
this.sendNotification("removeAllEntries", null);
@ -352,6 +367,12 @@ FormHistory.prototype = {
existingTransactionInProgress = this.dbConnection.transactionInProgress;
if (!existingTransactionInProgress)
this.dbConnection.beginTransaction();
this.moveToDeletedTable(
"SELECT guid, :timeDeleted FROM moz_formhistory " +
"WHERE firstUsed >= :beginTime AND firstUsed <= :endTime", {
beginTime: beginTime,
endTime: endTime
});
stmt = this.dbCreateStatement(query, params);
stmt.executeStep();
@ -370,6 +391,29 @@ FormHistory.prototype = {
this.dbConnection.commitTransaction();
},
moveToDeletedTable : function moveToDeletedTable(values, params) {
#ifdef ANDROID
this.log("Moving entries to deleted table.");
let stmt;
try {
// Move the entries to the deleted items table.
let query = "INSERT INTO moz_deleted_formhistory (guid, timeDeleted) ";
if (values) query += values;
stmt = this.dbCreateStatement(query, params);
stmt.execute();
} catch (e) {
this.log("Moving deleted entries failed: " + e);
throw e;
} finally {
if (stmt) {
stmt.reset();
}
}
#endif
},
get dbConnection() {
// Make sure dbConnection can't be called from now to prevent infinite loops.
delete FormHistory.prototype.dbConnection;