author | Kyle Huey <khuey@kylehuey.com> |
Thu, 05 May 2016 01:45:00 -0700 | |
changeset 296220 | 114ca1fc9c51036e4d2cd151125bb7c77d4b3d17 |
parent 296219 | 67b25748b63ac0f895c38a653eae0712cdb51007 |
child 296221 | 06463a4db4453264ede392cf854bdb4b53b39267 |
push id | 30233 |
push user | ryanvm@gmail.com |
push date | Thu, 05 May 2016 18:57:26 +0000 |
treeherder | mozilla-central@0177462aac74 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | froydnj |
bugs | 1268313 |
milestone | 49.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/docshell/shistory/nsSHistory.cpp +++ b/docshell/shistory/nsSHistory.cpp @@ -1378,20 +1378,18 @@ nsSHistory::RemoveEntries(nsTArray<uint6 bool didRemove = false; while (index > minIndex) { if (index != mIndex) { didRemove = RemoveDuplicate(index, index < mIndex) || didRemove; } --index; } if (didRemove && mRootDocShell) { - nsCOMPtr<nsIRunnable> ev = - NS_NewRunnableMethod(static_cast<nsDocShell*>(mRootDocShell), - &nsDocShell::FireDummyOnLocationChange); - NS_DispatchToCurrentThread(ev); + NS_DispatchToCurrentThread(NewRunnableMethod(static_cast<nsDocShell*>(mRootDocShell), + &nsDocShell::FireDummyOnLocationChange)); } } void nsSHistory::RemoveDynEntries(int32_t aOldIndex, int32_t aNewIndex) { // Search for the entries which are in the current index, // but not in the new one.
--- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -1231,17 +1231,17 @@ void Animation::DoFinishNotification(SyncNotifyFlag aSyncNotifyFlag) { CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get(); if (aSyncNotifyFlag == SyncNotifyFlag::Sync) { DoFinishNotificationImmediately(); } else if (!mFinishNotificationTask.IsPending()) { RefPtr<nsRunnableMethod<Animation>> runnable = - NS_NewRunnableMethod(this, &Animation::DoFinishNotificationImmediately); + NewRunnableMethod(this, &Animation::DoFinishNotificationImmediately); runtime->DispatchToMicroTask(runnable); mFinishNotificationTask = runnable; } } void Animation::ResetFinishedPromise() {
--- a/dom/archivereader/ArchiveEvent.cpp +++ b/dom/archivereader/ArchiveEvent.cpp @@ -81,18 +81,17 @@ ArchiveReaderEvent::Run() return Exec(); } nsresult ArchiveReaderEvent::RunShare(nsresult aStatus) { mStatus = aStatus; - nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &ArchiveReaderEvent::ShareMainThread); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(this, &ArchiveReaderEvent::ShareMainThread)); return NS_OK; } void ArchiveReaderEvent::ShareMainThread() { nsTArray<RefPtr<File>> fileList;
--- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -512,17 +512,17 @@ Element::WrapObject(JSContext *aCx, JS:: xblService->LoadBindings(this, uri, principal, getter_AddRefs(binding), &dummy); if (binding) { if (nsContentUtils::IsSafeToRunScript()) { binding->ExecuteAttachedHandler(); } else { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler)); + NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler)); } } } return obj; } /* virtual */
--- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -359,21 +359,17 @@ EventSource::OnStartRequest(nsIRequest * rv = httpChannel->GetContentType(contentType); NS_ENSURE_SUCCESS(rv, rv); if (!contentType.EqualsLiteral(TEXT_EVENT_STREAM)) { DispatchFailConnection(); return NS_ERROR_ABORT; } - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &EventSource::AnnounceConnection); - NS_ENSURE_STATE(event); - - rv = NS_DispatchToMainThread(event); + rv = NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::AnnounceConnection)); NS_ENSURE_SUCCESS(rv, rv); mStatus = PARSE_STATE_BEGIN_OF_STREAM; return NS_OK; } // this method parses the characters as they become available instead of @@ -469,21 +465,17 @@ EventSource::OnStopRequest(nsIRequest *a return NS_ERROR_ABORT; } nsresult rv = CheckHealthOfRequestCallback(aRequest); NS_ENSURE_SUCCESS(rv, rv); ClearFields(); - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &EventSource::ReestablishConnection); - NS_ENSURE_STATE(event); - - rv = NS_DispatchToMainThread(event); + rv = NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::ReestablishConnection)); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } //----------------------------------------------------------------------------- // EventSource::nsIChannelEventSink //----------------------------------------------------------------------------- @@ -895,21 +887,18 @@ EventSource::ConsoleError() NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } nsresult EventSource::DispatchFailConnection() { - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &EventSource::FailConnection); - NS_ENSURE_STATE(event); - return NS_DispatchToMainThread(event); + return NS_DispatchToMainThread(NewRunnableMethod(this, &EventSource::FailConnection)); } void EventSource::FailConnection() { if (mReadyState == CLOSED) { return; } @@ -973,17 +962,17 @@ EventSource::Thaw() } NS_ASSERTION(!mHttpChannel, "the connection hasn't been closed!!!"); mFrozen = false; nsresult rv; if (!mGoingToDispatchAllMessages && mMessagesToDispatch.GetSize() > 0) { nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents); + NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents); NS_ENSURE_STATE(event); mGoingToDispatchAllMessages = true; rv = NS_DispatchToMainThread(event); NS_ENSURE_SUCCESS(rv, rv); } @@ -1033,17 +1022,17 @@ EventSource::DispatchCurrentMessageEvent size_t sizeBefore = mMessagesToDispatch.GetSize(); mMessagesToDispatch.Push(message.forget()); NS_ENSURE_TRUE(mMessagesToDispatch.GetSize() == sizeBefore + 1, NS_ERROR_OUT_OF_MEMORY); if (!mGoingToDispatchAllMessages) { nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents); + NewRunnableMethod(this, &EventSource::DispatchAllMessageEvents); NS_ENSURE_STATE(event); mGoingToDispatchAllMessages = true; return NS_DispatchToMainThread(event); } return NS_OK;
--- a/dom/base/ScreenOrientation.cpp +++ b/dom/base/ScreenOrientation.cpp @@ -535,17 +535,17 @@ ScreenOrientation::Notify(const hal::Scr doc->SetCurrentOrientation(mType, mAngle); Promise* pendingPromise = doc->GetOrientationPendingPromise(); if (pendingPromise) { pendingPromise->MaybeResolve(JS::UndefinedHandleValue); doc->SetOrientationPendingPromise(nullptr); } - nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableMethod(this, + nsCOMPtr<nsIRunnable> runnable = NewRunnableMethod(this, &ScreenOrientation::DispatchChangeEvent); rv = NS_DispatchToMainThread(runnable); NS_WARN_IF(NS_FAILED(rv)); } } void ScreenOrientation::UpdateActiveOrientationLock(ScreenOrientationInternal aOrientation) @@ -610,17 +610,17 @@ ScreenOrientation::VisibleEventListener: doc->SetCurrentOrientation(orientation->DeviceType(), orientation->DeviceAngle()); Promise* pendingPromise = doc->GetOrientationPendingPromise(); if (pendingPromise) { pendingPromise->MaybeResolve(JS::UndefinedHandleValue); doc->SetOrientationPendingPromise(nullptr); } - nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableMethod(orientation, + nsCOMPtr<nsIRunnable> runnable = NewRunnableMethod(orientation, &ScreenOrientation::DispatchChangeEvent); rv = NS_DispatchToMainThread(runnable); if (NS_WARN_IF(rv.Failed())) { return rv.StealNSResult(); } } return NS_OK;
--- a/dom/base/nsContentSink.cpp +++ b/dom/base/nsContentSink.cpp @@ -260,17 +260,17 @@ nsContentSink::ProcessHTTPHeaders(nsICha if (NS_SUCCEEDED(rv) && !linkHeader.IsEmpty()) { mDocument->SetHeaderData(nsGkAtoms::link, NS_ConvertASCIItoUTF16(linkHeader)); NS_ASSERTION(!mProcessLinkHeaderEvent.get(), "Already dispatched an event?"); mProcessLinkHeaderEvent = - NS_NewNonOwningRunnableMethod(this, + NewNonOwningRunnableMethod(this, &nsContentSink::DoProcessLinkHeader); rv = NS_DispatchToCurrentThread(mProcessLinkHeaderEvent.get()); if (NS_FAILED(rv)) { mProcessLinkHeaderEvent.Forget(); } } return NS_OK;
--- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -5035,33 +5035,40 @@ nsContentUtils::WarnScriptWasIgnored(nsI } msg.AppendLiteral("Unable to run script because scripts are blocked internally."); LogSimpleConsoleError(msg, "DOM"); } /* static */ bool -nsContentUtils::AddScriptRunner(nsIRunnable* aRunnable) -{ - if (!aRunnable) { +nsContentUtils::AddScriptRunner(already_AddRefed<nsIRunnable> aRunnable) +{ + nsCOMPtr<nsIRunnable> runnable = aRunnable; + if (!runnable) { return false; } if (sScriptBlockerCount) { - return sBlockedScriptRunners->AppendElement(aRunnable) != nullptr; + return sBlockedScriptRunners->AppendElement(runnable.forget()) != nullptr; } - nsCOMPtr<nsIRunnable> run = aRunnable; - run->Run(); + runnable->Run(); return true; } /* static */ +bool +nsContentUtils::AddScriptRunner(nsIRunnable* aRunnable) { + nsCOMPtr<nsIRunnable> runnable = aRunnable; + return AddScriptRunner(runnable.forget()); +} + +/* static */ void nsContentUtils::RunInStableState(already_AddRefed<nsIRunnable> aRunnable) { MOZ_ASSERT(CycleCollectedJSRuntime::Get(), "Must be on a script thread!"); CycleCollectedJSRuntime::Get()->RunInStableState(Move(aRunnable)); } /* static */
--- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -1603,16 +1603,17 @@ public: * synchronously before the function returns. * * @param aRunnable The nsIRunnable to run as soon as it's safe to execute * scripts. Passing null is allowed and results in nothing * happening. It is also allowed to pass an object that * has not yet been AddRefed. * @return false on out of memory, true otherwise. */ + static bool AddScriptRunner(already_AddRefed<nsIRunnable> aRunnable); static bool AddScriptRunner(nsIRunnable* aRunnable); /** * Returns true if it's safe to execute content script and false otherwise. * * The only known case where this lies is mutation events. They run, and can * run anything else, when this function returns false, but this is ok. */
--- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -1003,17 +1003,17 @@ nsDOMWindowUtils::SendNativeKeyEvent(int const nsAString& aUnmodifiedCharacters, nsIObserver* aObserver) { // get the widget to send the event to nsCOMPtr<nsIWidget> widget = GetWidget(); if (!widget) return NS_ERROR_FAILURE; - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod <int32_t, int32_t, uint32_t, nsString, nsString, nsIObserver*> (widget, &nsIWidget::SynthesizeNativeKeyEvent, aNativeKeyboardLayout, aNativeKeyCode, aModifiers, aCharacters, aUnmodifiedCharacters, aObserver)); return NS_OK; } NS_IMETHODIMP nsDOMWindowUtils::SendNativeMouseEvent(int32_t aScreenX, @@ -1023,17 +1023,17 @@ nsDOMWindowUtils::SendNativeMouseEvent(i nsIDOMElement* aElement, nsIObserver* aObserver) { // get the widget to send the event to nsCOMPtr<nsIWidget> widget = GetWidgetForElement(aElement); if (!widget) return NS_ERROR_FAILURE; - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod <LayoutDeviceIntPoint, int32_t, int32_t, nsIObserver*> (widget, &nsIWidget::SynthesizeNativeMouseEvent, LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aModifierFlags, aObserver)); return NS_OK; } NS_IMETHODIMP @@ -1042,17 +1042,17 @@ nsDOMWindowUtils::SendNativeMouseMove(in nsIDOMElement* aElement, nsIObserver* aObserver) { // get the widget to send the event to nsCOMPtr<nsIWidget> widget = GetWidgetForElement(aElement); if (!widget) return NS_ERROR_FAILURE; - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod <LayoutDeviceIntPoint, nsIObserver*> (widget, &nsIWidget::SynthesizeNativeMouseMove, LayoutDeviceIntPoint(aScreenX, aScreenY), aObserver)); return NS_OK; } NS_IMETHODIMP nsDOMWindowUtils::SendNativeMouseScrollEvent(int32_t aScreenX, @@ -1067,17 +1067,17 @@ nsDOMWindowUtils::SendNativeMouseScrollE nsIObserver* aObserver) { // get the widget to send the event to nsCOMPtr<nsIWidget> widget = GetWidgetForElement(aElement); if (!widget) { return NS_ERROR_FAILURE; } - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod <mozilla::LayoutDeviceIntPoint, uint32_t, double, double, double, uint32_t, uint32_t, nsIObserver*> (widget, &nsIWidget::SynthesizeNativeMouseScrollEvent, LayoutDeviceIntPoint(aScreenX, aScreenY), aNativeMessage, aDeltaX, aDeltaY, aDeltaZ, aModifierFlags, aAdditionalFlags, aObserver)); return NS_OK; } NS_IMETHODIMP @@ -1093,17 +1093,17 @@ nsDOMWindowUtils::SendNativeTouchPoint(u if (!widget) { return NS_ERROR_FAILURE; } if (aPressure < 0 || aPressure > 1 || aOrientation > 359) { return NS_ERROR_INVALID_ARG; } - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod <uint32_t, nsIWidget::TouchPointerState, LayoutDeviceIntPoint, double, uint32_t, nsIObserver*> (widget, &nsIWidget::SynthesizeNativeTouchPoint, aPointerId, (nsIWidget::TouchPointerState)aTouchState, LayoutDeviceIntPoint(aScreenX, aScreenY), aPressure, aOrientation, aObserver)); return NS_OK; } @@ -1113,32 +1113,32 @@ nsDOMWindowUtils::SendNativeTouchTap(int bool aLongTap, nsIObserver* aObserver) { nsCOMPtr<nsIWidget> widget = GetWidget(); if (!widget) { return NS_ERROR_FAILURE; } - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs + NS_DispatchToMainThread(NewRunnableMethod <LayoutDeviceIntPoint, bool, nsIObserver*> (widget, &nsIWidget::SynthesizeNativeTouchTap, LayoutDeviceIntPoint(aScreenX, aScreenY), aLongTap, aObserver)); return NS_OK; } NS_IMETHODIMP nsDOMWindowUtils::ClearNativeTouchSequence(nsIObserver* aObserver) { nsCOMPtr<nsIWidget> widget = GetWidget(); if (!widget) { return NS_ERROR_FAILURE; } - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs<nsIObserver*> + NS_DispatchToMainThread(NewRunnableMethod<nsIObserver*> (widget, &nsIWidget::ClearNativeTouchSequence, aObserver)); return NS_OK; } NS_IMETHODIMP nsDOMWindowUtils::ActivateNativeMenuItemAt(const nsAString& indexString) { // get the widget to send the event to
--- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -4364,17 +4364,17 @@ nsDocument::SetStyleSheetApplicableState if (StyleSheetChangeEventsEnabled()) { DO_STYLESHEET_NOTIFICATION(StyleSheetApplicableStateChangeEvent, "StyleSheetApplicableStateChanged", mApplicable, aApplicable); } if (!mSSApplicableStateNotificationPending) { - nsCOMPtr<nsIRunnable> notification = NS_NewRunnableMethod(this, + nsCOMPtr<nsIRunnable> notification = NewRunnableMethod(this, &nsDocument::NotifyStyleSheetApplicableStateChanged); mSSApplicableStateNotificationPending = NS_SUCCEEDED(NS_DispatchToCurrentThread(notification)); } } void nsDocument::NotifyStyleSheetApplicableStateChanged() @@ -4973,17 +4973,17 @@ nsDocument::MaybeEndOutermostXBLUpdate() // Only call BindingManager()->EndOutermostUpdate() when // we're not in an update and it is safe to run scripts. if (mUpdateNestLevel == 0 && mInXBLUpdate) { if (nsContentUtils::IsSafeToRunScript()) { mInXBLUpdate = false; BindingManager()->EndOutermostUpdate(); } else if (!mInDestructor) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate)); + NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate)); } } } void nsDocument::BeginUpdate(nsUpdateType aUpdateType) { if (mUpdateNestLevel == 0 && !mInXBLUpdate) { @@ -5291,17 +5291,17 @@ nsDocument::UnblockDOMContentLoaded() if (--mBlockDOMContentLoaded != 0 || mDidFireDOMContentLoaded) { return; } mDidFireDOMContentLoaded = true; MOZ_ASSERT(mReadyState == READYSTATE_INTERACTIVE); if (!mSynchronousDOMContentLoaded) { nsCOMPtr<nsIRunnable> ev = - NS_NewRunnableMethod(this, &nsDocument::DispatchContentLoadedEvents); + NewRunnableMethod(this, &nsDocument::DispatchContentLoadedEvents); NS_DispatchToCurrentThread(ev); } else { DispatchContentLoadedEvents(); } } void nsDocument::ContentStateChanged(nsIContent* aContent, EventStates aStateMask) @@ -7274,17 +7274,17 @@ nsDocument::NotifyPossibleTitleChange(bo if (aBoundTitleElement) { mMayHaveTitleElement = true; } if (mPendingTitleChangeEvent.IsPending()) return; RefPtr<nsRunnableMethod<nsDocument, void, false> > event = - NS_NewNonOwningRunnableMethod(this, + NewNonOwningRunnableMethod(this, &nsDocument::DoNotifyPossibleTitleChange); nsresult rv = NS_DispatchToCurrentThread(event); if (NS_SUCCEEDED(rv)) { mPendingTitleChangeEvent = event; } } void @@ -7423,17 +7423,17 @@ nsDocument::InitializeFrameLoader(nsFram NS_WARNING("Trying to initialize a frame loader while" "document is being deleted"); return NS_ERROR_FAILURE; } mInitializableFrameLoaders.AppendElement(aLoader); if (!mFrameLoaderRunner) { mFrameLoaderRunner = - NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); + NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY); nsContentUtils::AddScriptRunner(mFrameLoaderRunner); } return NS_OK; } nsresult nsDocument::FinalizeFrameLoader(nsFrameLoader* aLoader, nsIRunnable* aFinalizer) @@ -7441,17 +7441,17 @@ nsDocument::FinalizeFrameLoader(nsFrameL mInitializableFrameLoaders.RemoveElement(aLoader); if (mInDestructor) { return NS_ERROR_FAILURE; } mFrameLoaderFinalizers.AppendElement(aFinalizer); if (!mFrameLoaderRunner) { mFrameLoaderRunner = - NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); + NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY); nsContentUtils::AddScriptRunner(mFrameLoaderRunner); } return NS_OK; } void nsDocument::MaybeInitializeFinalizeFrameLoaders() @@ -7465,17 +7465,17 @@ nsDocument::MaybeInitializeFinalizeFrame // We're not in an update, but it is not safe to run scripts, so // postpone frameloader initialization and finalization. if (!nsContentUtils::IsSafeToRunScript()) { if (!mInDestructor && !mFrameLoaderRunner && (mInitializableFrameLoaders.Length() || mFrameLoaderFinalizers.Length())) { mFrameLoaderRunner = - NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); + NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders); nsContentUtils::AddScriptRunner(mFrameLoaderRunner); } return; } mFrameLoaderRunner = nullptr; // Don't use a temporary array for mInitializableFrameLoaders, because // loading a frame may cause some other frameloader to be removed from the @@ -9076,17 +9076,17 @@ nsDocument::BlockOnload() // -- it's not ours. if (mOnloadBlockCount == 0 && mScriptGlobalObject) { if (!nsContentUtils::IsSafeToRunScript()) { // Because AddRequest may lead to OnStateChange calls in chrome, // block onload only when there are no script blockers. ++mAsyncOnloadBlockCount; if (mAsyncOnloadBlockCount == 1) { bool success = nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsDocument::AsyncBlockOnload)); + NewRunnableMethod(this, &nsDocument::AsyncBlockOnload)); // The script runner shouldn't fail to add. But if somebody broke // something and it does, we'll thrash at 100% cpu forever. The best // response is just to ignore the onload blocking request. See bug 579535. if (!success) { NS_WARNING("Disaster! Onload blocking script runner failed to add - expect bad things!"); mAsyncOnloadBlockCount = 0; } @@ -12792,17 +12792,17 @@ nsDocument::GetVisibilityState() const return dom::VisibilityState::Visible; } /* virtual */ void nsDocument::PostVisibilityUpdateEvent() { nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &nsDocument::UpdateVisibilityState); + NewRunnableMethod(this, &nsDocument::UpdateVisibilityState); NS_DispatchToMainThread(event); } NS_IMETHODIMP nsDocument::GetMozHidden(bool* aHidden) { *aHidden = MozHidden(); return NS_OK; @@ -13523,17 +13523,17 @@ nsIDocument::RebuildUserFontSet() // post an event to rebuild it. Setting the user font set to be dirty // and lazily rebuilding it isn't sufficient, since it is only the act // of rebuilding it that will trigger the style change reflow that // calls GetUserFontSet. (This reflow causes rebuilding of text runs, // which starts font loads, whose completion causes another style // change reflow). if (!mPostedFlushUserFontSet) { nsCOMPtr<nsIRunnable> ev = - NS_NewRunnableMethod(this, &nsIDocument::HandleRebuildUserFontSet); + NewRunnableMethod(this, &nsIDocument::HandleRebuildUserFontSet); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPostedFlushUserFontSet = true; } } } FontFaceSet* nsIDocument::Fonts()
--- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -2674,17 +2674,17 @@ nsGlobalWindow::SetNewDocument(nsIDocume } } /* No mDocShell means we're already been partially closed down. When that happens, setting status isn't a big requirement, so don't. (Doesn't happen under normal circumstances, but bug 49615 describes a case.) */ nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsGlobalWindow::ClearStatus)); + NewRunnableMethod(this, &nsGlobalWindow::ClearStatus)); // Sometimes, WouldReuseInnerWindow() returns true even if there's no inner // window (see bug 776497). Be safe. bool reUseInnerWindow = (aForceReuseInnerWindow || wouldReuseInnerWindow) && GetCurrentInnerWindowInternal(); nsresult rv = NS_OK; @@ -2980,31 +2980,31 @@ nsGlobalWindow::SetNewDocument(nsIDocume nsJSContext::PokeGC(JS::gcreason::SET_NEW_DOCUMENT); mContext->DidInitializeContext(); // We wait to fire the debugger hook until the window is all set up and hooked // up with the outer. See bug 969156. if (createdInnerWindow) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(newInnerWindow, - &nsGlobalWindow::FireOnNewGlobalObject)); + NewRunnableMethod(newInnerWindow, + &nsGlobalWindow::FireOnNewGlobalObject)); } if (newInnerWindow && !newInnerWindow->mHasNotifiedGlobalCreated && mDoc) { // We should probably notify. However if this is the, arguably bad, // situation when we're creating a temporary non-chrome-about-blank // document in a chrome docshell, don't notify just yet. Instead wait // until we have a real chrome doc. if (!mDocShell || mDocShell->ItemType() != nsIDocShellTreeItem::typeChrome || nsContentUtils::IsSystemPrincipal(mDoc->NodePrincipal())) { newInnerWindow->mHasNotifiedGlobalCreated = true; nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsGlobalWindow::DispatchDOMWindowCreated)); + NewRunnableMethod(this, &nsGlobalWindow::DispatchDOMWindowCreated)); } } PreloadLocalStorage(); return NS_OK; } @@ -11723,17 +11723,17 @@ public: : mWin(aWin) { MOZ_ASSERT(mWin); MOZ_ASSERT(mWin->IsOuterWindow()); } ~AutoUnblockScriptClosing() { void (nsGlobalWindow::*run)() = &nsGlobalWindow::UnblockScriptedClosing; - NS_DispatchToCurrentThread(NS_NewRunnableMethod(mWin, run)); + NS_DispatchToCurrentThread(NewRunnableMethod(mWin, run)); } }; nsresult nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName, const nsAString& aOptions, bool aDialog, bool aContentModal, bool aCalledNoScript, bool aDoJSFixups, bool aNavigate,
--- a/dom/base/nsScriptLoader.cpp +++ b/dom/base/nsScriptLoader.cpp @@ -492,18 +492,18 @@ nsScriptLoader::ProcessScriptElement(nsI nsresult rv = NS_OK; RefPtr<nsScriptLoadRequest> request; if (aElement->GetScriptExternal()) { // external script nsCOMPtr<nsIURI> scriptURI = aElement->GetScriptURI(); if (!scriptURI) { // Asynchronously report the failure to create a URI object NS_DispatchToCurrentThread( - NS_NewRunnableMethod(aElement, - &nsIScriptElement::FireErrorEvent)); + NewRunnableMethod(aElement, + &nsIScriptElement::FireErrorEvent)); return false; } // Double-check that the preload matches what we're asked to load now. mozilla::net::ReferrerPolicy ourRefPolicy = mDocument->GetReferrerPolicy(); CORSMode ourCORSMode = aElement->GetCORSMode(); nsTArray<PreloadInfo>::index_type i = mPreloads.IndexOf(scriptURI.get(), 0, PreloadURIComparator()); @@ -559,18 +559,18 @@ nsScriptLoader::ProcessScriptElement(nsI request->mReferrerPolicy = ourRefPolicy; // set aScriptFromHead to false so we don't treat non preloaded scripts as // blockers for full page load. See bug 792438. rv = StartLoad(request, type, false); if (NS_FAILED(rv)) { // Asynchronously report the load failure NS_DispatchToCurrentThread( - NS_NewRunnableMethod(aElement, - &nsIScriptElement::FireErrorEvent)); + NewRunnableMethod(aElement, + &nsIScriptElement::FireErrorEvent)); return false; } } // Should still be in loading stage of script. NS_ASSERTION(!request->InCompilingStage(), "Request should not yet be in compiling stage."); @@ -1139,20 +1139,18 @@ nsScriptLoader::EvaluateScript(nsScriptL context->SetProcessingScriptTag(oldProcessingScriptTag); return rv; } void nsScriptLoader::ProcessPendingRequestsAsync() { if (mParserBlockingRequest || !mPendingChildLoaders.IsEmpty()) { - nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this, - &nsScriptLoader::ProcessPendingRequests); - - NS_DispatchToCurrentThread(ev); + NS_DispatchToCurrentThread(NewRunnableMethod(this, + &nsScriptLoader::ProcessPendingRequests)); } } void nsScriptLoader::ProcessPendingRequests() { RefPtr<nsScriptLoadRequest> request;
--- a/dom/base/nsTextNode.cpp +++ b/dom/base/nsTextNode.cpp @@ -268,18 +268,17 @@ nsAttributeTextNode::AttributeChanged(ns const nsAttrValue* aOldValue) { if (aNameSpaceID == mNameSpaceID && aAttribute == mAttrName && aElement == mGrandparent) { // Since UpdateText notifies, do it when it's safe to run script. Note // that if we get unbound while the event is up that's ok -- we'll just // have no grandparent when it fires, and will do nothing. void (nsAttributeTextNode::*update)() = &nsAttributeTextNode::UpdateText; - nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this, update); - nsContentUtils::AddScriptRunner(ev); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); } } void nsAttributeTextNode::NodeWillBeDestroyed(const nsINode* aNode) { NS_ASSERTION(aNode == static_cast<nsINode*>(mGrandparent), "Wrong node!"); mGrandparent = nullptr;
--- a/dom/cache/Context.cpp +++ b/dom/cache/Context.cpp @@ -735,33 +735,33 @@ Context::ThreadsafeHandle::AllowToClose( if (mOwningThread == NS_GetCurrentThread()) { AllowToCloseOnOwningThread(); return; } // Dispatch is guaranteed to succeed here because we block shutdown until // all Contexts have been destroyed. nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &ThreadsafeHandle::AllowToCloseOnOwningThread); + NewRunnableMethod(this, &ThreadsafeHandle::AllowToCloseOnOwningThread); MOZ_ALWAYS_SUCCEEDS( mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)); } void Context::ThreadsafeHandle::InvalidateAndAllowToClose() { if (mOwningThread == NS_GetCurrentThread()) { InvalidateAndAllowToCloseOnOwningThread(); return; } // Dispatch is guaranteed to succeed here because we block shutdown until // all Contexts have been destroyed. nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &ThreadsafeHandle::InvalidateAndAllowToCloseOnOwningThread); + NewRunnableMethod(this, &ThreadsafeHandle::InvalidateAndAllowToCloseOnOwningThread); MOZ_ALWAYS_SUCCEEDS( mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)); } Context::ThreadsafeHandle::ThreadsafeHandle(Context* aContext) : mStrongRef(aContext) , mWeakRef(aContext) , mOwningThread(NS_GetCurrentThread()) @@ -775,20 +775,17 @@ Context::ThreadsafeHandle::~ThreadsafeHa // always holding a strong ref to the ThreadsafeHandle via the owning // runnable. So we cannot run the ThreadsafeHandle destructor simultaneously. if (!mStrongRef || mOwningThread == NS_GetCurrentThread()) { return; } // Dispatch is guaranteed to succeed here because we block shutdown until // all Contexts have been destroyed. - nsCOMPtr<nsIRunnable> runnable = - NS_NewNonOwningRunnableMethod(mStrongRef.forget().take(), &Context::Release); - MOZ_ALWAYS_SUCCEEDS( - mOwningThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)); + NS_ProxyRelease(mOwningThread, mStrongRef.forget()); } void Context::ThreadsafeHandle::AllowToCloseOnOwningThread() { MOZ_ASSERT(mOwningThread == NS_GetCurrentThread()); // A Context "closes" when its ref count drops to zero. Dropping this
--- a/dom/cache/Manager.cpp +++ b/dom/cache/Manager.cpp @@ -907,17 +907,17 @@ private: } void CallOnAsyncCopyCompleteOnTargetThread(nsresult aRv) { // May be on any thread, including STS event target. Non-owning runnable // here since we are guaranteed the Action will survive until // CompleteOnInitiatingThread is called. - nsCOMPtr<nsIRunnable> runnable = NS_NewNonOwningRunnableMethodWithArgs<nsresult>( + nsCOMPtr<nsIRunnable> runnable = NewNonOwningRunnableMethod<nsresult>( this, &CachePutAllAction::OnAsyncCopyComplete, aRv); MOZ_ALWAYS_SUCCEEDS( mTargetThread->Dispatch(runnable, nsIThread::DISPATCH_NORMAL)); } void DoResolve(nsresult aRv) { @@ -1756,19 +1756,17 @@ Manager::~Manager() MOZ_ASSERT(mState == Closing); MOZ_ASSERT(!mContext); nsCOMPtr<nsIThread> ioThread; mIOThread.swap(ioThread); // Don't spin the event loop in the destructor waiting for the thread to // shutdown. Defer this to the main thread, instead. - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(ioThread, &nsIThread::Shutdown); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable)); + MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(NewRunnableMethod(ioThread, &nsIThread::Shutdown))); } void Manager::Init(Manager* aOldManager) { NS_ASSERT_OWNINGTHREAD(Manager); RefPtr<Context> oldContext;
--- a/dom/camera/CameraPreviewMediaStream.cpp +++ b/dom/camera/CameraPreviewMediaStream.cpp @@ -166,28 +166,24 @@ CameraPreviewMediaStream::SetCurrentFram for (nsTArray<RefPtr<VideoFrameContainer> >::size_type i = 0; i < mVideoOutputs.Length(); ++i) { VideoFrameContainer* output = mVideoOutputs[i]; output->SetCurrentFrame(aIntrinsicSize, aImage, now); } ++mInvalidatePending; } - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &CameraPreviewMediaStream::Invalidate); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(this, &CameraPreviewMediaStream::Invalidate)); } void CameraPreviewMediaStream::ClearCurrentFrame() { MutexAutoLock lock(mMutex); for (nsTArray<RefPtr<VideoFrameContainer> >::size_type i = 0; i < mVideoOutputs.Length(); ++i) { VideoFrameContainer* output = mVideoOutputs[i]; output->ClearCurrentFrame(); - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(output, &VideoFrameContainer::Invalidate); - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(output, &VideoFrameContainer::Invalidate)); } } } // namespace mozilla
--- a/dom/camera/DOMCameraControl.cpp +++ b/dom/camera/DOMCameraControl.cpp @@ -68,20 +68,18 @@ public: void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID, StreamTime aTrackOffset, uint32_t aTrackEvents, const MediaSegment& aQueuedMedia, MediaStream* aInputStream, TrackID aInputTrackID) override { if (aTrackEvents & TRACK_EVENT_CREATED) { - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArgs<TrackID>( - this, &TrackCreatedListener::DoNotifyTrackCreated, aID); - aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); + aGraph->DispatchToMainThreadAfterStreamStateUpdate(NewRunnableMethod<TrackID>( + this, &TrackCreatedListener::DoNotifyTrackCreated, aID)); } } protected: ~TrackCreatedListener() {} nsDOMCameraControl* mCameraControl; };
--- a/dom/camera/DOMCameraManager.cpp +++ b/dom/camera/DOMCameraManager.cpp @@ -228,21 +228,21 @@ CameraPermissionRequest::GetRequester(ns return NS_OK; } nsresult CameraPermissionRequest::DispatchCallback(uint32_t aPermission) { nsCOMPtr<nsIRunnable> callbackRunnable; if (aPermission == nsIPermissionManager::ALLOW_ACTION) { - callbackRunnable = NS_NewRunnableMethod(this, &CameraPermissionRequest::CallAllow); + callbackRunnable = NewRunnableMethod(this, &CameraPermissionRequest::CallAllow); } else { - callbackRunnable = NS_NewRunnableMethod(this, &CameraPermissionRequest::CallCancel); + callbackRunnable = NewRunnableMethod(this, &CameraPermissionRequest::CallCancel); } - return NS_DispatchToMainThread(callbackRunnable); + return NS_DispatchToMainThread(callbackRunnable.forget()); } void CameraPermissionRequest::CallAllow() { mCameraManager->PermissionAllowed(mCameraId, mInitialConfig, mPromise); }
--- a/dom/devicestorage/DeviceStorageStatics.cpp +++ b/dom/devicestorage/DeviceStorageStatics.cpp @@ -483,17 +483,17 @@ DeviceStorageStatics::AddListener(nsDOMD StaticMutexAutoLock lock(sMutex); if (NS_WARN_IF(!sInstance)) { return; } MOZ_ASSERT(sInstance->mInitialized); if (sInstance->mListeners.IsEmpty()) { NS_DispatchToMainThread( - NS_NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Register)); + NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Register)); } RefPtr<ListenerWrapper> wrapper = new ListenerWrapper(aListener); sInstance->mListeners.AppendElement(wrapper.forget()); } /* static */ void @@ -514,17 +514,17 @@ DeviceStorageStatics::RemoveListener(nsD sInstance->mListeners.RemoveElementAt(i); removed = true; break; } } if (removed && sInstance->mListeners.IsEmpty()) { NS_DispatchToMainThread( - NS_NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Deregister)); + NewRunnableMethod(sInstance.get(), &DeviceStorageStatics::Deregister)); } } void DeviceStorageStatics::Register() { MOZ_ASSERT(NS_IsMainThread()); DS_LOG_INFO("");
--- a/dom/events/EventListenerService.cpp +++ b/dom/events/EventListenerService.cpp @@ -366,19 +366,18 @@ EventListenerService::NotifyAboutMainThr { MOZ_ASSERT(NS_IsMainThread()); if (mChangeListeners.IsEmpty()) { return; } if (!mPendingListenerChanges) { mPendingListenerChanges = nsArrayBase::Create(); - nsCOMPtr<nsIRunnable> runnable = NS_NewRunnableMethod(this, - &EventListenerService::NotifyPendingChanges); - NS_DispatchToCurrentThread(runnable); + NS_DispatchToCurrentThread(NewRunnableMethod(this, + &EventListenerService::NotifyPendingChanges)); } RefPtr<EventListenerChange> changes = mPendingListenerChangesSet.Get(aTarget); if (!changes) { changes = new EventListenerChange(aTarget); mPendingListenerChanges->AppendElement(changes, false); mPendingListenerChangesSet.Put(aTarget, changes); }
--- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -78,19 +78,17 @@ FetchDriver::Fetch(FetchDriverObserver* Telemetry::Accumulate(Telemetry::SERVICE_WORKER_REQUEST_PASSTHROUGH, mRequest->WasCreatedByFetchEvent()); // FIXME(nsm): Deal with HSTS. MOZ_RELEASE_ASSERT(!mRequest->IsSynchronous(), "Synchronous fetch not supported"); - nsCOMPtr<nsIRunnable> r = - NS_NewRunnableMethod(this, &FetchDriver::ContinueFetch); - return NS_DispatchToCurrentThread(r); + return NS_DispatchToCurrentThread(NewRunnableMethod(this, &FetchDriver::ContinueFetch)); } nsresult FetchDriver::ContinueFetch() { workers::AssertIsOnMainThread(); nsresult rv = HttpFetch();
--- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -218,17 +218,17 @@ HTMLCanvasPrintState::Done() { if (!mPendingNotify && !mIsDone) { // The canvas needs to be invalidated for printing reftests on linux to // work. if (mCanvas) { mCanvas->InvalidateCanvas(); } RefPtr<nsRunnableMethod<HTMLCanvasPrintState> > doneEvent = - NS_NewRunnableMethod(this, &HTMLCanvasPrintState::NotifyDone); + NewRunnableMethod(this, &HTMLCanvasPrintState::NotifyDone); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(doneEvent))) { mPendingNotify = true; } } } void HTMLCanvasPrintState::NotifyDone() @@ -498,17 +498,17 @@ HTMLCanvasElement::DispatchPrintCallback nsresult rv; nsCOMPtr<nsISupports> context; rv = GetContext(NS_LITERAL_STRING("2d"), getter_AddRefs(context)); NS_ENSURE_SUCCESS(rv, rv); } mPrintState = new HTMLCanvasPrintState(this, mCurrentContext, aCallback); RefPtr<nsRunnableMethod<HTMLCanvasElement> > renderEvent = - NS_NewRunnableMethod(this, &HTMLCanvasElement::CallPrintCallback); + NewRunnableMethod(this, &HTMLCanvasElement::CallPrintCallback); return NS_DispatchToCurrentThread(renderEvent); } void HTMLCanvasElement::CallPrintCallback() { ErrorResult rv; GetMozPrintCallback()->Call(*mPrintState, rv);
--- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -614,17 +614,17 @@ HTMLImageElement::BindToTree(nsIDocument // 1076583), but still need to delay if it is unsafe to run // script. // If loading is temporarily disabled, don't even launch MaybeLoadImage. // Otherwise MaybeLoadImage may run later when someone has reenabled // loading. if (LoadingEnabled()) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &HTMLImageElement::MaybeLoadImage)); + NewRunnableMethod(this, &HTMLImageElement::MaybeLoadImage)); } } return rv; } void HTMLImageElement::UnbindFromTree(bool aDeep, bool aNullParent) @@ -811,17 +811,17 @@ HTMLImageElement::CopyInnerTo(Element* a if (!destIsStatic) { // In SetAttr (called from nsGenericHTMLElement::CopyInnerTo), dest skipped // doing the image load because we passed in false for aNotify. But we // really do want it to do the load, so set it up to happen once the cloning // reaches a stable state. if (!dest->InResponsiveMode() && dest->HasAttr(kNameSpaceID_None, nsGkAtoms::src)) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(dest, &HTMLImageElement::MaybeLoadImage)); + NewRunnableMethod(dest, &HTMLImageElement::MaybeLoadImage)); } } return NS_OK; } CORSMode HTMLImageElement::GetCORSMode()
--- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -4349,17 +4349,17 @@ HTMLInputElement::BindToTree(nsIDocument // Our base URI may have changed; claim that our URI changed, and the // nsImageLoadingContent will decide whether a new image load is warranted. if (HasAttr(kNameSpaceID_None, nsGkAtoms::src)) { // FIXME: Bug 660963 it would be nice if we could just have // ClearBrokenState update our state and do it fast... ClearBrokenState(); RemoveStatesSilently(NS_EVENT_STATE_BROKEN); nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &HTMLInputElement::MaybeLoadImage)); + NewRunnableMethod(this, &HTMLInputElement::MaybeLoadImage)); } } // Add radio to document if we don't have a form already (if we do it's // already been added into that group) if (aDocument && !mForm && mType == NS_FORM_INPUT_RADIO) { AddedToRadioGroup(); }
--- a/dom/html/HTMLLinkElement.cpp +++ b/dom/html/HTMLLinkElement.cpp @@ -180,20 +180,20 @@ HTMLLinkElement::BindToTree(nsIDocument* aDocument->RegisterPendingLinkUpdate(this); } if (IsInComposedDoc()) { TryDNSPrefetchPreconnectOrPrefetch(); } void (HTMLLinkElement::*update)() = &HTMLLinkElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); void (HTMLLinkElement::*updateImport)() = &HTMLLinkElement::UpdateImport; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, updateImport)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, updateImport)); CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMLinkAdded")); return rv; } void HTMLLinkElement::LinkAdded()
--- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -837,29 +837,29 @@ void HTMLMediaElement::RunInStableState( nsCOMPtr<nsIRunnable> event = new nsSyncSection(this, aRunnable); nsContentUtils::RunInStableState(event.forget()); } void HTMLMediaElement::QueueLoadFromSourceTask() { ChangeDelayLoadStatus(true); ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_LOADING); - RunInStableState( - NS_NewRunnableMethod(this, &HTMLMediaElement::LoadFromSourceChildren)); + RefPtr<Runnable> r = NewRunnableMethod(this, &HTMLMediaElement::LoadFromSourceChildren); + RunInStableState(r); } void HTMLMediaElement::QueueSelectResourceTask() { // Don't allow multiple async select resource calls to be queued. if (mHaveQueuedSelectResource) return; mHaveQueuedSelectResource = true; ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE); - RunInStableState( - NS_NewRunnableMethod(this, &HTMLMediaElement::SelectResourceWrapper)); + RefPtr<Runnable> r = NewRunnableMethod(this, &HTMLMediaElement::SelectResourceWrapper); + RunInStableState(r); } NS_IMETHODIMP HTMLMediaElement::Load() { if (mIsRunningLoadMethod) { return NS_OK; } @@ -3166,47 +3166,47 @@ public: } // These notifications run on the media graph thread so we need to // dispatch events to the main thread. virtual void NotifyBlockingChanged(MediaStreamGraph* aGraph, Blocking aBlocked) override { nsCOMPtr<nsIRunnable> event; if (aBlocked == BLOCKED) { - event = NS_NewRunnableMethod(this, &StreamListener::DoNotifyBlocked); + event = NewRunnableMethod(this, &StreamListener::DoNotifyBlocked); } else { - event = NS_NewRunnableMethod(this, &StreamListener::DoNotifyUnblocked); + event = NewRunnableMethod(this, &StreamListener::DoNotifyUnblocked); } aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } virtual void NotifyEvent(MediaStreamGraph* aGraph, MediaStreamListener::MediaStreamGraphEvent event) override { if (event == EVENT_FINISHED) { nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &StreamListener::DoNotifyFinished); + NewRunnableMethod(this, &StreamListener::DoNotifyFinished); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } } virtual void NotifyHasCurrentData(MediaStreamGraph* aGraph) override { MutexAutoLock lock(mMutex); nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &StreamListener::DoNotifyHaveCurrentData); + NewRunnableMethod(this, &StreamListener::DoNotifyHaveCurrentData); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } virtual void NotifyOutput(MediaStreamGraph* aGraph, GraphTime aCurrentTime) override { MutexAutoLock lock(mMutex); if (mPendingNotifyOutput) return; mPendingNotifyOutput = true; nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &StreamListener::DoNotifyOutput); + NewRunnableMethod(this, &StreamListener::DoNotifyOutput); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } private: // These fields may only be accessed on the main thread HTMLMediaElement* mElement; bool mHaveCurrentData; bool mBlocked; @@ -3248,17 +3248,17 @@ public: if (mInitialSizeFound || aQueuedMedia.GetType() != MediaSegment::VIDEO) { return; } const VideoSegment& video = static_cast<const VideoSegment&>(aQueuedMedia); for (VideoSegment::ConstChunkIterator c(video); !c.IsEnded(); c.Next()) { if (c->mFrame.GetIntrinsicSize() != gfx::IntSize(0,0)) { mInitialSizeFound = true; nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethodWithArgs<gfx::IntSize>( + NewRunnableMethod<gfx::IntSize>( this, &StreamSizeListener::ReceivedSize, c->mFrame.GetIntrinsicSize()); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); return; } } } @@ -4589,17 +4589,17 @@ void HTMLMediaElement::AddRemoveSelfRefe // The observer service will hold a strong reference to us. This // will do to keep us alive. We need to know about shutdown so that // we can release our self-reference. nsContentUtils::RegisterShutdownObserver(this); } else { // Dispatch Release asynchronously so that we don't destroy this object // inside a call stack of method calls on this object nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &HTMLMediaElement::DoRemoveSelfReference); + NewRunnableMethod(this, &HTMLMediaElement::DoRemoveSelfReference); NS_DispatchToMainThread(event); } } UpdateAudioChannelPlayingState(); } void HTMLMediaElement::DoRemoveSelfReference()
--- a/dom/html/HTMLObjectElement.cpp +++ b/dom/html/HTMLObjectElement.cpp @@ -275,17 +275,17 @@ HTMLObjectElement::BindToTree(nsIDocumen // Don't kick off load from being bound to a plugin document - the plugin // document will call nsObjectLoadingContent::InitializeFromChannel() for the // initial load. nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(aDocument); // If we already have all the children, start the load. if (mIsDoneAddingChildren && !pluginDoc) { void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, start)); } return NS_OK; } void HTMLObjectElement::UnbindFromTree(bool aDeep, bool aNullParent)
--- a/dom/html/HTMLSharedObjectElement.cpp +++ b/dom/html/HTMLSharedObjectElement.cpp @@ -148,17 +148,17 @@ HTMLSharedObjectElement::BindToTree(nsID // document will call nsObjectLoadingContent::InitializeFromChannel() for the // initial load. nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(aDocument); // If we already have all the children, start the load. if (mIsDoneAddingChildren && !pluginDoc) { void (HTMLSharedObjectElement::*start)() = &HTMLSharedObjectElement::StartObjectLoad; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, start)); } return NS_OK; } void HTMLSharedObjectElement::UnbindFromTree(bool aDeep, bool aNullParent)
--- a/dom/html/HTMLStyleElement.cpp +++ b/dom/html/HTMLStyleElement.cpp @@ -142,17 +142,17 @@ HTMLStyleElement::BindToTree(nsIDocument bool aCompileEventHandlers) { nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent, aCompileEventHandlers); NS_ENSURE_SUCCESS(rv, rv); void (HTMLStyleElement::*update)() = &HTMLStyleElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); return rv; } void HTMLStyleElement::UnbindFromTree(bool aDeep, bool aNullParent) { nsCOMPtr<nsIDocument> oldDoc = GetUncomposedDoc();
--- a/dom/html/HTMLTrackElement.cpp +++ b/dom/html/HTMLTrackElement.cpp @@ -255,18 +255,18 @@ HTMLTrackElement::BindToTree(nsIDocument if (!mMediaParent) { mMediaParent = static_cast<HTMLMediaElement*>(aParent); HTMLMediaElement* media = static_cast<HTMLMediaElement*>(aParent); // TODO: separate notification for 'alternate' tracks? media->NotifyAddedSource(); LOG(LogLevel::Debug, ("Track element sent notification to parent.")); - mMediaParent->RunInStableState( - NS_NewRunnableMethod(this, &HTMLTrackElement::LoadResource)); + RefPtr<Runnable> r = NewRunnableMethod(this, &HTMLTrackElement::LoadResource); + mMediaParent->RunInStableState(r); } return NS_OK; } void HTMLTrackElement::UnbindFromTree(bool aDeep, bool aNullParent) { @@ -309,17 +309,17 @@ HTMLTrackElement::SetReadyState(uint16_t mTrack->SetReadyState(aReadyState); } } void HTMLTrackElement::DispatchTrackRunnable(const nsString& aEventName) { nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg + NewRunnableMethod <const nsString>(this, &HTMLTrackElement::DispatchTrustedEvent, aEventName); NS_DispatchToMainThread(runnable); } void HTMLTrackElement::DispatchTrustedEvent(const nsAString& aName)
--- a/dom/html/ImageDocument.cpp +++ b/dom/html/ImageDocument.cpp @@ -486,17 +486,17 @@ ImageDocument::Notify(imgIRequest* aRequ aRequest->GetImage(getter_AddRefs(image)); return OnSizeAvailable(aRequest, image); } // Run this using a script runner because HAS_TRANSPARENCY notifications can // come during painting and this will trigger invalidation. if (aType == imgINotificationObserver::HAS_TRANSPARENCY) { nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &ImageDocument::OnHasTransparency); + NewRunnableMethod(this, &ImageDocument::OnHasTransparency); nsContentUtils::AddScriptRunner(runnable); } if (aType == imgINotificationObserver::LOAD_COMPLETE) { uint32_t reqStatus; aRequest->GetImageStatus(&reqStatus); nsresult status = reqStatus & imgIRequest::STATUS_ERROR ? NS_ERROR_FAILURE : NS_OK; @@ -549,17 +549,17 @@ nsresult ImageDocument::OnSizeAvailable(imgIRequest* aRequest, imgIContainer* aImage) { // Styles have not yet been applied, so we don't know the final size. For now, // default to the image's intrinsic size. aImage->GetWidth(&mImageWidth); aImage->GetHeight(&mImageHeight); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &ImageDocument::DefaultCheckOverflowing); + NewRunnableMethod(this, &ImageDocument::DefaultCheckOverflowing); nsContentUtils::AddScriptRunner(runnable); UpdateTitleAndCharset(); return NS_OK; } nsresult ImageDocument::OnLoadComplete(imgIRequest* aRequest, nsresult aStatus)
--- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -2500,17 +2500,17 @@ void nsHTMLDocument::MaybeEditingStateChanged() { if (!mPendingMaybeEditingStateChanged && mUpdateNestLevel == 0 && (mContentEditableCount > 0) != IsEditingOn()) { if (nsContentUtils::IsSafeToRunScript()) { EditingStateChanged(); } else if (!mInDestructor) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsHTMLDocument::MaybeEditingStateChanged)); + NewRunnableMethod(this, &nsHTMLDocument::MaybeEditingStateChanged)); } } } void nsHTMLDocument::EndUpdate(nsUpdateType aUpdateType) { const bool reset = !mPendingMaybeEditingStateChanged;
--- a/dom/indexedDB/ActorsParent.cpp +++ b/dom/indexedDB/ActorsParent.cpp @@ -11818,17 +11818,17 @@ ConnectionPool::ShutdownThread(ThreadInf IDB_DEBUG_LOG(("ConnectionPool shutting down thread %lu", runnable->SerialNumber())); // This should clean up the thread with the profiler. MOZ_ALWAYS_SUCCEEDS(thread->Dispatch(runnable, NS_DISPATCH_NORMAL)); nsCOMPtr<nsIRunnable> shutdownRunnable = - NS_NewRunnableMethod(thread, &nsIThread::Shutdown); + NewRunnableMethod(thread, &nsIThread::Shutdown); MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(shutdownRunnable)); mTotalThreadCount--; } void ConnectionPool::CloseIdleDatabases() { @@ -13663,17 +13663,17 @@ Database::MaybeCloseConnection() { AssertIsOnBackgroundThread(); if (!mTransactions.Count() && !mActiveMutableFileCount && IsClosed() && mDirectoryLock) { nsCOMPtr<nsIRunnable> callback = - NS_NewRunnableMethod(this, &Database::ConnectionClosedCallback); + NewRunnableMethod(this, &Database::ConnectionClosedCallback); RefPtr<WaitForTransactionsHelper> helper = new WaitForTransactionsHelper(Id(), callback); helper->WaitForTransactions(); } } void @@ -21409,17 +21409,17 @@ OpenDatabaseOp::SendResults() if (NS_FAILED(mResultCode)) { mDatabase->Invalidate(); } // Make sure to release the database on this thread. mDatabase = nullptr; } else if (mDirectoryLock) { nsCOMPtr<nsIRunnable> callback = - NS_NewRunnableMethod(this, &OpenDatabaseOp::ConnectionClosedCallback); + NewRunnableMethod(this, &OpenDatabaseOp::ConnectionClosedCallback); RefPtr<WaitForTransactionsHelper> helper = new WaitForTransactionsHelper(mDatabaseId, callback); helper->WaitForTransactions(); } FinishSendResults(); }
--- a/dom/indexedDB/FileSnapshot.cpp +++ b/dom/indexedDB/FileSnapshot.cpp @@ -82,17 +82,17 @@ private: Destroy() { if (IsOnOwningThread()) { delete this; return; } nsCOMPtr<nsIRunnable> destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &StreamWrapper::Destroy); + NewNonOwningRunnableMethod(this, &StreamWrapper::Destroy); MOZ_ALWAYS_SUCCEEDS(mOwningThread->Dispatch(destroyRunnable, NS_DISPATCH_NORMAL)); } NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIINPUTSTREAM NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM
--- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -1031,19 +1031,19 @@ IDBDatabase::DelayedMaybeExpireFileActor { AssertIsOnOwningThread(); if (!mBackgroundActor || !mFileActors.Count()) { return; } nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<bool>(this, - &IDBDatabase::ExpireFileActors, - /* aExpireAll */ false); + NewRunnableMethod<bool>(this, + &IDBDatabase::ExpireFileActors, + /* aExpireAll */ false); MOZ_ASSERT(runnable); if (!NS_IsMainThread()) { // Wrap as a nsICancelableRunnable to make workers happy. nsCOMPtr<nsIRunnable> cancelable = new CancelableRunnableWrapper(runnable); cancelable.swap(runnable); }
--- a/dom/ipc/Blob.cpp +++ b/dom/ipc/Blob.cpp @@ -288,17 +288,17 @@ ReleaseOnTarget(SmartPtr<T>& aDoomed, ns MOZ_ASSERT(!EventTargetIsOnCurrentThread(aTarget)); T* doomedRaw; aDoomed.forget(&doomedRaw); auto* doomedSupports = static_cast<nsISupports*>(doomedRaw); nsCOMPtr<nsIRunnable> releaseRunnable = - NS_NewNonOwningRunnableMethod(doomedSupports, &nsISupports::Release); + NewNonOwningRunnableMethod(doomedSupports, &nsISupports::Release); MOZ_ASSERT(releaseRunnable); if (aTarget) { // If we're targeting a non-main thread then make sure the runnable is // cancelable. releaseRunnable = new CancelableRunnableWrapper(releaseRunnable, aTarget); MOZ_ALWAYS_SUCCEEDS(aTarget->Dispatch(releaseRunnable, @@ -1595,21 +1595,17 @@ private: nsCOMPtr<nsIInputStream> stream; mStream.swap(stream); nsCOMPtr<nsIThread> ioTarget; mIOTarget.swap(ioTarget); NS_WARN_IF_FALSE(NS_SUCCEEDED(stream->Close()), "Failed to close stream!"); - nsCOMPtr<nsIRunnable> shutdownRunnable = - NS_NewRunnableMethod(ioTarget, &nsIThread::Shutdown); - MOZ_ASSERT(shutdownRunnable); - - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(shutdownRunnable)); + MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(NewRunnableMethod(ioTarget, &nsIThread::Shutdown))); return NS_OK; } nsresult SendResponse() { AssertIsOnOwningThread(); @@ -2133,17 +2129,17 @@ RemoteBlobImpl::Destroy() mActor->NoteDyingRemoteBlobImpl(); } delete this; return; } nsCOMPtr<nsIRunnable> destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy); + NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy); if (mActorTarget) { destroyRunnable = new CancelableRunnableWrapper(destroyRunnable, mActorTarget); MOZ_ALWAYS_SUCCEEDS(mActorTarget->Dispatch(destroyRunnable, NS_DISPATCH_NORMAL)); } else { @@ -2561,17 +2557,17 @@ RemoteBlobImpl::Destroy() mActor->NoteDyingRemoteBlobImpl(); } delete this; return; } nsCOMPtr<nsIRunnable> destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy); + NewNonOwningRunnableMethod(this, &RemoteBlobImpl::Destroy); if (mActorTarget) { destroyRunnable = new CancelableRunnableWrapper(destroyRunnable, mActorTarget); MOZ_ALWAYS_SUCCEEDS(mActorTarget->Dispatch(destroyRunnable, NS_DISPATCH_NORMAL)); } else { @@ -3417,17 +3413,17 @@ BlobChild::NoteDyingRemoteBlobImpl() MOZ_ASSERT(mRemoteBlobImpl); MOZ_ASSERT(!mOwnsBlobImpl); // This may be called on any thread due to the fact that RemoteBlobImpl is // designed to be passed between threads. We must start the shutdown process // on the owning thread, so we proxy here if necessary. if (!IsOnOwningThread()) { nsCOMPtr<nsIRunnable> runnable = - NS_NewNonOwningRunnableMethod(this, &BlobChild::NoteDyingRemoteBlobImpl); + NewNonOwningRunnableMethod(this, &BlobChild::NoteDyingRemoteBlobImpl); if (mEventTarget) { runnable = new CancelableRunnableWrapper(runnable, mEventTarget); MOZ_ALWAYS_SUCCEEDS(mEventTarget->Dispatch(runnable, NS_DISPATCH_NORMAL)); } else { MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable)); @@ -3996,17 +3992,17 @@ BlobParent::NoteDyingRemoteBlobImpl() MOZ_ASSERT(mRemoteBlobImpl); MOZ_ASSERT(!mOwnsBlobImpl); // This may be called on any thread due to the fact that RemoteBlobImpl is // designed to be passed between threads. We must start the shutdown process // on the main thread, so we proxy here if necessary. if (!IsOnOwningThread()) { nsCOMPtr<nsIRunnable> runnable = - NS_NewNonOwningRunnableMethod(this, &BlobParent::NoteDyingRemoteBlobImpl); + NewNonOwningRunnableMethod(this, &BlobParent::NoteDyingRemoteBlobImpl); if (mEventTarget) { runnable = new CancelableRunnableWrapper(runnable, mEventTarget); MOZ_ALWAYS_SUCCEEDS(mEventTarget->Dispatch(runnable, NS_DISPATCH_NORMAL)); } else { MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable));
--- a/dom/ipc/ContentBridgeChild.cpp +++ b/dom/ipc/ContentBridgeChild.cpp @@ -29,18 +29,17 @@ ContentBridgeChild::~ContentBridgeChild( { RefPtr<DeleteTask<Transport>> task = new DeleteTask<Transport>(mTransport); XRE_GetIOMessageLoop()->PostTask(task.forget()); } void ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy) { - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy)); } /*static*/ ContentBridgeChild* ContentBridgeChild::Create(Transport* aTransport, ProcessId aOtherPid) { RefPtr<ContentBridgeChild> bridge = new ContentBridgeChild(aTransport); bridge->mSelfRef = bridge;
--- a/dom/ipc/ContentBridgeParent.cpp +++ b/dom/ipc/ContentBridgeParent.cpp @@ -32,18 +32,17 @@ ContentBridgeParent::~ContentBridgeParen void ContentBridgeParent::ActorDestroy(ActorDestroyReason aWhy) { nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); if (os) { os->RemoveObserver(this, "content-child-shutdown"); } - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy)); } /*static*/ ContentBridgeParent* ContentBridgeParent::Create(Transport* aTransport, ProcessId aOtherPid) { RefPtr<ContentBridgeParent> bridge = new ContentBridgeParent(aTransport); bridge->mSelfRef = bridge; @@ -163,18 +162,17 @@ ContentBridgeParent::DeallocPBrowserPare return nsIContentParent::DeallocPBrowserParent(aParent); } void ContentBridgeParent::NotifyTabDestroyed() { int32_t numLiveTabs = ManagedPBrowserParent().Count(); if (numLiveTabs == 1) { - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ContentBridgeParent::Close); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &ContentBridgeParent::Close)); } } // This implementation is identical to ContentParent::GetCPOWManager but we can't // move it to nsIContentParent because it calls ManagedPJavaScriptParent() which // only exists in PContentParent and PContentBridgeParent. jsipc::CPOWManager* ContentBridgeParent::GetCPOWManager()
--- a/dom/ipc/ContentBridgeParent.h +++ b/dom/ipc/ContentBridgeParent.h @@ -76,17 +76,17 @@ protected: void SetIsForBrowser(bool aIsForBrowser) { mIsForBrowser = aIsForBrowser; } void Close() { - // Trick NS_NewRunnableMethod + // Trick NewRunnableMethod PContentBridgeParent::Close(); } protected: virtual bool RecvSyncMessage(const nsString& aMsg, const ClonedMessageData& aData, InfallibleTArray<jsipc::CpowEntry>&& aCpows,
--- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -2175,20 +2175,20 @@ ContentParent::ActorDestroy(ActorDestroy } } } } // Destroy any processes created by this ContentParent for(uint32_t i = 0; i < childIDArray.Length(); i++) { ContentParent* cp = cpm->GetContentProcessById(childIDArray[i]); - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<ShutDownMethod>(cp, &ContentParent::ShutDownProcess, - SEND_SHUTDOWN_MESSAGE); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod + <ShutDownMethod>(cp, + &ContentParent::ShutDownProcess, + SEND_SHUTDOWN_MESSAGE)); } cpm->RemoveContentProcess(this->ChildID()); if (mDriverCrashGuard) { mDriverCrashGuard->NotifyCrashed(); } } @@ -2259,20 +2259,20 @@ ContentParent::NotifyTabDestroyed(const // There can be more than one PBrowser for a given app process // because of popup windows. When the last one closes, shut // us down. ContentProcessManager* cpm = ContentProcessManager::GetSingleton(); nsTArray<TabId> tabIds = cpm->GetTabParentsByProcessId(this->ChildID()); if (tabIds.Length() == 1) { // In the case of normal shutdown, send a shutdown message to child to // allow it to perform shutdown tasks. - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<ShutDownMethod>(this, &ContentParent::ShutDownProcess, - SEND_SHUTDOWN_MESSAGE); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod + <ShutDownMethod>(this, + &ContentParent::ShutDownProcess, + SEND_SHUTDOWN_MESSAGE)); } } jsipc::CPOWManager* ContentParent::GetCPOWManager() { if (PJavaScriptParent* p = LoneManagedOrNullAsserts(ManagedPJavaScriptParent())) { return CPOWManagerFor(p);
--- a/dom/ipc/PreallocatedProcessManager.cpp +++ b/dom/ipc/PreallocatedProcessManager.cpp @@ -199,32 +199,30 @@ PreallocatedProcessManagerImpl::Enable() void PreallocatedProcessManagerImpl::AllocateAfterDelay() { if (!mEnabled || mPreallocatedAppProcess) { return; } - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle); MessageLoop::current()->PostDelayedTask( - runnable.forget(), + NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle), Preferences::GetUint("dom.ipc.processPrelaunch.delayMs", DEFAULT_ALLOCATE_DELAY)); } void PreallocatedProcessManagerImpl::AllocateOnIdle() { if (!mEnabled || mPreallocatedAppProcess) { return; } - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow); - MessageLoop::current()->PostIdleTask(runnable.forget()); + MessageLoop::current()->PostIdleTask(NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow)); } void PreallocatedProcessManagerImpl::AllocateNow() { if (!mEnabled || mPreallocatedAppProcess) { return; }
--- a/dom/ipc/ProcessHangMonitor.cpp +++ b/dom/ipc/ProcessHangMonitor.cpp @@ -282,18 +282,17 @@ void HangMonitorChild::ActorDestroy(ActorDestroyReason aWhy) { MOZ_RELEASE_ASSERT(MessageLoop::current() == MonitorLoop()); mIPCOpen = false; // We use a task here to ensure that IPDL is finished with this // HangMonitorChild before it gets deleted on the main thread. - RefPtr<Runnable> runnable = NS_NewNonOwningRunnableMethod(this, &HangMonitorChild::ShutdownOnThread); - MonitorLoop()->PostTask(runnable.forget()); + MonitorLoop()->PostTask(NewNonOwningRunnableMethod(this, &HangMonitorChild::ShutdownOnThread)); } bool HangMonitorChild::RecvTerminateScript() { MOZ_RELEASE_ASSERT(MessageLoop::current() == MonitorLoop()); MonitorAutoLock lock(mMonitor); @@ -369,24 +368,20 @@ HangMonitorChild::NotifySlowScript(nsITa TabId id; if (aTabChild) { RefPtr<TabChild> tabChild = static_cast<TabChild*>(aTabChild); id = tabChild->GetTabId(); } nsAutoCString filename(aFileName); - RefPtr<Runnable> runnable = - NS_NewNonOwningRunnableMethodWithArgs<TabId, - nsCString, - unsigned>(this, - &HangMonitorChild::NotifySlowScriptAsync, - id, filename, aLineNo); - MonitorLoop()->PostTask(runnable.forget()); - + MonitorLoop()->PostTask(NewNonOwningRunnableMethod + <TabId, nsCString, unsigned>(this, + &HangMonitorChild::NotifySlowScriptAsync, + id, filename, aLineNo)); return SlowScriptAction::Continue; } bool HangMonitorChild::IsDebuggerStartupComplete() { MOZ_RELEASE_ASSERT(NS_IsMainThread()); @@ -404,21 +399,19 @@ void HangMonitorChild::NotifyPluginHang(uint32_t aPluginId) { // main thread in the child MOZ_RELEASE_ASSERT(NS_IsMainThread()); mSentReport = true; // bounce to background thread - RefPtr<Runnable> runnable = - NS_NewNonOwningRunnableMethodWithArgs<uint32_t>(this, - &HangMonitorChild::NotifyPluginHangAsync, - aPluginId); - MonitorLoop()->PostTask(runnable.forget()); + MonitorLoop()->PostTask(NewNonOwningRunnableMethod<uint32_t>(this, + &HangMonitorChild::NotifyPluginHangAsync, + aPluginId)); } void HangMonitorChild::NotifyPluginHangAsync(uint32_t aPluginId) { MOZ_RELEASE_ASSERT(MessageLoop::current() == MonitorLoop()); // bounce back to parent on background thread @@ -430,18 +423,17 @@ HangMonitorChild::NotifyPluginHangAsync( void HangMonitorChild::ClearHang() { MOZ_ASSERT(NS_IsMainThread()); if (mSentReport) { // bounce to background thread - RefPtr<Runnable> runnable = NS_NewNonOwningRunnableMethod(this, &HangMonitorChild::ClearHangAsync); - MonitorLoop()->PostTask(runnable.forget()); + MonitorLoop()->PostTask(NewNonOwningRunnableMethod(this, &HangMonitorChild::ClearHangAsync)); MonitorAutoLock lock(mMonitor); mSentReport = false; mTerminateScript = false; mStartDebugger = false; mFinishedStartingDebugger = false; } } @@ -496,18 +488,18 @@ HangMonitorParent::Shutdown() MonitorAutoLock lock(mMonitor); if (mProcess) { mProcess->Clear(); mProcess = nullptr; } - RefPtr<Runnable> runnable = NS_NewNonOwningRunnableMethod(this, &HangMonitorParent::ShutdownOnThread); - MonitorLoop()->PostTask(runnable.forget()); + MonitorLoop()->PostTask(NewNonOwningRunnableMethod(this, + &HangMonitorParent::ShutdownOnThread)); while (!mShutdownDone) { mMonitor.Wait(); } } void HangMonitorParent::ShutdownOnThread() @@ -817,52 +809,52 @@ HangMonitoredProcess::TerminateScript() if (mHangData.type() != HangData::TSlowScriptData) { return NS_ERROR_UNEXPECTED; } if (!mActor) { return NS_ERROR_UNEXPECTED; } - RefPtr<Runnable> runnable = NS_NewNonOwningRunnableMethod(mActor, &HangMonitorParent::TerminateScript); - ProcessHangMonitor::Get()->MonitorLoop()->PostTask(runnable.forget()); + ProcessHangMonitor::Get()->MonitorLoop()->PostTask(NewNonOwningRunnableMethod(mActor, + &HangMonitorParent::TerminateScript)); return NS_OK; } NS_IMETHODIMP HangMonitoredProcess::BeginStartingDebugger() { MOZ_RELEASE_ASSERT(NS_IsMainThread()); if (mHangData.type() != HangData::TSlowScriptData) { return NS_ERROR_UNEXPECTED; } if (!mActor) { return NS_ERROR_UNEXPECTED; } - RefPtr<Runnable> runnable = NS_NewNonOwningRunnableMethod(mActor, &HangMonitorParent::BeginStartingDebugger); - ProcessHangMonitor::Get()->MonitorLoop()->PostTask(runnable.forget()); + ProcessHangMonitor::Get()->MonitorLoop()->PostTask(NewNonOwningRunnableMethod(mActor, + &HangMonitorParent::BeginStartingDebugger)); return NS_OK; } NS_IMETHODIMP HangMonitoredProcess::EndStartingDebugger() { MOZ_RELEASE_ASSERT(NS_IsMainThread()); if (mHangData.type() != HangData::TSlowScriptData) { return NS_ERROR_UNEXPECTED; } if (!mActor) { return NS_ERROR_UNEXPECTED; } - RefPtr<Runnable> runnable = NS_NewNonOwningRunnableMethod(mActor, &HangMonitorParent::EndStartingDebugger); - ProcessHangMonitor::Get()->MonitorLoop()->PostTask(runnable.forget()); + ProcessHangMonitor::Get()->MonitorLoop()->PostTask(NewNonOwningRunnableMethod(mActor, + &HangMonitorParent::EndStartingDebugger)); return NS_OK; } NS_IMETHODIMP HangMonitoredProcess::TerminatePlugin() { MOZ_RELEASE_ASSERT(NS_IsMainThread()); if (mHangData.type() != HangData::TPluginHangData) { @@ -1030,45 +1022,43 @@ mozilla::CreateHangMonitorParent(Content MOZ_RELEASE_ASSERT(NS_IsMainThread()); ProcessHangMonitor* monitor = ProcessHangMonitor::GetOrCreate(); HangMonitorParent* parent = new HangMonitorParent(monitor); HangMonitoredProcess* process = new HangMonitoredProcess(parent, aContentParent); parent->SetProcess(process); - RefPtr<Runnable> runnable = - NS_NewNonOwningRunnableMethodWithArgs<mozilla::ipc::Transport*, - base::ProcessId, - MessageLoop*>(parent, - &HangMonitorParent::Open, - aTransport, aOtherPid, - XRE_GetIOMessageLoop()); - monitor->MonitorLoop()->PostTask(runnable.forget()); + monitor->MonitorLoop()->PostTask(NewNonOwningRunnableMethod + <mozilla::ipc::Transport*, + base::ProcessId, + MessageLoop*>(parent, + &HangMonitorParent::Open, + aTransport, aOtherPid, + XRE_GetIOMessageLoop())); return parent; } PProcessHangMonitorChild* mozilla::CreateHangMonitorChild(mozilla::ipc::Transport* aTransport, base::ProcessId aOtherPid) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); ProcessHangMonitor* monitor = ProcessHangMonitor::GetOrCreate(); HangMonitorChild* child = new HangMonitorChild(monitor); - RefPtr<Runnable> runnable = - NS_NewNonOwningRunnableMethodWithArgs<mozilla::ipc::Transport*, - base::ProcessId, - MessageLoop*>(child, - &HangMonitorChild::Open, - aTransport, aOtherPid, - XRE_GetIOMessageLoop()); - monitor->MonitorLoop()->PostTask(runnable.forget()); + monitor->MonitorLoop()->PostTask(NewNonOwningRunnableMethod + <mozilla::ipc::Transport*, + base::ProcessId, + MessageLoop*>(child, + &HangMonitorChild::Open, + aTransport, aOtherPid, + XRE_GetIOMessageLoop())); return child; } MessageLoop* ProcessHangMonitor::MonitorLoop() { return mThread->message_loop();
--- a/dom/jsurl/nsJSProtocolHandler.cpp +++ b/dom/jsurl/nsJSProtocolHandler.cpp @@ -654,18 +654,17 @@ nsJSChannel::AsyncOpen(nsIStreamListener } // We're returning success from asyncOpen(), but we didn't open a // stream channel. We'll have to notify ourselves, but make sure to do // it asynchronously. method = &nsJSChannel::NotifyListener; } - nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this, method); - nsresult rv = NS_DispatchToCurrentThread(ev); + nsresult rv = NS_DispatchToCurrentThread(mozilla::NewRunnableMethod(this, method)); if (NS_FAILED(rv)) { loadGroup->RemoveRequest(this, nullptr, rv); mIsActive = false; CleanupStrongRefs(); } return rv; }
--- a/dom/media/AbstractMediaDecoder.h +++ b/dom/media/AbstractMediaDecoder.h @@ -69,20 +69,19 @@ public: return nullptr; } protected: virtual void UpdateEstimatedMediaDuration(int64_t aDuration) {}; public: void DispatchUpdateEstimatedMediaDuration(int64_t aDuration) { - nsCOMPtr<nsIRunnable> r = - NS_NewRunnableMethodWithArg<int64_t>(this, &AbstractMediaDecoder::UpdateEstimatedMediaDuration, - aDuration); - NS_DispatchToMainThread(r); + NS_DispatchToMainThread(NewRunnableMethod<int64_t>(this, + &AbstractMediaDecoder::UpdateEstimatedMediaDuration, + aDuration)); } virtual VideoFrameContainer* GetVideoFrameContainer() = 0; virtual mozilla::layers::ImageContainer* GetImageContainer() = 0; // Returns the owner of this media decoder. The owner should only be used // on the main thread. virtual MediaDecoderOwner* GetOwner() = 0;
--- a/dom/media/DOMMediaStream.cpp +++ b/dom/media/DOMMediaStream.cpp @@ -186,23 +186,23 @@ public: void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID, StreamTime aTrackOffset, uint32_t aTrackEvents, const MediaSegment& aQueuedMedia, MediaStream* aInputStream, TrackID aInputTrackID) override { if (aTrackEvents & TRACK_EVENT_CREATED) { nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArgs<TrackID, MediaSegment::Type, MediaStream*, TrackID>( + NewRunnableMethod<TrackID, MediaSegment::Type, MediaStream*, TrackID>( this, &OwnedStreamListener::DoNotifyTrackCreated, aID, aQueuedMedia.GetType(), aInputStream, aInputTrackID); aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); } else if (aTrackEvents & TRACK_EVENT_ENDED) { nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArgs<MediaStream*, TrackID>( + NewRunnableMethod<MediaStream*, TrackID>( this, &OwnedStreamListener::DoNotifyTrackEnded, aInputStream, aInputTrackID); aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); } } private: // These fields may only be accessed on the main thread @@ -276,26 +276,26 @@ public: void NotifyQueuedTrackChanges(MediaStreamGraph* aGraph, TrackID aID, StreamTime aTrackOffset, uint32_t aTrackEvents, const MediaSegment& aQueuedMedia, MediaStream* aInputStream, TrackID aInputTrackID) override { if (aTrackEvents & TRACK_EVENT_ENDED) { nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArgs<StorensRefPtrPassByPtr<MediaStream>, TrackID>( + NewRunnableMethod<StorensRefPtrPassByPtr<MediaStream>, TrackID>( this, &PlaybackStreamListener::DoNotifyTrackEnded, aInputStream, aInputTrackID); aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); } } void NotifyFinishedTrackCreation(MediaStreamGraph* aGraph) override { nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &PlaybackStreamListener::DoNotifyFinishedTrackCreation); + NewRunnableMethod(this, &PlaybackStreamListener::DoNotifyFinishedTrackCreation); aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); } private: // These fields may only be accessed on the main thread DOMMediaStream* mStream; };
--- a/dom/media/MediaDecoderReader.cpp +++ b/dom/media/MediaDecoderReader.cpp @@ -80,18 +80,17 @@ MediaDecoderReader::MediaDecoderReader(A MOZ_ASSERT(NS_IsMainThread()); if (mDecoder && mDecoder->DataArrivedEvent()) { mDataArrivedListener = mDecoder->DataArrivedEvent()->Connect( mTaskQueue, this, &MediaDecoderReader::NotifyDataArrived); } // Dispatch initialization that needs to happen on that task queue. - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(this, &MediaDecoderReader::InitializationTask); - mTaskQueue->Dispatch(r.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &MediaDecoderReader::InitializationTask)); } void MediaDecoderReader::InitializationTask() { if (!mDecoder) { return; }
--- a/dom/media/MediaDecoderReaderWrapper.cpp +++ b/dom/media/MediaDecoderReaderWrapper.cpp @@ -311,39 +311,39 @@ MediaDecoderReaderWrapper::UpdateBuffere &MediaDecoderReader::UpdateBufferedWithPromise); } void MediaDecoderReaderWrapper::ReleaseMediaResources() { MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn()); nsCOMPtr<nsIRunnable> r = - NS_NewRunnableMethod(mReader, &MediaDecoderReader::ReleaseMediaResources); + NewRunnableMethod(mReader, &MediaDecoderReader::ReleaseMediaResources); mReader->OwnerThread()->Dispatch(r.forget()); } void MediaDecoderReaderWrapper::SetIdle() { MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn()); nsCOMPtr<nsIRunnable> r = - NS_NewRunnableMethod(mReader, &MediaDecoderReader::SetIdle); + NewRunnableMethod(mReader, &MediaDecoderReader::SetIdle); mReader->OwnerThread()->Dispatch(r.forget()); } void MediaDecoderReaderWrapper::ResetDecode() { MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn()); mAudioDataRequest.DisconnectIfExists(); mVideoDataRequest.DisconnectIfExists(); nsCOMPtr<nsIRunnable> r = - NS_NewRunnableMethod(mReader, &MediaDecoderReader::ResetDecode); + NewRunnableMethod(mReader, &MediaDecoderReader::ResetDecode); mReader->OwnerThread()->Dispatch(r.forget()); } RefPtr<ShutdownPromise> MediaDecoderReaderWrapper::Shutdown() { MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn()); MOZ_ASSERT(!mRequestAudioDataCB);
--- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -889,17 +889,17 @@ bool MediaDecoderStateMachine::IsPlaying return mMediaSink->IsPlaying(); } nsresult MediaDecoderStateMachine::Init(MediaDecoder* aDecoder) { MOZ_ASSERT(NS_IsMainThread()); // Dispatch initialization that needs to happen on that task queue. - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<RefPtr<MediaDecoder>>( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod<RefPtr<MediaDecoder>>( this, &MediaDecoderStateMachine::InitializationTask, aDecoder); mTaskQueue->Dispatch(r.forget()); mAudioQueueListener = AudioQueue().PopEvent().Connect( mTaskQueue, this, &MediaDecoderStateMachine::OnAudioPopped); mVideoQueueListener = VideoQueue().PopEvent().Connect( mTaskQueue, this, &MediaDecoderStateMachine::OnVideoPopped); @@ -912,18 +912,17 @@ nsresult MediaDecoderStateMachine::Init( OwnerThread(), __func__, this, &MediaDecoderStateMachine::OnCDMProxyReady, &MediaDecoderStateMachine::OnCDMProxyNotReady)); #endif nsresult rv = mReader->Init(); NS_ENSURE_SUCCESS(rv, rv); - r = NS_NewRunnableMethod(this, &MediaDecoderStateMachine::ReadMetadata); - OwnerThread()->Dispatch(r.forget()); + OwnerThread()->Dispatch(NewRunnableMethod(this, &MediaDecoderStateMachine::ReadMetadata)); return NS_OK; } void MediaDecoderStateMachine::SetMediaDecoderReaderWrapperCallback() { mAudioCallbackID = @@ -1114,17 +1113,17 @@ void MediaDecoderStateMachine::Recompute MOZ_ASSERT(duration.ToMicroseconds() >= 0); mDuration = Some(duration); } void MediaDecoderStateMachine::DispatchSetDormant(bool aDormant) { - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<bool>( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod<bool>( this, &MediaDecoderStateMachine::SetDormant, aDormant); OwnerThread()->Dispatch(r.forget()); } void MediaDecoderStateMachine::SetDormant(bool aDormant) { MOZ_ASSERT(OnTaskQueue()); @@ -2440,19 +2439,17 @@ void MediaDecoderStateMachine::ScheduleStateMachine() { MOZ_ASSERT(OnTaskQueue()); if (mDispatchedStateMachine) { return; } mDispatchedStateMachine = true; - nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethod(this, &MediaDecoderStateMachine::RunStateMachine); - OwnerThread()->Dispatch(task.forget()); + OwnerThread()->Dispatch(NewRunnableMethod(this, &MediaDecoderStateMachine::RunStateMachine)); } void MediaDecoderStateMachine::ScheduleStateMachineIn(int64_t aMicroseconds) { MOZ_ASSERT(OnTaskQueue()); // mDelayedScheduler.Ensure() may Disconnect() // the promise, which must happen on the state // machine task queue. @@ -2701,28 +2698,28 @@ MediaDecoderStateMachine::DumpDebugInfo( } void MediaDecoderStateMachine::AddOutputStream(ProcessedMediaStream* aStream, bool aFinishWhenEnded) { MOZ_ASSERT(NS_IsMainThread()); DECODER_LOG("AddOutputStream aStream=%p!", aStream); mOutputStreamManager->Add(aStream, aFinishWhenEnded); - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<bool>( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod<bool>( this, &MediaDecoderStateMachine::SetAudioCaptured, true); OwnerThread()->Dispatch(r.forget()); } void MediaDecoderStateMachine::RemoveOutputStream(MediaStream* aStream) { MOZ_ASSERT(NS_IsMainThread()); DECODER_LOG("RemoveOutputStream=%p!", aStream); mOutputStreamManager->Remove(aStream); if (mOutputStreamManager->IsEmpty()) { - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<bool>( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod<bool>( this, &MediaDecoderStateMachine::SetAudioCaptured, false); OwnerThread()->Dispatch(r.forget()); } } size_t MediaDecoderStateMachine::SizeOfVideoQueue() const {
--- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -766,17 +766,17 @@ MediaFormatReader::ScheduleUpdate(TrackT } auto& decoder = GetDecoderData(aTrack); if (decoder.mUpdateScheduled) { return; } LOGV("SchedulingUpdate(%s)", TrackTypeToStr(aTrack)); decoder.mUpdateScheduled = true; RefPtr<nsIRunnable> task( - NS_NewRunnableMethodWithArg<TrackType>(this, &MediaFormatReader::Update, aTrack)); + NewRunnableMethod<TrackType>(this, &MediaFormatReader::Update, aTrack)); OwnerThread()->Dispatch(task.forget()); } bool MediaFormatReader::UpdateReceivedNewData(TrackType aTrack) { MOZ_ASSERT(OnTaskQueue()); auto& decoder = GetDecoderData(aTrack); @@ -1317,44 +1317,44 @@ MediaFormatReader::Output(TrackType aTra if (!aSample) { NS_WARNING("MediaFormatReader::Output() passed a null sample"); Error(aTrack); return; } RefPtr<nsIRunnable> task = - NS_NewRunnableMethodWithArgs<TrackType, MediaData*>( + NewRunnableMethod<TrackType, MediaData*>( this, &MediaFormatReader::NotifyNewOutput, aTrack, aSample); OwnerThread()->Dispatch(task.forget()); } void MediaFormatReader::DrainComplete(TrackType aTrack) { RefPtr<nsIRunnable> task = - NS_NewRunnableMethodWithArg<TrackType>( + NewRunnableMethod<TrackType>( this, &MediaFormatReader::NotifyDrainComplete, aTrack); OwnerThread()->Dispatch(task.forget()); } void MediaFormatReader::InputExhausted(TrackType aTrack) { RefPtr<nsIRunnable> task = - NS_NewRunnableMethodWithArg<TrackType>( + NewRunnableMethod<TrackType>( this, &MediaFormatReader::NotifyInputExhausted, aTrack); OwnerThread()->Dispatch(task.forget()); } void MediaFormatReader::Error(TrackType aTrack) { RefPtr<nsIRunnable> task = - NS_NewRunnableMethodWithArg<TrackType>( + NewRunnableMethod<TrackType>( this, &MediaFormatReader::NotifyError, aTrack); OwnerThread()->Dispatch(task.forget()); } void MediaFormatReader::Flush(TrackType aTrack) { MOZ_ASSERT(OnTaskQueue()); @@ -1464,19 +1464,17 @@ MediaFormatReader::Seek(SeekTarget aTarg return SeekPromise::CreateAndReject(NS_ERROR_FAILURE, __func__); } mOriginalSeekTarget = Some(aTarget); mPendingSeekTime = Some(aTarget.GetTime()); RefPtr<SeekPromise> p = mSeekPromise.Ensure(__func__); - RefPtr<nsIRunnable> task( - NS_NewRunnableMethod(this, &MediaFormatReader::AttemptSeek)); - OwnerThread()->Dispatch(task.forget()); + OwnerThread()->Dispatch(NewRunnableMethod(this, &MediaFormatReader::AttemptSeek)); return p; } void MediaFormatReader::AttemptSeek() { MOZ_ASSERT(OnTaskQueue());
--- a/dom/media/MediaFormatReader.h +++ b/dom/media/MediaFormatReader.h @@ -77,17 +77,17 @@ public: bool IsDemuxOnlySupported() const override { return true; } void SetDemuxOnly(bool aDemuxedOnly) override { if (OnTaskQueue()) { mDemuxOnly = aDemuxedOnly; return; } - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<bool>( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod<bool>( this, &MediaDecoderReader::SetDemuxOnly, aDemuxedOnly); OwnerThread()->Dispatch(r.forget()); } bool UseBufferingHeuristics() const override { return mTrackDemuxersMayBlock; }
--- a/dom/media/MediaManager.h +++ b/dom/media/MediaManager.h @@ -272,21 +272,21 @@ public: void NotifyEvent(MediaStreamGraph* aGraph, MediaStreamListener::MediaStreamGraphEvent aEvent) override { switch (aEvent) { case EVENT_FINISHED: NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &GetUserMediaCallbackMediaStreamListener::NotifyFinished)); + NewRunnableMethod(this, &GetUserMediaCallbackMediaStreamListener::NotifyFinished)); break; case EVENT_REMOVED: NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &GetUserMediaCallbackMediaStreamListener::NotifyRemoved)); + NewRunnableMethod(this, &GetUserMediaCallbackMediaStreamListener::NotifyRemoved)); break; case EVENT_HAS_DIRECT_LISTENERS: NotifyDirectListeners(aGraph, true); break; case EVENT_HAS_NO_DIRECT_LISTENERS: NotifyDirectListeners(aGraph, false); break; default:
--- a/dom/media/MediaRecorder.cpp +++ b/dom/media/MediaRecorder.cpp @@ -814,20 +814,18 @@ private: void DoSessionEndTask(nsresult rv) { MOZ_ASSERT(NS_IsMainThread()); CleanupStreams(); NS_DispatchToMainThread( new DispatchStartEventRunnable(this, NS_LITERAL_STRING("start"))); if (NS_FAILED(rv)) { - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<nsresult>(mRecorder, - &MediaRecorder::NotifyError, rv); - NS_DispatchToMainThread(runnable); + NS_DispatchToMainThread(NewRunnableMethod<nsresult>(mRecorder, + &MediaRecorder::NotifyError, rv)); } if (NS_FAILED(NS_DispatchToMainThread(new EncoderErrorNotifierRunnable(this)))) { MOZ_ASSERT(false, "NS_DispatchToMainThread EncoderErrorNotifierRunnable failed"); } if (rv != NS_ERROR_DOM_SECURITY_ERR) { // Don't push a blob if there was a security error. if (NS_FAILED(NS_DispatchToMainThread(new PushBlobRunnable(this)))) { MOZ_ASSERT(false, "NS_DispatchToMainThread PushBlobRunnable failed");
--- a/dom/media/MediaResource.cpp +++ b/dom/media/MediaResource.cpp @@ -51,19 +51,18 @@ namespace mozilla { void MediaResource::Destroy() { // Ensures we only delete the MediaResource on the main thread. if (NS_IsMainThread()) { delete this; return; } - nsCOMPtr<nsIRunnable> destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &MediaResource::Destroy); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(destroyRunnable)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewNonOwningRunnableMethod(this, &MediaResource::Destroy))); } NS_IMPL_ADDREF(MediaResource) NS_IMPL_RELEASE_WITH_DESTROY(MediaResource, Destroy()) NS_IMPL_QUERY_INTERFACE0(MediaResource) ChannelMediaResource::ChannelMediaResource(MediaResourceCallback* aCallback, nsIChannel* aChannel, @@ -866,17 +865,17 @@ ChannelMediaResource::CacheClientNotifyD NS_ASSERTION(NS_IsMainThread(), "Don't call on non-main thread"); // NOTE: this can be called with the media cache lock held, so don't // block or do anything which might try to acquire a lock! if (mDataReceivedEvent.IsPending()) return; mDataReceivedEvent = - NS_NewNonOwningRunnableMethod(this, &ChannelMediaResource::DoNotifyDataReceived); + NewNonOwningRunnableMethod(this, &ChannelMediaResource::DoNotifyDataReceived); NS_DispatchToMainThread(mDataReceivedEvent.get()); } void ChannelMediaResource::CacheClientNotifyDataEnded(nsresult aStatus) { MOZ_ASSERT(NS_IsMainThread()); mCallback->NotifyDataEnded(aStatus);
--- a/dom/media/MediaStreamTrack.cpp +++ b/dom/media/MediaStreamTrack.cpp @@ -84,17 +84,17 @@ public: mTrack->NotifyPrincipalHandleChanged(aNewPrincipalHandle); } void NotifyPrincipalHandleChanged(MediaStreamGraph* aGraph, const PrincipalHandle& aNewPrincipalHandle) override { nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArgs<StoreCopyPassByConstLRef<PrincipalHandle>>( + NewRunnableMethod<StoreCopyPassByConstLRef<PrincipalHandle>>( this, &PrincipalHandleListener::DoNotifyPrincipalHandleChanged, aNewPrincipalHandle); aGraph->DispatchToMainThreadAfterStreamStateUpdate(runnable.forget()); } protected: // These fields may only be accessed on the main thread MediaStreamTrack* mTrack; };
--- a/dom/media/MediaTimer.cpp +++ b/dom/media/MediaTimer.cpp @@ -33,22 +33,22 @@ MediaTimer::MediaTimer() SharedThreadPool::Get(NS_LITERAL_CSTRING("MediaTimer"), 1)); mThread = threadPool.get(); mTimer->SetTarget(mThread); } void MediaTimer::DispatchDestroy() { - nsCOMPtr<nsIRunnable> task = NS_NewNonOwningRunnableMethod(this, &MediaTimer::Destroy); // Hold a strong reference to the thread so that it doesn't get deleted in // Destroy(), which may run completely before the stack if Dispatch() begins // to unwind. nsCOMPtr<nsIEventTarget> thread = mThread; - nsresult rv = thread->Dispatch(task, NS_DISPATCH_NORMAL); + nsresult rv = thread->Dispatch(NewNonOwningRunnableMethod(this, &MediaTimer::Destroy), + NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); (void) rv; } void MediaTimer::Destroy() { MOZ_ASSERT(OnMediaTimerThread()); @@ -92,18 +92,18 @@ void MediaTimer::ScheduleUpdate() { mMonitor.AssertCurrentThreadOwns(); if (mUpdateScheduled) { return; } mUpdateScheduled = true; - nsCOMPtr<nsIRunnable> task = NS_NewRunnableMethod(this, &MediaTimer::Update); - nsresult rv = mThread->Dispatch(task, NS_DISPATCH_NORMAL); + nsresult rv = mThread->Dispatch(NewRunnableMethod(this, &MediaTimer::Update), + NS_DISPATCH_NORMAL); MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv)); (void) rv; } void MediaTimer::Update() { MonitorAutoLock mon(mMonitor);
--- a/dom/media/RtspMediaResource.cpp +++ b/dom/media/RtspMediaResource.cpp @@ -520,18 +520,18 @@ RtspMediaResource::~RtspMediaResource() } void RtspMediaResource::SetSuspend(bool aIsSuspend) { NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread"); RTSPMLOG("SetSuspend %d",aIsSuspend); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<bool>(this, &RtspMediaResource::NotifySuspend, - aIsSuspend); + NewRunnableMethod<bool>(this, &RtspMediaResource::NotifySuspend, + aIsSuspend); NS_DispatchToMainThread(runnable); } void RtspMediaResource::NotifySuspend(bool aIsSuspend) { NS_ASSERTION(NS_IsMainThread(), "Only call on main thread"); RTSPMLOG("NotifySuspend %d",aIsSuspend);
--- a/dom/media/eme/CDMCallbackProxy.cpp +++ b/dom/media/eme/CDMCallbackProxy.cpp @@ -217,26 +217,26 @@ CDMCallbackProxy::SessionClosed(const ns bool keyStatusesChange = false; { CDMCaps::AutoLock caps(mProxy->Capabilites()); keyStatusesChange = caps.RemoveKeysForSession(NS_ConvertUTF8toUTF16(aSessionId)); } if (keyStatusesChange) { nsCOMPtr<nsIRunnable> task; - task = NS_NewRunnableMethodWithArg<nsString>(mProxy, + task = NewRunnableMethod<nsString>(mProxy, &CDMProxy::OnKeyStatusesChange, NS_ConvertUTF8toUTF16(aSessionId)); NS_DispatchToMainThread(task); } nsCOMPtr<nsIRunnable> task; - task = NS_NewRunnableMethodWithArg<nsString>(mProxy, - &CDMProxy::OnSessionClosed, - NS_ConvertUTF8toUTF16(aSessionId)); + task = NewRunnableMethod<nsString>(mProxy, + &CDMProxy::OnSessionClosed, + NS_ConvertUTF8toUTF16(aSessionId)); NS_DispatchToMainThread(task); } class SessionErrorTask : public Runnable { public: SessionErrorTask(CDMProxy* aProxy, const nsCString& aSessionId, nsresult aException, @@ -290,19 +290,19 @@ CDMCallbackProxy::KeyStatusChanged(const { CDMCaps::AutoLock caps(mProxy->Capabilites()); keyStatusesChange = caps.SetKeyStatus(aKeyId, NS_ConvertUTF8toUTF16(aSessionId), aStatus); } if (keyStatusesChange) { nsCOMPtr<nsIRunnable> task; - task = NS_NewRunnableMethodWithArg<nsString>(mProxy, - &CDMProxy::OnKeyStatusesChange, - NS_ConvertUTF8toUTF16(aSessionId)); + task = NewRunnableMethod<nsString>(mProxy, + &CDMProxy::OnKeyStatusesChange, + NS_ConvertUTF8toUTF16(aSessionId)); NS_DispatchToMainThread(task); } } void CDMCallbackProxy::SetCaps(uint64_t aCaps) { MOZ_ASSERT(mProxy->IsOnGMPThread()); @@ -320,13 +320,13 @@ CDMCallbackProxy::Decrypted(uint32_t aId mProxy->gmp_Decrypted(aId, aResult, aDecryptedData); } void CDMCallbackProxy::Terminated() { MOZ_ASSERT(mProxy->IsOnGMPThread()); - nsCOMPtr<nsIRunnable> task = NS_NewRunnableMethod(mProxy, &CDMProxy::Terminated); + nsCOMPtr<nsIRunnable> task = NewRunnableMethod(mProxy, &CDMProxy::Terminated); NS_DispatchToMainThread(task); } } // namespace mozilla
--- a/dom/media/eme/CDMProxy.cpp +++ b/dom/media/eme/CDMProxy.cpp @@ -78,19 +78,19 @@ CDMProxy::Init(PromiseId aPromiseId, nsAutoPtr<InitData> data(new InitData()); data->mPromiseId = aPromiseId; data->mOrigin = aOrigin; data->mTopLevelOrigin = aTopLevelOrigin; data->mGMPName = aGMPName; data->mInPrivateBrowsing = aInPrivateBrowsing; nsCOMPtr<nsIRunnable> task( - NS_NewRunnableMethodWithArg<nsAutoPtr<InitData>>(this, - &CDMProxy::gmp_Init, - Move(data))); + NewRunnableMethod<nsAutoPtr<InitData>>(this, + &CDMProxy::gmp_Init, + Move(data))); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } #ifdef DEBUG bool CDMProxy::IsOnGMPThread() { return NS_GetCurrentThread() == mGMPThread; @@ -114,19 +114,19 @@ CDMProxy::gmp_InitDone(GMPDecryptorProxy NS_LITERAL_CSTRING("GetGMPDecryptor failed to return a CDM")); return; } mCDM = aCDM; mCallback = new CDMCallbackProxy(this); mCDM->Init(mCallback); nsCOMPtr<nsIRunnable> task( - NS_NewRunnableMethodWithArg<uint32_t>(this, - &CDMProxy::OnCDMCreated, - aData->mPromiseId)); + NewRunnableMethod<uint32_t>(this, + &CDMProxy::OnCDMCreated, + aData->mPromiseId)); NS_DispatchToMainThread(task); } class gmp_InitDoneCallback : public GetGMPDecryptorCallback { public: gmp_InitDoneCallback(CDMProxy* aCDMProxy, nsAutoPtr<CDMProxy::InitData>&& aData) @@ -265,17 +265,17 @@ CDMProxy::CreateSession(uint32_t aCreate nsAutoPtr<CreateSessionData> data(new CreateSessionData()); data->mSessionType = aSessionType; data->mCreateSessionToken = aCreateSessionToken; data->mPromiseId = aPromiseId; data->mInitDataType = NS_ConvertUTF16toUTF8(aInitDataType); data->mInitData = Move(aInitData); nsCOMPtr<nsIRunnable> task( - NS_NewRunnableMethodWithArg<nsAutoPtr<CreateSessionData>>(this, &CDMProxy::gmp_CreateSession, data)); + NewRunnableMethod<nsAutoPtr<CreateSessionData>>(this, &CDMProxy::gmp_CreateSession, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } GMPSessionType ToGMPSessionType(dom::SessionType aSessionType) { switch (aSessionType) { case dom::SessionType::Temporary: return kGMPTemporySession; case dom::SessionType::Persistent: return kGMPPersistentSession; @@ -305,17 +305,17 @@ CDMProxy::LoadSession(PromiseId aPromise { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(mGMPThread); nsAutoPtr<SessionOpData> data(new SessionOpData()); data->mPromiseId = aPromiseId; data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); nsCOMPtr<nsIRunnable> task( - NS_NewRunnableMethodWithArg<nsAutoPtr<SessionOpData>>(this, &CDMProxy::gmp_LoadSession, data)); + NewRunnableMethod<nsAutoPtr<SessionOpData>>(this, &CDMProxy::gmp_LoadSession, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } void CDMProxy::gmp_LoadSession(nsAutoPtr<SessionOpData> aData) { MOZ_ASSERT(IsOnGMPThread()); @@ -333,17 +333,17 @@ CDMProxy::SetServerCertificate(PromiseId { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(mGMPThread); nsAutoPtr<SetServerCertificateData> data(new SetServerCertificateData()); data->mPromiseId = aPromiseId; data->mCert = Move(aCert); nsCOMPtr<nsIRunnable> task( - NS_NewRunnableMethodWithArg<nsAutoPtr<SetServerCertificateData>>(this, &CDMProxy::gmp_SetServerCertificate, data)); + NewRunnableMethod<nsAutoPtr<SetServerCertificateData>>(this, &CDMProxy::gmp_SetServerCertificate, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } void CDMProxy::gmp_SetServerCertificate(nsAutoPtr<SetServerCertificateData> aData) { MOZ_ASSERT(IsOnGMPThread()); if (!mCDM) { @@ -363,17 +363,17 @@ CDMProxy::UpdateSession(const nsAString& MOZ_ASSERT(mGMPThread); NS_ENSURE_TRUE_VOID(!mKeys.IsNull()); nsAutoPtr<UpdateSessionData> data(new UpdateSessionData()); data->mPromiseId = aPromiseId; data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); data->mResponse = Move(aResponse); nsCOMPtr<nsIRunnable> task( - NS_NewRunnableMethodWithArg<nsAutoPtr<UpdateSessionData>>(this, &CDMProxy::gmp_UpdateSession, data)); + NewRunnableMethod<nsAutoPtr<UpdateSessionData>>(this, &CDMProxy::gmp_UpdateSession, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } void CDMProxy::gmp_UpdateSession(nsAutoPtr<UpdateSessionData> aData) { MOZ_ASSERT(IsOnGMPThread()); if (!mCDM) { @@ -392,17 +392,17 @@ CDMProxy::CloseSession(const nsAString& { MOZ_ASSERT(NS_IsMainThread()); NS_ENSURE_TRUE_VOID(!mKeys.IsNull()); nsAutoPtr<SessionOpData> data(new SessionOpData()); data->mPromiseId = aPromiseId; data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); nsCOMPtr<nsIRunnable> task( - NS_NewRunnableMethodWithArg<nsAutoPtr<SessionOpData>>(this, &CDMProxy::gmp_CloseSession, data)); + NewRunnableMethod<nsAutoPtr<SessionOpData>>(this, &CDMProxy::gmp_CloseSession, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } void CDMProxy::gmp_CloseSession(nsAutoPtr<SessionOpData> aData) { MOZ_ASSERT(IsOnGMPThread()); if (!mCDM) { @@ -419,17 +419,17 @@ CDMProxy::RemoveSession(const nsAString& { MOZ_ASSERT(NS_IsMainThread()); NS_ENSURE_TRUE_VOID(!mKeys.IsNull()); nsAutoPtr<SessionOpData> data(new SessionOpData()); data->mPromiseId = aPromiseId; data->mSessionId = NS_ConvertUTF16toUTF8(aSessionId); nsCOMPtr<nsIRunnable> task( - NS_NewRunnableMethodWithArg<nsAutoPtr<SessionOpData>>(this, &CDMProxy::gmp_RemoveSession, data)); + NewRunnableMethod<nsAutoPtr<SessionOpData>>(this, &CDMProxy::gmp_RemoveSession, data)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } void CDMProxy::gmp_RemoveSession(nsAutoPtr<SessionOpData> aData) { MOZ_ASSERT(IsOnGMPThread()); if (!mCDM) { @@ -441,17 +441,17 @@ CDMProxy::gmp_RemoveSession(nsAutoPtr<Se } void CDMProxy::Shutdown() { MOZ_ASSERT(NS_IsMainThread()); mKeys.Clear(); // Note: This may end up being the last owning reference to the CDMProxy. - nsCOMPtr<nsIRunnable> task(NS_NewRunnableMethod(this, &CDMProxy::gmp_Shutdown)); + nsCOMPtr<nsIRunnable> task(NewRunnableMethod(this, &CDMProxy::gmp_Shutdown)); if (mGMPThread) { mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); } } void CDMProxy::gmp_Shutdown() { @@ -493,19 +493,19 @@ CDMProxy::ResolvePromise(PromiseId aId) if (NS_IsMainThread()) { if (!mKeys.IsNull()) { mKeys->ResolvePromise(aId); } else { NS_WARNING("CDMProxy unable to resolve promise!"); } } else { nsCOMPtr<nsIRunnable> task; - task = NS_NewRunnableMethodWithArg<PromiseId>(this, - &CDMProxy::ResolvePromise, - aId); + task = NewRunnableMethod<PromiseId>(this, + &CDMProxy::ResolvePromise, + aId); NS_DispatchToMainThread(task); } } const nsCString& CDMProxy::GetNodeId() const { return mNodeId; @@ -654,17 +654,17 @@ CDMProxy::Capabilites() { RefPtr<CDMProxy::DecryptPromise> CDMProxy::Decrypt(MediaRawData* aSample) { RefPtr<DecryptJob> job(new DecryptJob(aSample)); RefPtr<DecryptPromise> promise(job->Ensure()); nsCOMPtr<nsIRunnable> task( - NS_NewRunnableMethodWithArg<RefPtr<DecryptJob>>(this, &CDMProxy::gmp_Decrypt, job)); + NewRunnableMethod<RefPtr<DecryptJob>>(this, &CDMProxy::gmp_Decrypt, job)); mGMPThread->Dispatch(task, NS_DISPATCH_NORMAL); return promise; } void CDMProxy::gmp_Decrypt(RefPtr<DecryptJob> aJob) { MOZ_ASSERT(IsOnGMPThread());
--- a/dom/media/gmp/GMPContentParent.cpp +++ b/dom/media/gmp/GMPContentParent.cpp @@ -129,18 +129,18 @@ GMPContentParent::CloseIfUnused() if (mParent) { toClose = mParent->ForgetGMPContentParent(); } else { toClose = this; RefPtr<GeckoMediaPluginServiceChild> gmp( GeckoMediaPluginServiceChild::GetSingleton()); gmp->RemoveGMPContentParent(toClose); } - NS_DispatchToCurrentThread(NS_NewRunnableMethod(toClose, - &GMPContentParent::Close)); + NS_DispatchToCurrentThread(NewRunnableMethod(toClose, + &GMPContentParent::Close)); } } nsresult GMPContentParent::GetGMPDecryptor(GMPDecryptorParent** aGMPDP) { PGMPDecryptorParent* pdp = SendPGMPDecryptorConstructor(); if (!pdp) {
--- a/dom/media/gmp/GMPContentParent.h +++ b/dom/media/gmp/GMPContentParent.h @@ -74,17 +74,17 @@ private: PGMPDecryptorParent* AllocPGMPDecryptorParent() override; bool DeallocPGMPDecryptorParent(PGMPDecryptorParent* aActor) override; PGMPAudioDecoderParent* AllocPGMPAudioDecoderParent() override; bool DeallocPGMPAudioDecoderParent(PGMPAudioDecoderParent* aActor) override; void CloseIfUnused(); - // Needed because NS_NewRunnableMethod tried to use the class that the method + // Needed because NewRunnableMethod tried to use the class that the method // lives on to store the receiver, but PGMPContentParent isn't refcounted. void Close() { PGMPContentParent::Close(); } nsTArray<RefPtr<GMPVideoDecoderParent>> mVideoDecoders; nsTArray<RefPtr<GMPVideoEncoderParent>> mVideoEncoders;
--- a/dom/media/gmp/GMPDecryptorChild.cpp +++ b/dom/media/gmp/GMPDecryptorChild.cpp @@ -166,22 +166,20 @@ GMPDecryptorChild::KeyStatusChanged(cons } void GMPDecryptorChild::Decrypted(GMPBuffer* aBuffer, GMPErr aResult) { if (!ON_GMP_THREAD()) { // We should run this whole method on the GMP thread since the buffer needs // to be deleted after the SendDecrypted call. - RefPtr<Runnable> t = - NS_NewRunnableMethodWithArgs<GMPBuffer*, - GMPErr>(this, - &GMPDecryptorChild::Decrypted, - aBuffer, aResult); - mPlugin->GMPMessageLoop()->PostTask(t.forget()); + mPlugin->GMPMessageLoop()->PostTask(NewRunnableMethod + <GMPBuffer*, GMPErr>(this, + &GMPDecryptorChild::Decrypted, + aBuffer, aResult)); return; } if (!aBuffer) { NS_WARNING("GMPDecryptorCallback passed bull GMPBuffer"); return; }
--- a/dom/media/gmp/GMPParent.cpp +++ b/dom/media/gmp/GMPParent.cpp @@ -498,17 +498,17 @@ GMPParent::ChildTerminated() if (!gmpThread) { // Bug 1163239 - this can happen on shutdown. // PluginTerminated removes the GMP from the GMPService. // On shutdown we can have this case where it is already been // removed so there is no harm in not trying to remove it again. LOGD("%s::%s: GMPThread() returned nullptr.", __CLASS__, __FUNCTION__); } else { - gmpThread->Dispatch(NS_NewRunnableMethodWithArg<RefPtr<GMPParent>>( + gmpThread->Dispatch(NewRunnableMethod<RefPtr<GMPParent>>( mService, &GeckoMediaPluginServiceParent::PluginTerminated, self), NS_DISPATCH_NORMAL); } } void @@ -517,17 +517,17 @@ GMPParent::DeleteProcess() LOGD("%s", __FUNCTION__); if (mState != GMPStateClosing) { // Don't Close() twice! // Probably remove when bug 1043671 is resolved mState = GMPStateClosing; Close(); } - mProcess->Delete(NS_NewRunnableMethod(this, &GMPParent::ChildTerminated)); + mProcess->Delete(NewRunnableMethod(this, &GMPParent::ChildTerminated)); LOGD("%s: Shut down process", __FUNCTION__); mProcess = nullptr; mState = GMPStateNotLoaded; NS_DispatchToMainThread( new NotifyGMPShutdownTask(NS_ConvertUTF8toUTF16(mNodeId)), NS_DISPATCH_NORMAL);
--- a/dom/media/gmp/GMPPlatform.cpp +++ b/dom/media/gmp/GMPPlatform.cpp @@ -68,18 +68,17 @@ public: void Post() { // We assert here for two reasons. // 1) Nobody should be blocking the main thread. // 2) This prevents deadlocks when doing sync calls to main which if the // main thread tries to do a sync call back to the calling thread. MOZ_ASSERT(!IsOnChildMainThread()); - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &GMPSyncRunnable::Run); - mMessageLoop->PostTask(runnable.forget()); + mMessageLoop->PostTask(NewRunnableMethod(this, &GMPSyncRunnable::Run)); MonitorAutoLock lock(mMonitor); while (!mDone) { lock.Wait(); } } void Run() { @@ -117,18 +116,17 @@ CreateThread(GMPThread** aThread) GMPErr RunOnMainThread(GMPTask* aTask) { if (!aTask || !sMainLoop) { return GMPGenericErr; } RefPtr<GMPRunnable> r = new GMPRunnable(aTask); - RefPtr<Runnable> runnable = NS_NewRunnableMethod(r, &GMPRunnable::Run); - sMainLoop->PostTask(runnable.forget()); + sMainLoop->PostTask(NewRunnableMethod(r, &GMPRunnable::Run)); return GMPNoErr; } GMPErr SyncRunOnMainThread(GMPTask* aTask) { if (!aTask || !sMainLoop || IsOnChildMainThread()) { @@ -250,18 +248,17 @@ GMPThreadImpl::Post(GMPTask* aTask) bool started = mThread.Start(); if (!started) { NS_WARNING("Unable to start GMPThread!"); return; } } RefPtr<GMPRunnable> r = new GMPRunnable(aTask); - RefPtr<Runnable> runnable = NS_NewRunnableMethod(r.get(), &GMPRunnable::Run); - mThread.message_loop()->PostTask(runnable.forget()); + mThread.message_loop()->PostTask(NewRunnableMethod(r.get(), &GMPRunnable::Run)); } void GMPThreadImpl::Join() { { MutexAutoLock lock(mMutex); if (mThread.IsRunning()) {
--- a/dom/media/gmp/GMPProcessParent.cpp +++ b/dom/media/gmp/GMPProcessParent.cpp @@ -73,18 +73,17 @@ GMPProcessParent::Launch(int32_t aTimeou return SyncLaunch(args, aTimeoutMs, base::GetCurrentProcessArchitecture()); } void GMPProcessParent::Delete(nsCOMPtr<nsIRunnable> aCallback) { mDeletedCallback = aCallback; - RefPtr<mozilla::Runnable> task = NS_NewNonOwningRunnableMethod(this, &GMPProcessParent::DoDelete); - XRE_GetIOMessageLoop()->PostTask(task.forget()); + XRE_GetIOMessageLoop()->PostTask(NewNonOwningRunnableMethod(this, &GMPProcessParent::DoDelete)); } void GMPProcessParent::DoDelete() { MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); Join();
--- a/dom/media/gmp/GMPService.cpp +++ b/dom/media/gmp/GMPService.cpp @@ -321,17 +321,26 @@ GeckoMediaPluginService::ShutdownGMPThre } if (gmpThread) { gmpThread->Shutdown(); } } nsresult -GeckoMediaPluginService::GMPDispatch(nsIRunnable* event, uint32_t flags) +GeckoMediaPluginService::GMPDispatch(nsIRunnable* event, + uint32_t flags) +{ + nsCOMPtr<nsIRunnable> r(event); + return GMPDispatch(r.forget()); +} + +nsresult +GeckoMediaPluginService::GMPDispatch(already_AddRefed<nsIRunnable> event, + uint32_t flags) { nsCOMPtr<nsIRunnable> r(event); nsCOMPtr<nsIThread> thread; nsresult rv = GetThread(getter_AddRefs(thread)); if (NS_FAILED(rv)) { return rv; } return thread->Dispatch(r, flags);
--- a/dom/media/gmp/GMPService.h +++ b/dom/media/gmp/GMPService.h @@ -85,16 +85,17 @@ protected: virtual void InitializePlugins() = 0; virtual bool GetContentParentFrom(const nsACString& aNodeId, const nsCString& aAPI, const nsTArray<nsCString>& aTags, UniquePtr<GetGMPContentParentCallback>&& aCallback) = 0; nsresult GMPDispatch(nsIRunnable* event, uint32_t flags = NS_DISPATCH_NORMAL); + nsresult GMPDispatch(already_AddRefed<nsIRunnable> event, uint32_t flags = NS_DISPATCH_NORMAL); void ShutdownGMPThread(); Mutex mMutex; // Protects mGMPThread and mGMPThreadShutdown and some members // in derived classes. nsCOMPtr<nsIThread> mGMPThread; RefPtr<AbstractThread> mAbstractGMPThread; bool mGMPThreadShutdown; bool mShuttingDownOnGMPThread;
--- a/dom/media/gmp/GMPServiceParent.cpp +++ b/dom/media/gmp/GMPServiceParent.cpp @@ -414,18 +414,18 @@ GeckoMediaPluginServiceParent::Observe(n if (gmpThread) { LOGD(("%s::%s Starting to unload plugins, waiting for first sync shutdown..." , __CLASS__, __FUNCTION__)); #ifdef MOZ_CRASHREPORTER SetAsyncShutdownPluginState(nullptr, '0', NS_LITERAL_CSTRING("Dispatching UnloadPlugins")); #endif gmpThread->Dispatch( - NS_NewRunnableMethod(this, - &GeckoMediaPluginServiceParent::UnloadPlugins), + NewRunnableMethod(this, + &GeckoMediaPluginServiceParent::UnloadPlugins), NS_DISPATCH_NORMAL); #ifdef MOZ_CRASHREPORTER SetAsyncShutdownPluginState(nullptr, '1', NS_LITERAL_CSTRING("Waiting for sync shutdown")); #endif // Wait for UnloadPlugins() to do initial sync shutdown... while (mWaitingForPluginsSyncShutdown) { @@ -488,27 +488,27 @@ GeckoMediaPluginServiceParent::Observe(n // mTempNodeIds. This drops all the node ids we've cached in memory // for PB origin-pairs. If we try to open an origin-pair for non-PB // mode, we'll get the NodeId salt stored on-disk, and if we try to // open a PB mode origin-pair, we'll re-generate new salt. mTempNodeIds.Clear(); } else if (!strcmp("browser:purge-session-history", aTopic)) { // Clear everything! if (!aSomeData || nsDependentString(aSomeData).IsEmpty()) { - return GMPDispatch(NS_NewRunnableMethod( + return GMPDispatch(NewRunnableMethod( this, &GeckoMediaPluginServiceParent::ClearStorage)); } // Clear nodeIds/records modified after |t|. nsresult rv; PRTime t = nsDependentString(aSomeData).ToInteger64(&rv, 10); if (NS_FAILED(rv)) { return rv; } - return GMPDispatch(NS_NewRunnableMethodWithArg<PRTime>( + return GMPDispatch(NewRunnableMethod<PRTime>( this, &GeckoMediaPluginServiceParent::ClearRecentHistoryOnGMPThread, t)); } return NS_OK; } RefPtr<GenericPromise> @@ -600,17 +600,17 @@ GeckoMediaPluginServiceParent::AsyncShut { MutexAutoLock lock(mMutex); mAsyncShutdownPlugins.RemoveElement(aParent); } if (mShuttingDownOnGMPThread) { // The main thread may be waiting for async shutdown of plugins, // one of which has completed. Wake up the main thread by sending a task. - nsCOMPtr<nsIRunnable> task(NS_NewRunnableMethod( + nsCOMPtr<nsIRunnable> task(NewRunnableMethod( this, &GeckoMediaPluginServiceParent::NotifyAsyncShutdownComplete)); NS_DispatchToMainThread(task); } } #ifdef MOZ_CRASHREPORTER void GeckoMediaPluginServiceParent::SetAsyncShutdownPluginState(GMPParent* aGMPParent, @@ -732,17 +732,17 @@ GeckoMediaPluginServiceParent::UnloadPlu #endif plugin->CloseActive(true); } #ifdef MOZ_CRASHREPORTER SetAsyncShutdownPluginState(nullptr, '3', NS_LITERAL_CSTRING("Dispatching sync-shutdown-complete")); #endif - nsCOMPtr<nsIRunnable> task(NS_NewRunnableMethod( + nsCOMPtr<nsIRunnable> task(NewRunnableMethod( this, &GeckoMediaPluginServiceParent::NotifySyncShutdownComplete)); NS_DispatchToMainThread(task); } void GeckoMediaPluginServiceParent::CrashPlugins() { LOGD(("%s::%s", __CLASS__, __FUNCTION__)); @@ -1744,17 +1744,17 @@ GeckoMediaPluginServiceParent::ClearRece NS_DispatchToMainThread(new NotifyObserversTask("gmp-clear-storage-complete"), NS_DISPATCH_NORMAL); } NS_IMETHODIMP GeckoMediaPluginServiceParent::ForgetThisSite(const nsAString& aSite) { MOZ_ASSERT(NS_IsMainThread()); - return GMPDispatch(NS_NewRunnableMethodWithArg<nsCString>( + return GMPDispatch(NewRunnableMethod<nsCString>( this, &GeckoMediaPluginServiceParent::ForgetThisSiteOnGMPThread, NS_ConvertUTF16toUTF8(aSite))); } static bool IsNodeIdValid(GMPParent* aParent) { return !aParent->GetNodeId().IsEmpty(); }
--- a/dom/media/gmp/GMPVideoDecoderChild.cpp +++ b/dom/media/gmp/GMPVideoDecoderChild.cpp @@ -221,18 +221,18 @@ GMPVideoDecoderChild::Alloc(size_t aSize MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current()); bool rv; #ifndef SHMEM_ALLOC_IN_CHILD ++mNeedShmemIntrCount; rv = CallNeedShmem(aSize, aMem); --mNeedShmemIntrCount; if (mPendingDecodeComplete) { - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &GMPVideoDecoderChild::RecvDecodingComplete); - mPlugin->GMPMessageLoop()->PostTask(runnable.forget()); + mPlugin->GMPMessageLoop()->PostTask( + NewRunnableMethod(this, &GMPVideoDecoderChild::RecvDecodingComplete)); } #else #ifdef GMP_SAFE_SHMEM rv = AllocShmem(aSize, aType, aMem); #else rv = AllocUnsafeShmem(aSize, aType, aMem); #endif #endif
--- a/dom/media/gmp/GMPVideoEncoderChild.cpp +++ b/dom/media/gmp/GMPVideoEncoderChild.cpp @@ -202,18 +202,18 @@ GMPVideoEncoderChild::Alloc(size_t aSize MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current()); bool rv; #ifndef SHMEM_ALLOC_IN_CHILD ++mNeedShmemIntrCount; rv = CallNeedShmem(aSize, aMem); --mNeedShmemIntrCount; if (mPendingEncodeComplete) { - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &GMPVideoEncoderChild::RecvEncodingComplete); - mPlugin->GMPMessageLoop()->PostTask(runnable.forget()); + mPlugin->GMPMessageLoop()->PostTask( + NewRunnableMethod(this, &GMPVideoEncoderChild::RecvEncodingComplete)); } #else #ifdef GMP_SAFE_SHMEM rv = AllocShmem(aSize, aType, aMem); #else rv = AllocUnsafeShmem(aSize, aType, aMem); #endif #endif
--- a/dom/media/gtest/GMPTestMonitor.h +++ b/dom/media/gtest/GMPTestMonitor.h @@ -31,17 +31,17 @@ private: { MOZ_ASSERT(NS_IsMainThread()); mFinished = true; } public: void SetFinished() { - NS_DispatchToMainThread(NS_NewNonOwningRunnableMethod(this, - &GMPTestMonitor::MarkFinished)); + NS_DispatchToMainThread(mozilla::NewNonOwningRunnableMethod(this, + &GMPTestMonitor::MarkFinished)); } private: bool mFinished; }; #endif // __GMPTestMonitor_h__
--- a/dom/media/gtest/TestGMPCrossOrigin.cpp +++ b/dom/media/gtest/TestGMPCrossOrigin.cpp @@ -299,18 +299,18 @@ EnumerateGMPStorageDir(const nsACString& } return EnumerateDir(path, aDirIter); } class GMPShutdownObserver : public nsIRunnable , public nsIObserver { public: - GMPShutdownObserver(nsIRunnable* aShutdownTask, - nsIRunnable* Continuation, + GMPShutdownObserver(already_AddRefed<nsIRunnable> aShutdownTask, + already_AddRefed<nsIRunnable> Continuation, const nsACString& aNodeId) : mShutdownTask(aShutdownTask) , mContinuation(Continuation) , mNodeId(NS_ConvertUTF8toUTF16(aNodeId)) {} NS_DECL_THREADSAFE_ISUPPORTS @@ -366,17 +366,17 @@ public: return NS_OK; } const char* mTopic; }; class ClearGMPStorageTask : public nsIRunnable , public nsIObserver { public: - ClearGMPStorageTask(nsIRunnable* Continuation, + ClearGMPStorageTask(already_AddRefed<nsIRunnable> Continuation, nsIThread* aTarget, PRTime aSince) : mContinuation(Continuation) , mTarget(aTarget) , mSince(aSince) {} NS_DECL_THREADSAFE_ISUPPORTS @@ -416,21 +416,21 @@ private: nsCOMPtr<nsIRunnable> mContinuation; nsCOMPtr<nsIThread> mTarget; const PRTime mSince; }; NS_IMPL_ISUPPORTS(ClearGMPStorageTask, nsIRunnable, nsIObserver) static void -ClearGMPStorage(nsIRunnable* aContinuation, +ClearGMPStorage(already_AddRefed<nsIRunnable> aContinuation, nsIThread* aTarget, PRTime aSince = -1) { RefPtr<ClearGMPStorageTask> task( - new ClearGMPStorageTask(aContinuation, aTarget, aSince)); + new ClearGMPStorageTask(Move(aContinuation), aTarget, aSince)); NS_DispatchToMainThread(task, NS_DISPATCH_NORMAL); } static void SimulatePBModeExit() { NS_DispatchToMainThread(new NotifyObserversTask("last-pb-context-exited"), NS_DISPATCH_SYNC); } @@ -511,17 +511,17 @@ AssertIsOnGMPThread() class GMPStorageTest : public GMPDecryptorProxyCallback { NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPStorageTest) void DoTest(void (GMPStorageTest::*aTestMethod)()) { EnsureNSSInitializedChromeOrContent(); nsCOMPtr<nsIThread> thread(GetGMPThread()); - ClearGMPStorage(NS_NewRunnableMethod(this, aTestMethod), thread); + ClearGMPStorage(NewRunnableMethod(this, aTestMethod), thread); AwaitFinished(); } GMPStorageTest() : mDecryptor(nullptr) , mMonitor("GMPStorageTest") , mFinished(false) { @@ -564,17 +564,17 @@ class GMPStorageTest : public GMPDecrypt // NodeIds for the same origin pair in non-pb mode should be the same. EXPECT_TRUE(nodeId1.Equals(nodeId2)); // Node ids for a given origin pair should be different for the PB origins should be the same in PB mode. EXPECT_TRUE(!PBnodeId1.Equals(nodeId1)); EXPECT_TRUE(!PBnodeId2.Equals(nodeId2)); nsCOMPtr<nsIThread> thread(GetGMPThread()); - ClearGMPStorage(NS_NewRunnableMethodWithArg<nsCString>( + ClearGMPStorage(NewRunnableMethod<nsCString>( this, &GMPStorageTest::TestGetNodeId_Continuation, nodeId1), thread); } void TestGetNodeId_Continuation(nsCString aNodeId1) { EXPECT_TRUE(IsGMPStorageIsEmpty()); // Once we clear storage, the node ids generated for the same origin-pair // should be different. @@ -676,17 +676,17 @@ class GMPStorageTest : public GMPDecrypt RefPtr<GeckoMediaPluginService> service = GeckoMediaPluginService::GetGeckoMediaPluginService(); // Send a message to the fake GMP for it to run its own tests internally. // It sends us a "test-storage complete" message when its passed, or // some other message if its tests fail. Expect(NS_LITERAL_CSTRING("test-storage complete"), - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), NS_LITERAL_STRING("http://example2.com"), false, NS_LITERAL_CSTRING("test-storage")); } /** @@ -695,33 +695,33 @@ class GMPStorageTest : public GMPDecrypt * 3. Check if the storage data for the forgotten site are erased correctly. * 4. Check if the storage data for other sites remain unchanged. */ void TestForgetThisSite() { AssertIsOnGMPThread(); EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod( this, &GMPStorageTest::TestForgetThisSite_AnotherSite); - Expect(NS_LITERAL_CSTRING("test-storage complete"), r); + Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), NS_LITERAL_STRING("http://example2.com"), false, NS_LITERAL_CSTRING("test-storage")); } void TestForgetThisSite_AnotherSite() { Shutdown(); // Generate storage data for another site. - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod( this, &GMPStorageTest::TestForgetThisSite_CollectSiteInfo); - Expect(NS_LITERAL_CSTRING("test-storage complete"), r); + Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example3.com"), NS_LITERAL_STRING("http://example4.com"), false, NS_LITERAL_CSTRING("test-storage")); } struct NodeInfo { @@ -746,33 +746,33 @@ class GMPStorageTest : public GMPDecrypt }; void TestForgetThisSite_CollectSiteInfo() { nsAutoPtr<NodeInfo> siteInfo( new NodeInfo(NS_LITERAL_CSTRING("http://example1.com"))); // Collect nodeIds that are expected to remain for later comparison. EnumerateGMPStorageDir(NS_LITERAL_CSTRING("id"), NodeIdCollector(siteInfo)); // Invoke "Forget this site" on the main thread. - NS_DispatchToMainThread(NS_NewRunnableMethodWithArg<nsAutoPtr<NodeInfo>>( + NS_DispatchToMainThread(NewRunnableMethod<nsAutoPtr<NodeInfo>>( this, &GMPStorageTest::TestForgetThisSite_Forget, siteInfo)); } void TestForgetThisSite_Forget(nsAutoPtr<NodeInfo> aSiteInfo) { RefPtr<GeckoMediaPluginServiceParent> service = GeckoMediaPluginServiceParent::GetSingleton(); service->ForgetThisSite(NS_ConvertUTF8toUTF16(aSiteInfo->siteToForget)); nsCOMPtr<nsIThread> thread; service->GetThread(getter_AddRefs(thread)); - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethodWithArg<nsAutoPtr<NodeInfo>>( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod<nsAutoPtr<NodeInfo>>( this, &GMPStorageTest::TestForgetThisSite_Verify, aSiteInfo); thread->Dispatch(r, NS_DISPATCH_NORMAL); - nsCOMPtr<nsIRunnable> f = NS_NewRunnableMethod( + nsCOMPtr<nsIRunnable> f = NewRunnableMethod( this, &GMPStorageTest::SetFinished); thread->Dispatch(f, NS_DISPATCH_NORMAL); } class NodeIdVerifier { public: explicit NodeIdVerifier(const NodeInfo* aInfo) : mNodeInfo(aInfo) @@ -828,19 +828,19 @@ class GMPStorageTest : public GMPDecrypt * 4. Check if all directories in $profileDir/gmp/$platform/gmp-fake/id/ and * $profileDir/gmp/$platform/gmp-fake/storage are removed. */ void TestClearRecentHistory1() { AssertIsOnGMPThread(); EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory1_Clear); - Expect(NS_LITERAL_CSTRING("test-storage complete"), r); + Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), NS_LITERAL_STRING("http://example2.com"), false, NS_LITERAL_CSTRING("test-storage")); } /** @@ -850,19 +850,19 @@ class GMPStorageTest : public GMPDecrypt * 4. Check if all directories in $profileDir/gmp/$platform/gmp-fake/id/ and * $profileDir/gmp/$platform/gmp-fake/storage are removed. */ void TestClearRecentHistory2() { AssertIsOnGMPThread(); EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory2_Clear); - Expect(NS_LITERAL_CSTRING("test-storage complete"), r); + Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), NS_LITERAL_STRING("http://example2.com"), false, NS_LITERAL_CSTRING("test-storage")); } /** @@ -872,19 +872,19 @@ class GMPStorageTest : public GMPDecrypt * 4. Check if all directories in $profileDir/gmp/$platform/gmp-fake/id/ and * $profileDir/gmp/$platform/gmp-fake/storage remain unchanged. */ void TestClearRecentHistory3() { AssertIsOnGMPThread(); EXPECT_TRUE(IsGMPStorageIsEmpty()); // Generate storage data for some site. - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory3_Clear); - Expect(NS_LITERAL_CSTRING("test-storage complete"), r); + Expect(NS_LITERAL_CSTRING("test-storage complete"), r.forget()); CreateDecryptor(NS_LITERAL_STRING("http://example1.com"), NS_LITERAL_STRING("http://example2.com"), false, NS_LITERAL_CSTRING("test-storage")); } class MaxMTimeFinder { @@ -903,42 +903,42 @@ class GMPStorageTest : public GMPDecrypt PRTime mMaxTime; }; void TestClearRecentHistory1_Clear() { MaxMTimeFinder f; nsresult rv = EnumerateGMPStorageDir(NS_LITERAL_CSTRING("id"), f); EXPECT_TRUE(NS_SUCCEEDED(rv)); - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory_CheckEmpty); nsCOMPtr<nsIThread> t(GetGMPThread()); - ClearGMPStorage(r, t, f.GetResult()); + ClearGMPStorage(r.forget(), t, f.GetResult()); } void TestClearRecentHistory2_Clear() { MaxMTimeFinder f; nsresult rv = EnumerateGMPStorageDir(NS_LITERAL_CSTRING("storage"), f); EXPECT_TRUE(NS_SUCCEEDED(rv)); - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory_CheckEmpty); nsCOMPtr<nsIThread> t(GetGMPThread()); - ClearGMPStorage(r, t, f.GetResult()); + ClearGMPStorage(r.forget(), t, f.GetResult()); } void TestClearRecentHistory3_Clear() { MaxMTimeFinder f; nsresult rv = EnumerateGMPStorageDir(NS_LITERAL_CSTRING("storage"), f); EXPECT_TRUE(NS_SUCCEEDED(rv)); - nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod( + nsCOMPtr<nsIRunnable> r = NewRunnableMethod( this, &GMPStorageTest::TestClearRecentHistory_CheckNonEmpty); nsCOMPtr<nsIThread> t(GetGMPThread()); - ClearGMPStorage(r, t, f.GetResult() + 1); + ClearGMPStorage(r.forget(), t, f.GetResult() + 1); } class FileCounter { public: FileCounter() : mCount(0) {} void operator()(nsIFile* aFile) { ++mCount; } @@ -982,17 +982,17 @@ class GMPStorageTest : public GMPDecrypt void TestCrossOriginStorage() { EXPECT_TRUE(!mDecryptor); // Send the decryptor the message "store recordid $time" // Wait for the decrytor to send us "stored recordid $time" auto t = time(0); nsCString response("stored crossOriginTestRecordId "); response.AppendInt((int64_t)t); - Expect(response, NS_NewRunnableMethod(this, + Expect(response, NewRunnableMethod(this, &GMPStorageTest::TestCrossOriginStorage_RecordStoredContinuation)); nsCString update("store crossOriginTestRecordId "); update.AppendInt((int64_t)t); // Open decryptor on one, origin, write a record, and test that that // record can't be read on another origin. CreateDecryptor(NS_LITERAL_STRING("http://example3.com"), @@ -1002,60 +1002,60 @@ class GMPStorageTest : public GMPDecrypt } void TestCrossOriginStorage_RecordStoredContinuation() { // Close the old decryptor, and create a new one on a different origin, // and try to read the record. Shutdown(); Expect(NS_LITERAL_CSTRING("retrieve crossOriginTestRecordId succeeded (length 0 bytes)"), - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example5.com"), NS_LITERAL_STRING("http://example6.com"), false, NS_LITERAL_CSTRING("retrieve crossOriginTestRecordId")); } void TestPBStorage() { // Send the decryptor the message "store recordid $time" // Wait for the decrytor to send us "stored recordid $time" nsCString response("stored pbdata test-pb-data"); - Expect(response, NS_NewRunnableMethod(this, + Expect(response, NewRunnableMethod(this, &GMPStorageTest::TestPBStorage_RecordStoredContinuation)); // Open decryptor on one, origin, write a record, close decryptor, // open another, and test that record can be read, close decryptor, // then send pb-last-context-closed notification, then open decryptor // and check that it can't read that data; it should have been purged. CreateDecryptor(NS_LITERAL_STRING("http://pb1.com"), NS_LITERAL_STRING("http://pb2.com"), true, NS_LITERAL_CSTRING("store pbdata test-pb-data")); } void TestPBStorage_RecordStoredContinuation() { Shutdown(); Expect(NS_LITERAL_CSTRING("retrieve pbdata succeeded (length 12 bytes)"), - NS_NewRunnableMethod(this, + NewRunnableMethod(this, &GMPStorageTest::TestPBStorage_RecordRetrievedContinuation)); CreateDecryptor(NS_LITERAL_STRING("http://pb1.com"), NS_LITERAL_STRING("http://pb2.com"), true, NS_LITERAL_CSTRING("retrieve pbdata")); } void TestPBStorage_RecordRetrievedContinuation() { Shutdown(); SimulatePBModeExit(); Expect(NS_LITERAL_CSTRING("retrieve pbdata succeeded (length 0 bytes)"), - NS_NewRunnableMethod(this, + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://pb1.com"), NS_LITERAL_STRING("http://pb2.com"), true, NS_LITERAL_CSTRING("retrieve pbdata")); } @@ -1068,20 +1068,20 @@ class GMPStorageTest : public GMPDecrypt nsCOMPtr<nsIThread> thread(GetGMPThread()); thread->Dispatch(aContinuation, NS_DISPATCH_NORMAL); } void CreateAsyncShutdownTimeoutGMP(const nsAString& aOrigin1, const nsAString& aOrigin2, void (GMPStorageTest::*aCallback)()) { nsCOMPtr<nsIRunnable> continuation( - NS_NewRunnableMethodWithArg<nsCOMPtr<nsIRunnable>>( + NewRunnableMethod<nsCOMPtr<nsIRunnable>>( this, &GMPStorageTest::NextAsyncShutdownTimeoutTest, - NS_NewRunnableMethod(this, aCallback))); + NewRunnableMethod(this, aCallback))); CreateDecryptor(aOrigin1, aOrigin2, false, continuation); } void TestAsyncShutdownTimeout() { // Create decryptors that timeout in their async shutdown. // If the gtest hangs on shutdown, test fails! CreateAsyncShutdownTimeoutGMP(NS_LITERAL_STRING("http://example7.com"), @@ -1110,63 +1110,63 @@ class GMPStorageTest : public GMPDecrypt nsCString token; token.AppendInt((int64_t)t); update.Append(token); // Wait for a response from the GMP, so we know it's had time to receive // the token. nsCString response("shutdown-token received "); response.Append(token); - Expect(response, NS_NewRunnableMethodWithArg<nsCString>(this, + Expect(response, NewRunnableMethod<nsCString>(this, &GMPStorageTest::TestAsyncShutdownStorage_ReceivedShutdownToken, token)); // Test that a GMP can write to storage during shutdown, and retrieve // that written data in a subsequent session. CreateDecryptor(NS_LITERAL_STRING("http://example13.com"), NS_LITERAL_STRING("http://example14.com"), false, update); } void TestAsyncShutdownStorage_ReceivedShutdownToken(const nsCString& aToken) { - ShutdownThen(NS_NewRunnableMethodWithArg<nsCString>(this, + ShutdownThen(NewRunnableMethod<nsCString>(this, &GMPStorageTest::TestAsyncShutdownStorage_AsyncShutdownComplete, aToken)); } void TestAsyncShutdownStorage_AsyncShutdownComplete(const nsCString& aToken) { // Create a new instance of the plugin, retrieve the token written // during shutdown and verify it is correct. nsCString response("retrieved shutdown-token "); response.Append(aToken); Expect(response, - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example13.com"), NS_LITERAL_STRING("http://example14.com"), false, NS_LITERAL_CSTRING("retrieve-shutdown-token")); } #if defined(XP_WIN) void TestOutputProtection() { Shutdown(); Expect(NS_LITERAL_CSTRING("OP tests completed"), - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example15.com"), NS_LITERAL_STRING("http://example16.com"), false, NS_LITERAL_CSTRING("test-op-apis")); } #endif void TestPluginVoucher() { Expect(NS_LITERAL_CSTRING("retrieved plugin-voucher: gmp-fake placeholder voucher"), - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); CreateDecryptor(NS_LITERAL_STRING("http://example17.com"), NS_LITERAL_STRING("http://example18.com"), false, NS_LITERAL_CSTRING("retrieve-plugin-voucher")); } void TestGetRecordNamesInMemoryStorage() { @@ -1200,35 +1200,35 @@ class GMPStorageTest : public GMPDecrypt AppendIntPadded(mRecordNames, i); nsCString& update = *updates.AppendElement(); update.AppendLiteral("store data"); AppendIntPadded(update, i); update.AppendLiteral(" test-data"); AppendIntPadded(update, i); - nsIRunnable* continuation = nullptr; + nsCOMPtr<nsIRunnable> continuation; if (i + 1 == num) { continuation = - NS_NewRunnableMethod(this, &GMPStorageTest::TestGetRecordNames_QueryNames); + NewRunnableMethod(this, &GMPStorageTest::TestGetRecordNames_QueryNames); } - Expect(response, continuation); + Expect(response, continuation.forget()); } CreateDecryptor(NS_LITERAL_STRING("http://foo.com"), NS_LITERAL_STRING("http://bar.com"), aPrivateBrowsing, Move(updates)); } void TestGetRecordNames_QueryNames() { nsCString response("record-names "); response.Append(mRecordNames); Expect(response, - NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + NewRunnableMethod(this, &GMPStorageTest::SetFinished)); Update(NS_LITERAL_CSTRING("retrieve-record-names")); } void GetRecordNamesPersistentStorage() { TestGetRecordNames(false); } void TestLongRecordNames() { @@ -1255,48 +1255,48 @@ class GMPStorageTest : public GMPDecrypt MOZ_ASSERT(longRecordName.Length() < GMP_MAX_RECORD_NAME_SIZE); MOZ_ASSERT(longRecordName.Length() > 260); // Windows MAX_PATH nsCString response("stored "); response.Append(longRecordName); response.AppendLiteral(" "); response.Append(data); - Expect(response, NS_NewRunnableMethod(this, &GMPStorageTest::SetFinished)); + Expect(response, NewRunnableMethod(this, &GMPStorageTest::SetFinished)); nsCString update("store "); update.Append(longRecordName); update.AppendLiteral(" "); update.Append(data); CreateDecryptor(NS_LITERAL_STRING("http://fuz.com"), NS_LITERAL_STRING("http://baz.com"), false, update); } - void Expect(const nsCString& aMessage, nsIRunnable* aContinuation) { - mExpected.AppendElement(ExpectedMessage(aMessage, aContinuation)); + void Expect(const nsCString& aMessage, already_AddRefed<nsIRunnable> aContinuation) { + mExpected.AppendElement(ExpectedMessage(aMessage, Move(aContinuation))); } void AwaitFinished() { while (!mFinished) { NS_ProcessNextEvent(nullptr, true); } mFinished = false; } - void ShutdownThen(nsIRunnable* aContinuation) { + void ShutdownThen(already_AddRefed<nsIRunnable> aContinuation) { EXPECT_TRUE(!!mDecryptor); if (!mDecryptor) { return; } EXPECT_FALSE(mNodeId.IsEmpty()); RefPtr<GMPShutdownObserver> task( - new GMPShutdownObserver(NS_NewRunnableMethod(this, &GMPStorageTest::Shutdown), - aContinuation, mNodeId)); + new GMPShutdownObserver(NewRunnableMethod(this, &GMPStorageTest::Shutdown), + Move(aContinuation), mNodeId)); NS_DispatchToMainThread(task, NS_DISPATCH_NORMAL); } void Shutdown() { if (mDecryptor) { mDecryptor->Close(); mDecryptor = nullptr; mNodeId = EmptyCString(); @@ -1304,17 +1304,17 @@ class GMPStorageTest : public GMPDecrypt } void Dummy() { } void SetFinished() { mFinished = true; Shutdown(); - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &GMPStorageTest::Dummy)); + NS_DispatchToMainThread(NewRunnableMethod(this, &GMPStorageTest::Dummy)); } void SessionMessage(const nsCString& aSessionId, GMPSessionMessageType aMessageType, const nsTArray<uint8_t>& aMessage) override { MonitorAutoLock mon(mMonitor); @@ -1359,17 +1359,17 @@ class GMPStorageTest : public GMPDecrypt mDecryptor = nullptr; } } private: ~GMPStorageTest() { } struct ExpectedMessage { - ExpectedMessage(const nsCString& aMessage, nsIRunnable* aContinuation) + ExpectedMessage(const nsCString& aMessage, already_AddRefed<nsIRunnable> aContinuation) : mMessage(aMessage) , mContinuation(aContinuation) {} nsCString mMessage; nsCOMPtr<nsIRunnable> mContinuation; }; nsTArray<ExpectedMessage> mExpected; @@ -1381,19 +1381,19 @@ private: }; void GMPTestRunner::DoTest(void (GMPTestRunner::*aTestMethod)(GMPTestMonitor&)) { nsCOMPtr<nsIThread> thread(GetGMPThread()); GMPTestMonitor monitor; - thread->Dispatch(NS_NewRunnableMethodWithArg<GMPTestMonitor&>(this, - aTestMethod, - monitor), + thread->Dispatch(NewRunnableMethod<GMPTestMonitor&>(this, + aTestMethod, + monitor), NS_DISPATCH_NORMAL); monitor.AwaitFinished(); } TEST(GeckoMediaPlugins, GMPTestCodec) { RefPtr<GMPTestRunner> runner = new GMPTestRunner(); runner->DoTest(&GMPTestRunner::RunTestGMPTestCodec1); runner->DoTest(&GMPTestRunner::RunTestGMPTestCodec2);
--- a/dom/media/gtest/TestGMPRemoveAndDelete.cpp +++ b/dom/media/gtest/TestGMPRemoveAndDelete.cpp @@ -255,33 +255,33 @@ GMPRemoveTest::Setup() bool GMPRemoveTest::CreateVideoDecoder(nsCString aNodeId) { GMPVideoHost* host; GMPVideoDecoderProxy* decoder = nullptr; mGMPThread->Dispatch( - NS_NewNonOwningRunnableMethodWithArgs<nsCString, GMPVideoDecoderProxy**, GMPVideoHost**>( + NewNonOwningRunnableMethod<nsCString, GMPVideoDecoderProxy**, GMPVideoHost**>( this, &GMPRemoveTest::gmp_GetVideoDecoder, aNodeId, &decoder, &host), NS_DISPATCH_NORMAL); mTestMonitor.AwaitFinished(); if (!decoder) { return false; } GMPVideoCodec codec; memset(&codec, 0, sizeof(codec)); codec.mGMPApiVersion = 33; nsTArray<uint8_t> empty; mGMPThread->Dispatch( - NS_NewNonOwningRunnableMethodWithArgs<const GMPVideoCodec&, const nsTArray<uint8_t>&, GMPVideoDecoderCallbackProxy*, int32_t>( + NewNonOwningRunnableMethod<const GMPVideoCodec&, const nsTArray<uint8_t>&, GMPVideoDecoderCallbackProxy*, int32_t>( decoder, &GMPVideoDecoderProxy::InitDecode, codec, empty, this, 1 /* core count */), NS_DISPATCH_SYNC); if (mDecoder) { CloseVideoDecoder(); } @@ -323,34 +323,34 @@ GMPRemoveTest::gmp_GetVideoDecoder(nsCSt mTestMonitor.SetFinished(); } } void GMPRemoveTest::CloseVideoDecoder() { mGMPThread->Dispatch( - NS_NewNonOwningRunnableMethod(mDecoder, &GMPVideoDecoderProxy::Close), + NewNonOwningRunnableMethod(mDecoder, &GMPVideoDecoderProxy::Close), NS_DISPATCH_SYNC); mDecoder = nullptr; mHost = nullptr; } void GMPRemoveTest::DeletePluginDirectory(bool aCanDefer) { GetServiceParent()->RemoveAndDeletePluginDirectory(mTmpPath, aCanDefer); } GMPErr GMPRemoveTest::Decode() { mGMPThread->Dispatch( - NS_NewNonOwningRunnableMethod(this, &GMPRemoveTest::gmp_Decode), + NewNonOwningRunnableMethod(this, &GMPRemoveTest::gmp_Decode), NS_DISPATCH_NORMAL); mTestMonitor.AwaitFinished(); return mDecodeResult; } void GMPRemoveTest::gmp_Decode()
--- a/dom/media/gtest/TestMP4Reader.cpp +++ b/dom/media/gtest/TestMP4Reader.cpp @@ -38,28 +38,28 @@ public: reader->Init(nullptr); // This needs to be done before invoking GetBuffered. This is normally // done by MediaDecoderStateMachine. reader->DispatchSetStartTime(0); } void Init() { nsCOMPtr<nsIThread> thread; - nsresult rv = NS_NewThread(getter_AddRefs(thread), - NS_NewRunnableMethod(this, &TestBinding::ReadMetadata)); + nsCOMPtr<nsIRunnable> r = NewRunnableMethod(this, &TestBinding::ReadMetadata); + nsresult rv = NS_NewThread(getter_AddRefs(thread), r); EXPECT_EQ(NS_OK, rv); thread->Shutdown(); } private: virtual ~TestBinding() { { RefPtr<TaskQueue> queue = reader->OwnerThread(); - nsCOMPtr<nsIRunnable> task = NS_NewRunnableMethod(reader, &MP4Reader::Shutdown); + nsCOMPtr<nsIRunnable> task = NewRunnableMethod(reader, &MP4Reader::Shutdown); // Hackily bypass the tail dispatcher so that we can AwaitShutdownAndIdle. // In production code we'd use BeginShutdown + promises. queue->Dispatch(task.forget(), AbstractThread::AssertDispatchSuccess, AbstractThread::TailDispatch); queue->AwaitShutdownAndIdle(); } decoder = nullptr; resource = nullptr;
--- a/dom/media/mediasink/DecodedStream.cpp +++ b/dom/media/mediasink/DecodedStream.cpp @@ -49,17 +49,17 @@ public: mStream->GraphTimeToStreamTime(aCurrentTime)); } } void NotifyEvent(MediaStreamGraph* aGraph, MediaStreamGraphEvent event) override { if (event == EVENT_FINISHED) { nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &DecodedStreamGraphListener::DoNotifyFinished); + NewRunnableMethod(this, &DecodedStreamGraphListener::DoNotifyFinished); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } } void DoNotifyFinished() { mFinishPromise.ResolveIfExists(true, __func__); } @@ -94,19 +94,19 @@ UpdateStreamSuspended(MediaStream* aStre if (aBlocking) { aStream->Suspend(); } else { aStream->Resume(); } } else { nsCOMPtr<nsIRunnable> r; if (aBlocking) { - r = NS_NewRunnableMethod(aStream, &MediaStream::Suspend); + r = NewRunnableMethod(aStream, &MediaStream::Suspend); } else { - r = NS_NewRunnableMethod(aStream, &MediaStream::Resume); + r = NewRunnableMethod(aStream, &MediaStream::Resume); } AbstractThread::MainThread()->Dispatch(r.forget()); } } /* * All MediaStream-related data is protected by the decoder's monitor. * We have at most one DecodedStreamDaata per MediaDecoder. Its stream
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp +++ b/dom/media/mediasource/MediaSourceDemuxer.cpp @@ -172,17 +172,17 @@ MediaSourceDemuxer::GetCrypto() *crypto = mInfo.mCrypto; return crypto; } void MediaSourceDemuxer::AttachSourceBuffer(TrackBuffersManager* aSourceBuffer) { nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethodWithArg<TrackBuffersManager*>( + NewRunnableMethod<TrackBuffersManager*>( this, &MediaSourceDemuxer::DoAttachSourceBuffer, aSourceBuffer); GetTaskQueue()->Dispatch(task.forget()); } void MediaSourceDemuxer::DoAttachSourceBuffer(mozilla::TrackBuffersManager* aSourceBuffer) { @@ -190,17 +190,17 @@ MediaSourceDemuxer::DoAttachSourceBuffer mSourceBuffers.AppendElement(aSourceBuffer); ScanSourceBuffersForContent(); } void MediaSourceDemuxer::DetachSourceBuffer(TrackBuffersManager* aSourceBuffer) { nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethodWithArg<TrackBuffersManager*>( + NewRunnableMethod<TrackBuffersManager*>( this, &MediaSourceDemuxer::DoDetachSourceBuffer, aSourceBuffer); GetTaskQueue()->Dispatch(task.forget()); } void MediaSourceDemuxer::DoDetachSourceBuffer(TrackBuffersManager* aSourceBuffer) {
--- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -196,19 +196,17 @@ TrackBuffersManager::ProcessTasks() break; case Type::Reset: CompleteResetParserState(); break; default: NS_WARNING("Invalid Task"); } } - nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethod(this, &TrackBuffersManager::ProcessTasks); - GetTaskQueue()->Dispatch(task.forget()); + GetTaskQueue()->Dispatch(NewRunnableMethod(this, &TrackBuffersManager::ProcessTasks)); } // A PromiseHolder will assert upon destruction if it has a pending promise // that hasn't been completed. It is possible that a task didn't get processed // due to the owning SourceBuffer having shutdown. // We resolve/reject all pending promises and remove all pending tasks from the // queue. void @@ -788,19 +786,17 @@ TrackBuffersManager::RejectAppend(nsresu } void TrackBuffersManager::ScheduleSegmentParserLoop() { if (mDetached) { return; } - nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethod(this, &TrackBuffersManager::SegmentParserLoop); - GetTaskQueue()->Dispatch(task.forget()); + GetTaskQueue()->Dispatch(NewRunnableMethod(this, &TrackBuffersManager::SegmentParserLoop)); } void TrackBuffersManager::ShutdownDemuxers() { if (mVideoTracks.mDemuxer) { mVideoTracks.mDemuxer->BreakCycles(); mVideoTracks.mDemuxer = nullptr; @@ -966,21 +962,20 @@ TrackBuffersManager::OnDemuxerInitDone(n } int64_t videoDuration = numVideos ? info.mVideo.mDuration : 0; int64_t audioDuration = numAudios ? info.mAudio.mDuration : 0; int64_t duration = std::max(videoDuration, audioDuration); // 1. Update the duration attribute if it currently equals NaN. // Those steps are performed by the MediaSourceDecoder::SetInitialDuration - nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethodWithArg<int64_t>(mParentDecoder, - &MediaSourceDecoder::SetInitialDuration, - duration ? duration : -1); - AbstractThread::MainThread()->Dispatch(task.forget()); + AbstractThread::MainThread()->Dispatch(NewRunnableMethod<int64_t> + (mParentDecoder, + &MediaSourceDecoder::SetInitialDuration, + duration ? duration : -1)); // 2. If the initialization segment has no audio, video, or text tracks, then // run the append error algorithm with the decode error parameter set to true // and abort these steps. if (!numVideos && !numAudios) { RejectAppend(NS_ERROR_FAILURE, __func__); return; }
--- a/dom/media/omx/AudioOffloadPlayer.cpp +++ b/dom/media/omx/AudioOffloadPlayer.cpp @@ -349,17 +349,17 @@ status_t AudioOffloadPlayer::DoSeek() ("DoSeek ( %lld )", mSeekTarget.GetTime().ToMicroseconds())); mReachedEOS = false; mPositionTimeMediaUs = -1; mStartPosUs = mSeekTarget.GetTime().ToMicroseconds(); if (!mSeekPromise.IsEmpty()) { nsCOMPtr<nsIRunnable> nsEvent = - NS_NewRunnableMethodWithArg<MediaDecoderEventVisibility>( + NewRunnableMethod<MediaDecoderEventVisibility>( mObserver, &MediaDecoder::SeekingStarted, mSeekTarget.mEventVisibility); NS_DispatchToCurrentThread(nsEvent); } if (mPlaying) { mAudioSink->Pause(); @@ -420,42 +420,39 @@ int64_t AudioOffloadPlayer::GetOutputPla void AudioOffloadPlayer::NotifyAudioEOS() { android::Mutex::Autolock autoLock(mLock); // We do not reset mSeekTarget here. if (!mSeekPromise.IsEmpty()) { MediaDecoder::SeekResolveValue val(mReachedEOS, mSeekTarget.mEventVisibility); mSeekPromise.Resolve(val, __func__); } - nsCOMPtr<nsIRunnable> nsEvent = NS_NewRunnableMethod(mObserver, - &MediaDecoder::PlaybackEnded); - NS_DispatchToMainThread(nsEvent); + NS_DispatchToMainThread(NewRunnableMethod(mObserver, + &MediaDecoder::PlaybackEnded)); } void AudioOffloadPlayer::NotifyPositionChanged() { - nsCOMPtr<nsIRunnable> nsEvent = - NS_NewRunnableMethod(mObserver, &MediaOmxCommonDecoder::NotifyOffloadPlayerPositionChanged); - NS_DispatchToMainThread(nsEvent); + NS_DispatchToMainThread(NewRunnableMethod(mObserver, + &MediaOmxCommonDecoder::NotifyOffloadPlayerPositionChanged)); } void AudioOffloadPlayer::NotifyAudioTearDown() { // Fallback to state machine. // state machine's seeks will be done with // MediaDecoderEventVisibility::Suppressed. android::Mutex::Autolock autoLock(mLock); // We do not reset mSeekTarget here. if (!mSeekPromise.IsEmpty()) { MediaDecoder::SeekResolveValue val(mReachedEOS, mSeekTarget.mEventVisibility); mSeekPromise.Resolve(val, __func__); } - nsCOMPtr<nsIRunnable> nsEvent = NS_NewRunnableMethod(mObserver, - &MediaOmxCommonDecoder::AudioOffloadTearDown); - NS_DispatchToMainThread(nsEvent); + NS_DispatchToMainThread(NewRunnableMethod(mObserver, + &MediaOmxCommonDecoder::AudioOffloadTearDown)); } // static size_t AudioOffloadPlayer::AudioSinkCallback(GonkAudioSink* aAudioSink, void* aBuffer, size_t aSize, void* aCookie, GonkAudioSink::cb_event_t aEvent)
--- a/dom/media/platforms/agnostic/OpusDecoder.cpp +++ b/dom/media/platforms/agnostic/OpusDecoder.cpp @@ -127,21 +127,19 @@ OpusDataDecoder::DecodeHeader(const unsi } return NS_OK; } nsresult OpusDataDecoder::Input(MediaRawData* aSample) { - nsCOMPtr<nsIRunnable> runnable( - NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>( - this, &OpusDataDecoder::Decode, - RefPtr<MediaRawData>(aSample))); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>( + this, &OpusDataDecoder::Decode, + RefPtr<MediaRawData>(aSample))); return NS_OK; } void OpusDataDecoder::Decode(MediaRawData* aSample) { if (DoDecode(aSample) == -1) { @@ -304,19 +302,17 @@ void OpusDataDecoder::DoDrain() { mCallback->DrainComplete(); } nsresult OpusDataDecoder::Drain() { - RefPtr<nsIRunnable> runnable( - NS_NewRunnableMethod(this, &OpusDataDecoder::DoDrain)); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &OpusDataDecoder::DoDrain)); return NS_OK; } nsresult OpusDataDecoder::Flush() { mTaskQueue->Flush(); if (mOpusDecoder) {
--- a/dom/media/platforms/agnostic/VPXDecoder.cpp +++ b/dom/media/platforms/agnostic/VPXDecoder.cpp @@ -181,37 +181,33 @@ VPXDecoder::DecodeFrame(MediaRawData* aS } else if (mTaskQueue->IsEmpty()) { mCallback->InputExhausted(); } } nsresult VPXDecoder::Input(MediaRawData* aSample) { - nsCOMPtr<nsIRunnable> runnable( - NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>( - this, &VPXDecoder::DecodeFrame, - RefPtr<MediaRawData>(aSample))); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>( + this, &VPXDecoder::DecodeFrame, + RefPtr<MediaRawData>(aSample))); return NS_OK; } void VPXDecoder::DoDrain() { mCallback->DrainComplete(); } nsresult VPXDecoder::Drain() { - nsCOMPtr<nsIRunnable> runnable( - NS_NewRunnableMethod(this, &VPXDecoder::DoDrain)); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &VPXDecoder::DoDrain)); return NS_OK; } /* static */ bool VPXDecoder::IsVPX(const nsACString& aMimeType, uint8_t aCodecMask) {
--- a/dom/media/platforms/agnostic/VorbisDecoder.cpp +++ b/dom/media/platforms/agnostic/VorbisDecoder.cpp @@ -124,21 +124,19 @@ VorbisDataDecoder::DecodeHeader(const un &mVorbisComment, &pkt); return r == 0 ? NS_OK : NS_ERROR_FAILURE; } nsresult VorbisDataDecoder::Input(MediaRawData* aSample) { - nsCOMPtr<nsIRunnable> runnable( - NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>( - this, &VorbisDataDecoder::Decode, - RefPtr<MediaRawData>(aSample))); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>( + this, &VorbisDataDecoder::Decode, + RefPtr<MediaRawData>(aSample))); return NS_OK; } void VorbisDataDecoder::Decode(MediaRawData* aSample) { if (DoDecode(aSample) == -1) { @@ -260,19 +258,17 @@ void VorbisDataDecoder::DoDrain() { mCallback->DrainComplete(); } nsresult VorbisDataDecoder::Drain() { - nsCOMPtr<nsIRunnable> runnable( - NS_NewRunnableMethod(this, &VorbisDataDecoder::DoDrain)); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &VorbisDataDecoder::DoDrain)); return NS_OK; } nsresult VorbisDataDecoder::Flush() { mTaskQueue->Flush(); // Ignore failed results from vorbis_synthesis_restart. They
--- a/dom/media/platforms/agnostic/WAVDecoder.cpp +++ b/dom/media/platforms/agnostic/WAVDecoder.cpp @@ -65,21 +65,19 @@ RefPtr<MediaDataDecoder::InitPromise> WaveDataDecoder::Init() { return InitPromise::CreateAndResolve(TrackInfo::kAudioTrack, __func__); } nsresult WaveDataDecoder::Input(MediaRawData* aSample) { - nsCOMPtr<nsIRunnable> runnable( - NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>( - this, &WaveDataDecoder::Decode, - RefPtr<MediaRawData>(aSample))); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod<RefPtr<MediaRawData>>( + this, &WaveDataDecoder::Decode, + RefPtr<MediaRawData>(aSample))); return NS_OK; } void WaveDataDecoder::Decode(MediaRawData* aSample) { if (!DoDecode(aSample)) { @@ -153,19 +151,17 @@ void WaveDataDecoder::DoDrain() { mCallback->DrainComplete(); } nsresult WaveDataDecoder::Drain() { - nsCOMPtr<nsIRunnable> runnable( - NS_NewRunnableMethod(this, &WaveDataDecoder::DoDrain)); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &WaveDataDecoder::DoDrain)); return NS_OK; } nsresult WaveDataDecoder::Flush() { mTaskQueue->Flush(); mFrames = 0; @@ -181,9 +177,9 @@ WaveDataDecoder::IsWave(const nsACString return aMimeType.EqualsLiteral("audio/x-wav") || aMimeType.EqualsLiteral("audio/wave; codecs=1") || aMimeType.EqualsLiteral("audio/wave; codecs=6") || aMimeType.EqualsLiteral("audio/wave; codecs=7") || aMimeType.EqualsLiteral("audio/wave; codecs=65534"); } } // namespace mozilla -#undef LOG \ No newline at end of file +#undef LOG
--- a/dom/media/platforms/agnostic/eme/SamplesWaitingForKey.cpp +++ b/dom/media/platforms/agnostic/eme/SamplesWaitingForKey.cpp @@ -47,17 +47,17 @@ SamplesWaitingForKey::WaitIfKeyNotUsable void SamplesWaitingForKey::NotifyUsable(const CencKeyId& aKeyId) { MutexAutoLock lock(mMutex); size_t i = 0; while (i < mSamples.Length()) { if (aKeyId == mSamples[i]->mCrypto.mKeyId) { RefPtr<nsIRunnable> task; - task = NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>(mDecoder, + task = NewRunnableMethod<RefPtr<MediaRawData>>(mDecoder, &MediaDataDecoder::Input, RefPtr<MediaRawData>(mSamples[i])); mSamples.RemoveElementAt(i); mTaskQueue->Dispatch(task.forget()); } else { i++; } }
--- a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp +++ b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp @@ -53,48 +53,44 @@ MediaDataDecoderProxy::Input(MediaRawDat nsresult MediaDataDecoderProxy::Flush() { MOZ_ASSERT(!IsOnProxyThread()); MOZ_ASSERT(!mIsShutdown); mFlushComplete.Set(false); - nsCOMPtr<nsIRunnable> task; - task = NS_NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Flush); - mProxyThread->Dispatch(task.forget()); + mProxyThread->Dispatch(NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Flush)); mFlushComplete.WaitUntil(true); return NS_OK; } nsresult MediaDataDecoderProxy::Drain() { MOZ_ASSERT(!IsOnProxyThread()); MOZ_ASSERT(!mIsShutdown); - nsCOMPtr<nsIRunnable> task; - task = NS_NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Drain); - mProxyThread->Dispatch(task.forget()); + mProxyThread->Dispatch(NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Drain)); return NS_OK; } nsresult MediaDataDecoderProxy::Shutdown() { // Note that this *may* be called from the proxy thread also. MOZ_ASSERT(!mIsShutdown); #if defined(DEBUG) mIsShutdown = true; #endif - nsCOMPtr<nsIRunnable> task; - task = NS_NewRunnableMethod(mProxyDecoder, &MediaDataDecoder::Shutdown); - nsresult rv = mProxyThread->AsXPCOMThread()->Dispatch(task, NS_DISPATCH_SYNC); + nsresult rv = mProxyThread->AsXPCOMThread()->Dispatch(NewRunnableMethod(mProxyDecoder, + &MediaDataDecoder::Shutdown), + NS_DISPATCH_SYNC); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } void MediaDataDecoderProxy::FlushComplete() { mFlushComplete.Set(true);
--- a/dom/media/platforms/android/AndroidDecoderModule.cpp +++ b/dom/media/platforms/android/AndroidDecoderModule.cpp @@ -384,19 +384,18 @@ MediaCodecDataDecoder::InitDecoder(Surfa nsresult rv; NS_ENSURE_SUCCESS(rv = mDecoder->Configure(mFormat, aSurface, nullptr, 0), rv); NS_ENSURE_SUCCESS(rv = mDecoder->Start(), rv); NS_ENSURE_SUCCESS(rv = ResetInputBuffers(), rv); NS_ENSURE_SUCCESS(rv = ResetOutputBuffers(), rv); - rv = NS_NewNamedThread( - "MC Decoder", getter_AddRefs(mThread), - NS_NewRunnableMethod(this, &MediaCodecDataDecoder::DecoderLoop)); + nsCOMPtr<nsIRunnable> r = NewRunnableMethod(this, &MediaCodecDataDecoder::DecoderLoop); + rv = NS_NewNamedThread("MC Decoder", getter_AddRefs(mThread), r); return rv; } // This is in usec, so that's 10ms. static const int64_t kDecoderTimeout = 10000; #define BREAK_ON_DECODER_ERROR() \
--- a/dom/media/platforms/apple/AppleATDecoder.cpp +++ b/dom/media/platforms/apple/AppleATDecoder.cpp @@ -69,17 +69,17 @@ AppleATDecoder::Input(MediaRawData* aSam aSample, aSample->mDuration, aSample->mTime, aSample->mKeyframe ? " keyframe" : "", (unsigned long long)aSample->Size()); // Queue a task to perform the actual decoding on a separate thread. nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>( + NewRunnableMethod<RefPtr<MediaRawData>>( this, &AppleATDecoder::SubmitSample, RefPtr<MediaRawData>(aSample)); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; }
--- a/dom/media/platforms/apple/AppleVDADecoder.cpp +++ b/dom/media/platforms/apple/AppleVDADecoder.cpp @@ -95,17 +95,17 @@ AppleVDADecoder::Init() nsresult AppleVDADecoder::Shutdown() { MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); mIsShutDown = true; if (mTaskQueue) { nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &AppleVDADecoder::ProcessShutdown); + NewRunnableMethod(this, &AppleVDADecoder::ProcessShutdown); mTaskQueue->Dispatch(runnable.forget()); } else { ProcessShutdown(); } return NS_OK; } void @@ -128,47 +128,47 @@ AppleVDADecoder::Input(MediaRawData* aSa aSample->mTime, aSample->mDuration, aSample->mKeyframe ? " keyframe" : "", aSample->Size()); mInputIncoming++; nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>( + NewRunnableMethod<RefPtr<MediaRawData>>( this, &AppleVDADecoder::SubmitFrame, RefPtr<MediaRawData>(aSample)); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; } nsresult AppleVDADecoder::Flush() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); mIsFlushing = true; mTaskQueue->Flush(); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &AppleVDADecoder::ProcessFlush); + NewRunnableMethod(this, &AppleVDADecoder::ProcessFlush); MonitorAutoLock mon(mMonitor); mTaskQueue->Dispatch(runnable.forget()); while (mIsFlushing) { mon.Wait(); } mInputIncoming = 0; return NS_OK; } nsresult AppleVDADecoder::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &AppleVDADecoder::ProcessDrain); + NewRunnableMethod(this, &AppleVDADecoder::ProcessDrain); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; } void AppleVDADecoder::ProcessFlush() { MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
--- a/dom/media/platforms/apple/AppleVTDecoder.cpp +++ b/dom/media/platforms/apple/AppleVTDecoder.cpp @@ -102,17 +102,17 @@ AppleVTDecoder::Input(MediaRawData* aSam digest.AppendPrintf("%02x", digest_buf[i]); } LOG(" sha1 %s", digest.get()); #endif // LOG_MEDIA_SHA1 mInputIncoming++; nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>( + NewRunnableMethod<RefPtr<MediaRawData>>( this, &AppleVTDecoder::SubmitFrame, aSample); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; } void AppleVTDecoder::ProcessFlush() {
--- a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.cpp @@ -170,17 +170,17 @@ FFmpegAudioDecoder<LIBAV_VER>::DecodePac if (mTaskQueue->IsEmpty()) { mCallback->InputExhausted(); } } nsresult FFmpegAudioDecoder<LIBAV_VER>::Input(MediaRawData* aSample) { - nsCOMPtr<nsIRunnable> runnable(NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>( + nsCOMPtr<nsIRunnable> runnable(NewRunnableMethod<RefPtr<MediaRawData>>( this, &FFmpegAudioDecoder::DecodePacket, RefPtr<MediaRawData>(aSample))); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; } void FFmpegAudioDecoder<LIBAV_VER>::ProcessDrain() {
--- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.cpp @@ -99,46 +99,46 @@ FFmpegDataDecoder<LIBAV_VER>::InitDecode return NS_OK; } nsresult FFmpegDataDecoder<LIBAV_VER>::Shutdown() { if (mTaskQueue) { nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &FFmpegDataDecoder<LIBAV_VER>::ProcessShutdown); + NewRunnableMethod(this, &FFmpegDataDecoder<LIBAV_VER>::ProcessShutdown); mTaskQueue->Dispatch(runnable.forget()); } else { ProcessShutdown(); } return NS_OK; } nsresult FFmpegDataDecoder<LIBAV_VER>::Flush() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); mIsFlushing = true; mTaskQueue->Flush(); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &FFmpegDataDecoder<LIBAV_VER>::ProcessFlush); + NewRunnableMethod(this, &FFmpegDataDecoder<LIBAV_VER>::ProcessFlush); MonitorAutoLock mon(mMonitor); mTaskQueue->Dispatch(runnable.forget()); while (mIsFlushing) { mon.Wait(); } return NS_OK; } nsresult FFmpegDataDecoder<LIBAV_VER>::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &FFmpegDataDecoder<LIBAV_VER>::ProcessDrain); + NewRunnableMethod(this, &FFmpegDataDecoder<LIBAV_VER>::ProcessDrain); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; } void FFmpegDataDecoder<LIBAV_VER>::ProcessFlush() { MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp @@ -326,17 +326,17 @@ FFmpegVideoDecoder<LIBAV_VER>::DecodeFra mCallback->InputExhausted(); } } nsresult FFmpegVideoDecoder<LIBAV_VER>::Input(MediaRawData* aSample) { nsCOMPtr<nsIRunnable> runnable( - NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>( + NewRunnableMethod<RefPtr<MediaRawData>>( this, &FFmpegVideoDecoder<LIBAV_VER>::DecodeFrame, RefPtr<MediaRawData>(aSample))); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; } void
--- a/dom/media/platforms/omx/OmxDataDecoder.cpp +++ b/dom/media/platforms/omx/OmxDataDecoder.cpp @@ -109,19 +109,17 @@ OmxDataDecoder::OmxDataDecoder(const Tra , mShuttingDown(false) , mCheckingInputExhausted(false) , mPortSettingsChanged(-1, "OmxDataDecoder::mPortSettingsChanged") , mCallback(aCallback) { LOG(""); mOmxLayer = new OmxPromiseLayer(mOmxTaskQueue, this, aImageContainer); - nsCOMPtr<nsIRunnable> r = - NS_NewRunnableMethod(this, &OmxDataDecoder::InitializationTask); - mOmxTaskQueue->Dispatch(r.forget()); + mOmxTaskQueue->Dispatch(NewRunnableMethod(this, &OmxDataDecoder::InitializationTask)); } OmxDataDecoder::~OmxDataDecoder() { LOG(""); } void @@ -204,19 +202,17 @@ OmxDataDecoder::Input(MediaRawData* aSam nsresult OmxDataDecoder::Flush() { LOG(""); mFlushing = true; - nsCOMPtr<nsIRunnable> r = - NS_NewRunnableMethod(this, &OmxDataDecoder::DoFlush); - mOmxTaskQueue->Dispatch(r.forget()); + mOmxTaskQueue->Dispatch(NewRunnableMethod(this, &OmxDataDecoder::DoFlush)); // According to the definition of Flush() in PDM: // "the decoder must be ready to accept new input for decoding". // So it needs to wait for the Omx to complete the flush command. MonitorAutoLock lock(mMonitor); while (mFlushing) { lock.Wait(); } @@ -224,33 +220,29 @@ OmxDataDecoder::Flush() return NS_OK; } nsresult OmxDataDecoder::Drain() { LOG(""); - nsCOMPtr<nsIRunnable> r = - NS_NewRunnableMethod(this, &OmxDataDecoder::SendEosBuffer); - mOmxTaskQueue->Dispatch(r.forget()); + mOmxTaskQueue->Dispatch(NewRunnableMethod(this, &OmxDataDecoder::SendEosBuffer)); return NS_OK; } nsresult OmxDataDecoder::Shutdown() { LOG(""); mShuttingDown = true; - nsCOMPtr<nsIRunnable> r = - NS_NewRunnableMethod(this, &OmxDataDecoder::DoAsyncShutdown); - mOmxTaskQueue->Dispatch(r.forget()); + mOmxTaskQueue->Dispatch(NewRunnableMethod(this, &OmxDataDecoder::DoAsyncShutdown)); { // DoAsyncShutdown() will be running for a while, it could be still running // when reader releasing the decoder and then it causes problem. To avoid it, // Shutdown() must block until DoAsyncShutdown() is completed. MonitorAutoLock lock(mMonitor); while (mShuttingDown) { lock.Wait();
--- a/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp +++ b/dom/media/platforms/wmf/WMFMediaDataDecoder.cpp @@ -74,19 +74,17 @@ SendTelemetry(unsigned long hr) } nsresult WMFMediaDataDecoder::Shutdown() { MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); if (mTaskQueue) { - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessShutdown); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessShutdown)); } else { ProcessShutdown(); } mIsShutDown = true; return NS_OK; } void @@ -104,17 +102,17 @@ WMFMediaDataDecoder::ProcessShutdown() // Inserts data into the decoder's pipeline. nsresult WMFMediaDataDecoder::Input(MediaRawData* aSample) { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>( + NewRunnableMethod<RefPtr<MediaRawData>>( this, &WMFMediaDataDecoder::ProcessDecode, RefPtr<MediaRawData>(aSample)); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; } void @@ -180,21 +178,19 @@ WMFMediaDataDecoder::ProcessFlush() } nsresult WMFMediaDataDecoder::Flush() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessFlush); MonitorAutoLock mon(mMonitor); mIsFlushing = true; - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessFlush)); while (mIsFlushing) { mon.Wait(); } return NS_OK; } void WMFMediaDataDecoder::ProcessDrain() @@ -214,36 +210,34 @@ WMFMediaDataDecoder::ProcessDrain() } nsresult WMFMediaDataDecoder::Drain() { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); MOZ_DIAGNOSTIC_ASSERT(!mIsShutDown); - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessDrain); - mTaskQueue->Dispatch(runnable.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &WMFMediaDataDecoder::ProcessDrain)); return NS_OK; } bool WMFMediaDataDecoder::IsHardwareAccelerated(nsACString& aFailureReason) const { MOZ_ASSERT(!mIsShutDown); return mMFTManager && mMFTManager->IsHardwareAccelerated(aFailureReason); } nsresult WMFMediaDataDecoder::ConfigurationChanged(const TrackInfo& aConfig) { MOZ_ASSERT(mCallback->OnReaderTaskQueue()); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<UniquePtr<TrackInfo>&&>( + NewRunnableMethod<UniquePtr<TrackInfo>&&>( this, &WMFMediaDataDecoder::ProcessConfigurationChanged, aConfig.Clone()); mTaskQueue->Dispatch(runnable.forget()); return NS_OK; }
--- a/dom/media/platforms/wrappers/FuzzingWrapper.cpp +++ b/dom/media/platforms/wrappers/FuzzingWrapper.cpp @@ -131,17 +131,17 @@ DecoderCallbackFuzzingWrapper::SetDontDe mDontDelayInputExhausted = aDontDelayInputExhausted; } void DecoderCallbackFuzzingWrapper::Output(MediaData* aData) { if (!mTaskQueue->IsCurrentThreadIn()) { nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethodWithArg<StorensRefPtrPassByPtr<MediaData>>( + NewRunnableMethod<StorensRefPtrPassByPtr<MediaData>>( this, &DecoderCallbackFuzzingWrapper::Output, aData); mTaskQueue->Dispatch(task.forget()); return; } CFW_LOGV("aData.mTime=%lld", aData->mTime); MOZ_ASSERT(mCallback); if (mFrameOutputMinimumInterval) { if (!mPreviousOutput.IsNull()) { @@ -171,34 +171,30 @@ DecoderCallbackFuzzingWrapper::Output(Me // callback should deal with that. mCallback->Output(aData); } void DecoderCallbackFuzzingWrapper::Error() { if (!mTaskQueue->IsCurrentThreadIn()) { - nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::Error); - mTaskQueue->Dispatch(task.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::Error)); return; } CFW_LOGV(""); MOZ_ASSERT(mCallback); ClearDelayedOutput(); mCallback->Error(); } void DecoderCallbackFuzzingWrapper::InputExhausted() { if (!mTaskQueue->IsCurrentThreadIn()) { - nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::InputExhausted); - mTaskQueue->Dispatch(task.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::InputExhausted)); return; } if (!mDontDelayInputExhausted && !mDelayedOutput.empty()) { MediaDataAndInputExhausted& last = mDelayedOutput.back(); CFW_LOGD("InputExhausted delayed until after output of sample@%lld", last.first()->mTime); last.second() = true; return; @@ -207,19 +203,17 @@ DecoderCallbackFuzzingWrapper::InputExha MOZ_ASSERT(mCallback); mCallback->InputExhausted(); } void DecoderCallbackFuzzingWrapper::DrainComplete() { if (!mTaskQueue->IsCurrentThreadIn()) { - nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::DrainComplete); - mTaskQueue->Dispatch(task.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::DrainComplete)); return; } MOZ_ASSERT(mCallback); if (mDelayedOutput.empty()) { // No queued output -> Draining is complete now. CFW_LOGV("No delayed output -> DrainComplete now"); mCallback->DrainComplete(); } else { @@ -228,19 +222,17 @@ DecoderCallbackFuzzingWrapper::DrainComp mDraining = true; } } void DecoderCallbackFuzzingWrapper::ReleaseMediaResources() { if (!mTaskQueue->IsCurrentThreadIn()) { - nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::ReleaseMediaResources); - mTaskQueue->Dispatch(task.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::ReleaseMediaResources)); return; } CFW_LOGV(""); MOZ_ASSERT(mCallback); mCallback->ReleaseMediaResources(); } bool @@ -312,19 +304,17 @@ DecoderCallbackFuzzingWrapper::OutputDel } } void DecoderCallbackFuzzingWrapper::ClearDelayedOutput() { if (!mTaskQueue->IsCurrentThreadIn()) { DFW_LOGV("(dispatching self)"); - nsCOMPtr<nsIRunnable> task = - NS_NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::ClearDelayedOutput); - mTaskQueue->Dispatch(task.forget()); + mTaskQueue->Dispatch(NewRunnableMethod(this, &DecoderCallbackFuzzingWrapper::ClearDelayedOutput)); return; } DFW_LOGV(""); // In case a timer hasn't lapsed yet, before destroying the timer and its // attached waitUntil() promise, the 'Then' request must be disconnected. mDelayedOutputRequest.DisconnectIfExists(); mDelayedOutputTimer = nullptr; mDelayedOutput.clear();
--- a/dom/media/systemservices/MediaSystemResourceManager.cpp +++ b/dom/media/systemservices/MediaSystemResourceManager.cpp @@ -193,22 +193,21 @@ MediaSystemResourceManager::Acquire(Medi return; } // State Check if (aClient->mResourceState != MediaSystemResourceClient::RESOURCE_STATE_START) { HandleAcquireResult(aClient->mId, false); return; } aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING; - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<uint32_t>( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod<uint32_t>( this, &MediaSystemResourceManager::DoAcquire, - aClient->mId); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aClient->mId)); } bool MediaSystemResourceManager::AcquireSyncNoWait(MediaSystemResourceClient* aClient) { MOZ_ASSERT(aClient); MOZ_ASSERT(!InImageBridgeChildThread()); @@ -237,22 +236,21 @@ MediaSystemResourceManager::AcquireSyncN return false; } // Hold barrier Monitor until acquire task end. aClient->mAcquireSyncWaitMonitor = &barrier; aClient->mAcquireSyncWaitDone = &done; aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING; } - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<uint32_t>( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod<uint32_t>( this, &MediaSystemResourceManager::DoAcquire, - aClient->mId); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aClient->mId)); // should stop the thread until done. while (!done) { barrier.Wait(); } { ReentrantMonitorAutoEnter mon(mReentrantMonitor); @@ -305,22 +303,21 @@ MediaSystemResourceManager::ReleaseResou aClient->mResourceState == MediaSystemResourceClient::RESOURCE_STATE_END) { aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_END; return; } aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_END; - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<uint32_t>( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod<uint32_t>( this, &MediaSystemResourceManager::DoRelease, - aClient->mId); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aClient->mId)); } } void MediaSystemResourceManager::DoRelease(uint32_t aId) { MOZ_ASSERT(InImageBridgeChildThread()); if (mShutDown || !mChild) { @@ -334,23 +331,22 @@ MediaSystemResourceManager::RecvResponse { HandleAcquireResult(aId, aSuccess); } void MediaSystemResourceManager::HandleAcquireResult(uint32_t aId, bool aSuccess) { if (!InImageBridgeChildThread()) { - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<uint32_t, bool>( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod<uint32_t, bool>( this, &MediaSystemResourceManager::HandleAcquireResult, aId, - aSuccess); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aSuccess)); return; } ReentrantMonitorAutoEnter mon(mReentrantMonitor); MediaSystemResourceClient* client = mResourceClients.Get(aId); if (!client) { // Client was already unregistered. return;
--- a/dom/media/webaudio/AudioDestinationNode.cpp +++ b/dom/media/webaudio/AudioDestinationNode.cpp @@ -400,19 +400,18 @@ AudioDestinationNode::DestroyMediaStream } void AudioDestinationNode::NotifyMainThreadStreamFinished() { MOZ_ASSERT(mStream->IsFinished()); if (mIsOffline) { - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &AudioDestinationNode::FireOfflineCompletionEvent); - NS_DispatchToCurrentThread(runnable); + NS_DispatchToCurrentThread(NewRunnableMethod(this, + &AudioDestinationNode::FireOfflineCompletionEvent)); } } void AudioDestinationNode::FireOfflineCompletionEvent() { OfflineDestinationNodeEngine* engine = static_cast<OfflineDestinationNodeEngine*>(Stream()->Engine());
--- a/dom/media/webaudio/MediaBufferDecoder.cpp +++ b/dom/media/webaudio/MediaBufferDecoder.cpp @@ -117,17 +117,17 @@ public: private: void ReportFailureOnMainThread(WebAudioDecodeJob::ErrorCode aErrorCode) { if (NS_IsMainThread()) { Cleanup(); mDecodeJob.OnFailure(aErrorCode); } else { // Take extra care to cleanup on the main thread - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &MediaDecodeTask::Cleanup)); + NS_DispatchToMainThread(NewRunnableMethod(this, &MediaDecodeTask::Cleanup)); nsCOMPtr<nsIRunnable> event = new ReportResultTask(mDecodeJob, &WebAudioDecodeJob::OnFailure, aErrorCode); NS_DispatchToMainThread(event); } } void Decode();
--- a/dom/media/webaudio/blink/ReverbConvolver.cpp +++ b/dom/media/webaudio/blink/ReverbConvolver.cpp @@ -146,18 +146,18 @@ ReverbConvolver::ReverbConvolver(const f // Start up background thread // FIXME: would be better to up the thread priority here. It doesn't need to be real-time, but higher than the default... if (this->useBackgroundThreads() && m_backgroundStages.Length() > 0) { if (!m_backgroundThread.Start()) { NS_WARNING("Cannot start convolver thread."); return; } - RefPtr<Runnable> runnable = NS_NewNonOwningRunnableMethod(this, &ReverbConvolver::backgroundThreadEntry); - m_backgroundThread.message_loop()->PostTask(runnable.forget()); + m_backgroundThread.message_loop()->PostTask(NewNonOwningRunnableMethod(this, + &ReverbConvolver::backgroundThreadEntry)); } } ReverbConvolver::~ReverbConvolver() { // Wait for background thread to stop if (useBackgroundThreads() && m_backgroundThread.IsRunning()) { m_wantsToExit = true;
--- a/dom/media/webspeech/synth/nsSpeechTask.cpp +++ b/dom/media/webspeech/synth/nsSpeechTask.cpp @@ -56,22 +56,22 @@ public: MediaStreamListener::MediaStreamGraphEvent event) override { switch (event) { case EVENT_FINISHED: { if (!mStarted) { mStarted = true; nsCOMPtr<nsIRunnable> startRunnable = - NS_NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted); + NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted); aGraph->DispatchToMainThreadAfterStreamStateUpdate(startRunnable.forget()); } nsCOMPtr<nsIRunnable> endRunnable = - NS_NewRunnableMethod(this, &SynthStreamListener::DoNotifyFinished); + NewRunnableMethod(this, &SynthStreamListener::DoNotifyFinished); aGraph->DispatchToMainThreadAfterStreamStateUpdate(endRunnable.forget()); } break; case EVENT_REMOVED: mSpeechTask = nullptr; // Dereference MediaStream to destroy safety mStream = nullptr; break; @@ -80,17 +80,17 @@ public: } } void NotifyBlockingChanged(MediaStreamGraph* aGraph, Blocking aBlocked) override { if (aBlocked == MediaStreamListener::UNBLOCKED && !mStarted) { mStarted = true; nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted); + NewRunnableMethod(this, &SynthStreamListener::DoNotifyStarted); aGraph->DispatchToMainThreadAfterStreamStateUpdate(event.forget()); } } private: // Raw pointer; if we exist, the stream exists, // and 'mSpeechTask' exclusively owns it and therefor exists as well. nsSpeechTask* mSpeechTask;
--- a/dom/media/webspeech/synth/pico/nsPicoService.cpp +++ b/dom/media/webspeech/synth/pico/nsPicoService.cpp @@ -464,17 +464,17 @@ nsPicoService::Observe(nsISupports* aSub if (!Preferences::GetBool("media.webspeech.synth.enabled") || Preferences::GetBool("media.webspeech.synth.test")) { return NS_OK; } DebugOnly<nsresult> rv = NS_NewNamedThread("Pico Worker", getter_AddRefs(mThread)); MOZ_ASSERT(NS_SUCCEEDED(rv)); return mThread->Dispatch( - NS_NewRunnableMethod(this, &nsPicoService::Init), NS_DISPATCH_NORMAL); + NewRunnableMethod(this, &nsPicoService::Init), NS_DISPATCH_NORMAL); } // nsISpeechService NS_IMETHODIMP nsPicoService::Speak(const nsAString& aText, const nsAString& aUri, float aVolume, float aRate, float aPitch, nsISpeechTask* aTask) { @@ -574,17 +574,17 @@ nsPicoService::Init() rv = voiceFile->GetPersistentDescriptor(voice->mSgFile); MOZ_ASSERT(NS_SUCCEEDED(rv)); } } rv = dirIterator->HasMoreElements(&hasMoreElements); } - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &nsPicoService::RegisterVoices)); + NS_DispatchToMainThread(NewRunnableMethod(this, &nsPicoService::RegisterVoices)); } void nsPicoService::RegisterVoices() { nsSynthVoiceRegistry* registry = nsSynthVoiceRegistry::GetInstance(); for (auto iter = mVoices.Iter(); !iter.Done(); iter.Next()) {
--- a/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp +++ b/dom/media/webspeech/synth/speechd/SpeechDispatcherService.cpp @@ -269,17 +269,17 @@ SpeechDispatcherCallback::OnSpeechEvent( static void speechd_cb(size_t msg_id, size_t client_id, SPDNotificationType state) { SpeechDispatcherService* service = SpeechDispatcherService::GetInstance(false); if (service) { NS_DispatchToMainThread( - NS_NewRunnableMethodWithArgs<uint32_t, SPDNotificationType>( + NewRunnableMethod<uint32_t, SPDNotificationType>( service, &SpeechDispatcherService::EventNotify, static_cast<uint32_t>(msg_id), state)); } } NS_INTERFACE_MAP_BEGIN(SpeechDispatcherService) NS_INTERFACE_MAP_ENTRY(nsISpeechService) @@ -306,17 +306,17 @@ SpeechDispatcherService::Init() // While speech dispatcher has a "threaded" mode, only spd_say() is async. // Since synchronous socket i/o could impact startup time, we do // initialization in a separate thread. DebugOnly<nsresult> rv = NS_NewNamedThread("speechd init", getter_AddRefs(mInitThread)); MOZ_ASSERT(NS_SUCCEEDED(rv)); rv = mInitThread->Dispatch( - NS_NewRunnableMethod(this, &SpeechDispatcherService::Setup), NS_DISPATCH_NORMAL); + NewRunnableMethod(this, &SpeechDispatcherService::Setup), NS_DISPATCH_NORMAL); MOZ_ASSERT(NS_SUCCEEDED(rv)); } SpeechDispatcherService::~SpeechDispatcherService() { if (mInitThread) { mInitThread->Shutdown(); } @@ -407,17 +407,17 @@ SpeechDispatcherService::Setup() uri.Append(NS_ConvertUTF8toUTF16(lang)); mVoices.Put(uri, new SpeechDispatcherVoice( NS_ConvertUTF8toUTF16(list[i]->name), NS_ConvertUTF8toUTF16(lang))); } } - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &SpeechDispatcherService::RegisterVoices)); + NS_DispatchToMainThread(NewRunnableMethod(this, &SpeechDispatcherService::RegisterVoices)); //mInitialized = true; } // private methods void SpeechDispatcherService::RegisterVoices() @@ -513,20 +513,20 @@ SpeechDispatcherService::Speak(const nsA return NS_ERROR_FAILURE; } mCallbacks.Put(msg_id, callback); } else { // Speech dispatcher does not work well with empty strings. // In that case, don't send empty string to speechd, // and just emulate a speechd start and end event. - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs<SPDNotificationType>( + NS_DispatchToMainThread(NewRunnableMethod<SPDNotificationType>( callback, &SpeechDispatcherCallback::OnSpeechEvent, SPD_EVENT_BEGIN)); - NS_DispatchToMainThread(NS_NewRunnableMethodWithArgs<SPDNotificationType>( + NS_DispatchToMainThread(NewRunnableMethod<SPDNotificationType>( callback, &SpeechDispatcherCallback::OnSpeechEvent, SPD_EVENT_END)); } return NS_OK; } NS_IMETHODIMP SpeechDispatcherService::GetServiceType(SpeechServiceType* aServiceType)
--- a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp +++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp @@ -351,17 +351,17 @@ nsFakeSynthServices::Observe(nsISupports const char16_t* aData) { MOZ_ASSERT(NS_IsMainThread()); if(NS_WARN_IF(!(!strcmp(aTopic, "speech-synth-started")))) { return NS_ERROR_UNEXPECTED; } if (Preferences::GetBool("media.webspeech.synth.test")) { - NS_DispatchToMainThread(NS_NewRunnableMethod(this, &nsFakeSynthServices::Init)); + NS_DispatchToMainThread(NewRunnableMethod(this, &nsFakeSynthServices::Init)); } return NS_OK; } // static methods nsFakeSynthServices*
--- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -41,16 +41,17 @@ #include "nsIServiceWorkerManager.h" #include "nsISimpleEnumerator.h" #include "nsIUUIDGenerator.h" #include "nsIXPConnect.h" #include "nsNetUtil.h" #include "nsProxyRelease.h" #include "nsServiceManagerUtils.h" #include "nsStructuredCloneContainer.h" +#include "nsThreadUtils.h" #include "nsToolkitCompsCID.h" #include "nsXULAppAPI.h" #include "ServiceWorkerManager.h" #include "WorkerPrivate.h" #include "WorkerRunnable.h" #include "WorkerScope.h" #ifdef MOZ_B2G @@ -641,19 +642,18 @@ NotificationPermissionRequest::GetReques nsCOMPtr<nsIContentPermissionRequester> requester = mRequester; requester.forget(aRequester); return NS_OK; } inline nsresult NotificationPermissionRequest::DispatchResolvePromise() { - nsCOMPtr<nsIRunnable> resolveRunnable = NS_NewRunnableMethod(this, - &NotificationPermissionRequest::ResolvePromise); - return NS_DispatchToMainThread(resolveRunnable); + return NS_DispatchToMainThread(NewRunnableMethod(this, + &NotificationPermissionRequest::ResolvePromise)); } nsresult NotificationPermissionRequest::ResolvePromise() { nsresult rv = NS_OK; if (mPermission == NotificationPermission::Default) { // This will still be "default" if the user dismissed the doorhanger,
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp +++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp @@ -886,17 +886,17 @@ already_AddRefed<AndroidSurfaceTexture> return nullptr; RefPtr<AndroidSurfaceTexture> surface = AndroidSurfaceTexture::Create(TexturePoolOGL::GetGLContext(), texture); if (!surface) { return nullptr; } - nsCOMPtr<nsIRunnable> frameCallback = NS_NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable); + nsCOMPtr<nsIRunnable> frameCallback = NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable); surface->SetFrameAvailableCallback(frameCallback); return surface.forget(); } void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable() { if (mRunning == RUNNING && mOwner) AndroidBridge::Bridge()->InvalidateAndScheduleComposite();
--- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -3287,17 +3287,17 @@ PluginInstanceChild::RecvAsyncSetWindow( mCurrentAsyncSetWindowTask->Cancel(); mCurrentAsyncSetWindowTask = nullptr; } // We shouldn't process this now because it may be received within a nested // RPC call, and both Flash and Java don't expect to receive setwindow calls // at arbitrary times. mCurrentAsyncSetWindowTask = - NS_NewNonOwningCancelableRunnableMethodWithArgs<gfxSurfaceType, NPRemoteWindow, bool> + NewNonOwningCancelableRunnableMethod<gfxSurfaceType, NPRemoteWindow, bool> (this, &PluginInstanceChild::DoAsyncSetWindow, aSurfaceType, aWindow, true); RefPtr<Runnable> addrefedTask = mCurrentAsyncSetWindowTask; MessageLoop::current()->PostTask(addrefedTask.forget()); return true; } void @@ -4208,17 +4208,17 @@ PluginInstanceChild::AsyncShowPluginFram // When the plugin is using direct surfaces to draw, it is not driving // paints via paint events - it will drive painting via its own events // and/or DidComposite callbacks. if (IsUsingDirectDrawing()) { return; } mCurrentInvalidateTask = - NS_NewNonOwningCancelableRunnableMethod(this, &PluginInstanceChild::InvalidateRectDelayed); + NewNonOwningCancelableRunnableMethod(this, &PluginInstanceChild::InvalidateRectDelayed); RefPtr<Runnable> addrefedTask = mCurrentInvalidateTask; MessageLoop::current()->PostTask(addrefedTask.forget()); } void PluginInstanceChild::InvalidateRect(NPRect* aInvalidRect) { NS_ASSERTION(aInvalidRect, "Null pointer!");
--- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -1211,17 +1211,17 @@ PluginInstanceParent::EndUpdateBackgroun void PluginInstanceParent::ScheduleScrollCapture(int aTimeout) { if (mCaptureRefreshTask) { return; } CAPTURE_LOG("delayed scroll capture requested."); mCaptureRefreshTask = - NS_NewNonOwningCancelableRunnableMethod(this, &PluginInstanceParent::ScheduledUpdateScrollCaptureCallback); + NewNonOwningCancelableRunnableMethod(this, &PluginInstanceParent::ScheduledUpdateScrollCaptureCallback); RefPtr<Runnable> addrefedTask = mCaptureRefreshTask; MessageLoop::current()->PostDelayedTask(addrefedTask.forget(), kScrollCaptureDelayMs); } void PluginInstanceParent::ScheduledUpdateScrollCaptureCallback() {
--- a/dom/plugins/ipc/PluginProcessParent.cpp +++ b/dom/plugins/ipc/PluginProcessParent.cpp @@ -190,18 +190,17 @@ PluginProcessParent::Delete() MessageLoop* currentLoop = MessageLoop::current(); MessageLoop* ioLoop = XRE_GetIOMessageLoop(); if (currentLoop == ioLoop) { delete this; return; } - RefPtr<Runnable> runnable = NS_NewNonOwningRunnableMethod(this, &PluginProcessParent::Delete); - ioLoop->PostTask(runnable.forget()); + ioLoop->PostTask(NewNonOwningRunnableMethod(this, &PluginProcessParent::Delete)); } void PluginProcessParent::SetCallRunnableImmediately(bool aCallImmediately) { mRunCompleteTaskImmediately = aCallImmediately; }
--- a/dom/presentation/PresentationAvailability.cpp +++ b/dom/presentation/PresentationAvailability.cpp @@ -102,21 +102,20 @@ bool PresentationAvailability::Value() const { return mIsAvailable; } NS_IMETHODIMP PresentationAvailability::NotifyAvailableChange(bool aIsAvailable) { - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<bool>(this, - &PresentationAvailability::UpdateAvailabilityAndDispatchEvent, - aIsAvailable); - return NS_DispatchToCurrentThread(runnable); + return NS_DispatchToCurrentThread(NewRunnableMethod + <bool>(this, + &PresentationAvailability::UpdateAvailabilityAndDispatchEvent, + aIsAvailable)); } void PresentationAvailability::UpdateAvailabilityAndDispatchEvent(bool aIsAvailable) { mIsAvailable = aIsAvailable; NS_WARN_IF(NS_FAILED(DispatchTrustedEvent(NS_LITERAL_STRING("change")))); }
--- a/dom/presentation/PresentationDeviceManager.cpp +++ b/dom/presentation/PresentationDeviceManager.cpp @@ -150,17 +150,17 @@ NS_IMETHODIMP PresentationDeviceManager::GetAvailableDevices(nsIArray** aRetVal) { NS_ENSURE_ARG_POINTER(aRetVal); MOZ_ASSERT(NS_IsMainThread()); // Bug 1194049: some providers may discontinue discovery after timeout. // Call |ForceDiscovery()| here to make sure device lists are updated. NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &PresentationDeviceManager::ForceDiscovery)); + NewRunnableMethod(this, &PresentationDeviceManager::ForceDiscovery)); nsCOMPtr<nsIMutableArray> devices = do_CreateInstance(NS_ARRAY_CONTRACTID); for (uint32_t i = 0; i < mDevices.Length(); ++i) { devices->AppendElement(mDevices[i], false); } devices.forget(aRetVal);
--- a/dom/presentation/PresentationSessionInfo.cpp +++ b/dom/presentation/PresentationSessionInfo.cpp @@ -107,19 +107,19 @@ PresentationNetworkHelper::OnError(const NS_IMETHODIMP PresentationNetworkHelper::OnGetWifiIPAddress(const nsACString& aIPAddress) { MOZ_ASSERT(mInfo); MOZ_ASSERT(mFunc); NS_DispatchToMainThread( - NS_NewRunnableMethodWithArg<nsCString>(mInfo, - mFunc, - aIPAddress)); + NewRunnableMethod<nsCString>(mInfo, + mFunc, + aIPAddress)); return NS_OK; } } // anonymous namespace #endif // MOZ_WIDGET_ANDROID class TCPPresentationChannelDescription final : public nsIPresentationChannelDescription @@ -545,17 +545,17 @@ PresentationControllingInfo::GetAddress( nsAutoString ip; ip.Assign(ips[0]); // On Android platform, the IP address is retrieved from a callback function. // To make consistent code sequence, following function call is dispatched // into main thread instead of calling it directly. NS_DispatchToMainThread( - NS_NewRunnableMethodWithArg<nsCString>( + NewRunnableMethod<nsCString>( this, &PresentationControllingInfo::OnGetAddress, NS_ConvertUTF16toUTF8(ip))); NS_Free(prefixes); NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, ips); #elif defined(MOZ_WIDGET_ANDROID) @@ -565,26 +565,26 @@ PresentationControllingInfo::GetAddress( nsresult rv = networkHelper->GetWifiIPAddress(); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } #elif defined(MOZ_MULET) // In simulator,we need to use the "127.0.0.1" as target address. NS_DispatchToMainThread( - NS_NewRunnableMethodWithArg<nsCString>( + NewRunnableMethod<nsCString>( this, &PresentationControllingInfo::OnGetAddress, "127.0.0.1")); #else // TODO Get host IP via other platforms. NS_DispatchToMainThread( - NS_NewRunnableMethodWithArg<nsCString>( + NewRunnableMethod<nsCString>( this, &PresentationControllingInfo::OnGetAddress, EmptyCString())); #endif return NS_OK; }
--- a/dom/presentation/PresentationTCPSessionTransport.cpp +++ b/dom/presentation/PresentationTCPSessionTransport.cpp @@ -106,28 +106,28 @@ PresentationTCPSessionTransport::BuildTC if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } mRole = nsIPresentationService::ROLE_CONTROLLER; nsCOMPtr<nsIPresentationSessionTransport> sessionTransport = do_QueryObject(this); nsCOMPtr<nsIRunnable> onSessionTransportRunnable = - NS_NewRunnableMethodWithArgs + NewRunnableMethod <nsIPresentationSessionTransport*>(mListener, &nsIPresentationSessionTransportBuilderListener::OnSessionTransport, sessionTransport); - NS_DispatchToCurrentThread(onSessionTransportRunnable); + NS_DispatchToCurrentThread(onSessionTransportRunnable.forget()); nsCOMPtr<nsIRunnable> setReadyStateRunnable = - NS_NewRunnableMethodWithArgs<ReadyState>(this, - &PresentationTCPSessionTransport::SetReadyState, - ReadyState::OPEN); - return NS_DispatchToCurrentThread(setReadyStateRunnable); + NewRunnableMethod<ReadyState>(this, + &PresentationTCPSessionTransport::SetReadyState, + ReadyState::OPEN); + return NS_DispatchToCurrentThread(setReadyStateRunnable.forget()); } NS_IMETHODIMP PresentationTCPSessionTransport::BuildTCPReceiverTransport(nsIPresentationChannelDescription* aDescription, nsIPresentationSessionTransportBuilderListener* aListener) { if (NS_WARN_IF(!aDescription)) { return NS_ERROR_INVALID_ARG; @@ -188,21 +188,21 @@ PresentationTCPSessionTransport::BuildTC if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } mRole = nsIPresentationService::ROLE_RECEIVER; nsCOMPtr<nsIPresentationSessionTransport> sessionTransport = do_QueryObject(this); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArgs + NewRunnableMethod <nsIPresentationSessionTransport*>(mListener, &nsIPresentationSessionTransportBuilderListener::OnSessionTransport, sessionTransport); - return NS_DispatchToCurrentThread(runnable); + return NS_DispatchToCurrentThread(runnable.forget()); } nsresult PresentationTCPSessionTransport::CreateStream() { nsresult rv = mTransport->OpenInputStream(0, 0, 0, getter_AddRefs(mSocketInputStream)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv;
--- a/dom/presentation/provider/MulticastDNSDeviceProvider.cpp +++ b/dom/presentation/provider/MulticastDNSDeviceProvider.cpp @@ -716,17 +716,17 @@ MulticastDNSDeviceProvider::OnRegistrati { LOG_E("OnRegistrationFailed: %d", aErrorCode); MOZ_ASSERT(NS_IsMainThread()); mRegisterRequest = nullptr; if (aErrorCode == nsIDNSRegistrationListener::ERROR_SERVICE_NOT_RUNNING) { return NS_DispatchToMainThread( - NS_NewRunnableMethod(this, &MulticastDNSDeviceProvider::RegisterService)); + NewRunnableMethod(this, &MulticastDNSDeviceProvider::RegisterService)); } return NS_OK; } NS_IMETHODIMP MulticastDNSDeviceProvider::OnUnregistrationFailed(nsIDNSServiceInfo* aServiceInfo, int32_t aErrorCode)
--- a/dom/quota/ActorsParent.cpp +++ b/dom/quota/ActorsParent.cpp @@ -3079,23 +3079,25 @@ QuotaManager::Shutdown() mClients[index]->ShutdownWorkThreads(); } // Cancel the timer regardless of whether it actually fired. if (NS_FAILED(mShutdownTimer->Cancel())) { NS_WARNING("Failed to cancel shutdown timer!"); } + // NB: It's very important that runnable is destroyed on this thread + // (i.e. after we join the IO thread) because we can't release the + // QuotaManager on the IO thread. This should probably use + // NewNonOwningRunnableMethod ... + RefPtr<Runnable> runnable = + NewRunnableMethod(this, &QuotaManager::ReleaseIOThreadObjects); + MOZ_ASSERT(runnable); + // Give clients a chance to cleanup IO thread only objects. - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &QuotaManager::ReleaseIOThreadObjects); - if (!runnable) { - NS_WARNING("Failed to create runnable!"); - } - if (NS_FAILED(mIOThread->Dispatch(runnable, NS_DISPATCH_NORMAL))) { NS_WARNING("Failed to dispatch runnable!"); } // Make sure to join with our IO thread. if (NS_FAILED(mIOThread->Shutdown())) { NS_WARNING("Failed to shutdown IO thread!"); } @@ -5308,17 +5310,17 @@ Quota::RecvStartIdleMaintenance() if (QuotaManager::IsShuttingDown()) { return true; } QuotaManager* quotaManager = QuotaManager::Get(); if (!quotaManager) { nsCOMPtr<nsIRunnable> callback = - NS_NewRunnableMethod(this, &Quota::StartIdleMaintenance); + NewRunnableMethod(this, &Quota::StartIdleMaintenance); QuotaManager::GetOrCreate(callback); return true; } quotaManager->StartIdleMaintenance(); return true;
--- a/dom/storage/DOMStorageCache.cpp +++ b/dom/storage/DOMStorageCache.cpp @@ -105,18 +105,18 @@ DOMStorageCache::Release(void) // self from the manager's hash table. And we don't want to lock access to // that hash table. if (NS_IsMainThread()) { DOMStorageCacheBridge::Release(); return; } RefPtr<nsRunnableMethod<DOMStorageCacheBridge, void, false> > event = - NS_NewNonOwningRunnableMethod(static_cast<DOMStorageCacheBridge*>(this), - &DOMStorageCacheBridge::Release); + NewNonOwningRunnableMethod(static_cast<DOMStorageCacheBridge*>(this), + &DOMStorageCacheBridge::Release); nsresult rv = NS_DispatchToMainThread(event); if (NS_FAILED(rv)) { NS_WARNING("DOMStorageCache::Release() on a non-main thread"); DOMStorageCacheBridge::Release(); } } @@ -276,20 +276,17 @@ DOMStorageCache::KeepAlive() // Missing reference back to the manager means the cache is not responsible // for its lifetime. Used for keeping sessionStorage live forever. if (!mManager) { return; } if (!NS_IsMainThread()) { // Timer and the holder must be initialized on the main thread. - RefPtr<nsRunnableMethod<DOMStorageCache> > event = - NS_NewRunnableMethod(this, &DOMStorageCache::KeepAlive); - - NS_DispatchToMainThread(event); + NS_DispatchToMainThread(NewRunnableMethod(this, &DOMStorageCache::KeepAlive)); return; } nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/timer;1"); if (!timer) { return; }
--- a/dom/storage/DOMStorageDBThread.cpp +++ b/dom/storage/DOMStorageDBThread.cpp @@ -716,17 +716,17 @@ DOMStorageDBThread::TimeUntilFlush() } void DOMStorageDBThread::NotifyFlushCompletion() { #ifdef DOM_STORAGE_TESTS if (!NS_IsMainThread()) { RefPtr<nsRunnableMethod<DOMStorageDBThread, void, false> > event = - NS_NewNonOwningRunnableMethod(this, &DOMStorageDBThread::NotifyFlushCompletion); + NewNonOwningRunnableMethod(this, &DOMStorageDBThread::NotifyFlushCompletion); NS_DispatchToMainThread(event); return; } nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); if (obs) { obs->NotifyObservers(nullptr, "domstorage-test-flushed", nullptr); }
--- a/dom/svg/SVGFEImageElement.cpp +++ b/dom/svg/SVGFEImageElement.cpp @@ -150,17 +150,17 @@ SVGFEImageElement::BindToTree(nsIDocumen aCompileEventHandlers); if (mStringAttributes[HREF].IsExplicitlySet()) { // FIXME: Bug 660963 it would be nice if we could just have // ClearBrokenState update our state and do it fast... ClearBrokenState(); RemoveStatesSilently(NS_EVENT_STATE_BROKEN); nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &SVGFEImageElement::MaybeLoadSVGImage)); + NewRunnableMethod(this, &SVGFEImageElement::MaybeLoadSVGImage)); } return rv; } void SVGFEImageElement::UnbindFromTree(bool aDeep, bool aNullParent) {
--- a/dom/svg/SVGImageElement.cpp +++ b/dom/svg/SVGImageElement.cpp @@ -178,17 +178,17 @@ SVGImageElement::BindToTree(nsIDocument* aCompileEventHandlers); if (mStringAttributes[HREF].IsExplicitlySet()) { // FIXME: Bug 660963 it would be nice if we could just have // ClearBrokenState update our state and do it fast... ClearBrokenState(); RemoveStatesSilently(NS_EVENT_STATE_BROKEN); nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &SVGImageElement::MaybeLoadSVGImage)); + NewRunnableMethod(this, &SVGImageElement::MaybeLoadSVGImage)); } return rv; } void SVGImageElement::UnbindFromTree(bool aDeep, bool aNullParent) {
--- a/dom/svg/SVGStyleElement.cpp +++ b/dom/svg/SVGStyleElement.cpp @@ -73,17 +73,17 @@ SVGStyleElement::BindToTree(nsIDocument* bool aCompileEventHandlers) { nsresult rv = SVGStyleElementBase::BindToTree(aDocument, aParent, aBindingParent, aCompileEventHandlers); NS_ENSURE_SUCCESS(rv, rv); void (SVGStyleElement::*update)() = &SVGStyleElement::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); return rv; } void SVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent) { nsCOMPtr<nsIDocument> oldDoc = GetUncomposedDoc();
--- a/dom/tv/TVSource.cpp +++ b/dom/tv/TVSource.cpp @@ -367,50 +367,50 @@ TVSource::DispatchCurrentChannelChangedE { TVCurrentChannelChangedEventInit init; init.mChannel = aChannel; nsCOMPtr<nsIDOMEvent> event = TVCurrentChannelChangedEvent::Constructor(this, NS_LITERAL_STRING("currentchannelchanged"), init); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<nsCOMPtr<nsIDOMEvent>>(this, - &TVSource::DispatchTVEvent, - event); + NewRunnableMethod<nsCOMPtr<nsIDOMEvent>>(this, + &TVSource::DispatchTVEvent, + event); return NS_DispatchToCurrentThread(runnable); } nsresult TVSource::DispatchScanningStateChangedEvent(TVScanningState aState, TVChannel* aChannel) { TVScanningStateChangedEventInit init; init.mState = aState; init.mChannel = aChannel; nsCOMPtr<nsIDOMEvent> event = TVScanningStateChangedEvent::Constructor(this, NS_LITERAL_STRING("scanningstatechanged"), init); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<nsCOMPtr<nsIDOMEvent>>(this, - &TVSource::DispatchTVEvent, - event); + NewRunnableMethod<nsCOMPtr<nsIDOMEvent>>(this, + &TVSource::DispatchTVEvent, + event); return NS_DispatchToCurrentThread(runnable); } nsresult TVSource::DispatchEITBroadcastedEvent(const Sequence<OwningNonNull<TVProgram>>& aPrograms) { TVEITBroadcastedEventInit init; init.mPrograms = aPrograms; nsCOMPtr<nsIDOMEvent> event = TVEITBroadcastedEvent::Constructor(this, NS_LITERAL_STRING("eitbroadcasted"), init); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<nsCOMPtr<nsIDOMEvent>>(this, - &TVSource::DispatchTVEvent, - event); + NewRunnableMethod<nsCOMPtr<nsIDOMEvent>>(this, + &TVSource::DispatchTVEvent, + event); return NS_DispatchToCurrentThread(runnable); } } // namespace dom } // namespace mozilla
--- a/dom/tv/TVTuner.cpp +++ b/dom/tv/TVTuner.cpp @@ -310,19 +310,19 @@ TVTuner::DispatchCurrentSourceChangedEve { TVCurrentSourceChangedEventInit init; init.mSource = aSource; nsCOMPtr<nsIDOMEvent> event = TVCurrentSourceChangedEvent::Constructor(this, NS_LITERAL_STRING("currentsourcechanged"), init); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<nsCOMPtr<nsIDOMEvent>>(this, - &TVTuner::DispatchTVEvent, - event); + NewRunnableMethod<nsCOMPtr<nsIDOMEvent>>(this, + &TVTuner::DispatchTVEvent, + event); return NS_DispatchToCurrentThread(runnable); } nsresult TVTuner::NotifyImageSizeChanged(uint32_t aWidth, uint32_t aHeight) { DOMHwMediaStream* hwMediaStream = mStream->AsDOMHwMediaStream();
--- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -711,21 +711,19 @@ private: virtual bool Notify(Status aStatus) override { mWorkerPrivate->AssertIsOnWorkerThread(); if (aStatus >= Terminating && !mCanceled) { mCanceled = true; - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, - &ScriptLoaderRunnable::CancelMainThreadWithBindingAborted); - NS_ASSERTION(runnable, "This should never fail!"); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewRunnableMethod(this, + &ScriptLoaderRunnable::CancelMainThreadWithBindingAborted))); } return true; } bool IsMainWorkerScript() const {
--- a/dom/workers/ServiceWorkerEvents.cpp +++ b/dom/workers/ServiceWorkerEvents.cpp @@ -848,19 +848,18 @@ public: // only use the extracted location if we found one if (!spec.IsEmpty()) { mSourceSpec = spec; mLine = line; mColumn = column; } - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &WaitUntilHandler::ReportOnMainThread); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable.forget())); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewRunnableMethod(this, &WaitUntilHandler::ReportOnMainThread))); } void ReportOnMainThread() { AssertIsOnMainThread(); RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance();
--- a/dom/workers/ServiceWorkerJob.cpp +++ b/dom/workers/ServiceWorkerJob.cpp @@ -90,17 +90,17 @@ ServiceWorkerJob::Start(Callback* aFinal MOZ_ASSERT(!mFinalCallback); MOZ_ASSERT(!mResultCallbackList.Contains(aFinalCallback)); mFinalCallback = aFinalCallback; MOZ_ASSERT(mState == State::Initial); mState = State::Started; nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &ServiceWorkerJob::AsyncExecute); + NewRunnableMethod(this, &ServiceWorkerJob::AsyncExecute); // We may have to wait for the PBackground actor to be initialized // before proceeding. We should always be able to get a ServiceWorkerManager, // however, since Start() should not be called during shutdown. RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance(); if (!swm->HasBackgroundActor()) { swm->AppendPendingOperation(runnable); return;
--- a/dom/workers/ServiceWorkerPrivate.cpp +++ b/dom/workers/ServiceWorkerPrivate.cpp @@ -617,17 +617,17 @@ public: mWorkerPrivate->AssertIsOnWorkerThread(); mWorkerPrivate = nullptr; if (NS_WARN_IF(aReason > nsIPushErrorReporter::DELIVERY_INTERNAL_ERROR) || mMessageId.IsEmpty()) { return; } nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<uint16_t>(this, + NewRunnableMethod<uint16_t>(this, &PushErrorReporter::ReportOnMainThread, aReason); MOZ_ALWAYS_TRUE(NS_SUCCEEDED( NS_DispatchToMainThread(runnable.forget()))); } void ReportOnMainThread(uint16_t aReason) { AssertIsOnMainThread(); @@ -1452,17 +1452,17 @@ ServiceWorkerPrivate::SendFetchEvent(nsI const nsAString& aDocumentId, bool aIsReload) { AssertIsOnMainThread(); // if the ServiceWorker script fails to load for some reason, just resume // the original channel. nsCOMPtr<nsIRunnable> failRunnable = - NS_NewRunnableMethod(aChannel, &nsIInterceptedChannel::ResetInterception); + NewRunnableMethod(aChannel, &nsIInterceptedChannel::ResetInterception); nsresult rv = SpawnWorkerIfNeeded(FetchEvent, failRunnable, aLoadGroup); NS_ENSURE_SUCCESS(rv, rv); nsMainThreadPtrHandle<nsIInterceptedChannel> handle( new nsMainThreadPtrHolder<nsIInterceptedChannel>(aChannel, false)); if (NS_WARN_IF(!mInfo)) {
--- a/dom/workers/ServiceWorkerRegistrar.cpp +++ b/dom/workers/ServiceWorkerRegistrar.cpp @@ -535,17 +535,17 @@ public: Run() { RefPtr<ServiceWorkerRegistrar> service = ServiceWorkerRegistrar::Get(); MOZ_ASSERT(service); service->SaveData(); RefPtr<Runnable> runnable = - NS_NewRunnableMethod(service, &ServiceWorkerRegistrar::DataSaved); + NewRunnableMethod(service, &ServiceWorkerRegistrar::DataSaved); nsresult rv = mThread->Dispatch(runnable, NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } return NS_OK; } @@ -609,17 +609,17 @@ ServiceWorkerRegistrar::MaybeScheduleShu { AssertIsOnBackgroundThread(); if (mRunnableCounter || !mShuttingDown) { return; } RefPtr<Runnable> runnable = - NS_NewRunnableMethod(this, &ServiceWorkerRegistrar::ShutdownCompleted); + NewRunnableMethod(this, &ServiceWorkerRegistrar::ShutdownCompleted); nsresult rv = NS_DispatchToMainThread(runnable); if (NS_WARN_IF(NS_FAILED(rv))) { return; } } bool ServiceWorkerRegistrar::IsSupportedVersion(const nsACString& aVersion) const @@ -739,17 +739,17 @@ ServiceWorkerRegistrar::ProfileStarted() return; } nsCOMPtr<nsIEventTarget> target = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); MOZ_ASSERT(target, "Must have stream transport service"); nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(this, &ServiceWorkerRegistrar::LoadData); + NewRunnableMethod(this, &ServiceWorkerRegistrar::LoadData); rv = target->Dispatch(runnable, NS_DISPATCH_NORMAL); if (NS_FAILED(rv)) { NS_WARNING("Failed to dispatch the LoadDataRunnable."); } } void ServiceWorkerRegistrar::ProfileStopped()
--- a/dom/workers/ServiceWorkerRegistrationInfo.cpp +++ b/dom/workers/ServiceWorkerRegistrationInfo.cpp @@ -196,20 +196,19 @@ ServiceWorkerRegistrationInfo::GetServic } return serviceWorker.forget(); } void ServiceWorkerRegistrationInfo::TryToActivateAsync() { - nsCOMPtr<nsIRunnable> r = - NS_NewRunnableMethod(this, - &ServiceWorkerRegistrationInfo::TryToActivate); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(r)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewRunnableMethod(this, + &ServiceWorkerRegistrationInfo::TryToActivate))); } /* * TryToActivate should not be called directly, use TryToACtivateAsync instead. */ void ServiceWorkerRegistrationInfo::TryToActivate() { @@ -231,24 +230,24 @@ ServiceWorkerRegistrationInfo::Activate( // FIXME(nsm): Unlink appcache if there is one. RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance(); swm->CheckPendingReadyPromises(); // "Queue a task to fire a simple event named controllerchange..." nsCOMPtr<nsIRunnable> controllerChangeRunnable = - NS_NewRunnableMethodWithArg<RefPtr<ServiceWorkerRegistrationInfo>>( + NewRunnableMethod<RefPtr<ServiceWorkerRegistrationInfo>>( swm, &ServiceWorkerManager::FireControllerChange, this); NS_DispatchToMainThread(controllerChangeRunnable); nsCOMPtr<nsIRunnable> failRunnable = - NS_NewRunnableMethodWithArg<bool>(this, - &ServiceWorkerRegistrationInfo::FinishActivate, - false /* success */); + NewRunnableMethod<bool>(this, + &ServiceWorkerRegistrationInfo::FinishActivate, + false /* success */); nsMainThreadPtrHandle<ServiceWorkerRegistrationInfo> handle( new nsMainThreadPtrHolder<ServiceWorkerRegistrationInfo>(this)); RefPtr<LifeCycleEventCallback> callback = new ContinueActivateRunnable(handle); ServiceWorkerPrivate* workerPrivate = mActiveWorker->WorkerPrivate(); MOZ_ASSERT(workerPrivate); nsresult rv = workerPrivate->SendLifeCycleEvent(NS_LITERAL_STRING("activate"),
--- a/dom/workers/ServiceWorkerUpdateJob.cpp +++ b/dom/workers/ServiceWorkerUpdateJob.cpp @@ -484,25 +484,25 @@ ServiceWorkerUpdateJob::Install() // The job promise cannot be rejected after this point, but the job can // still fail; e.g. if the install event handler throws, etc. RefPtr<ServiceWorkerManager> swm = ServiceWorkerManager::GetInstance(); // fire the updatefound event nsCOMPtr<nsIRunnable> upr = - NS_NewRunnableMethodWithArg<RefPtr<ServiceWorkerRegistrationInfo>>( + NewRunnableMethod<RefPtr<ServiceWorkerRegistrationInfo>>( swm, &ServiceWorkerManager::FireUpdateFoundOnServiceWorkerRegistrations, mRegistration); NS_DispatchToMainThread(upr); // Call ContinueAfterInstallEvent(false) on main thread if the SW // script fails to load. - nsCOMPtr<nsIRunnable> failRunnable = NS_NewRunnableMethodWithArgs<bool> + nsCOMPtr<nsIRunnable> failRunnable = NewRunnableMethod<bool> (this, &ServiceWorkerUpdateJob::ContinueAfterInstallEvent, false); nsMainThreadPtrHandle<ServiceWorkerUpdateJob> handle( new nsMainThreadPtrHolder<ServiceWorkerUpdateJob>(this)); RefPtr<LifeCycleEventCallback> callback = new ContinueInstallRunnable(handle); // Send the install event to the worker thread ServiceWorkerPrivate* workerPrivate =
--- a/dom/xbl/nsBindingManager.cpp +++ b/dom/xbl/nsBindingManager.cpp @@ -342,17 +342,17 @@ nsBindingManager::AddToAttachedQueue(nsX return NS_OK; } void nsBindingManager::PostProcessAttachedQueueEvent() { mProcessAttachedQueueEvent = - NS_NewRunnableMethod(this, &nsBindingManager::DoProcessAttachedQueue); + NewRunnableMethod(this, &nsBindingManager::DoProcessAttachedQueue); nsresult rv = NS_DispatchToCurrentThread(mProcessAttachedQueueEvent); if (NS_SUCCEEDED(rv) && mDocument) { mDocument->BlockOnload(); } } // static void
--- a/dom/xml/XMLStylesheetProcessingInstruction.cpp +++ b/dom/xml/XMLStylesheetProcessingInstruction.cpp @@ -58,17 +58,17 @@ XMLStylesheetProcessingInstruction::Bind { nsresult rv = ProcessingInstruction::BindToTree(aDocument, aParent, aBindingParent, aCompileEventHandlers); NS_ENSURE_SUCCESS(rv, rv); void (XMLStylesheetProcessingInstruction::*update)() = &XMLStylesheetProcessingInstruction::UpdateStyleSheetInternal; - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, update)); return rv; } void XMLStylesheetProcessingInstruction::UnbindFromTree(bool aDeep, bool aNullParent) { nsCOMPtr<nsIDocument> oldDoc = GetUncomposedDoc();
--- a/dom/xml/nsXMLContentSink.cpp +++ b/dom/xml/nsXMLContentSink.cpp @@ -1548,17 +1548,17 @@ nsXMLContentSink::ContinueInterruptedPar if (mParser && mParser->IsParserEnabled()) { GetParser()->ContinueInterruptedParsing(); } } void nsXMLContentSink::ContinueInterruptedParsingAsync() { - nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this, + nsCOMPtr<nsIRunnable> ev = NewRunnableMethod(this, &nsXMLContentSink::ContinueInterruptedParsingIfEnabled); NS_DispatchToCurrentThread(ev); } nsIParser* nsXMLContentSink::GetParser() {
--- a/dom/xml/nsXMLPrettyPrinter.cpp +++ b/dom/xml/nsXMLPrettyPrinter.cpp @@ -189,17 +189,17 @@ nsXMLPrettyPrinter::MaybeUnhook(nsIConte // If there either aContent is null (the document-node was modified) or // there isn't a binding parent we know it's non-anonymous content. if ((!aContent || !aContent->GetBindingParent()) && !mUnhookPending) { // Can't blindly to mUnhookPending after AddScriptRunner, // since AddScriptRunner _could_ in theory run us // synchronously mUnhookPending = true; nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsXMLPrettyPrinter::Unhook)); + NewRunnableMethod(this, &nsXMLPrettyPrinter::Unhook)); } } void nsXMLPrettyPrinter::Unhook() { mDocument->RemoveObserver(this); nsCOMPtr<Element> element = mDocument->GetDocumentElement();
--- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -1010,17 +1010,17 @@ XULDocument::AttributeChanged(nsIDocumen // // XXX Namespace handling broken :-( nsAutoString persist; aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::persist, persist); // Persistence of attributes of xul:window is handled in nsXULWindow. if (ShouldPersistAttribute(aElement, aAttribute) && !persist.IsEmpty() && // XXXldb This should check that it's a token, not just a substring. persist.Find(nsDependentAtomString(aAttribute)) >= 0) { - nsContentUtils::AddScriptRunner(NS_NewRunnableMethodWithArgs + nsContentUtils::AddScriptRunner(NewRunnableMethod <nsIContent*, int32_t, nsIAtom*> (this, &XULDocument::DoPersist, aElement, kNameSpaceID_None, aAttribute)); } } void XULDocument::ContentAppended(nsIDocument* aDocument, @@ -3130,17 +3130,17 @@ XULDocument::MaybeBroadcast() { // Only broadcast when not in an update and when safe to run scripts. if (mUpdateNestLevel == 0 && (mDelayedAttrChangeBroadcasts.Length() || mDelayedBroadcasters.Length())) { if (!nsContentUtils::IsSafeToRunScript()) { if (!mInDestructor) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &XULDocument::MaybeBroadcast)); + NewRunnableMethod(this, &XULDocument::MaybeBroadcast)); } return; } if (!mHandlingDelayedAttrChange) { mHandlingDelayedAttrChange = true; for (uint32_t i = 0; i < mDelayedAttrChangeBroadcasts.Length(); ++i) { nsIAtom* attrName = mDelayedAttrChangeBroadcasts[i].mAttrName; if (mDelayedAttrChangeBroadcasts[i].mNeedsAttrChange) {
--- a/dom/xul/templates/nsXULTemplateBuilder.cpp +++ b/dom/xul/templates/nsXULTemplateBuilder.cpp @@ -1091,23 +1091,23 @@ nsXULTemplateBuilder::AttributeChanged(n const nsAttrValue* aOldValue) { if (aElement == mRoot && aNameSpaceID == kNameSpaceID_None) { // Check for a change to the 'ref' attribute on an atom, in which // case we may need to nuke and rebuild the entire content model // beneath the element. if (aAttribute == nsGkAtoms::ref) nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableRebuild)); + NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableRebuild)); // Check for a change to the 'datasources' attribute. If so, setup // mDB by parsing the new value and rebuild. else if (aAttribute == nsGkAtoms::datasources) { nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableLoadAndRebuild)); + NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableLoadAndRebuild)); } } } void nsXULTemplateBuilder::ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild, @@ -1117,17 +1117,17 @@ nsXULTemplateBuilder::ContentRemoved(nsI if (mRoot && nsContentUtils::ContentIsDescendantOf(mRoot, aChild)) { RefPtr<nsXULTemplateBuilder> kungFuDeathGrip(this); if (mQueryProcessor) mQueryProcessor->Done(); // Pass false to Uninit since content is going away anyway nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsXULTemplateBuilder::UninitFalse)); + NewRunnableMethod(this, &nsXULTemplateBuilder::UninitFalse)); MOZ_ASSERT(aDocument == mObservedDocument); StopObserving(); nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(aDocument); if (xuldoc) xuldoc->SetTemplateBuilderFor(mRoot, nullptr); @@ -1156,17 +1156,17 @@ nsXULTemplateBuilder::NodeWillBeDestroye if (mQueryProcessor) mQueryProcessor->Done(); mDataSource = nullptr; mDB = nullptr; mCompDB = nullptr; nsContentUtils::AddScriptRunner( - NS_NewRunnableMethod(this, &nsXULTemplateBuilder::UninitTrue)); + NewRunnableMethod(this, &nsXULTemplateBuilder::UninitTrue)); } //---------------------------------------------------------------------- // // Implementation methods
--- a/editor/libeditor/nsHTMLEditRules.cpp +++ b/editor/libeditor/nsHTMLEditRules.cpp @@ -8726,17 +8726,17 @@ nsHTMLEditRules::WillRelativeChangeZInde nsCOMPtr<nsIHTMLAbsPosEditor> absPosHTMLEditor = mHTMLEditor; int32_t zIndex; return absPosHTMLEditor->RelativeChangeElementZIndex(elt, aChange, &zIndex); } NS_IMETHODIMP nsHTMLEditRules::DocumentModified() { - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, &nsHTMLEditRules::DocumentModifiedWorker)); + nsContentUtils::AddScriptRunner(NewRunnableMethod(this, &nsHTMLEditRules::DocumentModifiedWorker)); return NS_OK; } void nsHTMLEditRules::DocumentModifiedWorker() { if (!mHTMLEditor) { return;
--- a/editor/libeditor/nsHTMLEditor.cpp +++ b/editor/libeditor/nsHTMLEditor.cpp @@ -3199,17 +3199,17 @@ nsHTMLEditor::DoContentInserted(nsIDocum { if (!aChild) { return; } nsCOMPtr<nsIHTMLEditor> kungFuDeathGrip(this); if (ShouldReplaceRootElement()) { - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod( + nsContentUtils::AddScriptRunner(NewRunnableMethod( this, &nsHTMLEditor::ResetRootElementAndEventTarget)); } // We don't need to handle our own modifications else if (!mAction && (aContainer ? aContainer->IsEditable() : aDocument->IsEditable())) { if (IsMozEditorBogusNode(aChild)) { // Ignore insertion of the bogus node return; } @@ -3241,17 +3241,17 @@ nsHTMLEditor::DoContentInserted(nsIDocum void nsHTMLEditor::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aChild, int32_t aIndexInContainer, nsIContent* aPreviousSibling) { nsCOMPtr<nsIHTMLEditor> kungFuDeathGrip(this); if (SameCOMIdentity(aChild, mRootElement)) { - nsContentUtils::AddScriptRunner(NS_NewRunnableMethod( + nsContentUtils::AddScriptRunner(NewRunnableMethod( this, &nsHTMLEditor::ResetRootElementAndEventTarget)); } // We don't need to handle our own modifications else if (!mAction && (aContainer ? aContainer->IsEditable() : aDocument->IsEditable())) { if (aChild && IsMozEditorBogusNode(aChild)) { // Ignore removal of the bogus node return; }
--- a/embedding/components/webbrowserpersist/WebBrowserPersistDocumentParent.cpp +++ b/embedding/components/webbrowserpersist/WebBrowserPersistDocumentParent.cpp @@ -38,17 +38,17 @@ WebBrowserPersistDocumentParent::ActorDe } if (mOnReady) { // Bug 1202887: If this is part of a subtree destruction, then // anything which could cause another actor in that subtree to // be Send__delete__()ed will cause use-after-free -- such as // dropping the last reference to another document's // WebBrowserPersistRemoteDocument. To avoid that, defer the // callback until after the entire subtree is destroyed. - nsCOMPtr<nsIRunnable> errorLater = NS_NewRunnableMethodWithArg + nsCOMPtr<nsIRunnable> errorLater = NewRunnableMethod <nsresult>(mOnReady, &nsIWebBrowserPersistDocumentReceiver::OnError, NS_ERROR_FAILURE); NS_DispatchToCurrentThread(errorLater); mOnReady = nullptr; } } WebBrowserPersistDocumentParent::~WebBrowserPersistDocumentParent()
--- a/embedding/components/webbrowserpersist/WebBrowserPersistResourcesParent.cpp +++ b/embedding/components/webbrowserpersist/WebBrowserPersistResourcesParent.cpp @@ -28,17 +28,17 @@ WebBrowserPersistResourcesParent::~WebBr } void WebBrowserPersistResourcesParent::ActorDestroy(ActorDestroyReason aWhy) { if (aWhy != Deletion && mVisitor) { // See comment in WebBrowserPersistDocumentParent::ActorDestroy // (or bug 1202887) for why this is deferred. - nsCOMPtr<nsIRunnable> errorLater = NS_NewRunnableMethodWithArgs + nsCOMPtr<nsIRunnable> errorLater = NewRunnableMethod <nsCOMPtr<nsIWebBrowserPersistDocument>, nsresult> (mVisitor, &nsIWebBrowserPersistResourceVisitor::EndVisit, mDocument, NS_ERROR_FAILURE); NS_DispatchToCurrentThread(errorLater); } mVisitor = nullptr; }
--- a/embedding/components/webbrowserpersist/WebBrowserPersistSerializeParent.cpp +++ b/embedding/components/webbrowserpersist/WebBrowserPersistSerializeParent.cpp @@ -72,17 +72,17 @@ WebBrowserPersistSerializeParent::Recv__ void WebBrowserPersistSerializeParent::ActorDestroy(ActorDestroyReason aWhy) { if (mFinish) { MOZ_ASSERT(aWhy != Deletion); // See comment in WebBrowserPersistDocumentParent::ActorDestroy // (or bug 1202887) for why this is deferred. - nsCOMPtr<nsIRunnable> errorLater = NS_NewRunnableMethodWithArgs + nsCOMPtr<nsIRunnable> errorLater = NewRunnableMethod <nsCOMPtr<nsIWebBrowserPersistDocument>, nsCOMPtr<nsIOutputStream>, nsCString, nsresult> (mFinish, &nsIWebBrowserPersistWriteCompletion::OnFinish, mDocument, mStream, EmptyCString(), NS_ERROR_FAILURE); NS_DispatchToCurrentThread(errorLater); mFinish = nullptr; } }
--- a/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp +++ b/embedding/components/webbrowserpersist/nsWebBrowserPersist.cpp @@ -667,17 +667,17 @@ nsWebBrowserPersist::SerializeNextFile() if (mDocList.Length() == 0) { // ...or not quite done, if there are still uploads. if (mUploadList.Count() > 0) { return; } // Finish and clean things up. Defer this because the caller // may have been expecting to use the listeners that that // method will clear. - NS_DispatchToCurrentThread(NS_NewRunnableMethod(this, + NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsWebBrowserPersist::FinishDownload)); return; } // There are no URIs to save, so just save the next document. mStartSaving = true; mozilla::UniquePtr<DocData> docData(mDocList.ElementAt(0)); mDocList.RemoveElementAt(0); // O(n^2) but probably doesn't matter. @@ -779,17 +779,17 @@ nsWebBrowserPersist::OnWrite::OnFinish(n mParent->EndDownload(rv); } // Either we failed and we're done, or we're uploading and // the OnStopRequest callback is responsible for the next // SerializeNextFile(). return NS_OK; } } - NS_DispatchToCurrentThread(NS_NewRunnableMethod(mParent, + NS_DispatchToCurrentThread(NewRunnableMethod(mParent, &nsWebBrowserPersist::SerializeNextFile)); return NS_OK; } //***************************************************************************** // nsWebBrowserPersist::nsIRequestObserver //***************************************************************************** @@ -1789,18 +1789,18 @@ nsWebBrowserPersist::FinishSaveDocumentI if (mWalkStack.Length() > 0) { mozilla::UniquePtr<WalkData> toWalk; mWalkStack.LastElement().swap(toWalk); mWalkStack.TruncateLength(mWalkStack.Length() - 1); // Bounce this off the event loop to avoid stack overflow. typedef StoreCopyPassByRRef<decltype(toWalk)> WalkStorage; auto saveMethod = &nsWebBrowserPersist::SaveDocumentDeferred; nsCOMPtr<nsIRunnable> saveLater = - NS_NewRunnableMethodWithArg<WalkStorage>(this, saveMethod, - mozilla::Move(toWalk)); + NewRunnableMethod<WalkStorage>(this, saveMethod, + mozilla::Move(toWalk)); NS_DispatchToCurrentThread(saveLater); } else { // Done walking DOMs; on to the serialization phase. SerializeNextFile(); } } void nsWebBrowserPersist::Cleanup()
--- a/gfx/gl/AndroidSurfaceTexture.cpp +++ b/gfx/gl/AndroidSurfaceTexture.cpp @@ -288,18 +288,17 @@ AndroidSurfaceTexture::SetDefaultSize(mo void AndroidSurfaceTexture::NotifyFrameAvailable() { if (mFrameAvailableCallback) { // Proxy to main thread if we aren't on it if (!NS_IsMainThread()) { // Proxy to main thread - nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &AndroidSurfaceTexture::NotifyFrameAvailable); - NS_DispatchToCurrentThread(event); + NS_DispatchToCurrentThread(NewRunnableMethod(this, &AndroidSurfaceTexture::NotifyFrameAvailable)); } else { mFrameAvailableCallback->Run(); } } } } // gl } // mozilla
--- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -644,18 +644,18 @@ APZCTreeManager::FlushApzRepaints(uint64 { // Previously, paints were throttled and therefore this method was used to // ensure any pending paints were flushed. Now, paints are flushed // immediately, so it is safe to simply send a notification now. APZCTM_LOG("Flushing repaints for layers id %" PRIu64, aLayersId); const CompositorBridgeParent::LayerTreeState* state = CompositorBridgeParent::GetIndirectShadowTree(aLayersId); MOZ_ASSERT(state && state->mController); - NS_DispatchToMainThread(NS_NewRunnableMethod( - state->mController.get(), &GeckoContentController::NotifyFlushComplete)); + NS_DispatchToMainThread(NewRunnableMethod( + state->mController, &GeckoContentController::NotifyFlushComplete)); } nsEventStatus APZCTreeManager::ReceiveInputEvent(InputData& aEvent, ScrollableLayerGuid* aOutTargetGuid, uint64_t* aOutInputBlockId) { APZThreadUtils::AssertOnControllerThread(); @@ -1340,18 +1340,17 @@ APZCTreeManager::AdjustScrollForSurfaceS } void APZCTreeManager::ClearTree() { // Ensure that no references to APZCs are alive in any lingering input // blocks. This breaks cycles from InputBlockState::mTargetApzc back to // the InputQueue. - RefPtr<Runnable> runnable = NS_NewRunnableMethod(mInputQueue.get(), &InputQueue::Clear); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod(mInputQueue, &InputQueue::Clear)); MutexAutoLock lock(mTreeLock); // Collect the nodes into a list, and then destroy each one. // We can't destroy them as we collect them, because ForEachNode() // does a pre-order traversal of the tree, and Destroy() nulls out // the fields needed to reach the children of the node. nsTArray<RefPtr<HitTestingTreeNode>> nodesToDestroy;
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -511,19 +511,19 @@ public: // This APZC or an APZC further down the handoff chain may be be overscrolled. // Start a snap-back animation on the overscrolled APZC. // Note: // This needs to be a deferred task even though it can safely run // while holding mMonitor, because otherwise, if the overscrolled APZC // is this one, then the SetState(NOTHING) in UpdateAnimation will // stomp on the SetState(SNAP_BACK) it does. mDeferredTasks.AppendElement( - NS_NewRunnableMethodWithArg<AsyncPanZoomController*>(mOverscrollHandoffChain.get(), - &OverscrollHandoffChain::SnapBackOverscrolledApzc, - &mApzc)); + NewRunnableMethod<AsyncPanZoomController*>(mOverscrollHandoffChain.get(), + &OverscrollHandoffChain::SnapBackOverscrolledApzc, + &mApzc)); return false; } // AdjustDisplacement() zeroes out the Axis velocity if we're in overscroll. // Since we need to hand off the velocity to the tree manager in such a case, // we save it here. Would be ParentLayerVector instead of ParentLayerPoint // if we had vector classes. ParentLayerPoint velocity = mApzc.GetVelocityVector(); @@ -563,23 +563,23 @@ public: // there isn't, we take the new fling ourselves, entering an overscrolled // state. // Note: APZC is holding mMonitor, so directly calling // HandleFlingOverscroll() (which acquires the tree lock) would violate // the lock ordering. Instead we schedule HandleFlingOverscroll() to be // called after mMonitor is released. APZC_LOG("%p fling went into overscroll, handing off with velocity %s\n", &mApzc, Stringify(velocity).c_str()); mDeferredTasks.AppendElement( - NS_NewRunnableMethodWithArgs<ParentLayerPoint, - RefPtr<const OverscrollHandoffChain>, - RefPtr<const AsyncPanZoomController>>(&mApzc, - &AsyncPanZoomController::HandleFlingOverscroll, - velocity, - mOverscrollHandoffChain, - mScrolledApzc)); + NewRunnableMethod<ParentLayerPoint, + RefPtr<const OverscrollHandoffChain>, + RefPtr<const AsyncPanZoomController>>(&mApzc, + &AsyncPanZoomController::HandleFlingOverscroll, + velocity, + mOverscrollHandoffChain, + mScrolledApzc)); // If there is a remaining velocity on this APZC, continue this fling // as well. (This fling and the handed-off fling will run concurrently.) // Note that AdjustDisplacement() will have zeroed out the velocity // along the axes where we're overscrolled. return !IsZero(mApzc.GetVelocityVector()); } @@ -697,17 +697,17 @@ public: // animation too early. We do still want to request a fling snap, though, // in case the end of the axis at which we're overscrolled is not a valid // snap point, so we request one now. If there are no snap points, this will // do nothing. If there are snap points, we'll get a scrollTo that snaps us // back to the nearest valid snap point. // The scroll snapping is done in a deferred task, otherwise the state // change to NOTHING caused by the overscroll animation ending would // clobber a possible state change to SMOOTH_SCROLL in ScrollSnap(). - mDeferredTasks.AppendElement(NS_NewRunnableMethod(&mApzc, &AsyncPanZoomController::ScrollSnap)); + mDeferredTasks.AppendElement(NewRunnableMethod(&mApzc, &AsyncPanZoomController::ScrollSnap)); return false; } return true; } virtual bool WantsRepaints() override { return false; @@ -814,19 +814,19 @@ public: // there is an APZC further in the handoff chain which is pannable; if // there isn't, we take the new fling ourselves, entering an overscrolled // state. // Note: APZC is holding mMonitor, so directly calling // HandleSmoothScrollOverscroll() (which acquires the tree lock) would violate // the lock ordering. Instead we schedule HandleSmoothScrollOverscroll() to be // called after mMonitor is released. mDeferredTasks.AppendElement( - NS_NewRunnableMethodWithArgs<ParentLayerPoint>(&mApzc, - &AsyncPanZoomController::HandleSmoothScrollOverscroll, - velocity)); + NewRunnableMethod<ParentLayerPoint>(&mApzc, + &AsyncPanZoomController::HandleSmoothScrollOverscroll, + velocity)); return false; } return true; } void SetDestination(const nsPoint& aNewDestination) { mXAxisModel.SetDestination(static_cast<int32_t>(aNewDestination.x)); @@ -2176,21 +2176,21 @@ nsEventStatus AsyncPanZoomController::Ge touch->SetSingleTapOccurred(); } // Because this may be being running as part of APZCTreeManager::ReceiveInputEvent, // calling controller->HandleSingleTap directly might mean that content receives // the single tap message before the corresponding touch-up. To avoid that we // schedule the singletap message to run on the next spin of the event loop. // See bug 965381 for the issue this was causing. RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<CSSPoint, - mozilla::Modifiers, - ScrollableLayerGuid>(controller, &GeckoContentController::HandleSingleTap, - geckoScreenPoint, aModifiers, - GetGuid()); + NewRunnableMethod<CSSPoint, + mozilla::Modifiers, + ScrollableLayerGuid>(controller, &GeckoContentController::HandleSingleTap, + geckoScreenPoint, aModifiers, + GetGuid()); controller->PostDelayedTask(runnable.forget(), 0); return nsEventStatus_eConsumeNoDefault; } } return nsEventStatus_eIgnore; } @@ -2990,17 +2990,17 @@ void AsyncPanZoomController::RequestCont // Reinvoke this method on the main thread if it's not there already. It's // important to do this before the call to CalculatePendingDisplayPort, so // that CalculatePendingDisplayPort uses the most recent available version of // mFrameMetrics, just before the paint request is dispatched to content. if (!NS_IsMainThread()) { // use the local variable to resolve the function overload. auto func = static_cast<void (AsyncPanZoomController::*)()> (&AsyncPanZoomController::RequestContentRepaint); - NS_DispatchToMainThread(NS_NewRunnableMethod(this, func)); + NS_DispatchToMainThread(NewRunnableMethod(this, func)); return; } MOZ_ASSERT(NS_IsMainThread()); ReentrantMonitorAutoEnter lock(mMonitor); ParentLayerPoint velocity = GetVelocityVector(); mFrameMetrics.SetDisplayPortMargins(CalculatePendingDisplayPort(mFrameMetrics, velocity)); @@ -3723,17 +3723,17 @@ void AsyncPanZoomController::ZoomToRect( endZoomToMetrics.SetPaintRequestTime(TimeStamp::Now()); if (NS_IsMainThread()) { RequestContentRepaint(endZoomToMetrics, velocity); } else { // use a local var to resolve the function overload auto func = static_cast<void (AsyncPanZoomController::*)(const FrameMetrics&, const ParentLayerPoint&)> (&AsyncPanZoomController::RequestContentRepaint); NS_DispatchToMainThread( - NS_NewRunnableMethodWithArgs<FrameMetrics, ParentLayerPoint>( + NewRunnableMethod<FrameMetrics, ParentLayerPoint>( this, func, endZoomToMetrics, velocity)); } } } CancelableBlockState* AsyncPanZoomController::CurrentInputBlock() const {
--- a/gfx/layers/apz/src/GestureEventListener.cpp +++ b/gfx/layers/apz/src/GestureEventListener.cpp @@ -493,17 +493,17 @@ void GestureEventListener::CancelLongTap mLongTapTimeoutTask->Cancel(); mLongTapTimeoutTask = nullptr; } } void GestureEventListener::CreateLongTapTimeoutTask() { RefPtr<CancelableRunnable> task = - NS_NewCancelableRunnableMethod(this, &GestureEventListener::HandleInputTimeoutLongTap); + NewCancelableRunnableMethod(this, &GestureEventListener::HandleInputTimeoutLongTap); mLongTapTimeoutTask = task; mAsyncPanZoomController->PostDelayedTask( task.forget(), gfxPrefs::UiClickHoldContextMenusDelay()); } void GestureEventListener::CancelMaxTapTimeoutTask() @@ -520,19 +520,19 @@ void GestureEventListener::CancelMaxTapT } void GestureEventListener::CreateMaxTapTimeoutTask() { mLastTapInput = mLastTouchInput; TouchBlockState* block = mAsyncPanZoomController->GetInputQueue()->CurrentTouchBlock(); RefPtr<CancelableRunnable> task = - NS_NewCancelableRunnableMethodWithArgs<bool>(this, - &GestureEventListener::HandleInputTimeoutMaxTap, - block->IsDuringFastFling()); + NewCancelableRunnableMethod<bool>(this, + &GestureEventListener::HandleInputTimeoutMaxTap, + block->IsDuringFastFling()); mMaxTapTimeoutTask = task; mAsyncPanZoomController->PostDelayedTask( task.forget(), MAX_TAP_TIME); } } // namespace layers
--- a/gfx/layers/apz/src/InputQueue.cpp +++ b/gfx/layers/apz/src/InputQueue.cpp @@ -565,20 +565,20 @@ InputQueue::IsDragOnScrollbar(bool aHitS return mDragTracker.IsOnScrollbar(aHitScrollbar); } void InputQueue::ScheduleMainThreadTimeout(const RefPtr<AsyncPanZoomController>& aTarget, CancelableBlockState* aBlock) { INPQ_LOG("scheduling main thread timeout for target %p\n", aTarget.get()); aBlock->StartContentResponseTimer(); - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<uint64_t>(this, &InputQueue::MainThreadTimeout, aBlock->GetBlockId()); - aTarget->PostDelayedTask(runnable.forget(), - gfxPrefs::APZContentResponseTimeout()); + aTarget->PostDelayedTask(NewRunnableMethod<uint64_t>(this, + &InputQueue::MainThreadTimeout, + aBlock->GetBlockId()), + gfxPrefs::APZContentResponseTimeout()); } void InputQueue::MainThreadTimeout(const uint64_t& aInputBlockId) { APZThreadUtils::AssertOnControllerThread(); INPQ_LOG("got a main thread timeout; block=%" PRIu64 "\n", aInputBlockId); bool success = false;
--- a/gfx/layers/apz/util/ActiveElementManager.cpp +++ b/gfx/layers/apz/util/ActiveElementManager.cpp @@ -90,19 +90,19 @@ ActiveElementManager::TriggerElementActi if (!mCanBePan) { SetActive(mTarget); } else { CancelTask(); // this is only needed because of bug 1169802. Fixing that // bug properly should make this unnecessary. MOZ_ASSERT(mSetActiveTask == nullptr); RefPtr<CancelableRunnable> task = - NS_NewCancelableRunnableMethodWithArgs<nsCOMPtr<dom::Element>>(this, - &ActiveElementManager::SetActiveTask, - mTarget); + NewCancelableRunnableMethod<nsCOMPtr<dom::Element>>(this, + &ActiveElementManager::SetActiveTask, + mTarget); mSetActiveTask = task; MessageLoop::current()->PostDelayedTask(task.forget(), sActivationDelayMs); AEM_LOG("Scheduling mSetActiveTask %p\n", mSetActiveTask); } } void ActiveElementManager::ClearActivation()
--- a/gfx/layers/apz/util/ChromeProcessController.cpp +++ b/gfx/layers/apz/util/ChromeProcessController.cpp @@ -31,18 +31,17 @@ ChromeProcessController::ChromeProcessCo , mAPZCTreeManager(aAPZCTreeManager) , mUILoop(MessageLoop::current()) { // Otherwise we're initializing mUILoop incorrectly. MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aAPZEventState); MOZ_ASSERT(aAPZCTreeManager); - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ChromeProcessController::InitializeRoot); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod(this, &ChromeProcessController::InitializeRoot)); } ChromeProcessController::~ChromeProcessController() {} void ChromeProcessController::InitializeRoot() { APZCCallbackHelper::InitializeRootDisplayport(GetPresShell()); @@ -66,18 +65,17 @@ ChromeProcessController::PostDelayedTask { MessageLoop::current()->PostDelayedTask(Move(aTask), aDelayMs); } void ChromeProcessController::Destroy() { if (MessageLoop::current() != mUILoop) { - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ChromeProcessController::Destroy); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod(this, &ChromeProcessController::Destroy)); return; } MOZ_ASSERT(MessageLoop::current() == mUILoop); mWidget = nullptr; } nsIPresShell* @@ -116,22 +114,22 @@ ChromeProcessController::GetRootContentD } void ChromeProcessController::HandleDoubleTap(const mozilla::CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid) { if (MessageLoop::current() != mUILoop) { - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<CSSPoint, - Modifiers, - ScrollableLayerGuid>(this, &ChromeProcessController::HandleDoubleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod + <CSSPoint, + Modifiers, + ScrollableLayerGuid>(this, + &ChromeProcessController::HandleDoubleTap, + aPoint, aModifiers, aGuid)); return; } nsCOMPtr<nsIDocument> document = GetRootContentDocument(aGuid.mScrollId); if (!document.get()) { return; } @@ -156,75 +154,72 @@ ChromeProcessController::HandleDoubleTap } void ChromeProcessController::HandleSingleTap(const CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid) { if (MessageLoop::current() != mUILoop) { - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<CSSPoint, - Modifiers, - ScrollableLayerGuid>(this, &ChromeProcessController::HandleSingleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod + <CSSPoint, + Modifiers, + ScrollableLayerGuid>(this, + &ChromeProcessController::HandleSingleTap, + aPoint, aModifiers, aGuid)); return; } mAPZEventState->ProcessSingleTap(aPoint, aModifiers, aGuid); } void ChromeProcessController::HandleLongTap(const mozilla::CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId) { if (MessageLoop::current() != mUILoop) { - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<mozilla::CSSPoint, - Modifiers, - ScrollableLayerGuid, - uint64_t>(this, &ChromeProcessController::HandleLongTap, - aPoint, aModifiers, aGuid, aInputBlockId); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod + <mozilla::CSSPoint, + Modifiers, + ScrollableLayerGuid, + uint64_t>(this, &ChromeProcessController::HandleLongTap, + aPoint, aModifiers, aGuid, aInputBlockId)); return; } mAPZEventState->ProcessLongTap(GetPresShell(), aPoint, aModifiers, aGuid, aInputBlockId); } void ChromeProcessController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, APZStateChange aChange, int aArg) { if (MessageLoop::current() != mUILoop) { - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<ScrollableLayerGuid, - APZStateChange, - int>(this, &ChromeProcessController::NotifyAPZStateChange, - aGuid, aChange, aArg); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod + <ScrollableLayerGuid, + APZStateChange, + int>(this, &ChromeProcessController::NotifyAPZStateChange, + aGuid, aChange, aArg)); return; } mAPZEventState->ProcessAPZStateChange(GetRootDocument(), aGuid.mScrollId, aChange, aArg); } void ChromeProcessController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent) { if (MessageLoop::current() != mUILoop) { - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<FrameMetrics::ViewID, - nsString>(this, &ChromeProcessController::NotifyMozMouseScrollEvent, - aScrollId, aEvent); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod + <FrameMetrics::ViewID, + nsString>(this, &ChromeProcessController::NotifyMozMouseScrollEvent, + aScrollId, aEvent)); return; } APZCCallbackHelper::NotifyMozMouseScrollEvent(aScrollId, aEvent); } void ChromeProcessController::NotifyFlushComplete()
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -356,17 +356,17 @@ void CompositorVsyncScheduler::SetDisplay(bool aDisplayEnable) { // SetDisplay() is usually called from nsScreenManager at main thread. Post // to compositor thread if needs. if (!CompositorBridgeParent::IsInCompositorThread()) { MOZ_ASSERT(NS_IsMainThread()); MonitorAutoLock lock(mSetDisplayMonitor); RefPtr<CancelableRunnable> task = - NS_NewCancelableRunnableMethodWithArgs<bool>(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable); + NewCancelableRunnableMethod<bool>(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable); mSetDisplayTask = task; ScheduleTask(task.forget(), 0); return; } else { MonitorAutoLock lock(mSetDisplayMonitor); mSetDisplayTask = nullptr; } @@ -421,18 +421,18 @@ CompositorVsyncScheduler::Destroy() void CompositorVsyncScheduler::PostCompositeTask(TimeStamp aCompositeTimestamp) { // can be called from the compositor or vsync thread MonitorAutoLock lock(mCurrentCompositeTaskMonitor); if (mCurrentCompositeTask == nullptr) { RefPtr<CancelableRunnable> task = - NS_NewCancelableRunnableMethodWithArgs<TimeStamp>(this, &CompositorVsyncScheduler::Composite, - aCompositeTimestamp); + NewCancelableRunnableMethod<TimeStamp>(this, &CompositorVsyncScheduler::Composite, + aCompositeTimestamp); mCurrentCompositeTask = task; ScheduleTask(task.forget(), 0); } } void CompositorVsyncScheduler::ScheduleComposition() { @@ -475,17 +475,17 @@ CompositorVsyncScheduler::CancelCurrentS * How many skipped vsync events until we stop listening to vsync events? */ void CompositorVsyncScheduler::SetNeedsComposite() { if (!CompositorBridgeParent::IsInCompositorThread()) { MonitorAutoLock lock(mSetNeedsCompositeMonitor); RefPtr<CancelableRunnable> task = - NS_NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::SetNeedsComposite); + NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::SetNeedsComposite); mSetNeedsCompositeTask = task; ScheduleTask(task.forget(), 0); return; } else { MonitorAutoLock lock(mSetNeedsCompositeMonitor); mSetNeedsCompositeTask = nullptr; } @@ -975,35 +975,32 @@ CompositorBridgeParent::ActorDestroy(Act mCompositorScheduler->Destroy(); // There are chances that the ref count reaches zero on the main thread shortly // after this function returns while some ipdl code still needs to run on // this thread. // We must keep the compositor parent alive untill the code handling message // reception is finished on this thread. mSelfRef = this; - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::DeferredDestroy)); } void CompositorBridgeParent::ScheduleRenderOnCompositorThread() { MOZ_ASSERT(CompositorLoop()); - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ScheduleComposition); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ScheduleComposition)); } void CompositorBridgeParent::InvalidateOnCompositorThread() { MOZ_ASSERT(CompositorLoop()); - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::Invalidate); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::Invalidate)); } void CompositorBridgeParent::PauseComposition() { MOZ_ASSERT(IsInCompositorThread(), "PauseComposition() can only be called on the compositor thread"); @@ -1084,48 +1081,46 @@ CompositorBridgeParent::ResumeCompositio * really is paused. */ void CompositorBridgeParent::SchedulePauseOnCompositorThread() { MonitorAutoLock lock(mPauseCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::PauseComposition); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::PauseComposition)); // Wait until the pause has actually been processed by the compositor thread lock.Wait(); } bool CompositorBridgeParent::ScheduleResumeOnCompositorThread() { MonitorAutoLock lock(mResumeCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ResumeComposition); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ResumeComposition)); // Wait until the resume has actually been processed by the compositor thread lock.Wait(); return !mPaused; } bool CompositorBridgeParent::ScheduleResumeOnCompositorThread(int width, int height) { MonitorAutoLock lock(mResumeCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<int, int>(this, &CompositorBridgeParent::ResumeCompositionAndResize, - width, height); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod + <int, int>(this, + &CompositorBridgeParent::ResumeCompositionAndResize, + width, height)); // Wait until the resume has actually been processed by the compositor thread lock.Wait(); return !mPaused; } void @@ -1367,17 +1362,17 @@ CompositorBridgeParent::ScheduleRotation if (!aIsFirstPaint && !mCompositionManager->IsFirstPaint() && mCompositionManager->RequiresReorientation(aTargetConfig.orientation())) { if (mForceCompositionTask != nullptr) { mForceCompositionTask->Cancel(); } RefPtr<CancelableRunnable> task = - NS_NewCancelableRunnableMethod(this, &CompositorBridgeParent::ForceComposition); + NewCancelableRunnableMethod(this, &CompositorBridgeParent::ForceComposition); mForceCompositionTask = task; ScheduleTask(task.forget(), gfxPrefs::OrientationSyncMillis()); } } void CompositorBridgeParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree, const uint64_t& aTransactionId, @@ -2108,23 +2103,22 @@ CompositorBridgeParent::InvalidateRemote bool CompositorBridgeParent::ResetCompositor(const nsTArray<LayersBackend>& aBackendHints, TextureFactoryIdentifier* aOutIdentifier) { Maybe<TextureFactoryIdentifier> newIdentifier; { MonitorAutoLock lock(mResetCompositorMonitor); - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<StoreCopyPassByConstLRef<nsTArray<LayersBackend>>, - Maybe<TextureFactoryIdentifier>*>(this, - &CompositorBridgeParent::ResetCompositorTask, - aBackendHints, - &newIdentifier); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod + <StoreCopyPassByConstLRef<nsTArray<LayersBackend>>, + Maybe<TextureFactoryIdentifier>*>(this, + &CompositorBridgeParent::ResetCompositorTask, + aBackendHints, + &newIdentifier)); mResetCompositorMonitor.Wait(); } if (!newIdentifier) { return false; } @@ -2282,18 +2276,17 @@ CrossProcessCompositorBridgeParent::Acto if (mSubprocess) { mSubprocess->DissociateActor(); mSubprocess = nullptr; } // We must keep this object alive untill the code handling message // reception is finished on this thread. - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy)); } PLayerTransactionParent* CrossProcessCompositorBridgeParent::AllocPLayerTransactionParent( const nsTArray<LayersBackend>&, const uint64_t& aId, TextureFactoryIdentifier* aTextureFactoryIdentifier, bool *aSuccess) @@ -2530,34 +2523,32 @@ CompositorBridgeParent::UpdatePluginWind mCachedPluginData = lts.mPluginData; return true; } void CompositorBridgeParent::ScheduleShowAllPluginWindows() { MOZ_ASSERT(CompositorLoop()); - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ShowAllPluginWindows); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ShowAllPluginWindows)); } void CompositorBridgeParent::ShowAllPluginWindows() { MOZ_ASSERT(!NS_IsMainThread()); mDeferPluginWindows = false; ScheduleComposition(); } void CompositorBridgeParent::ScheduleHideAllPluginWindows() { MOZ_ASSERT(CompositorLoop()); - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::HideAllPluginWindows); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::HideAllPluginWindows)); } void CompositorBridgeParent::HideAllPluginWindows() { MOZ_ASSERT(!NS_IsMainThread()); // No plugins in the cache implies no plugins to manage // in this content.
--- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -101,18 +101,17 @@ ImageBridgeParent::ActorDestroy(ActorDes // Can't alloc/dealloc shmems from now on. mClosed = true; if (mSubprocess) { mSubprocess->DissociateActor(); mSubprocess = nullptr; } - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ImageBridgeParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &ImageBridgeParent::DeferredDestroy)); // It is very important that this method gets called at shutdown (be it a clean // or an abnormal shutdown), because DeferredDestroy is what clears mSelfRef. // If mSelfRef is not null and ActorDestroy is not called, the ImageBridgeParent // is leaked which causes the CompositorThreadHolder to be leaked and // CompsoitorParent's shutdown ends up spinning the event loop forever, waiting // for the compositor thread to terminate. }
--- a/gfx/layers/ipc/RemoteContentController.cpp +++ b/gfx/layers/ipc/RemoteContentController.cpp @@ -53,44 +53,42 @@ RemoteContentController::RequestContentR void RemoteContentController::HandleDoubleTap(const CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid) { if (MessageLoop::current() != mUILoop) { // We have to send this message from the "UI thread" (main // thread). - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<CSSPoint, - Modifiers, - ScrollableLayerGuid>(this, &RemoteContentController::HandleDoubleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod<CSSPoint, + Modifiers, + ScrollableLayerGuid>(this, + &RemoteContentController::HandleDoubleTap, + aPoint, aModifiers, aGuid)); return; } if (CanSend()) { Unused << SendHandleDoubleTap(mBrowserParent->AdjustTapToChildWidget(aPoint), aModifiers, aGuid); } } void RemoteContentController::HandleSingleTap(const CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid) { if (MessageLoop::current() != mUILoop) { // We have to send this message from the "UI thread" (main // thread). - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<CSSPoint, - Modifiers, - ScrollableLayerGuid>(this, &RemoteContentController::HandleSingleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod<CSSPoint, + Modifiers, + ScrollableLayerGuid>(this, + &RemoteContentController::HandleSingleTap, + aPoint, aModifiers, aGuid)); return; } bool callTakeFocusForClickFromTap; layout::RenderFrameParent* frame; if (mBrowserParent && (frame = mBrowserParent->GetRenderFrame()) && mLayersId == frame->GetLayersId()) { // Avoid going over IPC and back for calling TakeFocusForClickFromTap, @@ -111,23 +109,22 @@ void RemoteContentController::HandleLongTap(const CSSPoint& aPoint, Modifiers aModifiers, const ScrollableLayerGuid& aGuid, uint64_t aInputBlockId) { if (MessageLoop::current() != mUILoop) { // We have to send this message from the "UI thread" (main // thread). - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<CSSPoint, - Modifiers, - ScrollableLayerGuid, - uint64_t>(this, &RemoteContentController::HandleLongTap, - aPoint, aModifiers, aGuid, aInputBlockId); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod<CSSPoint, + Modifiers, + ScrollableLayerGuid, + uint64_t>(this, + &RemoteContentController::HandleLongTap, + aPoint, aModifiers, aGuid, aInputBlockId)); return; } if (CanSend()) { Unused << SendHandleLongTap(mBrowserParent->AdjustTapToChildWidget(aPoint), aModifiers, aGuid, aInputBlockId); } } @@ -155,39 +152,37 @@ RemoteContentController::GetTouchSensiti } void RemoteContentController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, APZStateChange aChange, int aArg) { if (MessageLoop::current() != mUILoop) { - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<ScrollableLayerGuid, - APZStateChange, - int>(this, &RemoteContentController::NotifyAPZStateChange, - aGuid, aChange, aArg); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod<ScrollableLayerGuid, + APZStateChange, + int>(this, + &RemoteContentController::NotifyAPZStateChange, + aGuid, aChange, aArg)); return; } if (CanSend()) { Unused << SendNotifyAPZStateChange(aGuid.mScrollId, aChange, aArg); } } void RemoteContentController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent) { if (MessageLoop::current() != mUILoop) { - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<FrameMetrics::ViewID, - nsString>(this, &RemoteContentController::NotifyMozMouseScrollEvent, - aScrollId, aEvent); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask(NewRunnableMethod<FrameMetrics::ViewID, + nsString>(this, + &RemoteContentController::NotifyMozMouseScrollEvent, + aScrollId, aEvent)); return; } if (mBrowserParent) { Unused << mBrowserParent->SendMouseScrollTestEvent(mLayersId, aScrollId, aEvent); } } @@ -227,40 +222,37 @@ RemoteContentController::RecvContentRece const bool& aPreventDefault) { if (aGuid.mLayersId != mLayersId) { // Guard against bad data from hijacked child processes NS_ERROR("Unexpected layers id in RecvContentReceivedInputBlock; dropping message..."); return false; } if (RefPtr<APZCTreeManager> apzcTreeManager = GetApzcTreeManager()) { - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<uint64_t, - bool>(apzcTreeManager, - &APZCTreeManager::ContentReceivedInputBlock, - aInputBlockId, aPreventDefault); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod<uint64_t, + bool>(apzcTreeManager, + &APZCTreeManager::ContentReceivedInputBlock, + aInputBlockId, aPreventDefault)); } return true; } bool RemoteContentController::RecvStartScrollbarDrag(const AsyncDragMetrics& aDragMetrics) { if (RefPtr<APZCTreeManager> apzcTreeManager = GetApzcTreeManager()) { ScrollableLayerGuid guid(mLayersId, aDragMetrics.mPresShellId, aDragMetrics.mViewId); - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<ScrollableLayerGuid, - AsyncDragMetrics>(apzcTreeManager, - &APZCTreeManager::StartScrollbarDrag, - guid, aDragMetrics); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + <ScrollableLayerGuid, + AsyncDragMetrics>(apzcTreeManager, + &APZCTreeManager::StartScrollbarDrag, + guid, aDragMetrics)); } return true; } bool RemoteContentController::RecvSetTargetAPZC(const uint64_t& aInputBlockId, nsTArray<ScrollableLayerGuid>&& aTargets) { @@ -270,37 +262,36 @@ RemoteContentController::RecvSetTargetAP NS_ERROR("Unexpected layers id in SetTargetAPZC; dropping message..."); return false; } } if (RefPtr<APZCTreeManager> apzcTreeManager = GetApzcTreeManager()) { // need a local var to disambiguate between the SetTargetAPZC overloads. void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray<ScrollableLayerGuid>&) = &APZCTreeManager::SetTargetAPZC; - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<uint64_t, - StoreCopyPassByRRef<nsTArray<ScrollableLayerGuid>>>(apzcTreeManager, setTargetApzcFunc, - aInputBlockId, aTargets); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + <uint64_t, + StoreCopyPassByRRef<nsTArray<ScrollableLayerGuid>>> + (apzcTreeManager, setTargetApzcFunc, aInputBlockId, aTargets)); } return true; } bool RemoteContentController::RecvSetAllowedTouchBehavior(const uint64_t& aInputBlockId, nsTArray<TouchBehaviorFlags>&& aFlags) { if (RefPtr<APZCTreeManager> apzcTreeManager = GetApzcTreeManager()) { - RefPtr<Runnable> runnable = - NS_NewRunnableMethodWithArgs<uint64_t, - StoreCopyPassByRRef<nsTArray<TouchBehaviorFlags>>>(apzcTreeManager, - &APZCTreeManager::SetAllowedTouchBehavior, - aInputBlockId, Move(aFlags)); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod + <uint64_t, + StoreCopyPassByRRef<nsTArray<TouchBehaviorFlags>>> + (apzcTreeManager, + &APZCTreeManager::SetAllowedTouchBehavior, + aInputBlockId, Move(aFlags))); } return true; } bool RemoteContentController::RecvUpdateZoomConstraints(const uint32_t& aPresShellId, const ViewID& aViewId, const MaybeZoomConstraints& aConstraints)
--- a/gfx/thebes/SoftwareVsyncSource.cpp +++ b/gfx/thebes/SoftwareVsyncSource.cpp @@ -4,16 +4,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "SoftwareVsyncSource.h" #include "base/task.h" #include "gfxPlatform.h" #include "nsThreadUtils.h" +using namespace mozilla; + SoftwareVsyncSource::SoftwareVsyncSource() { MOZ_ASSERT(NS_IsMainThread()); mGlobalDisplay = new SoftwareDisplay(); } SoftwareVsyncSource::~SoftwareVsyncSource() { @@ -40,18 +42,18 @@ SoftwareDisplay::EnableVsync() { MOZ_ASSERT(mVsyncThread->IsRunning()); if (NS_IsMainThread()) { if (mVsyncEnabled) { return; } mVsyncEnabled = true; - RefPtr<mozilla::Runnable> runnable = NS_NewRunnableMethod(this, &SoftwareDisplay::EnableVsync); - mVsyncThread->message_loop()->PostTask(runnable.forget()); + mVsyncThread->message_loop()->PostTask( + NewRunnableMethod(this, &SoftwareDisplay::EnableVsync)); return; } MOZ_ASSERT(IsInSoftwareVsyncThread()); NotifyVsync(mozilla::TimeStamp::Now()); } void @@ -59,18 +61,18 @@ SoftwareDisplay::DisableVsync() { MOZ_ASSERT(mVsyncThread->IsRunning()); if (NS_IsMainThread()) { if (!mVsyncEnabled) { return; } mVsyncEnabled = false; - RefPtr<mozilla::Runnable> runnable = NS_NewRunnableMethod(this, &SoftwareDisplay::DisableVsync); - mVsyncThread->message_loop()->PostTask(runnable.forget()); + mVsyncThread->message_loop()->PostTask( + NewRunnableMethod(this, &SoftwareDisplay::DisableVsync)); return; } MOZ_ASSERT(IsInSoftwareVsyncThread()); if (mCurrentVsyncTask) { mCurrentVsyncTask->Cancel(); mCurrentVsyncTask = nullptr; } @@ -124,21 +126,21 @@ SoftwareDisplay::ScheduleNextVsync(mozil mozilla::TimeStamp nextVsync = aVsyncTimestamp + mVsyncRate; mozilla::TimeDuration delay = nextVsync - mozilla::TimeStamp::Now(); if (delay.ToMilliseconds() < 0) { delay = mozilla::TimeDuration::FromMilliseconds(0); nextVsync = mozilla::TimeStamp::Now(); } mCurrentVsyncTask = - NS_NewCancelableRunnableMethodWithArgs<mozilla::TimeStamp>(this, - &SoftwareDisplay::NotifyVsync, - nextVsync); + NewCancelableRunnableMethod<mozilla::TimeStamp>(this, + &SoftwareDisplay::NotifyVsync, + nextVsync); - RefPtr<mozilla::Runnable> addrefedTask = mCurrentVsyncTask; + RefPtr<Runnable> addrefedTask = mCurrentVsyncTask; mVsyncThread->message_loop()->PostDelayedTask( addrefedTask.forget(), delay.ToMilliseconds()); } void SoftwareDisplay::Shutdown() {
--- a/gfx/vr/ipc/VRManagerParent.cpp +++ b/gfx/vr/ipc/VRManagerParent.cpp @@ -107,18 +107,17 @@ VRManagerParent::DeferredDestroy() mCompositorThreadHolder = nullptr; mSelfRef = nullptr; } void VRManagerParent::ActorDestroy(ActorDestroyReason why) { UnregisterFromManager(); - RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &VRManagerParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this, &VRManagerParent::DeferredDestroy)); } mozilla::ipc::IToplevelProtocol* VRManagerParent::CloneToplevel(const InfallibleTArray<mozilla::ipc::ProtocolFdMapping>& aFds, base::ProcessHandle aPeerProcess, mozilla::ipc::ProtocolCloneContext* aCtx) { for (unsigned int i = 0; i < aFds.Length(); i++) {
--- a/image/DecodePool.cpp +++ b/image/DecodePool.cpp @@ -168,19 +168,17 @@ public: #endif // MOZ_NUWA_PROCESS } /// Shut down the provided decode pool thread. static void ShutdownThread(nsIThread* aThisThread) { // Threads have to be shut down from another thread, so we'll ask the // main thread to do it for us. - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(aThisThread, &nsIThread::Shutdown); - NS_DispatchToMainThread(runnable); + NS_DispatchToMainThread(NewRunnableMethod(aThisThread, &nsIThread::Shutdown)); } /** * Requests shutdown. New work items will be dropped on the floor, and all * decode pool threads will be shut down once existing work items have been * processed. */ void RequestShutdown()
--- a/image/RasterImage.cpp +++ b/image/RasterImage.cpp @@ -433,19 +433,17 @@ RasterImage::IsOpaque() return !(progress & FLAG_HAS_TRANSPARENCY); } void RasterImage::OnSurfaceDiscarded() { MOZ_ASSERT(mProgressTracker); - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(mProgressTracker, &ProgressTracker::OnDiscard); - NS_DispatchToMainThread(runnable); + NS_DispatchToMainThread(NewRunnableMethod(mProgressTracker, &ProgressTracker::OnDiscard)); } //****************************************************************************** NS_IMETHODIMP RasterImage::GetAnimated(bool* aAnimated) { if (mError) { return NS_ERROR_FAILURE;
--- a/image/VectorImage.cpp +++ b/image/VectorImage.cpp @@ -1058,19 +1058,17 @@ VectorImage::RequestDiscard() return NS_OK; } void VectorImage::OnSurfaceDiscarded() { MOZ_ASSERT(mProgressTracker); - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethod(mProgressTracker, &ProgressTracker::OnDiscard); - NS_DispatchToMainThread(runnable); + NS_DispatchToMainThread(NewRunnableMethod(mProgressTracker, &ProgressTracker::OnDiscard)); } //****************************************************************************** NS_IMETHODIMP VectorImage::ResetAnimation() { if (mError) { return NS_ERROR_FAILURE;
--- a/image/imgRequestProxy.cpp +++ b/image/imgRequestProxy.cpp @@ -344,19 +344,17 @@ imgRequestProxy::CancelAndForgetObserver if (GetOwner()) { GetOwner()->RemoveProxy(this, aStatus); } mIsInLoadGroup = oldIsInLoadGroup; if (mIsInLoadGroup) { - nsCOMPtr<nsIRunnable> ev = - NS_NewRunnableMethod(this, &imgRequestProxy::DoRemoveFromLoadGroup); - NS_DispatchToCurrentThread(ev); + NS_DispatchToCurrentThread(NewRunnableMethod(this, &imgRequestProxy::DoRemoveFromLoadGroup)); } NullOutListener(); return NS_OK; } NS_IMETHODIMP
--- a/ipc/glue/BackgroundImpl.cpp +++ b/ipc/glue/BackgroundImpl.cpp @@ -428,19 +428,18 @@ private: threadLocalInfo->mActor->AssertActorDestroyed(); // Since the actor is created on the main thread it must only // be released on the main thread as well. if (!NS_IsMainThread()) { ChildImpl* actor; threadLocalInfo->mActor.forget(&actor); - nsCOMPtr<nsIRunnable> releaser = - NS_NewNonOwningRunnableMethod(actor, &ChildImpl::Release); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(releaser)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewNonOwningRunnableMethod(actor, &ChildImpl::Release))); } } delete threadLocalInfo; } } static void DispatchFailureCallback(nsIEventTarget* aEventTarget); @@ -998,21 +997,18 @@ ParentImpl::GetContentParent(PBackground if (actor->mContent) { // We need to hand out a reference to our ContentParent but we also need to // keep the one we have. We can't call AddRef here because ContentParent is // not threadsafe so instead we dispatch a runnable to the main thread to do // it for us. This is safe since we are guaranteed that our AddRef runnable // will run before the reference we hand out can be released, and the // ContentParent can't die as long as the existing reference is maintained. - nsCOMPtr<nsIRunnable> runnable = - NS_NewNonOwningRunnableMethod(actor->mContent, &ContentParent::AddRef); - MOZ_ASSERT(runnable); - - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewNonOwningRunnableMethod(actor->mContent, &ContentParent::AddRef))); } return already_AddRefed<ContentParent>(actor->mContent.get()); } // static intptr_t ParentImpl::GetRawContentParentForComparison( @@ -1266,21 +1262,18 @@ ParentImpl::ShutdownTimerCallback(nsITim void ParentImpl::Destroy() { // May be called on any thread! AssertIsInMainProcess(); - nsCOMPtr<nsIRunnable> destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &ParentImpl::MainThreadActorDestroy); - MOZ_ASSERT(destroyRunnable); - - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(destroyRunnable)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToMainThread(NewNonOwningRunnableMethod(this, &ParentImpl::MainThreadActorDestroy))); } void ParentImpl::MainThreadActorDestroy() { AssertIsInMainProcess(); AssertIsOnMainThread(); MOZ_ASSERT_IF(mIsOtherProcessActor, mContent); @@ -1358,21 +1351,19 @@ ParentImpl::ActorDestroy(ActorDestroyRea // This is tricky. We should be able to call Destroy() here directly because // we're not going to touch 'this' or our MessageChannel any longer on this // thread. Destroy() dispatches the MainThreadActorDestroy runnable and when // it runs it will destroy 'this' and our associated MessageChannel. However, // IPDL is about to call MessageChannel::Clear() on this thread! To avoid // racing with the main thread we must ensure that the MessageChannel lives // long enough to be cleared in this call stack. - nsCOMPtr<nsIRunnable> destroyRunnable = - NS_NewNonOwningRunnableMethod(this, &ParentImpl::Destroy); - MOZ_ASSERT(destroyRunnable); - MOZ_ALWAYS_SUCCEEDS(NS_DispatchToCurrentThread(destroyRunnable)); + MOZ_ALWAYS_SUCCEEDS( + NS_DispatchToCurrentThread(NewNonOwningRunnableMethod(this, &ParentImpl::Destroy))); } NS_IMPL_ISUPPORTS(ParentImpl::ShutdownObserver, nsIObserver) NS_IMETHODIMP ParentImpl::ShutdownObserver::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData)
--- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -339,40 +339,36 @@ void GeckoChildProcessHost::InitWindowsG bool GeckoChildProcessHost::SyncLaunch(std::vector<std::string> aExtraOpts, int aTimeoutMs, base::ProcessArchitecture arch) { PrepareLaunch(); MessageLoop* ioLoop = XRE_GetIOMessageLoop(); NS_ASSERTION(MessageLoop::current() != ioLoop, "sync launch from the IO thread NYI"); - RefPtr<Runnable> runnable = - NS_NewNonOwningRunnableMethodWithArgs<std::vector<std::string>, - base::ProcessArchitecture>(this, - &GeckoChildProcessHost::RunPerformAsyncLaunch, - aExtraOpts, arch); - ioLoop->PostTask(runnable.forget()); + ioLoop->PostTask(NewNonOwningRunnableMethod + <std::vector<std::string>, base::ProcessArchitecture> + (this, &GeckoChildProcessHost::RunPerformAsyncLaunch, + aExtraOpts, arch)); return WaitUntilConnected(aTimeoutMs); } bool GeckoChildProcessHost::AsyncLaunch(std::vector<std::string> aExtraOpts, base::ProcessArchitecture arch) { PrepareLaunch(); MessageLoop* ioLoop = XRE_GetIOMessageLoop(); - RefPtr<Runnable> runnable = - NS_NewNonOwningRunnableMethodWithArgs<std::vector<std::string>, - base::ProcessArchitecture>(this, - &GeckoChildProcessHost::RunPerformAsyncLaunch, - aExtraOpts, arch); - ioLoop->PostTask(runnable.forget()); + ioLoop->PostTask(NewNonOwningRunnableMethod + <std::vector<std::string>, base::ProcessArchitecture> + (this, &GeckoChildProcessHost::RunPerformAsyncLaunch, + aExtraOpts, arch)); // This may look like the sync launch wait, but we only delay as // long as it takes to create the channel. MonitorAutoLock lock(mMonitor); while (mProcessState < CHANNEL_INITIALIZED) { lock.Wait(); } @@ -418,23 +414,20 @@ GeckoChildProcessHost::WaitUntilConnecte } bool GeckoChildProcessHost::LaunchAndWaitForProcessHandle(StringVector aExtraOpts) { PrepareLaunch(); MessageLoop* ioLoop = XRE_GetIOMessageLoop(); - RefPtr<Runnable> runnable = - NS_NewNonOwningRunnableMethodWithArgs<std::vector<std::string>, - base::ProcessArchitecture>(this, - &GeckoChildProcessHost::RunPerformAsyncLaunch, - aExtraOpts, - base::GetCurrentProcessArchitecture()); - ioLoop->PostTask(runnable.forget()); + ioLoop->PostTask(NewNonOwningRunnableMethod + <std::vector<std::string>, base::ProcessArchitecture> + (this, &GeckoChildProcessHost::RunPerformAsyncLaunch, + aExtraOpts, base::GetCurrentProcessArchitecture())); MonitorAutoLock lock(mMonitor); while (mProcessState < PROCESS_CREATED) { lock.Wait(); } MOZ_ASSERT(mProcessState == PROCESS_ERROR || mChildProcessHandle); return mProcessState < PROCESS_ERROR;
--- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -491,21 +491,20 @@ MessageChannel::MessageChannel(MessageLi MOZ_COUNT_CTOR(ipc::MessageChannel); #ifdef OS_WIN mTopFrame = nullptr; mIsSyncWaitingOnNonMainThread = false; #endif RefPtr<CancelableRunnable> runnable = - NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnMaybeDequeueOne); + NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnMaybeDequeueOne); mDequeueOneTask = new RefCountedTask(runnable.forget()); - runnable = NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::DispatchOnChannelConnected); - + runnable = NewNonOwningCancelableRunnableMethod(this, &MessageChannel::DispatchOnChannelConnected); mOnChannelConnectedTask = new RefCountedTask(runnable.forget()); #ifdef OS_WIN mEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr); MOZ_RELEASE_ASSERT(mEvent, "CreateEvent failed! Nothing is going to work!"); #endif } @@ -688,21 +687,20 @@ MessageChannel::Open(MessageChannel *aTa case ParentSide: oppSide = ChildSide; break; case UnknownSide: break; } mMonitor = new RefCountedMonitor(); MonitorAutoLock lock(*mMonitor); mChannelState = ChannelOpening; - RefPtr<Runnable> runnable = - NS_NewNonOwningRunnableMethodWithArgs<MessageChannel*, Side>(aTargetChan, - &MessageChannel::OnOpenAsSlave, - this, oppSide); - aTargetLoop->PostTask(runnable.forget()); + aTargetLoop->PostTask(NewNonOwningRunnableMethod + <MessageChannel*, Side>(aTargetChan, + &MessageChannel::OnOpenAsSlave, + this, oppSide)); while (ChannelOpening == mChannelState) mMonitor->Wait(); MOZ_RELEASE_ASSERT(ChannelConnected == mChannelState, "not connected when awoken"); return (ChannelConnected == mChannelState); } void @@ -2092,17 +2090,17 @@ MessageChannel::OnNotifyMaybeChannelErro // should only continue once OnChannelError has completed. { MonitorAutoLock lock(*mMonitor); // nothing to do here } if (IsOnCxxStack()) { mChannelErrorTask = - NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError); + NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError); RefPtr<Runnable> task = mChannelErrorTask; // 10 ms delay is completely arbitrary mWorkerLoop->PostDelayedTask(task.forget(), 10); return; } NotifyMaybeChannelError(); } @@ -2112,17 +2110,17 @@ MessageChannel::PostErrorNotifyTask() { mMonitor->AssertCurrentThreadOwns(); if (mChannelErrorTask) return; // This must be the last code that runs on this thread! mChannelErrorTask = - NS_NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError); + NewNonOwningCancelableRunnableMethod(this, &MessageChannel::OnNotifyMaybeChannelError); RefPtr<Runnable> task = mChannelErrorTask; mWorkerLoop->PostTask(task.forget()); } // Special async message. class GoodbyeMessage : public IPC::Message { public:
--- a/ipc/glue/MessageLink.cpp +++ b/ipc/glue/MessageLink.cpp @@ -113,24 +113,22 @@ ProcessLink::Open(mozilla::ipc::Transpor { MonitorAutoLock lock(*mChan->mMonitor); if (needOpen) { // Transport::Connect() has not been called. Call it so // we start polling our pipe and processing outgoing // messages. - RefPtr<Runnable> runnable = NS_NewNonOwningRunnableMethod(this, &ProcessLink::OnChannelOpened); - mIOLoop->PostTask(runnable.forget()); + mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnChannelOpened)); } else { // Transport::Connect() has already been called. Take // over the channel from the previous listener and process // any queued messages. - RefPtr<Runnable> runnable = NS_NewNonOwningRunnableMethod(this, &ProcessLink::OnTakeConnectedChannel); - mIOLoop->PostTask(runnable.forget()); + mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnTakeConnectedChannel)); } #ifdef MOZ_NUWA_PROCESS if (IsNuwaProcess() && NS_IsMainThread() && Preferences::GetBool("dom.ipc.processPrelaunch.testMode")) { // The pref value is turned on in a deadlock test against the Nuwa // process. The sleep here makes it easy to trigger the deadlock // that an IPC channel is still opening but the worker loop is @@ -147,19 +145,17 @@ ProcessLink::Open(mozilla::ipc::Transpor } void ProcessLink::EchoMessage(Message *msg) { mChan->AssertWorkerThread(); mChan->mMonitor->AssertCurrentThreadOwns(); - RefPtr<Runnable> runnable = - NS_NewNonOwningRunnableMethodWithArgs<Message*>(this, &ProcessLink::OnEchoMessage, msg); - mIOLoop->PostTask(runnable.forget()); + mIOLoop->PostTask(NewNonOwningRunnableMethod<Message*>(this, &ProcessLink::OnEchoMessage, msg)); // OnEchoMessage takes ownership of |msg| } void ProcessLink::SendMessage(Message *msg) { mChan->AssertWorkerThread(); mChan->mMonitor->AssertCurrentThreadOwns(); @@ -195,29 +191,26 @@ ProcessLink::SendMessage(Message *msg) "with a blocked IPC channel from \n%s", jsstack ? jsstack : "<no JS stack>"); JS_smprintf_free(jsstack); MOZ_CRASH(); } #endif #endif - RefPtr<Runnable> runnable = - NS_NewNonOwningRunnableMethodWithArgs<Message*>(mTransport, &Transport::Send, msg); - mIOLoop->PostTask(runnable.forget()); + mIOLoop->PostTask(NewNonOwningRunnableMethod<Message*>(mTransport, &Transport::Send, msg)); } void ProcessLink::SendClose() { mChan->AssertWorkerThread(); mChan->mMonitor->AssertCurrentThreadOwns(); - RefPtr<Runnable> runnable = NS_NewNonOwningRunnableMethod(this, &ProcessLink::OnCloseChannel); - mIOLoop->PostTask(runnable.forget()); + mIOLoop->PostTask(NewNonOwningRunnableMethod(this, &ProcessLink::OnCloseChannel)); } ThreadLink::ThreadLink(MessageChannel *aChan, MessageChannel *aTargetChan) : MessageLink(aChan), mTargetChan(aTargetChan) { }
--- a/layout/base/ZoomConstraintsClient.cpp +++ b/layout/base/ZoomConstraintsClient.cpp @@ -147,17 +147,17 @@ ZoomConstraintsClient::Observe(nsISuppor if (SameCOMIdentity(aSubject, mDocument) && BEFORE_FIRST_PAINT.EqualsASCII(aTopic)) { ZCC_LOG("Got a before-first-paint event in %p\n", this); RefreshZoomConstraints(); } else if (NS_PREF_CHANGED.EqualsASCII(aTopic)) { ZCC_LOG("Got a pref-change event in %p\n", this); // We need to run this later because all the pref change listeners need // to execute before we can be guaranteed that gfxPrefs::ForceUserScalable() // returns the updated value. - NS_DispatchToMainThread(NS_NewRunnableMethod( + NS_DispatchToMainThread(NewRunnableMethod( this, &ZoomConstraintsClient::RefreshZoomConstraints)); } return NS_OK; } void ZoomConstraintsClient::ScreenSizeChanged() {
--- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1585,17 +1585,17 @@ nsPresContext::GetTheme() void nsPresContext::ThemeChanged() { if (!mPendingThemeChanged) { sLookAndFeelChanged = true; sThemeChanged = true; nsCOMPtr<nsIRunnable> ev = - NS_NewRunnableMethod(this, &nsPresContext::ThemeChangedInternal); + NewRunnableMethod(this, &nsPresContext::ThemeChangedInternal); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPendingThemeChanged = true; } } } static void NotifyThemeChanged(TabParent* aTabParent, void* aArg) @@ -1644,17 +1644,17 @@ nsPresContext::ThemeChangedInternal() } void nsPresContext::SysColorChanged() { if (!mPendingSysColorChanged) { sLookAndFeelChanged = true; nsCOMPtr<nsIRunnable> ev = - NS_NewRunnableMethod(this, &nsPresContext::SysColorChangedInternal); + NewRunnableMethod(this, &nsPresContext::SysColorChangedInternal); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPendingSysColorChanged = true; } } } void nsPresContext::SysColorChangedInternal() @@ -1676,17 +1676,17 @@ nsPresContext::SysColorChangedInternal() RebuildAllStyleData(nsChangeHint(0), nsRestyleHint(0)); } void nsPresContext::UIResolutionChanged() { if (!mPendingUIResolutionChanged) { nsCOMPtr<nsIRunnable> ev = - NS_NewRunnableMethod(this, &nsPresContext::UIResolutionChangedInternal); + NewRunnableMethod(this, &nsPresContext::UIResolutionChangedInternal); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPendingUIResolutionChanged = true; } } } void nsPresContext::UIResolutionChangedSync() @@ -1927,17 +1927,17 @@ nsPresContext::MediaFeatureValuesChanged void nsPresContext::PostMediaFeatureValuesChangedEvent() { // FIXME: We should probably replace this event with use of // nsRefreshDriver::AddStyleFlushObserver (except the pres shell would // need to track whether it's been added). if (!mPendingMediaFeatureValuesChanged) { nsCOMPtr<nsIRunnable> ev = - NS_NewRunnableMethod(this, &nsPresContext::HandleMediaFeatureValuesChangedEvent); + NewRunnableMethod(this, &nsPresContext::HandleMediaFeatureValuesChangedEvent); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPendingMediaFeatureValuesChanged = true; mDocument->SetNeedStyleFlush(); } } } void @@ -2118,17 +2118,17 @@ nsPresContext::RebuildCounterStyles() // Still in its initial state, no need to reset. return; } mCounterStylesDirty = true; mDocument->SetNeedStyleFlush(); if (!mPostedFlushCounterStyles) { nsCOMPtr<nsIRunnable> ev = - NS_NewRunnableMethod(this, &nsPresContext::HandleRebuildCounterStyles); + NewRunnableMethod(this, &nsPresContext::HandleRebuildCounterStyles); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mPostedFlushCounterStyles = true; } } } void nsPresContext::NotifyMissingFonts()
--- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1905,17 +1905,17 @@ PresShell::ResizeReflowIgnoreOverride(ns if (mAsyncResizeEventTimer) { mAsyncResizeTimerIsActive = true; mAsyncResizeEventTimer->InitWithFuncCallback(AsyncResizeEventCallback, this, 15, nsITimer::TYPE_ONE_SHOT); } } else { RefPtr<nsRunnableMethod<PresShell> > resizeEvent = - NS_NewRunnableMethod(this, &PresShell::FireResizeEvent); + NewRunnableMethod(this, &PresShell::FireResizeEvent); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(resizeEvent))) { mResizeEvent = resizeEvent; mDocument->SetNeedStyleFlush(); } } } return NS_OK; //XXX this needs to be real. MMP @@ -6086,17 +6086,17 @@ PresShell::ScheduleApproximateFrameVisib return; } if (mUpdateApproximateFrameVisibilityEvent.IsPending()) { return; } RefPtr<nsRunnableMethod<PresShell> > ev = - NS_NewRunnableMethod(this, &PresShell::UpdateApproximateFrameVisibility); + NewRunnableMethod(this, &PresShell::UpdateApproximateFrameVisibility); if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) { mUpdateApproximateFrameVisibilityEvent = ev; } } void PresShell::MarkFrameVisibleInDisplayPort(nsIFrame* aFrame) { @@ -6369,17 +6369,17 @@ PresShell::Paint(nsView* aViewToP DecVisibleCount(oldInDisplayPortFrames, VisibilityCounter::IN_DISPLAYPORT); if (mVisibleRegions && !mNotifyCompositorOfVisibleRegionsChangeEvent.IsPending()) { // Asynchronously notify the compositor of the new visible regions, // since this is happening during a paint and updating the visible // regions triggers a recomposite. RefPtr<nsRunnableMethod<PresShell>> event = - NS_NewRunnableMethod(this, &PresShell::NotifyCompositorOfVisibleRegionsChange); + NewRunnableMethod(this, &PresShell::NotifyCompositorOfVisibleRegionsChange); if (NS_SUCCEEDED(NS_DispatchToMainThread(event))) { mNotifyCompositorOfVisibleRegionsChangeEvent = event; } } return; }
--- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -412,19 +412,19 @@ private: mRecentVsync = aVsyncTimestamp; if (!mProcessedVsync) { return true; } mProcessedVsync = false; } nsCOMPtr<nsIRunnable> vsyncEvent = - NS_NewRunnableMethodWithArg<TimeStamp>(this, - &RefreshDriverVsyncObserver::TickRefreshDriver, - aVsyncTimestamp); + NewRunnableMethod<TimeStamp>(this, + &RefreshDriverVsyncObserver::TickRefreshDriver, + aVsyncTimestamp); NS_DispatchToMainThread(vsyncEvent); } else { TickRefreshDriver(aVsyncTimestamp); } return true; } @@ -1970,17 +1970,17 @@ nsRefreshDriver::Thaw() } if (mFreezeCount == 0) { if (ObserverCount() || ImageRequestCount()) { // FIXME: This isn't quite right, since our EnsureTimerStarted call // updates our mMostRecentRefresh, but the DoRefresh call won't run // and notify our observers until we get back to the event loop. // Thus MostRecentRefresh() will lie between now and the DoRefresh. - NS_DispatchToCurrentThread(NS_NewRunnableMethod(this, &nsRefreshDriver::DoRefresh)); + NS_DispatchToCurrentThread(NewRunnableMethod(this, &nsRefreshDriver::DoRefresh)); EnsureTimerStarted(); } } } void nsRefreshDriver::FinishedWaitingForTransaction() {
--- a/layout/ipc/VsyncParent.cpp +++ b/layout/ipc/VsyncParent.cpp @@ -45,19 +45,19 @@ VsyncParent::~VsyncParent() } bool VsyncParent::NotifyVsync(TimeStamp aTimeStamp) { // Called on hardware vsync thread. We should post to current ipc thread. MOZ_ASSERT(!IsOnBackgroundThread()); nsCOMPtr<nsIRunnable> vsyncEvent = - NS_NewRunnableMethodWithArg<TimeStamp>(this, - &VsyncParent::DispatchVsyncEvent, - aTimeStamp); + NewRunnableMethod<TimeStamp>(this, + &VsyncParent::DispatchVsyncEvent, + aTimeStamp); MOZ_ALWAYS_SUCCEEDS(mBackgroundThread->Dispatch(vsyncEvent, NS_DISPATCH_NORMAL)); return true; } void VsyncParent::DispatchVsyncEvent(TimeStamp aTimeStamp) { AssertIsOnBackgroundThread();
--- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -1466,17 +1466,17 @@ FontFaceSet::OnFontFaceStatusChanged(Fon // relevant elements in the document. We want to wait until the reflow // request has been done before the FontFaceSet is marked as Loaded so // that we don't briefly set the FontFaceSet to Loaded and then Loading // again once the reflow is pending. So we go around the event loop // and call CheckLoadingFinished() after the reflow has been queued. if (!mDelayedLoadCheck) { mDelayedLoadCheck = true; nsCOMPtr<nsIRunnable> checkTask = - NS_NewRunnableMethod(this, &FontFaceSet::CheckLoadingFinishedAfterDelay); + NewRunnableMethod(this, &FontFaceSet::CheckLoadingFinishedAfterDelay); NS_DispatchToMainThread(checkTask); } } } void FontFaceSet::DidRefresh() {
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -187,17 +187,17 @@ public: disabled_frame_sent_ = true; } else { disabled_frame_sent_ = false; } ++mLength; // Atomic nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArgs<StorensRefPtrPassByPtr<Image>, bool>( + NewRunnableMethod<StorensRefPtrPassByPtr<Image>, bool>( this, &VideoFrameConverter::ProcessVideoFrame, aChunk.mFrame.GetImage(), forceBlack); mTaskQueue->Dispatch(runnable.forget()); } void AddListener(VideoConverterListener* aListener) { MutexAutoLock lock(mMutex);
--- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -1199,21 +1199,20 @@ nsJARChannel::OnDataAvailable(nsIRequest // simply report progress here instead of hooking ourselves up as a // nsITransportEventSink implementation. // XXX do the 64-bit stuff for real if (mProgressSink && NS_SUCCEEDED(rv)) { if (NS_IsMainThread()) { FireOnProgress(offset + count); } else { - nsCOMPtr<nsIRunnable> runnable = - NS_NewRunnableMethodWithArg<uint64_t>(this, - &nsJARChannel::FireOnProgress, - offset + count); - NS_DispatchToMainThread(runnable); + NS_DispatchToMainThread(NewRunnableMethod + <uint64_t>(this, + &nsJARChannel::FireOnProgress, + offset + count)); } } return rv; // let the pump cancel on failure } NS_IMETHODIMP nsJARChannel::RetargetDeliveryTo(nsIEventTarget* aEventTarget)
--- a/netwerk/base/BackgroundFileSaver.cpp +++ b/netwerk/base/BackgroundFileSaver.cpp @@ -322,21 +322,19 @@ BackgroundFileSaver::GetWorkerThreadAtte // And in any case, Finish already closes one end of the pipe, causing the // copy to finish properly on its own. if (mWorkerThreadAttentionRequested) { return NS_OK; } if (!mAsyncCopyContext) { // Copy is not in progress, post an event to handle the change manually. - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &BackgroundFileSaver::ProcessAttention); - NS_ENSURE_TRUE(event, NS_ERROR_FAILURE); - - rv = mWorkerThread->Dispatch(event, NS_DISPATCH_NORMAL); + rv = mWorkerThread->Dispatch(NewRunnableMethod(this, + &BackgroundFileSaver::ProcessAttention), + NS_DISPATCH_NORMAL); NS_ENSURE_SUCCESS(rv, rv); } else if (aShouldInterruptCopy) { // Interrupt the copy. The copy will be resumed, if needed, by the // ProcessAttention function, invoked by the AsyncCopyCallback function. NS_CancelAsyncCopy(mAsyncCopyContext, NS_ERROR_ABORT); } // Indicate that attention has been requested successfully, there is no need @@ -744,20 +742,19 @@ BackgroundFileSaver::CheckCompletion() if (NS_FAILED(rv)) { LOG(("Unable to extract signature information [this = %p].", this)); } else { LOG(("Signature extraction success! [this = %p]", this)); } } // Post an event to notify that the operation completed. - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethod(this, &BackgroundFileSaver::NotifySaveComplete); - if (!event || - NS_FAILED(mControlThread->Dispatch(event, NS_DISPATCH_NORMAL))) { + if (NS_FAILED(mControlThread->Dispatch(NewRunnableMethod(this, + &BackgroundFileSaver::NotifySaveComplete), + NS_DISPATCH_NORMAL))) { NS_WARNING("Unable to post completion event to the control thread."); } return true; } // Called on the control thread. nsresult @@ -1151,20 +1148,19 @@ BackgroundFileSaverStreamListener::Async // we have now consumed enough data. if (self->mReceivedTooMuchData) { uint64_t available; nsresult rv = self->mPipeInputStream->Available(&available); if (NS_FAILED(rv) || available < REQUEST_RESUME_AT) { self->mReceivedTooMuchData = false; // Post an event to verify if the request should be resumed. - nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(self, - &BackgroundFileSaverStreamListener::NotifySuspendOrResume); - if (!event || NS_FAILED(self->mControlThread->Dispatch(event, - NS_DISPATCH_NORMAL))) { + if (NS_FAILED(self->mControlThread->Dispatch(NewRunnableMethod(self, + &BackgroundFileSaverStreamListener::NotifySuspendOrResume), + NS_DISPATCH_NORMAL))) { NS_WARNING("Unable to post resume event to the control thread."); } } } } // Called on the control thread. nsresult
--- a/netwerk/base/Dashboard.cpp +++ b/netwerk/base/Dashboard.cpp @@ -170,20 +170,19 @@ NS_IMETHODIMP ConnectionData::OnTransportStatus(nsITransport *aTransport, nsresult aStatus, int64_t aProgress, int64_t aProgressMax) { if (aStatus == NS_NET_STATUS_CONNECTED_TO) { StopTimer(); } GetErrorString(aStatus, mStatus); - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethodWithArg<RefPtr<ConnectionData> > - (mDashboard, &Dashboard::GetConnectionStatus, this); - mThread->Dispatch(event, NS_DISPATCH_NORMAL); + mThread->Dispatch(NewRunnableMethod<RefPtr<ConnectionData>> + (mDashboard, &Dashboard::GetConnectionStatus, this), + NS_DISPATCH_NORMAL); return NS_OK; } NS_IMETHODIMP ConnectionData::Notify(nsITimer *aTimer) { MOZ_ASSERT(aTimer == mTimer); @@ -192,20 +191,19 @@ ConnectionData::Notify(nsITimer *aTimer) mSocket->Close(NS_ERROR_ABORT); mSocket = nullptr; mStreamIn = nullptr; } mTimer = nullptr; mStatus.AssignLiteral(MOZ_UTF16("NS_ERROR_NET_TIMEOUT")); - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethodWithArg<RefPtr<ConnectionData> > - (mDashboard, &Dashboard::GetConnectionStatus, this); - mThread->Dispatch(event, NS_DISPATCH_NORMAL); + mThread->Dispatch(NewRunnableMethod<RefPtr<ConnectionData>> + (mDashboard, &Dashboard::GetConnectionStatus, this), + NS_DISPATCH_NORMAL); return NS_OK; } void ConnectionData::StartTimer(uint32_t aTimeout) { if (!mTimer) { @@ -282,20 +280,19 @@ NS_IMETHODIMP LookupHelper::OnLookupComplete(nsICancelable *aRequest, nsIDNSRecord *aRecord, nsresult aStatus) { MOZ_ASSERT(aRequest == mCancel); mCancel = nullptr; mStatus = aStatus; RefPtr<LookupArgument> arg = new LookupArgument(aRecord, this); - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethodWithArg<RefPtr<LookupArgument> >( - this, &LookupHelper::ConstructAnswer, arg); - mThread->Dispatch(event, NS_DISPATCH_NORMAL); + mThread->Dispatch(NewRunnableMethod<RefPtr<LookupArgument>> + (this, &LookupHelper::ConstructAnswer, arg), + NS_DISPATCH_NORMAL); return NS_OK; } nsresult LookupHelper::ConstructAnswer(LookupArgument *aArgument) { nsIDNSRecord *aRecord = aArgument->mRecord; @@ -349,36 +346,34 @@ Dashboard::~Dashboard() NS_IMETHODIMP Dashboard::RequestSockets(NetDashboardCallback *aCallback) { RefPtr<SocketData> socketData = new SocketData(); socketData->mCallback = new nsMainThreadPtrHolder<NetDashboardCallback>(aCallback, true); socketData->mThread = NS_GetCurrentThread(); - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethodWithArg<RefPtr<SocketData> > - (this, &Dashboard::GetSocketsDispatch, socketData); - gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL); + gSocketTransportService->Dispatch(NewRunnableMethod<RefPtr<SocketData>> + (this, &Dashboard::GetSocketsDispatch, socketData), + NS_DISPATCH_NORMAL); return NS_OK; } nsresult Dashboard::GetSocketsDispatch(SocketData *aSocketData) { RefPtr<SocketData> socketData = aSocketData; if (gSocketTransportService) { gSocketTransportService->GetSocketConnections(&socketData->mData); socketData->mTotalSent = gSocketTransportService->GetSentBytes(); socketData->mTotalRecv = gSocketTransportService->GetReceivedBytes(); } - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethodWithArg<RefPtr<SocketData> > - (this, &Dashboard::GetSockets, socketData); - socketData->mThread->Dispatch(event, NS_DISPATCH_NORMAL); + socketData->mThread->Dispatch(NewRunnableMethod<RefPtr<SocketData>> + (this, &Dashboard::GetSockets, socketData), + NS_DISPATCH_NORMAL); return NS_OK; } nsresult Dashboard::GetSockets(SocketData *aSocketData) { RefPtr<SocketData> socketData = aSocketData; AutoSafeJSContext cx; @@ -421,32 +416,30 @@ Dashboard::GetSockets(SocketData *aSocke NS_IMETHODIMP Dashboard::RequestHttpConnections(NetDashboardCallback *aCallback) { RefPtr<HttpData> httpData = new HttpData(); httpData->mCallback = new nsMainThreadPtrHolder<NetDashboardCallback>(aCallback, true); httpData->mThread = NS_GetCurrentThread(); - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethodWithArg<RefPtr<HttpData> > - (this, &Dashboard::GetHttpDispatch, httpData); - gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL); + gSocketTransportService->Dispatch(NewRunnableMethod<RefPtr<HttpData>> + (this, &Dashboard::GetHttpDispatch, httpData), + NS_DISPATCH_NORMAL); return NS_OK; } nsresult Dashboard::GetHttpDispatch(HttpData *aHttpData) { RefPtr<HttpData> httpData = aHttpData; HttpInfo::GetHttpConnectionData(&httpData->mData); - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethodWithArg<RefPtr<HttpData> > - (this, &Dashboard::GetHttpConnections, httpData); - httpData->mThread->Dispatch(event, NS_DISPATCH_NORMAL); + httpData->mThread->Dispatch(NewRunnableMethod<RefPtr<HttpData>> + (this, &Dashboard::GetHttpConnections, httpData), + NS_DISPATCH_NORMAL); return NS_OK; } nsresult Dashboard::GetHttpConnections(HttpData *aHttpData) { RefPtr<HttpData> httpData = aHttpData; @@ -599,20 +592,19 @@ Dashboard::NewMsgReceived(const nsACStri NS_IMETHODIMP Dashboard::RequestWebsocketConnections(NetDashboardCallback *aCallback) { RefPtr<WebSocketRequest> wsRequest = new WebSocketRequest(); wsRequest->mCallback = new nsMainThreadPtrHolder<NetDashboardCallback>(aCallback, true); wsRequest->mThread = NS_GetCurrentThread(); - nsCOMPtr<nsIRunnable> event = - NS_NewRunnableMethodWithArg<RefPtr<WebSocketRequest> > - (this, &Dashboard::GetWebSocketConnections, wsRequest); - wsRequest->mThread->Dispatch(event, NS_DISPATCH_NORMAL); + wsRequest->mThread->Dispatch(NewRunnableMethod<RefPtr<WebSocketRequest>> + (this, &Dashboard::GetWebSocketConnections, wsRequest), + NS_DISPATCH_NORMAL); return NS_OK;