Bug 919535 - Use AsyncShutdown in Sqlite.jsm. r=Yoric
authorGregory Szorc <gps@mozilla.com>
Wed, 02 Oct 2013 14:24:33 +0200
changeset 165258 a5046a3a30eac9a613265824a8d9f2c99a53ee39
parent 165257 b4f347a62071149e59562aba128b488437c8df1d
child 165259 c180e7c60c14cd1923bb3e034d94556142a40623
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs919535
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 919535 - Use AsyncShutdown in Sqlite.jsm. r=Yoric
toolkit/modules/Sqlite.jsm
--- a/toolkit/modules/Sqlite.jsm
+++ b/toolkit/modules/Sqlite.jsm
@@ -11,16 +11,18 @@ this.EXPORTED_SYMBOLS = [
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
 Cu.import("resource://gre/modules/osfile.jsm");
 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",
                                   "resource://gre/modules/FileUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Task",
                                   "resource://gre/modules/Task.jsm");
 
 
@@ -192,16 +194,17 @@ function OpenedConnection(connection, ba
     };
   }
 
   this._log = logProxy;
 
   this._log.info("Opened");
 
   this._connection = connection;
+  this._connectionIdentifier = basename + " Conn #" + number;
   this._open = true;
 
   this._cachedStatements = new Map();
   this._anonymousStatements = new Map();
   this._anonymousCounter = 0;
 
   // A map from statement index to mozIStoragePendingStatement, to allow for
   // canceling prior to finalizing the mozIStorageStatements.
@@ -277,16 +280,21 @@ OpenedConnection.prototype = Object.free
     if (!this._connection) {
       return Promise.resolve();
     }
 
     this._log.debug("Request to close connection.");
     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
     // immediately.
     if (!this._inProgressTransaction) {
       this._finalize(deferred);
       return deferred.promise;
     }