From afbe1e8534add209ae77d550c626ef33e845cbf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Thu, 22 Dec 2011 11:21:37 -0500 Subject: [PATCH] Bug 702848 - Finalize the statements in services sync/modules/engines/forms.js. r=dolske. --- services/sync/modules/engines/forms.js | 11 +++++++++++ toolkit/components/satchel/nsFormHistory.js | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/services/sync/modules/engines/forms.js b/services/sync/modules/engines/forms.js index 76a2a992f46f..03610ef5c0d7 100644 --- a/services/sync/modules/engines/forms.js +++ b/services/sync/modules/engines/forms.js @@ -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; } }, diff --git a/toolkit/components/satchel/nsFormHistory.js b/toolkit/components/satchel/nsFormHistory.js index cdacd67ac15b..6a1974665314 100644 --- a/toolkit/components/satchel/nsFormHistory.js +++ b/toolkit/components/satchel/nsFormHistory.js @@ -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(); }