Bug 1089695 - Fixing wrong dependency in Places shutdown. r=mak
This commit is contained in:
@@ -65,7 +65,13 @@ Sanitizer.prototype = {
|
|||||||
var itemsToClear = [...aItemsToClear];
|
var itemsToClear = [...aItemsToClear];
|
||||||
} else {
|
} else {
|
||||||
let branch = Services.prefs.getBranch(this.prefDomain);
|
let branch = Services.prefs.getBranch(this.prefDomain);
|
||||||
itemsToClear = Object.keys(this.items).filter(itemName => branch.getBoolPref(itemName));
|
itemsToClear = Object.keys(this.items).filter(itemName => {
|
||||||
|
try {
|
||||||
|
return branch.getBoolPref(itemName);
|
||||||
|
} catch (ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure open windows get cleared first, if they're in our list, so that they don't stick
|
// Ensure open windows get cleared first, if they're in our list, so that they don't stick
|
||||||
|
|||||||
@@ -71,13 +71,11 @@ add_task(function* test_execute() {
|
|||||||
}
|
}
|
||||||
do_print("Add cache.");
|
do_print("Add cache.");
|
||||||
yield storeCache(FTP_URL, "testData");
|
yield storeCache(FTP_URL, "testData");
|
||||||
});
|
|
||||||
|
|
||||||
add_task(function* run_test_continue() {
|
|
||||||
do_print("Simulate and wait shutdown.");
|
do_print("Simulate and wait shutdown.");
|
||||||
yield shutdownPlaces();
|
yield shutdownPlaces();
|
||||||
|
|
||||||
let stmt = DBConn().createStatement(
|
let stmt = DBConn(true).createStatement(
|
||||||
"SELECT id FROM moz_places WHERE url = :page_url "
|
"SELECT id FROM moz_places WHERE url = :page_url "
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -93,13 +91,7 @@ add_task(function* run_test_continue() {
|
|||||||
|
|
||||||
do_print("Check cache");
|
do_print("Check cache");
|
||||||
// Check cache.
|
// Check cache.
|
||||||
let promiseCacheChecked = checkCache(FTP_URL);
|
yield checkCache(FTP_URL);
|
||||||
|
|
||||||
do_print("Shutdown the download manager");
|
|
||||||
// Shutdown the download manager.
|
|
||||||
Services.obs.notifyObservers(null, "quit-application", null);
|
|
||||||
|
|
||||||
yield promiseCacheChecked;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function storeCache(aURL, aContent) {
|
function storeCache(aURL, aContent) {
|
||||||
|
|||||||
@@ -2075,6 +2075,19 @@ XPCOMUtils.defineLazyGetter(this, "bundle", function() {
|
|||||||
createBundle(PLACES_STRING_BUNDLE_URI);
|
createBundle(PLACES_STRING_BUNDLE_URI);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// A promise resolved once the Sqlite.jsm connections
|
||||||
|
// can be closed.
|
||||||
|
let promiseCanCloseConnection = function() {
|
||||||
|
let TOPIC = "places-will-close-connection";
|
||||||
|
return new Promise(resolve => {
|
||||||
|
let observer = function() {
|
||||||
|
Services.obs.removeObserver(observer, TOPIC);
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
Services.obs.addObserver(observer, TOPIC, false)
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
XPCOMUtils.defineLazyGetter(this, "gAsyncDBConnPromised",
|
XPCOMUtils.defineLazyGetter(this, "gAsyncDBConnPromised",
|
||||||
() => new Promise((resolve) => {
|
() => new Promise((resolve) => {
|
||||||
Sqlite.cloneStorageConnection({
|
Sqlite.cloneStorageConnection({
|
||||||
@@ -2082,12 +2095,23 @@ XPCOMUtils.defineLazyGetter(this, "gAsyncDBConnPromised",
|
|||||||
readOnly: true
|
readOnly: true
|
||||||
}).then(conn => {
|
}).then(conn => {
|
||||||
try {
|
try {
|
||||||
Sqlite.shutdown.addBlocker(
|
let state = "0. not started";
|
||||||
"PlacesUtils read-only connection closing",
|
|
||||||
conn.close.bind(conn));
|
let promiseReady = promiseCanCloseConnection();
|
||||||
PlacesUtils.history.shutdownClient.jsclient.addBlocker(
|
let promiseShutdownComplete = Task.async(function*() {
|
||||||
"PlacesUtils read-only connection closing",
|
// Don't close the connection as long as it might be used.
|
||||||
conn.close.bind(conn));
|
state = "1. waiting for `places-will-close-connection`";
|
||||||
|
yield promiseReady;
|
||||||
|
|
||||||
|
// But close the connection before Sqlite shutdown.
|
||||||
|
state = "2. closing the connection";
|
||||||
|
yield conn.close();
|
||||||
|
|
||||||
|
state = "3. done";
|
||||||
|
})();
|
||||||
|
Sqlite.shutdown.addBlocker("PlacesUtils read-only connection closing",
|
||||||
|
promiseShutdownComplete,
|
||||||
|
() => state);
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
// It's too late to block shutdown, just close the connection.
|
// It's too late to block shutdown, just close the connection.
|
||||||
conn.close();
|
conn.close();
|
||||||
@@ -2104,12 +2128,23 @@ XPCOMUtils.defineLazyGetter(this, "gAsyncDBWrapperPromised",
|
|||||||
connection: PlacesUtils.history.DBConnection,
|
connection: PlacesUtils.history.DBConnection,
|
||||||
}).then(conn => {
|
}).then(conn => {
|
||||||
try {
|
try {
|
||||||
Sqlite.shutdown.addBlocker(
|
let state = "0. not started";
|
||||||
"PlacesUtils wrapped connection closing",
|
|
||||||
conn.close.bind(conn));
|
let promiseReady = promiseCanCloseConnection();
|
||||||
PlacesUtils.history.shutdownClient.jsclient.addBlocker(
|
let promiseShutdownComplete = Task.async(function*() {
|
||||||
"PlacesUtils wrapped connection closing",
|
// Don't close the connection as long as it might be used.
|
||||||
conn.close.bind(conn));
|
state = "1. waiting for `places-will-close-connection`";
|
||||||
|
yield promiseReady;
|
||||||
|
|
||||||
|
// But close the connection before Sqlite shutdown.
|
||||||
|
state = "2. closing the connection";
|
||||||
|
yield conn.close();
|
||||||
|
|
||||||
|
state = "3. done";
|
||||||
|
})();
|
||||||
|
Sqlite.shutdown.addBlocker("PlacesUtils wrapped connection closing",
|
||||||
|
promiseShutdownComplete,
|
||||||
|
() => state);
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
// It's too late to block shutdown, just close the connection.
|
// It's too late to block shutdown, just close the connection.
|
||||||
conn.close();
|
conn.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user