From 6560ac9c5c152bffa5c570dfa58e83bf5c7d0959 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Wed, 2 Oct 2013 14:24:33 +0200 Subject: [PATCH] Bug 919535 - Use AsyncShutdown in Sqlite.jsm. r=Yoric --- toolkit/modules/Sqlite.jsm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/toolkit/modules/Sqlite.jsm b/toolkit/modules/Sqlite.jsm index 737ccd44e53..14d0aafe4b9 100644 --- a/toolkit/modules/Sqlite.jsm +++ b/toolkit/modules/Sqlite.jsm @@ -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