Bug 1355161 - script-generated patch to replace .{currentThread,mainThread}.dispatch(..., Ci.nsIThread.DISPATCH_NORMAL) with .dispatchToMainThread(...), r=froydnj.

This commit is contained in:
Florian Queze 2017-04-14 18:29:12 +02:00
Родитель 65ba8f32ee
Коммит a363fb8c8b
100 изменённых файлов: 213 добавлений и 244 удалений

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

@ -80,8 +80,7 @@ function setImmediate(callback, ...params) {
// if dispatch loop is not scheduled schedule one. Own scheduler
if (!dispatcher.scheduled) {
dispatcher.scheduled = true;
threadManager.currentThread.dispatch(dispatcher,
Ci.nsIThread.DISPATCH_NORMAL);
threadManager.dispatchToMainThread(dispatcher);
}
return id;
}

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

@ -49,8 +49,7 @@ else {
let listener = function (subject, topic) {
Services.obs.removeObserver(this, topic);
Startup.initialized = true;
Services.tm.currentThread.dispatch(() => gOnceInitializedDeferred.resolve(),
Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(() => gOnceInitializedDeferred.resolve());
}
Services.obs.addObserver(listener, appStartup, false);

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

@ -456,8 +456,7 @@ nsHttpServer.prototype =
self._notifyStopped();
}
};
gThreadManager.currentThread
.dispatch(stopEvent, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(stopEvent);
}
},
@ -2695,8 +2694,7 @@ ServerHandler.prototype =
let writeMore = function writeMore()
{
gThreadManager.currentThread
.dispatch(writeData, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(writeData);
}
var input = new BinaryInputStream(fis);
@ -3767,13 +3765,13 @@ Response.prototype =
// way to handle both cases without removing bodyOutputStream access and
// moving its effective write(data, length) method onto Response, which
// would be slower and require more code than this anyway.
gThreadManager.currentThread.dispatch({
gThreadManager.dispatchToMainThread({
run: function()
{
dumpn("*** canceling copy asynchronously...");
copier.cancel(Cr.NS_ERROR_UNEXPECTED);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
else
{
@ -4522,7 +4520,7 @@ WriteThroughCopier.prototype =
}
};
gThreadManager.currentThread.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(event);
},
/**

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

@ -456,8 +456,7 @@ nsHttpServer.prototype =
self._notifyStopped();
}
};
gThreadManager.currentThread
.dispatch(stopEvent, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(stopEvent);
}
},
@ -2695,8 +2694,7 @@ ServerHandler.prototype =
let writeMore = function writeMore()
{
gThreadManager.currentThread
.dispatch(writeData, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(writeData);
}
var input = new BinaryInputStream(fis);
@ -3767,13 +3765,13 @@ Response.prototype =
// way to handle both cases without removing bodyOutputStream access and
// moving its effective write(data, length) method onto Response, which
// would be slower and require more code than this anyway.
gThreadManager.currentThread.dispatch({
gThreadManager.dispatchToMainThread({
run: function()
{
dumpn("*** canceling copy asynchronously...");
copier.cancel(Cr.NS_ERROR_UNEXPECTED);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
else
{
@ -4522,7 +4520,7 @@ WriteThroughCopier.prototype =
}
};
gThreadManager.currentThread.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(event);
},
/**

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

@ -457,8 +457,7 @@ nsHttpServer.prototype =
self._notifyStopped();
}
};
gThreadManager.currentThread
.dispatch(stopEvent, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(stopEvent);
}
},
@ -2696,8 +2695,7 @@ ServerHandler.prototype =
let writeMore = function writeMore()
{
gThreadManager.currentThread
.dispatch(writeData, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(writeData);
}
var input = new BinaryInputStream(fis);
@ -3768,13 +3766,13 @@ Response.prototype =
// way to handle both cases without removing bodyOutputStream access and
// moving its effective write(data, length) method onto Response, which
// would be slower and require more code than this anyway.
gThreadManager.currentThread.dispatch({
gThreadManager.dispatchToMainThread({
run: function()
{
dumpn("*** canceling copy asynchronously...");
copier.cancel(Cr.NS_ERROR_UNEXPECTED);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
else
{
@ -4523,7 +4521,7 @@ WriteThroughCopier.prototype =
}
};
gThreadManager.currentThread.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(event);
},
/**

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

@ -456,8 +456,7 @@ nsHttpServer.prototype =
self._notifyStopped();
}
};
gThreadManager.currentThread
.dispatch(stopEvent, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(stopEvent);
}
},
@ -2695,8 +2694,7 @@ ServerHandler.prototype =
let writeMore = function writeMore()
{
gThreadManager.currentThread
.dispatch(writeData, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(writeData);
}
var input = new BinaryInputStream(fis);
@ -3767,13 +3765,13 @@ Response.prototype =
// way to handle both cases without removing bodyOutputStream access and
// moving its effective write(data, length) method onto Response, which
// would be slower and require more code than this anyway.
gThreadManager.currentThread.dispatch({
gThreadManager.dispatchToMainThread({
run: function()
{
dumpn("*** canceling copy asynchronously...");
copier.cancel(Cr.NS_ERROR_UNEXPECTED);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
else
{
@ -4522,7 +4520,7 @@ WriteThroughCopier.prototype =
}
};
gThreadManager.currentThread.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(event);
},
/**

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

@ -457,8 +457,7 @@ nsHttpServer.prototype =
self._notifyStopped();
}
};
gThreadManager.currentThread
.dispatch(stopEvent, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(stopEvent);
}
},
@ -2696,8 +2695,7 @@ ServerHandler.prototype =
let writeMore = function writeMore()
{
gThreadManager.currentThread
.dispatch(writeData, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(writeData);
}
var input = new BinaryInputStream(fis);
@ -3768,13 +3766,13 @@ Response.prototype =
// way to handle both cases without removing bodyOutputStream access and
// moving its effective write(data, length) method onto Response, which
// would be slower and require more code than this anyway.
gThreadManager.currentThread.dispatch({
gThreadManager.dispatchToMainThread({
run: function()
{
dumpn("*** canceling copy asynchronously...");
copier.cancel(Cr.NS_ERROR_UNEXPECTED);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
else
{
@ -4523,7 +4521,7 @@ WriteThroughCopier.prototype =
}
};
gThreadManager.currentThread.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(event);
},
/**

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

@ -50,9 +50,9 @@ SSLExceptions.prototype = {
aSslStatus,
aTargetHost) {
this._sslStatus = aSslStatus.QueryInterface(Ci.nsISSLStatus);
Services.tm.currentThread.dispatch({
Services.tm.dispatchToMainThread({
run: this._addOverride.bind(this)
}, Ci.nsIThread.DISPATCH_NORMAL);
});
return true; // suppress error UI
},

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

@ -521,6 +521,6 @@ var FullZoom = {
_executeSoon: function FullZoom__executeSoon(callback) {
if (!callback)
return;
Services.tm.mainThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(callback);
},
};

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

@ -60,7 +60,7 @@ add_task(function*() {
// The click is handled async; wait for an event loop turn for that to
// happen.
yield new Promise(function(resolve) {
Services.tm.mainThread.dispatch(resolve, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(resolve);
});
}
}

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

@ -43,7 +43,7 @@ add_task(function*() {
ourPrompt.onButtonClick(0);
// Wait for that click to actually be handled completely.
yield new Promise(function(resolve) {
Services.tm.mainThread.dispatch(resolve, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(resolve);
});
// check permission is set
let ps = Services.perms;

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

@ -2294,5 +2294,5 @@ function __dumpDragData(aEvent, caller) {
}
function dispatchFunction(aFunc) {
Services.tm.currentThread.dispatch(aFunc, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(aFunc);
}

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

@ -1092,11 +1092,11 @@ DownloadsPlacesView.prototype = {
// first item is activated, and pass the item to the richlistbox
// setters only at a point we know for sure the binding is attached.
firstDownloadElement._shell.ensureActive();
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
this._richlistbox.selectedItem = firstDownloadElement;
this._richlistbox.currentItem = firstDownloadElement;
this._initiallySelectedElement = firstDownloadElement;
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
}
},

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

@ -394,9 +394,9 @@ class TabTracker extends TabTrackerBase {
// `tabs.onRemoved.addListener`, then the tab would be closed before the
// event listener is registered. To make sure that the event listener is
// notified, we dispatch `tabs.onRemoved` asynchronously.
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
this.emit("tab-removed", {nativeTab, tabId, windowId, isWindowClosing});
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
getBrowserData(browser) {

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

@ -235,7 +235,7 @@ this.MigratorPrototype = {
// Used to periodically give back control to the main-thread loop.
let unblockMainThread = function() {
return new Promise(resolve => {
Services.tm.mainThread.dispatch(resolve, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(resolve);
});
};

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

@ -1033,9 +1033,9 @@ BrowserGlue.prototype = {
} catch (ex) { /* Don't break the default prompt if telemetry is broken. */ }
if (willPrompt) {
Services.tm.mainThread.dispatch(function() {
Services.tm.dispatchToMainThread(function() {
DefaultBrowserCheck.prompt(RecentWindow.getMostRecentBrowserWindow());
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
}

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

@ -1427,10 +1427,10 @@
this._rebuild();
break;
case "popuphidden":
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
this.selectedButton = null;
this._contextEngine = null;
}, Ci.nsIThread.DISPATCH_NORMAL);
});
break;
}
]]></body>

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

