diff --git a/addon-sdk/source/lib/sdk/timers.js b/addon-sdk/source/lib/sdk/timers.js index e97db01f22f0..ef91ab37e86c 100644 --- a/addon-sdk/source/lib/sdk/timers.js +++ b/addon-sdk/source/lib/sdk/timers.js @@ -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; } diff --git a/addon-sdk/source/modules/system/Startup.js b/addon-sdk/source/modules/system/Startup.js index fd34d6be8cfe..8277b38189cf 100644 --- a/addon-sdk/source/modules/system/Startup.js +++ b/addon-sdk/source/modules/system/Startup.js @@ -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); diff --git a/addon-sdk/source/test/addons/content-permissions/httpd.js b/addon-sdk/source/test/addons/content-permissions/httpd.js index 481a0d471051..be55901c7b44 100644 --- a/addon-sdk/source/test/addons/content-permissions/httpd.js +++ b/addon-sdk/source/test/addons/content-permissions/httpd.js @@ -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); }, /** diff --git a/addon-sdk/source/test/addons/content-script-messages-latency/httpd.js b/addon-sdk/source/test/addons/content-script-messages-latency/httpd.js index 481a0d471051..be55901c7b44 100644 --- a/addon-sdk/source/test/addons/content-script-messages-latency/httpd.js +++ b/addon-sdk/source/test/addons/content-script-messages-latency/httpd.js @@ -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); }, /** diff --git a/addon-sdk/source/test/addons/e10s-content/lib/httpd.js b/addon-sdk/source/test/addons/e10s-content/lib/httpd.js index 6b3533c498aa..98b6f6ca85a1 100644 --- a/addon-sdk/source/test/addons/e10s-content/lib/httpd.js +++ b/addon-sdk/source/test/addons/e10s-content/lib/httpd.js @@ -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); }, /** diff --git a/addon-sdk/source/test/addons/places/lib/httpd.js b/addon-sdk/source/test/addons/places/lib/httpd.js index 481a0d471051..be55901c7b44 100644 --- a/addon-sdk/source/test/addons/places/lib/httpd.js +++ b/addon-sdk/source/test/addons/places/lib/httpd.js @@ -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); }, /** diff --git a/addon-sdk/source/test/lib/httpd.js b/addon-sdk/source/test/lib/httpd.js index 6b3533c498aa..98b6f6ca85a1 100644 --- a/addon-sdk/source/test/lib/httpd.js +++ b/addon-sdk/source/test/lib/httpd.js @@ -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); }, /** diff --git a/b2g/components/ErrorPage.jsm b/b2g/components/ErrorPage.jsm index 07346fc86c6e..c4ed2ce325be 100644 --- a/b2g/components/ErrorPage.jsm +++ b/b2g/components/ErrorPage.jsm @@ -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 }, diff --git a/browser/base/content/browser-fullZoom.js b/browser/base/content/browser-fullZoom.js index 1c6a4d795411..883dcdc95c27 100644 --- a/browser/base/content/browser-fullZoom.js +++ b/browser/base/content/browser-fullZoom.js @@ -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); }, }; diff --git a/browser/base/content/test/tabPrompts/browser_multiplePrompts.js b/browser/base/content/test/tabPrompts/browser_multiplePrompts.js index cedccb24bb55..663455139be5 100644 --- a/browser/base/content/test/tabPrompts/browser_multiplePrompts.js +++ b/browser/base/content/test/tabPrompts/browser_multiplePrompts.js @@ -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); }); } } diff --git a/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js b/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js index f8d845cc314c..2b31c044b83e 100644 --- a/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js +++ b/browser/base/content/test/tabPrompts/browser_openPromptInBackgroundTab.js @@ -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; diff --git a/browser/components/customizableui/CustomizeMode.jsm b/browser/components/customizableui/CustomizeMode.jsm index 384b6d314ed5..3efd66f4e0b2 100644 --- a/browser/components/customizableui/CustomizeMode.jsm +++ b/browser/components/customizableui/CustomizeMode.jsm @@ -2294,5 +2294,5 @@ function __dumpDragData(aEvent, caller) { } function dispatchFunction(aFunc) { - Services.tm.currentThread.dispatch(aFunc, Ci.nsIThread.DISPATCH_NORMAL); + Services.tm.dispatchToMainThread(aFunc); } diff --git a/browser/components/downloads/content/allDownloadsViewOverlay.js b/browser/components/downloads/content/allDownloadsViewOverlay.js index dd3280f297b4..e93ef3ef59a6 100644 --- a/browser/components/downloads/content/allDownloadsViewOverlay.js +++ b/browser/components/downloads/content/allDownloadsViewOverlay.js @@ -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); + }); } } }, diff --git a/browser/components/extensions/ext-utils.js b/browser/components/extensions/ext-utils.js index e30b9214c798..ed0a6c8c0282 100644 --- a/browser/components/extensions/ext-utils.js +++ b/browser/components/extensions/ext-utils.js @@ -393,9 +393,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) { diff --git a/browser/components/migration/MigrationUtils.jsm b/browser/components/migration/MigrationUtils.jsm index acdbfbe34616..220682358112 100644 --- a/browser/components/migration/MigrationUtils.jsm +++ b/browser/components/migration/MigrationUtils.jsm @@ -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); }); }; diff --git a/browser/components/nsBrowserGlue.js b/browser/components/nsBrowserGlue.js index a16bc7b5d894..23dde19da702 100644 --- a/browser/components/nsBrowserGlue.js +++ b/browser/components/nsBrowserGlue.js @@ -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); + }); } } diff --git a/browser/components/search/content/search.xml b/browser/components/search/content/search.xml index 1b29c864356a..91030e67d56c 100644 --- a/browser/components/search/content/search.xml +++ b/browser/components/search/content/search.xml @@ -1423,10 +1423,10 @@ this._rebuild(); break; case "popuphidden": - Services.tm.mainThread.dispatch(() => { + Services.tm.dispatchToMainThread(() => { this.selectedButton = null; this._contextEngine = null; - }, Ci.nsIThread.DISPATCH_NORMAL); + }); break; } ]]> diff --git a/browser/components/sessionstore/test/content.js b/browser/components/sessionstore/test/content.js index 3d50d6b1f03e..2653ae856f52 100644 --- a/browser/components/sessionstore/test/content.js +++ b/browser/components/sessionstore/test/content.js @@ -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({ diff --git a/browser/experiments/test/addons/experiment-racybranch/bootstrap.js b/browser/experiments/test/addons/experiment-racybranch/bootstrap.js index d77fd43452ed..fa0499485c86 100644 --- a/browser/experiments/test/addons/experiment-racybranch/bootstrap.js +++ b/browser/experiments/test/addons/experiment-racybranch/bootstrap.js @@ -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() { diff --git a/browser/modules/SocialService.jsm b/browser/modules/SocialService.jsm index 1604498639ee..e386ada8c469 100644 --- a/browser/modules/SocialService.jsm +++ b/browser/modules/SocialService.jsm @@ -330,7 +330,7 @@ function initService() { } function schedule(callback) { - Services.tm.mainThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL); + Services.tm.dispatchToMainThread(callback); } // Public API diff --git a/browser/modules/webrtcUI.jsm b/browser/modules/webrtcUI.jsm index 4304de38d2e7..03cd9847bbe2 100644 --- a/browser/modules/webrtcUI.jsm +++ b/browser/modules/webrtcUI.jsm @@ -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); diff --git a/devtools/client/debugger/new/debugger.js b/devtools/client/debugger/new/debugger.js index e067a88f55a7..2f1716f2040b 100644 --- a/devtools/client/debugger/new/debugger.js +++ b/devtools/client/debugger/new/debugger.js @@ -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; }, diff --git a/devtools/client/debugger/new/integration-tests.js b/devtools/client/debugger/new/integration-tests.js index ee48712d6cd2..be6ce186ca28 100644 --- a/devtools/client/debugger/new/integration-tests.js +++ b/devtools/client/debugger/new/integration-tests.js @@ -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; }, diff --git a/devtools/client/debugger/views/global-search-view.js b/devtools/client/debugger/views/global-search-view.js index 6b8b6e43c8e2..1e7dbabeee70 100644 --- a/devtools/client/debugger/views/global-search-view.js +++ b/devtools/client/debugger/views/global-search-view.js @@ -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", ""); }, diff --git a/devtools/client/shared/DOMHelpers.jsm b/devtools/client/shared/DOMHelpers.jsm index 3177f852e83d..5b446a2fc79d 100644 --- a/devtools/client/shared/DOMHelpers.jsm +++ b/devtools/client/shared/DOMHelpers.jsm @@ -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); } diff --git a/devtools/client/shared/widgets/VariablesView.jsm b/devtools/client/shared/widgets/VariablesView.jsm index b533a21a6c9a..19834c2f554c 100644 --- a/devtools/client/shared/widgets/VariablesView.jsm +++ b/devtools/client/shared/widgets/VariablesView.jsm @@ -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; diff --git a/devtools/server/actors/tab.js b/devtools/server/actors/tab.js index be6d578d3268..c8d1f69ddaca 100644 --- a/devtools/server/actors/tab.js +++ b/devtools/server/actors/tab.js @@ -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 {}; }, diff --git a/devtools/server/actors/webbrowser.js b/devtools/server/actors/webbrowser.js index 2ce38ae02383..3fdd57c95753 100644 --- a/devtools/server/actors/webbrowser.js +++ b/devtools/server/actors/webbrowser.js @@ -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; diff --git a/devtools/server/actors/webextension-inspected-window.js b/devtools/server/actors/webextension-inspected-window.js index ebed53b85c4d..d1fa18f6a650 100644 --- a/devtools/server/actors/webextension-inspected-window.js +++ b/devtools/server/actors/webextension-inspected-window.js @@ -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 {}; }, diff --git a/devtools/server/tests/unit/head_dbg.js b/devtools/server/tests/unit/head_dbg.js index 9d58b1f75756..567a6e6f87d8 100644 --- a/devtools/server/tests/unit/head_dbg.js +++ b/devtools/server/tests/unit/head_dbg.js @@ -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 diff --git a/devtools/server/tests/unit/test_blackboxing-05.js b/devtools/server/tests/unit/test_blackboxing-05.js index 1835070ac44b..cbb5f23d2fa3 100644 --- a/devtools/server/tests/unit/test_blackboxing-05.js +++ b/devtools/server/tests/unit/test_blackboxing-05.js @@ -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(); diff --git a/devtools/server/tests/unit/test_nsjsinspector.js b/devtools/server/tests/unit/test_nsjsinspector.js index 7cef47b940f7..101912de9217 100644 --- a/devtools/server/tests/unit/test_nsjsinspector.js +++ b/devtools/server/tests/unit/test_nsjsinspector.js @@ -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); diff --git a/devtools/server/tests/unit/test_stepping-06.js b/devtools/server/tests/unit/test_stepping-06.js index 9842b01057e1..c5fc10c416f8 100644 --- a/devtools/server/tests/unit/test_stepping-06.js +++ b/devtools/server/tests/unit/test_stepping-06.js @@ -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); + }); }); }); } diff --git a/devtools/shared/DevToolsUtils.js b/devtools/shared/DevToolsUtils.js index bf63700eee71..8e5e4e9149cb 100644 --- a/devtools/shared/DevToolsUtils.js +++ b/devtools/shared/DevToolsUtils.js @@ -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); + }); } }; diff --git a/devtools/shared/transport/stream-utils.js b/devtools/shared/transport/stream-utils.js index 2600a6b1c286..b2d9455e5344 100644 --- a/devtools/shared/transport/stream-utils.js +++ b/devtools/shared/transport/stream-utils.js @@ -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; }, diff --git a/dom/base/IndexedDBHelper.jsm b/dom/base/IndexedDBHelper.jsm index 587fb901f91f..c61bc3f0123d 100644 --- a/dom/base/IndexedDBHelper.jsm +++ b/dom/base/IndexedDBHelper.jsm @@ -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; } diff --git a/dom/base/test/file_simplecontentpolicy.js b/dom/base/test/file_simplecontentpolicy.js index 2727b953064b..00d5527b69c0 100644 --- a/dom/base/test/file_simplecontentpolicy.js +++ b/dom/base/test/file_simplecontentpolicy.js @@ -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"; diff --git a/dom/browser-element/BrowserElementPromptService.jsm b/dom/browser-element/BrowserElementPromptService.jsm index 1442304db13f..ce1a249f6c7a 100644 --- a/dom/browser-element/BrowserElementPromptService.jsm +++ b/dom/browser-element/BrowserElementPromptService.jsm @@ -369,7 +369,7 @@ BrowserElementAuthPrompt.prototype = { } } - Services.tm.currentThread.dispatch(runnable, Ci.nsIThread.DISPATCH_NORMAL); + Services.tm.dispatchToMainThread(runnable); }, _getFrameFromChannel: function(channel) { diff --git a/dom/notification/NotificationStorage.js b/dom/notification/NotificationStorage.js index 8fbda4ae5b03..96395c9bb670 100644 --- a/dom/notification/NotificationStorage.js +++ b/dom/notification/NotificationStorage.js @@ -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); } } diff --git a/dom/presentation/provider/PresentationControlService.js b/dom/presentation/provider/PresentationControlService.js index 0ef923f351a7..55af6869b5ec 100644 --- a/dom/presentation/provider/PresentationControlService.js +++ b/dom/presentation/provider/PresentationControlService.js @@ -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) { diff --git a/dom/presentation/tests/mochitest/PresentationSessionChromeScript1UA.js b/dom/presentation/tests/mochitest/PresentationSessionChromeScript1UA.js index ab20ff9607e7..2240c0128765 100644 --- a/dom/presentation/tests/mochitest/PresentationSessionChromeScript1UA.js +++ b/dom/presentation/tests/mochitest/PresentationSessionChromeScript1UA.js @@ -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) { diff --git a/dom/presentation/tests/xpcshell/test_multicast_dns_device_provider.js b/dom/presentation/tests/xpcshell/test_multicast_dns_device_provider.js index 8da964f048ce..ca4013a90c63 100644 --- a/dom/presentation/tests/xpcshell/test_multicast_dns_device_provider.js +++ b/dom/presentation/tests/xpcshell/test_multicast_dns_device_provider.js @@ -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() {}, diff --git a/dom/system/gonk/DataCallManager.js b/dom/system/gonk/DataCallManager.js index aa64a3f33e67..4e52c4fb0df0 100644 --- a/dom/system/gonk/DataCallManager.js +++ b/dom/system/gonk/DataCallManager.js @@ -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 diff --git a/dom/system/gonk/NetworkService.js b/dom/system/gonk/NetworkService.js index 86cd18194884..a5c8d24d09b5 100644 --- a/dom/system/gonk/NetworkService.js +++ b/dom/system/gonk/NetworkService.js @@ -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); + }); } } }; diff --git a/dom/system/gonk/TetheringService.js b/dom/system/gonk/TetheringService.js index ff8f6d83bd2a..383142a6448a 100644 --- a/dom/system/gonk/TetheringService.js +++ b/dom/system/gonk/TetheringService.js @@ -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); + }); } }, diff --git a/js/xpconnect/tests/unit/head_ongc.js b/js/xpconnect/tests/unit/head_ongc.js index 85989f1d9d4b..5801909a02b3 100644 --- a/js/xpconnect/tests/unit/head_ongc.js +++ b/js/xpconnect/tests/unit/head_ongc.js @@ -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 diff --git a/js/xpconnect/tests/unit/head_watchdog.js b/js/xpconnect/tests/unit/head_watchdog.js index 87ec5de76910..9c0fd2fc4cd4 100644 --- a/js/xpconnect/tests/unit/head_watchdog.js +++ b/js/xpconnect/tests/unit/head_watchdog.js @@ -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}); } // diff --git a/mobile/android/components/PromptService.js b/mobile/android/components/PromptService.js index d60d3c109f0a..5d64a66681d9 100644 --- a/mobile/android/components/PromptService.js +++ b/mobile/android/components/PromptService.js @@ -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) { diff --git a/mobile/android/components/extensions/ext-utils.js b/mobile/android/components/extensions/ext-utils.js index 2d67f55f2f5e..36b9ee8806fc 100644 --- a/mobile/android/components/extensions/ext-utils.js +++ b/mobile/android/components/extensions/ext-utils.js @@ -327,9 +327,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) { diff --git a/mobile/android/modules/MediaPlayerApp.jsm b/mobile/android/modules/MediaPlayerApp.jsm index 90bac6544553..9c19b80cf932 100644 --- a/mobile/android/modules/MediaPlayerApp.jsm +++ b/mobile/android/modules/MediaPlayerApp.jsm @@ -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)); } } diff --git a/mobile/android/tests/browser/chrome/test_awsy_lite.html b/mobile/android/tests/browser/chrome/test_awsy_lite.html index 2f69a0e9fe4d..5330685fbe6e 100644 --- a/mobile/android/tests/browser/chrome/test_awsy_lite.html +++ b/mobile/android/tests/browser/chrome/test_awsy_lite.html @@ -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() { diff --git a/mobile/android/tests/browser/chrome/test_video_discovery.html b/mobile/android/tests/browser/chrome/test_video_discovery.html index 12d3c3e4e69d..4f0afb5fbbc6 100644 --- a/mobile/android/tests/browser/chrome/test_video_discovery.html +++ b/mobile/android/tests/browser/chrome/test_video_discovery.html @@ -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}); } diff --git a/mobile/android/tests/browser/robocop/robocop_head.js b/mobile/android/tests/browser/robocop/robocop_head.js index f56f6bc26380..fa6318c69d35 100644 --- a/mobile/android/tests/browser/robocop/robocop_head.js +++ b/mobile/android/tests/browser/robocop/robocop_head.js @@ -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) { diff --git a/mobile/android/tests/browser/robocop/testBrowserDiscovery.js b/mobile/android/tests/browser/robocop/testBrowserDiscovery.js index 528726916669..b0f768e417a3 100644 --- a/mobile/android/tests/browser/robocop/testBrowserDiscovery.js +++ b/mobile/android/tests/browser/robocop/testBrowserDiscovery.js @@ -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}); }); diff --git a/mobile/android/tests/browser/robocop/testHistoryService.js b/mobile/android/tests/browser/robocop/testHistoryService.js index ab14c4c2fcec..962889efd568 100644 --- a/mobile/android/tests/browser/robocop/testHistoryService.js +++ b/mobile/android/tests/browser/robocop/testHistoryService.js @@ -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}); }); diff --git a/mobile/android/tests/browser/robocop/testTrackingProtection.js b/mobile/android/tests/browser/robocop/testTrackingProtection.js index 18cf8adb3c19..5427e365a464 100644 --- a/mobile/android/tests/browser/robocop/testTrackingProtection.js +++ b/mobile/android/tests/browser/robocop/testTrackingProtection.js @@ -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}); }); diff --git a/mobile/android/tests/browser/robocop/testVideoControls.js b/mobile/android/tests/browser/robocop/testVideoControls.js index bd42f1d1b561..f619d9e4d7bc 100644 --- a/mobile/android/tests/browser/robocop/testVideoControls.js +++ b/mobile/android/tests/browser/robocop/testVideoControls.js @@ -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) { diff --git a/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js b/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js index c8fbb87872b7..10903893d1a8 100644 --- a/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js +++ b/netwerk/test/browser/browser_nsIFormPOSTActionChannel.js @@ -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); diff --git a/netwerk/test/httpserver/test/test_async_response_sending.js b/netwerk/test/httpserver/test/test_async_response_sending.js index 84ec74daf484..7e3a904ed09f 100644 --- a/netwerk/test/httpserver/test/test_async_response_sending.js +++ b/netwerk/test/httpserver/test/test_async_response_sending.js @@ -1616,7 +1616,7 @@ CopyTest.prototype = } } }; - gThreadManager.currentThread.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL); + gThreadManager.dispatchToMainThread(event); }, /** diff --git a/netwerk/test/httpserver/test/test_processasync.js b/netwerk/test/httpserver/test/test_processasync.js index 21ded660d7d5..b0bd4ff7ead9 100644 --- a/netwerk/test/httpserver/test/test_processasync.js +++ b/netwerk/test/httpserver/test/test_processasync.js @@ -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(); diff --git a/netwerk/test/httpserver/test/test_seizepower.js b/netwerk/test/httpserver/test/test_seizepower.js index de42fc6925c2..fef0cee6e6ad 100644 --- a/netwerk/test/httpserver/test/test_seizepower.js +++ b/netwerk/test/httpserver/test/test_seizepower.js @@ -47,12 +47,12 @@ function checkException(fun, err, msg) function callASAPLater(fun) { - gThreadManager.currentThread.dispatch({ + gThreadManager.dispatchToMainThread({ run: function() { fun(); } - }, Ci.nsIThread.DISPATCH_NORMAL); + }); } diff --git a/services/common/utils.js b/services/common/utils.js index 904ead063bf9..fd9862c2b776 100644 --- a/services/common/utils.js +++ b/services/common/utils.js @@ -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); }, /** diff --git a/services/fxaccounts/Credentials.jsm b/services/fxaccounts/Credentials.jsm index 183193ab6a97..a5247b32d55a 100644 --- a/services/fxaccounts/Credentials.jsm +++ b/services/fxaccounts/Credentials.jsm @@ -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; diff --git a/services/sync/modules/SyncedTabs.jsm b/services/sync/modules/SyncedTabs.jsm index ef49ea8e4b20..75bc52aefb1a 100644 --- a/services/sync/modules/SyncedTabs.jsm +++ b/services/sync/modules/SyncedTabs.jsm @@ -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); + }); }); }, diff --git a/services/sync/tps/extensions/mozmill/resource/stdlib/httpd.js b/services/sync/tps/extensions/mozmill/resource/stdlib/httpd.js index ca116121832c..0ebd4915a25a 100644 --- a/services/sync/tps/extensions/mozmill/resource/stdlib/httpd.js +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/httpd.js @@ -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); }, /** diff --git a/testing/mochitest/browser-harness.xul b/testing/mochitest/browser-harness.xul index a163dbdaaa92..63b5d25fe538 100644 --- a/testing/mochitest/browser-harness.xul +++ b/testing/mochitest/browser-harness.xul @@ -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) { diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js index 42715290294b..afda210782c1 100644 --- a/testing/mochitest/browser-test.js +++ b/testing/mochitest/browser-test.js @@ -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() { diff --git a/testing/modules/TestUtils.jsm b/testing/modules/TestUtils.jsm index 49bb20f368d0..e87cb9d5aa7c 100644 --- a/testing/modules/TestUtils.jsm +++ b/testing/modules/TestUtils.jsm @@ -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); }, /** diff --git a/testing/specialpowers/content/specialpowersAPI.js b/testing/specialpowers/content/specialpowersAPI.js index f2180e0cf16d..e35968b1015a 100644 --- a/testing/specialpowers/content/specialpowersAPI.js +++ b/testing/specialpowers/content/specialpowersAPI.js @@ -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), diff --git a/testing/xpcshell/head.js b/testing/xpcshell/head.js index 0abf17e19f6d..0c1fe8064b1e 100644 --- a/testing/xpcshell/head.js +++ b/testing/xpcshell/head.js @@ -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); + }); } /** diff --git a/toolkit/components/addoncompat/RemoteAddonsChild.jsm b/toolkit/components/addoncompat/RemoteAddonsChild.jsm index ccecacf64fad..7c225b84b7c6 100644 --- a/toolkit/components/addoncompat/RemoteAddonsChild.jsm +++ b/toolkit/components/addoncompat/RemoteAddonsChild.jsm @@ -354,7 +354,7 @@ AboutProtocolChannel.prototype = { } catch (e) {} } }; - Services.tm.currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL); + Services.tm.dispatchToMainThread(runnable); }, asyncOpen2(listener) { diff --git a/toolkit/components/addoncompat/tests/addon/bootstrap.js b/toolkit/components/addoncompat/tests/addon/bootstrap.js index 0665c0d813de..1fcf8af8ff5d 100644 --- a/toolkit/components/addoncompat/tests/addon/bootstrap.js +++ b/toolkit/components/addoncompat/tests/addon/bootstrap.js @@ -288,7 +288,7 @@ function testAboutModuleRegistration() { } catch (e) {} } }; - Services.tm.currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL); + Services.tm.dispatchToMainThread(runnable); }, asyncOpen2(listener) { diff --git a/toolkit/components/contentprefs/ContentPrefService2.jsm b/toolkit/components/contentprefs/ContentPrefService2.jsm index 3833387ed14c..c7d13565ee24 100644 --- a/toolkit/components/contentprefs/ContentPrefService2.jsm +++ b/toolkit/components/contentprefs/ContentPrefService2.jsm @@ -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) { diff --git a/toolkit/components/contentprefs/nsContentPrefService.js b/toolkit/components/contentprefs/nsContentPrefService.js index 07c224fbda4f..62eae4cf6336 100644 --- a/toolkit/components/contentprefs/nsContentPrefService.js +++ b/toolkit/components/contentprefs/nsContentPrefService.js @@ -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) { diff --git a/toolkit/components/filepicker/nsFilePicker.js b/toolkit/components/filepicker/nsFilePicker.js index 5b88e5154c0b..76302ef0832c 100644 --- a/toolkit/components/filepicker/nsFilePicker.js +++ b/toolkit/components/filepicker/nsFilePicker.js @@ -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() { diff --git a/toolkit/components/formautofill/FormAutofillContentService.js b/toolkit/components/formautofill/FormAutofillContentService.js index 1de839f54d63..2e8bae0ad70e 100644 --- a/toolkit/components/formautofill/FormAutofillContentService.js +++ b/toolkit/components/formautofill/FormAutofillContentService.js @@ -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); }); }, }; diff --git a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js index 25381ab67adc..8ed4e58f19c1 100644 --- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js +++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js @@ -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"); }, diff --git a/toolkit/components/perfmonitoring/PerformanceWatcher.jsm b/toolkit/components/perfmonitoring/PerformanceWatcher.jsm index 609d05991e9c..d9773e135837 100644 --- a/toolkit/components/perfmonitoring/PerformanceWatcher.jsm +++ b/toolkit/components/perfmonitoring/PerformanceWatcher.jsm @@ -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); + }); } }; diff --git a/toolkit/components/places/PlacesUtils.jsm b/toolkit/components/places/PlacesUtils.jsm index b13a18f954e4..42956163ee89 100644 --- a/toolkit/components/places/PlacesUtils.jsm +++ b/toolkit/components/places/PlacesUtils.jsm @@ -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); }); } } diff --git a/toolkit/components/places/nsLivemarkService.js b/toolkit/components/places/nsLivemarkService.js index c04144c740dc..6ad1e9e3ba96 100644 --- a/toolkit/components/places/nsLivemarkService.js +++ b/toolkit/components/places/nsLivemarkService.js @@ -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); + }); } } } diff --git a/toolkit/components/places/tests/bookmarks/test_async_observers.js b/toolkit/components/places/tests/bookmarks/test_async_observers.js index 5326f7bd60e5..1c8c1cfcf652 100644 --- a/toolkit/components/places/tests/bookmarks/test_async_observers.js +++ b/toolkit/components/places/tests/bookmarks/test_async_observers.js @@ -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"); shutdownPlaces(); diff --git a/toolkit/components/prompts/content/tabprompts.xml b/toolkit/components/prompts/content/tabprompts.xml index 0252e0761905..e03637f6851a 100644 --- a/toolkit/components/prompts/content/tabprompts.xml +++ b/toolkit/components/prompts/content/tabprompts.xml @@ -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); + }); ]]> diff --git a/toolkit/components/search/nsSearchService.js b/toolkit/components/search/nsSearchService.js index 75c9d6b94898..7e568efadcb3 100644 --- a/toolkit/components/search/nsSearchService.js +++ b/toolkit/components/search/nsSearchService.js @@ -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); } /** diff --git a/toolkit/components/telemetry/TelemetrySession.jsm b/toolkit/components/telemetry/TelemetrySession.jsm index 7991383b608f..9fdb442cf504 100644 --- a/toolkit/components/telemetry/TelemetrySession.jsm +++ b/toolkit/components/telemetry/TelemetrySession.jsm @@ -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"); - }), Ci.nsIThread.DISPATCH_NORMAL); + })); break; case "application-background": diff --git a/toolkit/components/telemetry/tests/unit/head.js b/toolkit/components/telemetry/tests/unit/head.js index f6d4ebfa75bd..544d39885078 100644 --- a/toolkit/components/telemetry/tests/unit/head.js +++ b/toolkit/components/telemetry/tests/unit/head.js @@ -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()); }, () => {}); diff --git a/toolkit/components/telemetry/tests/unit/test_PingSender.js b/toolkit/components/telemetry/tests/unit/test_PingSender.js index 45217c36746e..445cffc65543 100644 --- a/toolkit/components/telemetry/tests/unit/test_PingSender.js +++ b/toolkit/components/telemetry/tests/unit/test_PingSender.js @@ -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); diff --git a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm index 34f677ffb44b..9f6f2b554436 100644 --- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm +++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm @@ -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 @@ -502,5 +502,5 @@ function tel(histogramID, value) { } function schedule(callback) { - Services.tm.mainThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL); + Services.tm.dispatchToMainThread(callback); } diff --git a/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js b/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js index 33d1e496e6e8..65614d44e0b3 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js +++ b/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js @@ -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. diff --git a/toolkit/content/browser-content.js b/toolkit/content/browser-content.js index 68736a95df19..bcc1f7fa394d 100644 --- a/toolkit/content/browser-content.js +++ b/toolkit/content/browser-content.js @@ -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. diff --git a/toolkit/content/contentAreaUtils.js b/toolkit/content/contentAreaUtils.js index f38a8f87d7b3..6443dc8a3ce2 100644 --- a/toolkit/content/contentAreaUtils.js +++ b/toolkit/content/contentAreaUtils.js @@ -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); diff --git a/toolkit/content/widgets/remote-browser.xml b/toolkit/content/widgets/remote-browser.xml index bbdaae467091..88c3c7e0bada 100644 --- a/toolkit/content/widgets/remote-browser.xml +++ b/toolkit/content/widgets/remote-browser.xml @@ -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); diff --git a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js index e936c493effd..ac1bb3ee531b 100644 --- a/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js +++ b/toolkit/forgetaboutsite/test/unit/test_removeDataFromDomain.js @@ -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"); diff --git a/toolkit/modules/PropertyListUtils.jsm b/toolkit/modules/PropertyListUtils.jsm index 6b8ac751707e..5bac044af8be 100644 --- a/toolkit/modules/PropertyListUtils.jsm +++ b/toolkit/modules/PropertyListUtils.jsm @@ -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)); }, /** diff --git a/toolkit/modules/Troubleshoot.jsm b/toolkit/modules/Troubleshoot.jsm index 8209e229a474..ad9d72b3bc90 100644 --- a/toolkit/modules/Troubleshoot.jsm +++ b/toolkit/modules/Troubleshoot.jsm @@ -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 { diff --git a/toolkit/modules/addons/WebRequest.jsm b/toolkit/modules/addons/WebRequest.jsm index 3345be15d675..c744a777879f 100644 --- a/toolkit/modules/addons/WebRequest.jsm +++ b/toolkit/modules/addons/WebRequest.jsm @@ -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) { diff --git a/toolkit/modules/tests/xpcshell/test_task.js b/toolkit/modules/tests/xpcshell/test_task.js index fdcd56514955..65a0c65812f0 100644 --- a/toolkit/modules/tests/xpcshell/test_task.js +++ b/toolkit/modules/tests/xpcshell/test_task.js @@ -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; } diff --git a/toolkit/mozapps/downloads/DownloadLastDir.jsm b/toolkit/mozapps/downloads/DownloadLastDir.jsm index 00c62898223a..b66766cda01f 100644 --- a/toolkit/mozapps/downloads/DownloadLastDir.jsm +++ b/toolkit/mozapps/downloads/DownloadLastDir.jsm @@ -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; } diff --git a/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedRecovery.js b/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedRecovery.js index f64cfa7d91e8..fbc2e5f4167a 100644 --- a/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedRecovery.js +++ b/toolkit/mozapps/update/tests/unit_aus_update/downloadInterruptedRecovery.js @@ -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() { diff --git a/xpcom/tests/unit/test_bug656331.js b/xpcom/tests/unit/test_bug656331.js index 3bc1f82c09e9..2d3856752204 100644 --- a/xpcom/tests/unit/test_bug656331.js +++ b/xpcom/tests/unit/test_bug656331.js @@ -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); + }); }