зеркало из https://github.com/mozilla/gecko-dev.git
Bug 711570 - finalize statements and close connection. r=zpao.
--HG-- extra : rebase_source : 6816e8f2b0d8edaea7b39e0a0fa4a4c2c288b8a2
This commit is contained in:
Родитель
04c63497fd
Коммит
a27307c9cb
|
@ -1299,9 +1299,19 @@ LoginManagerStorage_mozStorage.prototype = {
|
|||
this._dbCleanup(true);
|
||||
throw e;
|
||||
}
|
||||
|
||||
Services.obs.addObserver(this, "profile-before-change", false);
|
||||
return isFirstRun;
|
||||
},
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "profile-before-change":
|
||||
Services.obs.removeObserver(this, "profile-before-change");
|
||||
this._dbClose();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
_dbCreate: function () {
|
||||
this.log("Creating Database");
|
||||
|
@ -1617,6 +1627,23 @@ LoginManagerStorage_mozStorage.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
_dbClose : function () {
|
||||
this.log("Closing the DB connection.");
|
||||
// Finalize all statements to free memory, avoid errors later
|
||||
for each (let stmt in this._dbStmts) {
|
||||
stmt.finalize();
|
||||
}
|
||||
this._dbStmts = {};
|
||||
|
||||
if (this._dbConnection !== null) {
|
||||
try {
|
||||
this._dbConnection.close();
|
||||
} catch (e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
}
|
||||
this._dbConnection = null;
|
||||
},
|
||||
|
||||
/*
|
||||
* _dbCleanup
|
||||
|
@ -1633,15 +1660,7 @@ LoginManagerStorage_mozStorage.prototype = {
|
|||
this._storageService.backupDatabaseFile(this._signonsFile, backupFile);
|
||||
}
|
||||
|
||||
// Finalize all statements to free memory, avoid errors later
|
||||
for each (let stmt in this._dbStmts) {
|
||||
stmt.finalize();
|
||||
}
|
||||
this._dbStmts = {};
|
||||
|
||||
// Close the connection, ignore 'already closed' error
|
||||
try { this._dbConnection.close() } catch(e) {}
|
||||
this._dbConnection = null;
|
||||
this._dbClose();
|
||||
this._signonsFile.remove(false);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче