зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
27c58cf89f
Коммит
452dc60022
|
@ -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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче