Bug 1372670 - part 4 - use nsIThreadManager::dispatchToMainThread more from JS; r=florian

We did an automated conversion for many of these in another bug, but
these instances were either missed or have been added since then.
This commit is contained in:
Nathan Froyd 2017-06-21 12:59:28 -04:00
Родитель 27c58cf89f
Коммит 452dc60022
8 изменённых файлов: 17 добавлений и 23 удалений

Просмотреть файл

@ -98,8 +98,8 @@ function getListStyleImage(button) {
async function promiseAnimationFrame(win = window) {
await new Promise(resolve => win.requestAnimationFrame(resolve));
let {mainThread} = Services.tm;
return new Promise(resolve => mainThread.dispatch(resolve, mainThread.DISPATCH_NORMAL));
let {tm} = Services;
return new Promise(resolve => tm.dispatchToMainThread(resolve));
}
function promisePopupShown(popup) {

Просмотреть файл

@ -2079,12 +2079,11 @@ dump(`callFromJSON: < ${JSON.stringify(call)}\n`);
return result ? JSON.parse(result) : result;
}
let thread = Services.tm.currentThread;
thread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
dump(`callFromJSON (async): > ${JSON.stringify(call)}\n`);
let result = this.process.sendMessage(JSON.stringify(call));
dump(`callFromJSON: < ${JSON.stringify(call)}\n`);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
},
table: {

Просмотреть файл

@ -25,15 +25,14 @@ function executeSoon(aFun)
{
let comp = SpecialPowers.wrap(Components);
let thread = comp.classes["@mozilla.org/thread-manager;1"]
.getService(comp.interfaces.nsIThreadManager)
.mainThread;
let tm = comp.classes["@mozilla.org/thread-manager;1"]
.getService(comp.interfaces.nsIThreadManager);
thread.dispatch({
tm.dispatchToMainThread({
run() {
aFun();
}
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
});
}
function clearAllDatabases(callback) {

Просмотреть файл

@ -28,15 +28,14 @@ function* testSteps()
let comp = this.window ? SpecialPowers.wrap(Components) : Components;
let tm = comp.classes["@mozilla.org/thread-manager;1"]
.getService(comp.interfaces.nsIThreadManager);
let thread = tm.currentThread;
let eventHasRun;
thread.dispatch(function() {
tm.dispatchToMainThread(function() {
eventHasRun = true;
transaction2 = db.transaction("foo");
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
});
tm.spinEventLoopUntil(() => eventHasRun);

Просмотреть файл

@ -205,10 +205,8 @@ add_task(function* test_close_does_not_spin_event_loop() {
// Post the event before we call close, so it would run if the event loop was
// spun during close.
let thread = Cc["@mozilla.org/thread-manager;1"].
getService(Ci.nsIThreadManager).
currentThread;
thread.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL);
Cc["@mozilla.org/thread-manager;1"].
getService(Ci.nsIThreadManager).dispatchToMainThread(event);
// Sanity check, then close the database. Afterwards, we should not have ran!
do_check_false(event.ran);

Просмотреть файл

@ -23,7 +23,7 @@ const defer = function () {
return deferred;
};
const executeSoon = function (func) {
Services.tm.mainThread.dispatch(func, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(func);
};
const flags = { wantVerbose: false, wantLogging: false };

Просмотреть файл

@ -48,7 +48,7 @@ function promiseOneEvent(target, eventName, capture) {
}
function executeSoon(callback) {
Services.tm.mainThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(callback);
}
/**

Просмотреть файл

@ -4,10 +4,9 @@
if (shouldDelay) {
let shouldCrashNow = false;
let tm = Components.classes["@mozilla.org/thread-manager;1"]
.getService();
let thr = tm.currentThread;
thr.dispatch({ run: () => { shouldCrashNow = true; } },
Components.interfaces.nsIThread.DISPATCH_NORMAL);
.getService(Components.interfaces.nsIThreadManager);
tm.dispatchToMainThread({ run: () => { shouldCrashNow = true; } })
tm.spinEventLoopUntil(() => shouldCrashNow);
}