Bug 919535 - Use AsyncShutdown in Sqlite.jsm. r=Yoric

This commit is contained in:
Gregory Szorc 2013-10-02 14:24:33 +02:00
parent 9ddf4f6916
commit 6560ac9c5c

View File

@ -16,6 +16,8 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://services-common/log4moz.js");
XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown",
"resource://gre/modules/AsyncShutdown.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "CommonUtils",
"resource://services-common/utils.js");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
@ -197,6 +199,7 @@ function OpenedConnection(connection, basename, number, options) {
this._log.info("Opened");
this._connection = connection;
this._connectionIdentifier = basename + " Conn #" + number;
this._open = true;
this._cachedStatements = new Map();
@ -282,6 +285,11 @@ OpenedConnection.prototype = Object.freeze({
this._clearIdleShrinkTimer();
let deferred = Promise.defer();
AsyncShutdown.profileBeforeChange.addBlocker(
"Sqlite.jsm: " + this._connectionIdentifier,
deferred.promise
);
// We need to take extra care with transactions during shutdown.
//
// If we don't have a transaction in progress, we can proceed with shutdown