@ -14,7 +14,7 @@ Cu.import("resource:///modules/sessionstore/FrameTree.jsm", this);
var gFrameTree = new FrameTree(this);
function executeSoon(callback) {
Services.tm.mainThread.dispatch(callback, Components.interfaces.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(callback);
}
gFrameTree.addObserver({

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

@ -13,8 +13,7 @@ function startup(data, reasonCode) {
gStarted = true;
// delay realstartup to trigger the race condition
Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager)
.mainThread.dispatch(realstartup, 0);
Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager).dispatchToMainThread(realstartup);
}
function realstartup() {

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

@ -330,7 +330,7 @@ function initService() {
}
function schedule(callback) {
Services.tm.mainThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(callback);
}
// Public API

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

@ -174,9 +174,9 @@ this.webrtcUI = {
let identityBox = browserWindow.document.getElementById("identity-box");
if (AppConstants.platform == "macosx" && !Services.focus.activeWindow) {
browserWindow.addEventListener("activate", function() {
Services.tm.mainThread.dispatch(function() {
Services.tm.dispatchToMainThread(function() {
identityBox.click();
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}, {once: true});
Cc["@mozilla.org/widget/macdocksupport;1"].getService(Ci.nsIMacDockSupport)
.activateApplication(true);

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

@ -9210,13 +9210,13 @@ return /******/ (function(modules) { // webpackBootstrap
copy: function() {
// Dispatch to the next tick so that it's possible to attach a progress
// event listener, even for extremely fast copies (like when testing).
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
try {
this._copy();
} catch (e) {
this._deferred.reject(e);
}
}, 0);
});
return this;
},

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

@ -8048,13 +8048,13 @@ return /******/ (function(modules) { // webpackBootstrap
copy: function() {
// Dispatch to the next tick so that it's possible to attach a progress
// event listener, even for extremely fast copies (like when testing).
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
try {
this._copy();
} catch (e) {
this._deferred.reject(e);
}
}, 0);
});
return this;
},

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

@ -235,9 +235,9 @@ GlobalSearchView.prototype = Heritage.extend(WidgetMethods, {
// Dispatch subsequent document manipulation operations, to avoid
// blocking the main thread when a large number of search results
// is found, thus giving the impression of faster searching.
Services.tm.currentThread.dispatch({ run:
Services.tm.dispatchToMainThread({ run:
this._createSourceResultsUI.bind(this, sourceResults)
}, 0);
});
}
}
},
@ -332,12 +332,12 @@ GlobalSearchView.prototype = Heritage.extend(WidgetMethods, {
* The match to start a bounce animation for.
*/
_bounceMatch: function (aMatch) {
Services.tm.currentThread.dispatch({ run: () => {
Services.tm.dispatchToMainThread({ run: () => {
aMatch.addEventListener("transitionend", function () {
aMatch.removeAttribute("focused");
}, {once: true});
aMatch.setAttribute("focused", "");
}}, 0);
}});
aMatch.setAttribute("focusing", "");
},

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

@ -152,13 +152,13 @@ DOMHelpers.prototype = {
// If in `callback` the URL of the window is changed and a listener to DOMContentLoaded
// is attached, the event we just received will be also be caught by the new listener.
// We want to avoid that so we execute the callback in the next queue.
Services.tm.mainThread.dispatch(callback, 0);
Services.tm.dispatchToMainThread(callback);
}
};
if ((window.document.readyState == "complete" ||
window.document.readyState == "interactive") &&
window.location.href == targetURL) {
Services.tm.mainThread.dispatch(callback, 0);
Services.tm.dispatchToMainThread(callback);
} else {
docShell.chromeEventHandler.addEventListener("DOMContentLoaded", onReady);
}

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

@ -1497,7 +1497,7 @@ Scope.prototype = {
this._openEnum();
}
if (this._variablesView._nonEnumVisible) {
Services.tm.currentThread.dispatch({ run: this._openNonEnum }, 0);
Services.tm.dispatchToMainThread({ run: this._openNonEnum });
}
this._isExpanded = true;

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

@ -957,7 +957,7 @@ TabActor.prototype = {
let force = request && request.options && request.options.force;
// Wait a tick so that the response packet can be dispatched before the
// subsequent navigation event packet.
Services.tm.currentThread.dispatch(DevToolsUtils.makeInfallible(() => {
Services.tm.dispatchToMainThread(DevToolsUtils.makeInfallible(() => {
// This won't work while the browser is shutting down and we don't really
// care.
if (Services.startup.shuttingDown) {
@ -966,7 +966,7 @@ TabActor.prototype = {
this.webNavigation.reload(force ?
Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE :
Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
}, "TabActor.prototype.onReload's delayed body"), 0);
}, "TabActor.prototype.onReload's delayed body"));
return {};
},
@ -976,9 +976,9 @@ TabActor.prototype = {
onNavigateTo(request) {
// Wait a tick so that the response packet can be dispatched before the
// subsequent navigation event packet.
Services.tm.currentThread.dispatch(DevToolsUtils.makeInfallible(() => {
Services.tm.dispatchToMainThread(DevToolsUtils.makeInfallible(() => {
this.window.location = request.url;
}, "TabActor.prototype.onNavigateTo's delayed body"), 0);
}, "TabActor.prototype.onNavigateTo's delayed body"));
return {};
},

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

@ -671,7 +671,7 @@ DevToolsUtils.makeInfallible(function (window) {
* a nsIWindowMediatorListener's onCloseWindow hook (bug 873589), so
* handle the close in a different tick.
*/
Services.tm.currentThread.dispatch(DevToolsUtils.makeInfallible(() => {
Services.tm.dispatchToMainThread(DevToolsUtils.makeInfallible(() => {
/*
* Scan the entire map for actors representing tabs that were in this
* top-level window, and exit them.
@ -682,7 +682,7 @@ DevToolsUtils.makeInfallible(function (window) {
this._handleActorClose(actor, browser);
}
}
}, "BrowserTabList.prototype.onCloseWindow's delayed body"), 0);
}, "BrowserTabList.prototype.onCloseWindow's delayed body"));
}, "BrowserTabList.prototype.onCloseWindow");
exports.BrowserTabList = BrowserTabList;

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

@ -315,7 +315,7 @@ var WebExtensionInspectedWindowActor = protocol.ActorClassWithSpec(
// Execute the reload in a dispatched runnable, so that we can
// return the reply to the caller before the reload is actually
// started.
Services.tm.currentThread.dispatch(delayedReload, 0);
Services.tm.dispatchToMainThread(delayedReload);
return {};
},

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

@ -585,9 +585,9 @@ StubTransport.prototype.send = function () {};
StubTransport.prototype.close = function () {};
function executeSoon(func) {
Services.tm.mainThread.dispatch({
Services.tm.dispatchToMainThread({
run: DevToolsUtils.makeInfallible(func)
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
// The do_check_* family of functions expect their last argument to be an

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

@ -24,9 +24,9 @@ function run_test() {
// XXX: We have to do an executeSoon so that the error isn't caught and
// reported by DebuggerClient.requester (because we are using the local
// transport and share a stack) which causes the test to fail.
Services.tm.mainThread.dispatch({
Services.tm.dispatchToMainThread({
run: test_black_box
}, Ci.nsIThread.DISPATCH_NORMAL);
});
});
});
do_test_pending();

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

@ -22,7 +22,7 @@ function run_test() {
function test_nesting() {
do_check_eq(inspector.eventLoopNestLevel, 0);
tm.currentThread.dispatch({ run: enterEventLoop}, 0);
tm.dispatchToMainThread({ run: enterEventLoop});
do_check_eq(inspector.enterNestedEventLoop(requestor(gCount)), 0);
do_check_eq(inspector.eventLoopNestLevel, 0);
@ -31,7 +31,7 @@ function test_nesting() {
function enterEventLoop() {
if (gCount++ < MAX) {
tm.currentThread.dispatch({ run: enterEventLoop}, 0);
tm.dispatchToMainThread({ run: enterEventLoop});
Object.create(requestor(gCount));
@ -41,7 +41,7 @@ function enterEventLoop() {
do_check_eq(inspector.enterNestedEventLoop(requestor(gCount)), gCount);
} else {
do_check_eq(gCount, MAX + 1);
tm.currentThread.dispatch({ run: exitEventLoop}, 0);
tm.dispatchToMainThread({ run: exitEventLoop});
}
}
@ -50,7 +50,7 @@ function exitEventLoop() {
do_check_eq(inspector.lastNestRequestor.url, requestor(gCount - 1).url);
do_check_eq(inspector.lastNestRequestor.connection, requestor(gCount - 1).connection);
if (gCount-- > 1) {
tm.currentThread.dispatch({ run: exitEventLoop}, 0);
tm.dispatchToMainThread({ run: exitEventLoop});
}
do_check_eq(inspector.exitNestedEventLoop(), gCount);

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

@ -33,9 +33,9 @@ function run_test_with_server(server, callback) {
// XXX: We have to do an executeSoon so that the error isn't caught and
// reported by DebuggerClient.requester (because we are using the local
// transport and share a stack) which causes the test to fail.
Services.tm.mainThread.dispatch({
Services.tm.dispatchToMainThread({
run: test_simple_stepping
}, Ci.nsIThread.DISPATCH_NORMAL);
});
});
});
}

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

@ -46,9 +46,9 @@ exports.executeSoon = function (fn) {
} else {
executor = fn;
}
Services.tm.mainThread.dispatch({
Services.tm.dispatchToMainThread({
run: exports.makeInfallible(executor)
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
};

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

@ -99,13 +99,13 @@ StreamCopier.prototype = {
copy: function () {
// Dispatch to the next tick so that it's possible to attach a progress
// event listener, even for extremely fast copies (like when testing).
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
try {
this._copy();
} catch (e) {
this._deferred.reject(e);
}
}, 0);
});
return this;
},

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

@ -71,8 +71,7 @@ IndexedDBHelper.prototype = {
req = indexedDB.open(this.dbName, this.dbVersion);
} catch (e) {
if (DEBUG) debug("Error opening database: " + self.dbName);
Services.tm.currentThread.dispatch(() => invokeCallbacks(getErrorName(e)),
Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(() => invokeCallbacks(getErrorName(e)));
return;
}
req.onsuccess = function (event) {
@ -114,8 +113,7 @@ IndexedDBHelper.prototype = {
if (this._db) {
if (DEBUG) debug("ensureDB: already have a database, returning early.");
if (aSuccessCb) {
Services.tm.currentThread.dispatch(aSuccessCb,
Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(aSuccessCb);
}
return;
}

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

@ -7,7 +7,7 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function executeSoon(f)
{
Services.tm.mainThread.dispatch(f, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(f);
}
var urlSuffix = "/this/is/the/test/url";

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

@ -369,7 +369,7 @@ BrowserElementAuthPrompt.prototype = {
}
}
Services.tm.currentThread.dispatch(runnable, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(runnable);
},
_getFrameFromChannel: function(channel) {

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

@ -224,7 +224,7 @@ NotificationStorage.prototype = {
// fetching from the database.
notifications.forEach(function(notification) {
try {
Services.tm.currentThread.dispatch(
Services.tm.dispatchToMainThread(
callback.handle.bind(callback,
notification.id,
notification.title,
@ -235,15 +235,13 @@ NotificationStorage.prototype = {
notification.icon,
notification.data,
notification.mozbehavior,
notification.serviceWorkerRegistrationScope),
Ci.nsIThread.DISPATCH_NORMAL);
notification.serviceWorkerRegistrationScope));
} catch (e) {
if (DEBUG) { debug("Error calling callback handle: " + e); }
}
});
try {
Services.tm.currentThread.dispatch(callback.done,
Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(callback.done);
} catch (e) {
if (DEBUG) { debug("Error calling callback done: " + e); }
}

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

@ -124,19 +124,19 @@ PresentationControlService.prototype = {
},
_notifyServerReady: function() {
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
if (this._listener) {
this._listener.onServerReady(this._port, this.certFingerprint);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
},
_notifyServerStopped: function(aRv) {
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
if (this._listener) {
this._listener.onServerStopped(aRv);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
},
isCompatibleServer: function(aVersion) {

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

@ -49,9 +49,9 @@ const mockControlChannelOfSender = {
.notifyReconnected();
},
sendOffer: function(offer) {
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
mockControlChannelOfReceiver.onOffer(offer);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
},
onAnswer: function(answer) {
this._listener
@ -127,9 +127,9 @@ const mockControlChannelOfReceiver = {
.onOffer(offer);
},
sendAnswer: function(answer) {
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
mockControlChannelOfSender.onAnswer(answer);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
},
disconnect: function(reason) {
if (!this._listener) {

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

@ -804,9 +804,9 @@ function ignoreIncompatibleDevice() {
let mockServerObj = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlService]),
startServer: function() {
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
this.listener.onServerReady(this.port, this.certFingerprint);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
},
sessionRequest: function() {},
close: function() {},
@ -889,9 +889,9 @@ function ignoreSelfDevice() {
let mockServerObj = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPresentationControlService]),
startServer: function() {
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
this.listener.onServerReady(this.port, this.certFingerprint);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
},
sessionRequest: function() {},
close: function() {},
@ -1253,14 +1253,14 @@ function serverRetry() {
startServer: function(encrypted, port) {
if (!isRetrying) {
isRetrying = true;
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
this.listener.onServerStopped(Cr.NS_ERROR_FAILURE);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
} else {
this.port = 54321;
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
this.listener.onServerReady(this.port, this.certFingerprint);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
},
sessionRequest: function() {},

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

@ -1300,13 +1300,13 @@ DataCall.prototype = {
if (this.state == NETWORK_STATE_CONNECTED) {
// This needs to run asynchronously, to behave the same way as the case of
// non-shared apn, see bug 1059110.
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
// Do not notify if state changed while this event was being dispatched,
// the state probably was notified already or need not to be notified.
if (aNetworkInterface.info.state == RIL.GECKO_NETWORK_STATE_CONNECTED) {
aNetworkInterface.notifyRILNetworkInterface();
}
}, Ci.nsIEventTarget.DISPATCH_NORMAL);
});
return;
}
@ -1431,7 +1431,7 @@ DataCall.prototype = {
// Notify the DISCONNECTED event immediately after network interface is
// removed from requestedNetworkIfaces, to make the DataCall, shared or
// not, to have the same behavior.
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
// Do not notify if state changed while this event was being dispatched,
// the state probably was notified already or need not to be notified.
if (aNetworkInterface.info.state == RIL.GECKO_NETWORK_STATE_DISCONNECTED) {
@ -1442,7 +1442,7 @@ DataCall.prototype = {
this.resetLinkInfo();
}
}
}, Ci.nsIEventTarget.DISPATCH_NORMAL);
});
}
// Only deactivate data call if no more network interface needs this

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

@ -115,9 +115,9 @@ NetworkWorkerRequestQueue.prototype = {
this.tasks.shift();
if (this.tasks.length > 0) {
// Run queue on the next tick.
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
this.runQueue();
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
}
};

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

@ -593,9 +593,9 @@ TetheringService.prototype = {
if (aCallback) {
// Callback asynchronously to avoid netsted toggling.
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
aCallback.wifiTetheringEnabledChange(aMsg);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
},

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

@ -26,8 +26,7 @@ function newGlobal() {
addTestingFunctionsToGlobal(this);
function executeSoon(f) {
Services.tm.mainThread.dispatch({ run: f },
Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread({ run: f });
}
// The onGarbageCollection tests don't play well gczeal settings and lead to

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

@ -56,7 +56,7 @@ function do_log_info(aMessage)
// from the operation callback.
function executeSoon(fn) {
var tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
tm.mainThread.dispatch({run: fn}, Ci.nsIThread.DISPATCH_NORMAL);
tm.dispatchToMainThread({run: fn});
}
//

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

@ -491,7 +491,7 @@ InternalPrompt.prototype = {
}
}
Services.tm.mainThread.dispatch(runnable, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(runnable);
},
asyncPromptAuth: function asyncPromptAuth(aChannel, aCallback, aContext, aLevel, aAuthInfo) {

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

@ -328,9 +328,9 @@ class TabTracker extends TabTrackerBase {
let windowId = windowTracker.getId(nativeTab.browser.ownerGlobal);
let tabId = this.getId(nativeTab);
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
this.emit("tab-removed", {nativeTab, tabId, windowId, isWindowClosing});
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
getBrowserData(browser) {

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

@ -68,9 +68,9 @@ function RemoteMedia(id, listener) {
this._listener = listener;
if ("onRemoteMediaStart" in this._listener) {
Services.tm.mainThread.dispatch((function() {
Services.tm.dispatchToMainThread((function() {
this._listener.onRemoteMediaStart(this);
}).bind(this), Ci.nsIThread.DISPATCH_NORMAL);
}).bind(this));
}
}

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

@ -68,7 +68,7 @@
var domWindowUtils = gWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils);
function runSoon(f) {
threadMan.mainThread.dispatch({ run: f }, Ci.nsIThread.DISPATCH_NORMAL);
threadMan.dispatchToMainThread({ run: f });
}
function cc() {

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

@ -70,7 +70,7 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186
let url = "http://mochi.test:8888/chrome/mobile/android/tests/browser/chrome/video_discovery.html";
browser = BrowserApp.addTab(url, { selected: true, parentId: BrowserApp.selectedTab.id }).browser;
browser.addEventListener("load", function(event) {
Services.tm.mainThread.dispatch(test_video, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(test_video);
}, {capture: true, once: true});
}

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

@ -199,7 +199,7 @@ function do_execute_soon(callback) {
var tm = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager);
tm.mainThread.dispatch({
tm.dispatchToMainThread({
run: function() {
try {
callback();
@ -225,7 +225,7 @@ function do_execute_soon(callback) {
do_test_finished();
}
}
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
});
}
function do_throw(text, stack) {

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

@ -14,7 +14,7 @@ var browser;
function setHandlerFunc(handler, test) {
browser.addEventListener("DOMLinkAdded", function(event) {
Services.tm.mainThread.dispatch(handler.bind(this, test), Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(handler.bind(this, test));
}, {once: true});
}
@ -27,7 +27,7 @@ add_test(function setup_browser() {
let url = "http://mochi.test:8888/tests/robocop/link_discovery.html";
browser = BrowserApp.addTab(url, { selected: true, parentId: BrowserApp.selectedTab.id }).browser;
browser.addEventListener("load", function(event) {
Services.tm.mainThread.dispatch(run_next_test, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(run_next_test);
}, {capture: true, once: true});
});

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

@ -79,7 +79,7 @@ add_test(function setup_browser() {
let url = "about:blank";
gBrowser = BrowserApp.addTab(url, { selected: true, parentId: BrowserApp.selectedTab.id }).browser;
gBrowser.addEventListener("load", function(event) {
Services.tm.mainThread.dispatch(run_next_test, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(run_next_test);
}, {capture: true, once: true});
});

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

@ -92,7 +92,7 @@ add_task(function* test_tracking_pb() {
let browser = BrowserApp.addTab("about:blank", { selected: true, parentId: BrowserApp.selectedTab.id, isPrivate: true }).browser;
yield new Promise((resolve, reject) => {
browser.addEventListener("load", function(event) {
Services.tm.mainThread.dispatch(resolve, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(resolve);
}, {capture: true, once: true});
});
@ -147,7 +147,7 @@ add_task(function* test_tracking_not_pb() {
let browser = BrowserApp.addTab("about:blank", { selected: true }).browser;
yield new Promise((resolve, reject) => {
browser.addEventListener("load", function(event) {
Services.tm.mainThread.dispatch(resolve, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(resolve);
}, {capture: true, once: true});
});

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

@ -39,7 +39,7 @@ add_test(function setup_browser() {
video = contentDocument.getElementById("video");
ok(video, "Found the video element");
Services.tm.mainThread.dispatch(run_next_test, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(run_next_test);
}, {capture: true, once: true});
});
@ -47,14 +47,14 @@ add_test(function test_webm() {
// Load the test video
video.src = "http://mochi.test:8888/tests/robocop/video-pattern.webm";
Services.tm.mainThread.dispatch(testLoad, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(testLoad);
});
add_test(function test_ogg() {
// Load the test video
video.src = "http://mochi.test:8888/tests/robocop/video-pattern.ogg";
Services.tm.mainThread.dispatch(testLoad, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(testLoad);
});
function getButtonByAttribute(aName, aValue) {

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

@ -191,7 +191,7 @@ document.getElementById('form').submit();
} catch(e) {}
}
};
Services.tm.currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(runnable);
},
asyncOpen2: function(aListener) {
this.asyncOpen(aListener, null);

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

@ -495,8 +495,7 @@ nsHttpServer.prototype =
self._notifyStopped();
}
};
gThreadManager.currentThread
.dispatch(stopEvent, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(stopEvent);
}
},
@ -2861,8 +2860,7 @@ ServerHandler.prototype =
}
let writeMore = function () {
gThreadManager.currentThread
.dispatch(writeData, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(writeData);
}
var input = new BinaryInputStream(fis);
@ -3943,13 +3941,13 @@ Response.prototype =
// way to handle both cases without removing bodyOutputStream access and
// moving its effective write(data, length) method onto Response, which
// would be slower and require more code than this anyway.
gThreadManager.currentThread.dispatch({
gThreadManager.dispatchToMainThread({
run: function()
{
dumpn("*** canceling copy asynchronously...");
copier.cancel(Cr.NS_ERROR_UNEXPECTED);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
else
{
@ -4698,7 +4696,7 @@ WriteThroughCopier.prototype =
}
};
gThreadManager.currentThread.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(event);
},
/**

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

@ -1616,7 +1616,7 @@ CopyTest.prototype =
}
}
};
gThreadManager.currentThread.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(event);
},
/**

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

@ -285,8 +285,7 @@ function handleAsyncOrdering(request, response)
// Use gThreadManager here because it's expedient, *not* because it's
// intended for public use! If you do this in client code, expect me to
// knowingly break your code by changing the variable name. :-P
gThreadManager.currentThread
.dispatch(writeData, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(writeData);
}
step();
response.processAsync();

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

@ -47,12 +47,12 @@ function checkException(fun, err, msg)
function callASAPLater(fun)
{
gThreadManager.currentThread.dispatch({
gThreadManager.dispatchToMainThread({
run: function()
{
fun();
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}

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

@ -132,7 +132,7 @@ this.CommonUtils = {
if (thisObj) {
callback = callback.bind(thisObj);
}
Services.tm.currentThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(callback);
},
/**

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

@ -126,8 +126,7 @@ this.Credentials = Object.freeze({
deferred.resolve(result);
}
Services.tm.currentThread.dispatch(runnable,
Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(runnable);
log.debug("Dispatched thread for credentials setup crypto work");
return deferred.promise;

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

@ -172,7 +172,7 @@ let SyncedTabsInternal = {
// Sync is currently synchronous, so do it after an event-loop spin to help
// keep the UI responsive.
return new Promise((resolve, reject) => {
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
try {
log.info("Doing a tab sync.");
Weave.Service.sync(["tabs"]);
@ -181,7 +181,7 @@ let SyncedTabsInternal = {
log.error("Sync failed", ex);
reject(ex);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
});
},

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

@ -495,8 +495,7 @@ nsHttpServer.prototype =
self._notifyStopped();
}
};
gThreadManager.currentThread
.dispatch(stopEvent, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(stopEvent);
}
},
@ -2856,8 +2855,7 @@ ServerHandler.prototype =
function writeMore()
{
gThreadManager.currentThread
.dispatch(writeData, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(writeData);
}
var input = new BinaryInputStream(fis);
@ -3929,13 +3927,13 @@ Response.prototype =
// way to handle both cases without removing bodyOutputStream access and
// moving its effective write(data, length) method onto Response, which
// would be slower and require more code than this anyway.
gThreadManager.currentThread.dispatch({
gThreadManager.dispatchToMainThread({
run: function()
{
dumpn("*** canceling copy asynchronously...");
copier.cancel(Cr.NS_ERROR_UNEXPECTED);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
else
{
@ -4684,7 +4682,7 @@ WriteThroughCopier.prototype =
}
};
gThreadManager.currentThread.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL);
gThreadManager.dispatchToMainThread(event);
},
/**

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

@ -257,7 +257,7 @@
function executeSoon(callback) {
let tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
tm.mainThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL);
tm.dispatchToMainThread(callback);
}
function waitForFocus(callback, win) {

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

@ -949,11 +949,11 @@ function testScope(aTester, aTest, expected) {
};
this.executeSoon = function test_executeSoon(func) {
Services.tm.mainThread.dispatch({
Services.tm.dispatchToMainThread({
run: function() {
func();
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
};
this.waitForExplicitFinish = function test_waitForExplicitFinish() {

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

@ -24,7 +24,7 @@ Cu.import("resource://gre/modules/Services.jsm");
this.TestUtils = {
executeSoon(callbackFn) {
Services.tm.mainThread.dispatch(callbackFn, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(callbackFn);
},
/**

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

@ -343,9 +343,9 @@ SPConsoleListener.prototype = {
// Run in a separate runnable since console listeners aren't
// supposed to touch content and this one might.
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
this.callback.call(undefined, m);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
if (!m.isScriptError && m.message === "SENTINEL")
Services.console.unregisterListener(this);
@ -1237,13 +1237,13 @@ SpecialPowersAPI.prototype = {
obs.observe = wrapCallback(obs.observe);
}
let asyncObs = (...args) => {
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
if (typeof obs == 'function') {
obs.call(undefined, ...args);
} else {
obs.observe.call(undefined, ...args);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
};
this._asyncObservers.set(obs, asyncObs);
Services.obs.addObserver(asyncObs, notification, weak);
@ -2139,13 +2139,13 @@ SpecialPowersAPI.prototype = {
Cc["@mozilla.org/url-classifier/dbservice;1"].getService(Ci.nsIURIClassifier);
let wrapCallback = (...args) => {
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
if (typeof callback == 'function') {
callback.call(undefined, ...args);
} else {
callback.onClassifyComplete.call(undefined, ...args);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
};
return classifierService.classify(unwrapIfWrapped(principal), eventTarget,
@ -2158,13 +2158,13 @@ SpecialPowersAPI.prototype = {
Cc["@mozilla.org/url-classifier/dbservice;1"].getService(Ci.nsIURIClassifier);
let wrapCallback = (...args) => {
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
if (typeof callback == 'function') {
callback.call(undefined, ...args);
} else {
callback.onClassifyComplete.call(undefined, ...args);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
};
return classifierService.asyncClassifyLocalWithTables(unwrapIfWrapped(uri),

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

@ -697,7 +697,7 @@ function do_execute_soon(callback, aName) {
var tm = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager);
tm.mainThread.dispatch({
tm.dispatchToMainThread({
run: function() {
try {
callback();
@ -722,7 +722,7 @@ function do_execute_soon(callback, aName) {
do_test_finished(funcName);
}
}
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
});
}
/**

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

@ -354,7 +354,7 @@ AboutProtocolChannel.prototype = {
} catch (e) {}
}
};
Services.tm.currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(runnable);
},
asyncOpen2(listener) {

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

@ -288,7 +288,7 @@ function testAboutModuleRegistration() {
} catch (e) {}
}
};
Services.tm.currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(runnable);
},
asyncOpen2(listener) {

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

@ -784,8 +784,7 @@ ContentPrefService2.prototype = {
},
_schedule: function CPS2__schedule(fn) {
Services.tm.mainThread.dispatch(fn.bind(this),
Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(fn.bind(this));
},
addObserverForName: function CPS2_addObserverForName(name, observer) {

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

@ -574,7 +574,7 @@ ContentPrefService.prototype = {
_scheduleCallback(func) {
let tm = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
tm.mainThread.dispatch(func, Ci.nsIThread.DISPATCH_NORMAL);
tm.dispatchToMainThread(func);
},
_selectPref: function ContentPrefService__selectPref(aGroup, aSetting, aCallback) {

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

@ -201,7 +201,7 @@ nsFilePicker.prototype = {
open(aFilePickerShownCallback) {
var tm = Components.classes["@mozilla.org/thread-manager;1"]
.getService(Components.interfaces.nsIThreadManager);
tm.mainThread.dispatch(() => {
tm.dispatchToMainThread(() => {
let result = Components.interfaces.nsIFilePicker.returnCancel;
try {
result = this.show();
@ -248,7 +248,7 @@ nsFilePicker.prototype = {
aFilePickerShownCallback.done(result);
}
});
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
});
},
show() {

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

@ -246,7 +246,7 @@ FormHandler.prototype = {
*/
waitForTick() {
return new Promise(function(resolve) {
Services.tm.currentThread.dispatch(resolve, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(resolve);
});
},
};

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

@ -180,7 +180,7 @@ LoginManagerPromptFactory.prototype = {
prompt.inProgress = true;
}
Services.tm.mainThread.dispatch(runnable, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(runnable);
this.log("_doAsyncPrompt:run dispatched");
},

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

@ -274,7 +274,7 @@ BufferedObserver.prototype.observe = function(source, details) {
this._buffer.push({source, details});
if (!this._isDispatching) {
this._isDispatching = true;
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
// Grab buffer, in case something in the listener could modify it.
let buffer = this._buffer;
this._buffer = [];
@ -284,7 +284,7 @@ BufferedObserver.prototype.observe = function(source, details) {
this._isDispatching = false;
this._listener(buffer);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
};

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

@ -1560,7 +1560,7 @@ this.PlacesUtils = {
// Delaying to catch issues with asynchronous behavior while waiting
// to implement asynchronous annotations in bug 699844.
Services.tm.mainThread.dispatch(function() {
Services.tm.dispatchToMainThread(function() {
if (aCharset && aCharset.length > 0) {
PlacesUtils.annotations.setPageAnnotation(
aURI, PlacesUtils.CHARSET_ANNO, aCharset, 0,
@ -1570,7 +1570,7 @@ this.PlacesUtils = {
aURI, PlacesUtils.CHARSET_ANNO);
}
deferred.resolve();
}, Ci.nsIThread.DISPATCH_NORMAL);
});
return deferred.promise;
},
@ -1585,7 +1585,7 @@ this.PlacesUtils = {
getCharsetForURI: function PU_getCharsetForURI(aURI) {
let deferred = Promise.defer();
Services.tm.mainThread.dispatch(function() {
Services.tm.dispatchToMainThread(function() {
let charset = null;
try {
@ -1594,7 +1594,7 @@ this.PlacesUtils = {
} catch (ex) { }
deferred.resolve(charset);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
return deferred.promise;
},
@ -1975,7 +1975,7 @@ this.PlacesUtils = {
// So we let everyone else have a go every few items (bug 1186714).
if (++yieldCounter % 50 == 0) {
yield new Promise(resolve => {
Services.tm.currentThread.dispatch(resolve, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(resolve);
});
}
}

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

@ -676,9 +676,9 @@ Livemark.prototype = {
let nodes = this._nodes.get(container);
for (let node of nodes) {
if (!aURI || node.uri == aURI.spec) {
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
observer.nodeHistoryDetailsChanged(node, 0, aVisitedStatus);
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}
}
}

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

@ -133,14 +133,14 @@ add_task(function* shutdown() {
Services.obs.removeObserver(onNotification, "places-will-close-connection");
do_check_true(true, "Observed fake places shutdown");
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
// WARNING: this is very bad, never use out of testing code.
PlacesUtils.bookmarks.QueryInterface(Ci.nsINavHistoryObserver)
.onPageChanged(NetUtil.newURI("http://book.ma.rk/"),
Ci.nsINavHistoryObserver.ATTRIBUTE_FAVICON,
"test", "test");
deferred.resolve(promiseTopicObserved("places-connection-closed"));
}, Ci.nsIThread.DISPATCH_NORMAL);
});
}, "places-will-close-connection", false);
shutdownPlaces();

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

@ -284,11 +284,10 @@
// runnable, and if exiting moral state posts a runnable we will
// incorrectly process that runnable before leaving our event
// loop spin.
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
this.Dialog["onButton" + buttonNum]();
this.shutdownPrompt();
},
Ci.nsIThread.DISPATCH_NORMAL);
});
]]>
</body>
</method>

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

@ -2637,7 +2637,7 @@ const gEmptyParseSubmissionResult =
Object.freeze(new ParseSubmissionResult(null, "", -1, 0));
function executeSoon(func) {
Services.tm.mainThread.dispatch(func, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(func);
}
/**

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

@ -1974,12 +1974,12 @@ var Impl = {
case "idle-daily":
// Enqueue to main-thread, otherwise components may be inited by the
// idle-daily category and miss the gather-telemetry notification.
Services.tm.mainThread.dispatch((function() {
Services.tm.dispatchToMainThread((function() {
// Notify that data should be gathered now.
// TODO: We are keeping this behaviour for now but it will be removed as soon as
// bug 1127907 lands.
Services.obs.notifyObservers(null, "gather-telemetry", null);
}), Ci.nsIThread.DISPATCH_NORMAL);
}));
break;
case "application-background":

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

@ -86,8 +86,7 @@ const PingServer = {
const deferred = this._defers[this._currentDeferred++];
// Send the ping to the consumer on the next tick, so that the completion gets
// signaled to Telemetry.
return new Promise(r => Services.tm.currentThread.dispatch(() => r(deferred.promise),
Ci.nsIThread.DISPATCH_NORMAL));
return new Promise(r => Services.tm.dispatchToMainThread(() => r(deferred.promise)));
},
promiseNextPing() {
@ -315,7 +314,7 @@ if (runningInParent) {
fakePingSendTimer((callback, timeout) => {
Services.tm.mainThread.dispatch(() => callback(), Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(() => callback());
},
() => {});

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

@ -76,8 +76,7 @@ add_task(function* test_pingSender() {
if (hitCount >= 2) {
// Resolve the promise on the next tick.
Services.tm.currentThread.dispatch(() => deferred404Hit.resolve(),
Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(() => deferred404Hit.resolve());
}
});
failingServer.start(-1);

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

@ -264,9 +264,9 @@ const BackgroundPageThumbs = {
// browser's message manager if it happens on the same stack as the
// listener. Trying to send a message to the manager in that case
// throws NS_ERROR_NOT_INITIALIZED.
Services.tm.currentThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
curCapture._done(null, TEL_CAPTURE_DONE_CRASHED);
}, Ci.nsIEventTarget.DISPATCH_NORMAL);
});
}
// else: we must have been idle and not currently doing a capture (eg,
// maybe a GC or similar crashed) - so there's no need to attempt a
@ -503,5 +503,5 @@ function tel(histogramID, value) {
}
function schedule(callback) {
Services.tm.mainThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(callback);
}

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

@ -232,7 +232,7 @@ HashCompleter.prototype = {
// Start off this request. Without dispatching to a thread, every call to
// complete makes an individual HTTP request.
Services.tm.currentThread.dispatch(this, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(this);
},
// This is called after several calls to |complete|, or after the
@ -273,7 +273,7 @@ HashCompleter.prototype = {
// gethashUrl and fetch the next pending request, if there is one.
finishRequest: function(url, aStatus) {
this._backoffs[url].noteServerResponse(aStatus);
Services.tm.currentThread.dispatch(this, Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(this);
},
// Returns true if we can make a request from the given url, false otherwise.

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

@ -656,7 +656,7 @@ var Printing = {
// The print preview docshell will be in a different TabGroup,
// so we run it in a separate runnable to avoid touching a
// different TabGroup in our own runnable.
Services.tm.mainThread.dispatch(() => {
Services.tm.dispatchToMainThread(() => {
try {
docShell.printPreview.printPreview(printSettings, contentWindow, this);
} catch (error) {
@ -665,7 +665,7 @@ var Printing = {
Components.utils.reportError(error);
notifyEntered(error);
}
}, Ci.nsIThread.DISPATCH_NORMAL);
});
} catch (error) {
// This might fail if we, for example, attempt to print a XUL document.
// In that case, we inform the parent to bail out of print preview.

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

@ -690,9 +690,9 @@ function promiseTargetFile(aFpP, /* optional */ aSkipPrompt, /* optional */ aRel
let deferred = Promise.defer();
if (useDownloadDir) {
// Keep async behavior in both branches
Services.tm.mainThread.dispatch(function() {
Services.tm.dispatchToMainThread(function() {
deferred.resolve(null);
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
});
} else {
downloadLastDir.getFileAsync(aRelatedURI, function getFileAsyncCB(aFile) {
deferred.resolve(aFile);

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

@ -346,7 +346,7 @@
}
// Dispatch something to ensure that the main thread wakes up.
Services.tm.mainThread.dispatch(function() {}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(function() {});
}
let timer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);

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

@ -382,9 +382,9 @@ function waitForPurgeNotification() {
// test_storage_cleared needs this extra executeSoon because
// the DOMStorage clean-up is also listening to this same observer
// which is run synchronously.
Services.tm.mainThread.dispatch(function() {
Services.tm.dispatchToMainThread(function() {
deferred.resolve();
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
});
}
};
Services.obs.addObserver(observer, "browser:purge-domain-data", false);

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

@ -90,7 +90,7 @@ this.PropertyListUtils = Object.freeze({
// We guarantee not to throw directly for any other exceptions, and always
// call aCallback.
Services.tm.mainThread.dispatch(function() {
Services.tm.dispatchToMainThread(function() {
let self = this;
function readDOMFile(aFile) {
let fileReader = new FileReader();
@ -126,7 +126,7 @@ this.PropertyListUtils = Object.freeze({
aCallback(null);
throw ex;
}
}.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
}.bind(this));
},
/**

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

@ -151,8 +151,7 @@ this.Troubleshoot = {
snapshot[providerName] = providerData;
if (--numPending == 0)
// Ensure that done is always and truly called asynchronously.
Services.tm.mainThread.dispatch(done.bind(null, snapshot),
Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(done.bind(null, snapshot));
}
for (let name in dataProviders) {
try {

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

@ -67,7 +67,7 @@ var RequestId = {
};
function runLater(job) {
Services.tm.currentThread.dispatch(job, Ci.nsIEventTarget.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(job);
}
function parseFilter(filter) {

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

@ -28,8 +28,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
*/
function promiseResolvedLater(aValue) {
let deferred = Promise.defer();
Services.tm.mainThread.dispatch(() => deferred.resolve(aValue),
Ci.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(() => deferred.resolve(aValue));
return deferred.promise;
}

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

@ -148,8 +148,7 @@ DownloadLastDir.prototype = {
getFileAsync(aURI, aCallback) {
let plainPrefFile = this._getLastFile();
if (!aURI || !isContentPrefEnabled()) {
Services.tm.mainThread.dispatch(() => aCallback(plainPrefFile),
Components.interfaces.nsIThread.DISPATCH_NORMAL);
Services.tm.dispatchToMainThread(() => aCallback(plainPrefFile));
return;
}

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

@ -103,7 +103,7 @@ IncrementalDownload.prototype = {
getService(Ci.nsIThreadManager);
// Do the actual operation async to give a chance for observers
// to add themselves.
tm.mainThread.dispatch(function() {
tm.dispatchToMainThread(function() {
this._observer = observer.QueryInterface(Ci.nsIRequestObserver);
this._ctxt = ctxt;
this._observer.onStartRequest(this, this._ctxt);
@ -129,15 +129,15 @@ IncrementalDownload.prototype = {
// status being changed to online.
let tm2 = Cc["@mozilla.org/thread-manager;1"].
getService(Ci.nsIThreadManager);
tm2.mainThread.dispatch(function() {
tm2.dispatchToMainThread(function() {
Services.obs.notifyObservers(gAUS,
"network:offline-status-changed",
"online");
}, Ci.nsIThread.DISPATCH_NORMAL);
});
break;
}
this._observer.onStopRequest(this, this._ctxt, status);
}.bind(this), Ci.nsIThread.DISPATCH_NORMAL);
}.bind(this));
},
get URI() {

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

@ -31,9 +31,9 @@ function run_test() {
do_test_pending();
Components.classes["@mozilla.org/thread-manager;1"].
getService(Ci.nsIThreadManager).mainThread.dispatch(function() {
getService(Ci.nsIThreadManager).dispatchToMainThread(function() {
cs.unregisterListener(kConsoleListener);
do_check_true(gFound);
do_test_finished();
}, 0);
});
}