Bug 702848 - Finalize the statements in services sync/modules/engines/forms.js. r=dolske.

This commit is contained in:
Rafael Ávila de Espíndola 2011-12-22 11:21:37 -05:00
parent 347c7c6e99
commit afbe1e8534
2 changed files with 15 additions and 1 deletions

View File

@ -79,6 +79,13 @@ let FormWrapper = {
return this._stmts[query] = db.createAsyncStatement(query);
},
_finalize : function () {
for each (let stmt in FormWrapper._stmts) {
stmt.finalize();
}
FormWrapper._stmts = {};
},
get _getAllEntriesStmt() {
const query =
"SELECT fieldname name, value FROM moz_formhistory " +
@ -270,6 +277,7 @@ function FormTracker(name) {
Tracker.call(this, name);
Svc.Obs.add("weave:engine:start-tracking", this);
Svc.Obs.add("weave:engine:stop-tracking", this);
Svc.Obs.add("profile-change-teardown", this);
}
FormTracker.prototype = {
__proto__: Tracker.prototype,
@ -320,6 +328,9 @@ FormTracker.prototype = {
this.trackEntry(name, value);
}
break;
case "profile-change-teardown":
FormWrapper._finalize();
break;
}
},

View File

@ -137,6 +137,7 @@ FormHistory.prototype = {
this.messageManager.addMessageListener("FormHistory:FormSubmitEntries", this);
// Add observers
Services.obs.addObserver(this, "profile-change-teardown", true);
Services.obs.addObserver(this, "profile-before-change", true);
Services.obs.addObserver(this, "idle-daily", true);
Services.obs.addObserver(this, "formhistory-expire-now", true);
@ -402,6 +403,9 @@ FormHistory.prototype = {
this.expireOldEntries();
break;
case "profile-before-change":
// FIXME (bug 696486): close the connection in here.
break;
case "profile-change-teardown":
this._dbFinalize();
break;
default:
@ -870,7 +874,6 @@ FormHistory.prototype = {
* Finalize all statements to allow closing the connection correctly.
*/
_dbFinalize : function FH__dbFinalize() {
// FIXME (bug 696486): close the connection in here.
for each (let stmt in this.dbStmts) {
stmt.finalize();
}