mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-01 12:03:08 +00:00
Bug 1041433 - UnifiedComplete: Close connections on Sqlite.shutdown.addBlocker. r=mano
This commit is contained in:
parent
17a6489feb
commit
ae658c889c
@ -1921,6 +1921,7 @@ XPCOMUtils.defineLazyGetter(this, "gAsyncDBConnPromised", () => {
|
||||
catch(ex) {
|
||||
// It's too late to block shutdown, just close the connection.
|
||||
return conn.close();
|
||||
throw (ex);
|
||||
}
|
||||
return Promise.resolve();
|
||||
}).then(null, Cu.reportError);
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
|
||||
|
||||
const TOPIC_SHUTDOWN = "places-shutdown";
|
||||
const TOPIC_PREFCHANGED = "nsPref:changed";
|
||||
|
||||
const DEFAULT_BEHAVIOR = 0;
|
||||
@ -1463,19 +1462,9 @@ Search.prototype = {
|
||||
//// component @mozilla.org/autocomplete/search;1?name=unifiedcomplete
|
||||
|
||||
function UnifiedComplete() {
|
||||
Services.obs.addObserver(this, TOPIC_SHUTDOWN, true);
|
||||
}
|
||||
|
||||
UnifiedComplete.prototype = {
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// nsIObserver
|
||||
|
||||
observe: function (subject, topic, data) {
|
||||
if (topic === TOPIC_SHUTDOWN) {
|
||||
this.ensureShutdown();
|
||||
}
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// Database handling
|
||||
|
||||
@ -1500,6 +1489,18 @@ UnifiedComplete.prototype = {
|
||||
readOnly: true
|
||||
});
|
||||
|
||||
try {
|
||||
Sqlite.shutdown.addBlocker("Places UnifiedComplete.js clone closing",
|
||||
Task.async(function* () {
|
||||
SwitchToTabStorage.shutdown();
|
||||
yield conn.close();
|
||||
}));
|
||||
} catch (ex) {
|
||||
// It's too late to block shutdown, just close the connection.
|
||||
yield conn.close();
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// Autocomplete often fallbacks to a table scan due to lack of text
|
||||
// indices. A larger cache helps reducing IO and improving performance.
|
||||
// The value used here is larger than the default Storage value defined
|
||||
@ -1515,20 +1516,6 @@ UnifiedComplete.prototype = {
|
||||
return this._promiseDatabase;
|
||||
},
|
||||
|
||||
/**
|
||||
* Used to stop running queries and close the database handle.
|
||||
*/
|
||||
ensureShutdown: function () {
|
||||
if (this._promiseDatabase) {
|
||||
Task.spawn(function* () {
|
||||
let conn = yield this.getDatabaseHandle();
|
||||
SwitchToTabStorage.shutdown();
|
||||
yield conn.close()
|
||||
}.bind(this)).then(null, Cu.reportError);
|
||||
this._promiseDatabase = null;
|
||||
}
|
||||
},
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//// mozIPlacesAutoComplete
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user