From de92769e7e08886ed515f83f8791d80d93117e46 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Fri, 29 Apr 2016 14:21:18 +0200 Subject: [PATCH] Backed out changeset 4bcb784492bb (bug 1268313) --HG-- extra : rebase_source : f2f752ab73f5bbf31a909892a0fac0f42c894430 --- dom/ipc/ContentBridgeChild.cpp | 4 +- dom/ipc/ContentBridgeParent.cpp | 8 +- dom/ipc/ContentBridgeParent.h | 6 -- dom/ipc/ContentParent.cpp | 14 ++-- dom/ipc/PreallocatedProcessManager.cpp | 9 +- dom/media/gmp/GMPDecryptorChild.cpp | 9 +- dom/media/gmp/GMPPlatform.cpp | 10 +-- dom/media/gmp/GMPStorageChild.cpp | 2 +- dom/media/gmp/GMPVideoDecoderChild.cpp | 3 +- dom/media/gmp/GMPVideoEncoderChild.cpp | 3 +- .../MediaSystemResourceManager.cpp | 28 +++---- gfx/layers/apz/src/APZCTreeManager.cpp | 4 +- gfx/layers/apz/src/AsyncPanZoomController.cpp | 41 +++++---- gfx/layers/apz/src/InputQueue.cpp | 5 +- gfx/layers/apz/util/APZCCallbackHelper.cpp | 8 +- gfx/layers/apz/util/APZCCallbackHelper.h | 6 +- .../apz/util/ChromeProcessController.cpp | 52 ++++-------- gfx/layers/ipc/CompositorBridgeParent.cpp | 44 ++++------ gfx/layers/ipc/RemoteContentController.cpp | 83 +++++++------------ gfx/thebes/SoftwareVsyncSource.cpp | 8 +- gfx/vr/ipc/VRManagerParent.cpp | 4 +- ipc/chromium/src/base/task.h | 5 -- widget/nsBaseWidget.cpp | 31 +++---- xpcom/base/nsDumpUtils.cpp | 4 +- xpcom/base/nsDumpUtils.h | 5 +- 25 files changed, 149 insertions(+), 247 deletions(-) diff --git a/dom/ipc/ContentBridgeChild.cpp b/dom/ipc/ContentBridgeChild.cpp index 6d6b4f44bb2b..30dbfc720f5d 100644 --- a/dom/ipc/ContentBridgeChild.cpp +++ b/dom/ipc/ContentBridgeChild.cpp @@ -34,8 +34,8 @@ ContentBridgeChild::~ContentBridgeChild() void ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy) { - RefPtr runnable = NS_NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask( + NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy)); } /*static*/ ContentBridgeChild* diff --git a/dom/ipc/ContentBridgeParent.cpp b/dom/ipc/ContentBridgeParent.cpp index 7fd22c7a51a6..608f7f2abcf8 100644 --- a/dom/ipc/ContentBridgeParent.cpp +++ b/dom/ipc/ContentBridgeParent.cpp @@ -37,8 +37,8 @@ ContentBridgeParent::ActorDestroy(ActorDestroyReason aWhy) if (os) { os->RemoveObserver(this, "content-child-shutdown"); } - RefPtr runnable = NS_NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask( + NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy)); } /*static*/ ContentBridgeParent* @@ -168,8 +168,8 @@ ContentBridgeParent::NotifyTabDestroyed() { int32_t numLiveTabs = ManagedPBrowserParent().Count(); if (numLiveTabs == 1) { - RefPtr runnable = NS_NewRunnableMethod(this, &ContentBridgeParent::Close); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask( + NewRunnableMethod(this, &ContentBridgeParent::Close)); } } diff --git a/dom/ipc/ContentBridgeParent.h b/dom/ipc/ContentBridgeParent.h index abff80392b20..2094bc8251d4 100644 --- a/dom/ipc/ContentBridgeParent.h +++ b/dom/ipc/ContentBridgeParent.h @@ -79,12 +79,6 @@ protected: mIsForBrowser = aIsForBrowser; } - void Close() - { - // Trick NS_NewRunnableMethod - PContentBridgeParent::Close(); - } - protected: virtual bool RecvSyncMessage(const nsString& aMsg, diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 3ad093c2165e..01887ab9cf03 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -2177,10 +2177,9 @@ ContentParent::ActorDestroy(ActorDestroyReason why) // Destroy any processes created by this ContentParent for(uint32_t i = 0; i < childIDArray.Length(); i++) { ContentParent* cp = cpm->GetContentProcessById(childIDArray[i]); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(cp, &ContentParent::ShutDownProcess, - SEND_SHUTDOWN_MESSAGE); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask( + NewRunnableMethod(cp, &ContentParent::ShutDownProcess, + SEND_SHUTDOWN_MESSAGE)); } cpm->RemoveContentProcess(this->ChildID()); @@ -2261,10 +2260,9 @@ ContentParent::NotifyTabDestroyed(const TabId& aTabId, 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 = - NS_NewRunnableMethodWithArgs(this, &ContentParent::ShutDownProcess, - SEND_SHUTDOWN_MESSAGE); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask( + NewRunnableMethod(this, &ContentParent::ShutDownProcess, + SEND_SHUTDOWN_MESSAGE)); } } diff --git a/dom/ipc/PreallocatedProcessManager.cpp b/dom/ipc/PreallocatedProcessManager.cpp index edb438aeca86..697e6199477c 100644 --- a/dom/ipc/PreallocatedProcessManager.cpp +++ b/dom/ipc/PreallocatedProcessManager.cpp @@ -204,9 +204,8 @@ PreallocatedProcessManagerImpl::AllocateAfterDelay() return; } - RefPtr runnable = NS_NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle); MessageLoop::current()->PostDelayedTask( - runnable.forget(), + NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle), Preferences::GetUint("dom.ipc.processPrelaunch.delayMs", DEFAULT_ALLOCATE_DELAY)); } @@ -218,8 +217,8 @@ PreallocatedProcessManagerImpl::AllocateOnIdle() return; } - RefPtr runnable = NS_NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow); - MessageLoop::current()->PostIdleTask(runnable.forget()); + MessageLoop::current()->PostIdleTask( + NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow)); } void @@ -244,7 +243,7 @@ PreallocatedProcessManagerImpl::ScheduleDelayedNuwaFork() return; } - RefPtr task = NS_NewCancelableRunnableMethod( + RefPtr task = NewRunnableMethod( this, &PreallocatedProcessManagerImpl::DelayedNuwaFork); mPreallocateAppProcessTask = task; MessageLoop::current()->PostDelayedTask(task.forget(), diff --git a/dom/media/gmp/GMPDecryptorChild.cpp b/dom/media/gmp/GMPDecryptorChild.cpp index 1999165d76f4..0627aad15e14 100644 --- a/dom/media/gmp/GMPDecryptorChild.cpp +++ b/dom/media/gmp/GMPDecryptorChild.cpp @@ -61,8 +61,7 @@ GMPDecryptorChild::CallOnGMPThread(MethodType aMethod, ParamType&&... aParams) // Use const reference when we have to. auto m = &GMPDecryptorChild::CallMethod< decltype(aMethod), typename AddConstReference::Type...>; - RefPtr t = - dont_add_new_uses_of_this::NewRunnableMethod(this, m, aMethod, Forward(aParams)...); + RefPtr t = NewRunnableMethod(this, m, aMethod, Forward(aParams)...); mPlugin->GMPMessageLoop()->PostTask(t.forget()); } } @@ -171,11 +170,7 @@ 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 t = - NS_NewRunnableMethodWithArgs(this, - &GMPDecryptorChild::Decrypted, - aBuffer, aResult); + RefPtr t = NewRunnableMethod(this, &GMPDecryptorChild::Decrypted, aBuffer, aResult); mPlugin->GMPMessageLoop()->PostTask(t.forget()); return; } diff --git a/dom/media/gmp/GMPPlatform.cpp b/dom/media/gmp/GMPPlatform.cpp index 23d7256671ef..05c513209b68 100644 --- a/dom/media/gmp/GMPPlatform.cpp +++ b/dom/media/gmp/GMPPlatform.cpp @@ -73,8 +73,7 @@ public: // main thread tries to do a sync call back to the calling thread. MOZ_ASSERT(!IsOnChildMainThread()); - RefPtr runnable = NS_NewRunnableMethod(this, &SyncRunnable::Run); - mMessageLoop->PostTask(runnable.forget()); + mMessageLoop->PostTask(NewRunnableMethod(this, &SyncRunnable::Run)); MonitorAutoLock lock(mMonitor); while (!mDone) { lock.Wait(); @@ -122,8 +121,7 @@ RunOnMainThread(GMPTask* aTask) } RefPtr r = new Runnable(aTask); - RefPtr runnable = NS_NewRunnableMethod(r, &Runnable::Run); - sMainLoop->PostTask(runnable.forget()); + sMainLoop->PostTask(NewRunnableMethod(r.get(), &Runnable::Run)); return GMPNoErr; } @@ -255,8 +253,8 @@ GMPThreadImpl::Post(GMPTask* aTask) } RefPtr r = new Runnable(aTask); - RefPtr runnable = NS_NewRunnableMethod(r, &Runnable::Run); - mThread.message_loop()->PostTask(runnable.forget()); + + mThread.message_loop()->PostTask(NewRunnableMethod(r.get(), &Runnable::Run)); } void diff --git a/dom/media/gmp/GMPStorageChild.cpp b/dom/media/gmp/GMPStorageChild.cpp index 37186c16bd5a..62056cd8ff25 100644 --- a/dom/media/gmp/GMPStorageChild.cpp +++ b/dom/media/gmp/GMPStorageChild.cpp @@ -15,7 +15,7 @@ _func(__VA_ARGS__); \ } else { \ mPlugin->GMPMessageLoop()->PostTask( \ - dont_add_new_uses_of_this::NewRunnableMethod(this, &GMPStorageChild::_func, ##__VA_ARGS__) \ + NewRunnableMethod(this, &GMPStorageChild::_func, ##__VA_ARGS__) \ ); \ } \ } while(false) diff --git a/dom/media/gmp/GMPVideoDecoderChild.cpp b/dom/media/gmp/GMPVideoDecoderChild.cpp index 1eb3e53df44b..4d0074a2728a 100644 --- a/dom/media/gmp/GMPVideoDecoderChild.cpp +++ b/dom/media/gmp/GMPVideoDecoderChild.cpp @@ -226,8 +226,7 @@ GMPVideoDecoderChild::Alloc(size_t aSize, rv = CallNeedShmem(aSize, aMem); --mNeedShmemIntrCount; if (mPendingDecodeComplete) { - RefPtr runnable = NS_NewRunnableMethod(this, &GMPVideoDecoderChild::RecvDecodingComplete); - mPlugin->GMPMessageLoop()->PostTask(runnable.forget()); + mPlugin->GMPMessageLoop()->PostTask(NewRunnableMethod(this, &GMPVideoDecoderChild::RecvDecodingComplete)); } #else #ifdef GMP_SAFE_SHMEM diff --git a/dom/media/gmp/GMPVideoEncoderChild.cpp b/dom/media/gmp/GMPVideoEncoderChild.cpp index d10a677789da..319450cb0d65 100644 --- a/dom/media/gmp/GMPVideoEncoderChild.cpp +++ b/dom/media/gmp/GMPVideoEncoderChild.cpp @@ -207,8 +207,7 @@ GMPVideoEncoderChild::Alloc(size_t aSize, rv = CallNeedShmem(aSize, aMem); --mNeedShmemIntrCount; if (mPendingEncodeComplete) { - RefPtr runnable = NS_NewRunnableMethod(this, &GMPVideoEncoderChild::RecvEncodingComplete); - mPlugin->GMPMessageLoop()->PostTask(runnable.forget()); + mPlugin->GMPMessageLoop()->PostTask(NewRunnableMethod(this, &GMPVideoEncoderChild::RecvEncodingComplete)); } #else #ifdef GMP_SAFE_SHMEM diff --git a/dom/media/systemservices/MediaSystemResourceManager.cpp b/dom/media/systemservices/MediaSystemResourceManager.cpp index 2da48288f37a..4d833dd2397f 100644 --- a/dom/media/systemservices/MediaSystemResourceManager.cpp +++ b/dom/media/systemservices/MediaSystemResourceManager.cpp @@ -198,12 +198,11 @@ MediaSystemResourceManager::Acquire(MediaSystemResourceClient* aClient) return; } aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING; - RefPtr runnable = - NS_NewRunnableMethodWithArgs( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod( this, &MediaSystemResourceManager::DoAcquire, - aClient->mId); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aClient->mId)); } bool @@ -242,12 +241,11 @@ MediaSystemResourceManager::AcquireSyncNoWait(MediaSystemResourceClient* aClient aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING; } - RefPtr runnable = - NS_NewRunnableMethodWithArgs( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod( this, &MediaSystemResourceManager::DoAcquire, - aClient->mId); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aClient->mId)); // should stop the thread until done. while (!done) { @@ -310,12 +308,11 @@ MediaSystemResourceManager::ReleaseResource(MediaSystemResourceClient* aClient) aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_END; - RefPtr runnable = - NS_NewRunnableMethodWithArgs( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod( this, &MediaSystemResourceManager::DoRelease, - aClient->mId); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aClient->mId)); } } @@ -339,13 +336,12 @@ void MediaSystemResourceManager::HandleAcquireResult(uint32_t aId, bool aSuccess) { if (!InImageBridgeChildThread()) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs( + ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask( + NewRunnableMethod( this, &MediaSystemResourceManager::HandleAcquireResult, aId, - aSuccess); - ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget()); + aSuccess)); return; } diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index fd66eaea20fa..a09407fa79eb 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -1335,8 +1335,8 @@ 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 = NS_NewRunnableMethod(mInputQueue.get(), &InputQueue::Clear); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod( + mInputQueue.get(), &InputQueue::Clear)); MutexAutoLock lock(mTreeLock); diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index d74536e38015..cef0f6c53767 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -516,9 +516,9 @@ public: // is this one, then the SetState(NOTHING) in UpdateAnimation will // stomp on the SetState(SNAP_BACK) it does. mDeferredTasks.AppendElement( - NS_NewRunnableMethodWithArg(mOverscrollHandoffChain.get(), - &OverscrollHandoffChain::SnapBackOverscrolledApzc, - &mApzc)); + NewRunnableMethod(mOverscrollHandoffChain.get(), + &OverscrollHandoffChain::SnapBackOverscrolledApzc, + &mApzc)); return false; } @@ -568,13 +568,11 @@ public: // 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, - RefPtr>(&mApzc, - &AsyncPanZoomController::HandleFlingOverscroll, - velocity, - mOverscrollHandoffChain, - mScrolledApzc)); + NewRunnableMethod(&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.) @@ -702,7 +700,9 @@ public: // 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; @@ -819,9 +819,9 @@ public: // the lock ordering. Instead we schedule HandleSmoothScrollOverscroll() to be // called after mMonitor is released. mDeferredTasks.AppendElement( - NS_NewRunnableMethodWithArgs(&mApzc, - &AsyncPanZoomController::HandleSmoothScrollOverscroll, - velocity)); + NewRunnableMethod(&mApzc, + &AsyncPanZoomController::HandleSmoothScrollOverscroll, + velocity)); return false; } @@ -2172,14 +2172,11 @@ nsEventStatus AsyncPanZoomController::GenerateSingleTap(const ScreenIntPoint& aP // 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 = - NS_NewRunnableMethodWithArgs(controller, &GeckoContentController::HandleSingleTap, - geckoScreenPoint, aModifiers, - GetGuid()); - - controller->PostDelayedTask(runnable.forget(), 0); + controller->PostDelayedTask( + NewRunnableMethod(controller.get(), &GeckoContentController::HandleSingleTap, + geckoScreenPoint, aModifiers, + GetGuid()), + 0); return nsEventStatus_eConsumeNoDefault; } } diff --git a/gfx/layers/apz/src/InputQueue.cpp b/gfx/layers/apz/src/InputQueue.cpp index 1fe5606da344..0909465d6a6c 100644 --- a/gfx/layers/apz/src/InputQueue.cpp +++ b/gfx/layers/apz/src/InputQueue.cpp @@ -570,9 +570,8 @@ InputQueue::ScheduleMainThreadTimeout(const RefPtr& aTar CancelableBlockState* aBlock) { INPQ_LOG("scheduling main thread timeout for target %p\n", aTarget.get()); aBlock->StartContentResponseTimer(); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &InputQueue::MainThreadTimeout, aBlock->GetBlockId()); - aTarget->PostDelayedTask(runnable.forget(), + aTarget->PostDelayedTask( + NewRunnableMethod(this, &InputQueue::MainThreadTimeout, aBlock->GetBlockId()), gfxPrefs::APZContentResponseTimeout()); } diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index c1a77138b83c..e5fa1c9a9027 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -688,7 +688,7 @@ public: } APZCCH_LOG("Got refresh, sending target APZCs for input block %" PRIu64 "\n", mInputBlockId); - SendLayersDependentApzcTargetConfirmation(mPresShell, mInputBlockId, Move(mTargets)); + SendLayersDependentApzcTargetConfirmation(mPresShell, mInputBlockId, mTargets); if (!mPresShell->RemovePostRefreshObserver(this)) { MOZ_ASSERT_UNREACHABLE("Unable to unregister post-refresh observer! Leaking it instead of leaving garbage registered"); @@ -719,7 +719,7 @@ SendSetTargetAPZCNotificationHelper(nsIWidget* aWidget, if (waitForRefresh) { APZCCH_LOG("At least one target got a new displayport, need to wait for refresh\n"); waitForRefresh = aShell->AddPostRefreshObserver( - new DisplayportSetListener(aShell, aInputBlockId, Move(aTargets))); + new DisplayportSetListener(aShell, aInputBlockId, aTargets)); } if (!waitForRefresh) { APZCCH_LOG("Sending target APZCs for input block %" PRIu64 "\n", aInputBlockId); @@ -770,7 +770,7 @@ APZCCallbackHelper::SendSetTargetAPZCNotification(nsIWidget* aWidget, aWidget, shell, aInputBlockId, - Move(targets), + targets, waitForRefresh); } } @@ -790,7 +790,7 @@ APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification( widget::ContentHelper::GetAllowedTouchBehavior( aWidget, aEvent.mTouches[i]->mRefPoint)); } - aCallback(aInputBlockId, Move(flags)); + aCallback(aInputBlockId, flags); } void diff --git a/gfx/layers/apz/util/APZCCallbackHelper.h b/gfx/layers/apz/util/APZCCallbackHelper.h index c9002c05e790..c421957823ba 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.h +++ b/gfx/layers/apz/util/APZCCallbackHelper.h @@ -141,9 +141,9 @@ public: /* Figure out the allowed touch behaviors of each touch point in |aEvent| * and send that information to the provided callback. */ static void SendSetAllowedTouchBehaviorNotification(nsIWidget* aWidget, - const WidgetTouchEvent& aEvent, - uint64_t aInputBlockId, - const SetAllowedTouchBehaviorCallback& aCallback); + const WidgetTouchEvent& aEvent, + uint64_t aInputBlockId, + const SetAllowedTouchBehaviorCallback& aCallback); /* Notify content of a mouse scroll testing event. */ static void NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent); diff --git a/gfx/layers/apz/util/ChromeProcessController.cpp b/gfx/layers/apz/util/ChromeProcessController.cpp index 54950bd04d43..ee7aab2375da 100644 --- a/gfx/layers/apz/util/ChromeProcessController.cpp +++ b/gfx/layers/apz/util/ChromeProcessController.cpp @@ -36,8 +36,8 @@ ChromeProcessController::ChromeProcessController(nsIWidget* aWidget, MOZ_ASSERT(aAPZEventState); MOZ_ASSERT(aAPZCTreeManager); - RefPtr runnable = NS_NewRunnableMethod(this, &ChromeProcessController::InitializeRoot); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &ChromeProcessController::InitializeRoot)); } ChromeProcessController::~ChromeProcessController() {} @@ -71,8 +71,8 @@ void ChromeProcessController::Destroy() { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = NS_NewRunnableMethod(this, &ChromeProcessController::Destroy); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &ChromeProcessController::Destroy)); return; } @@ -121,12 +121,9 @@ ChromeProcessController::HandleDoubleTap(const mozilla::CSSPoint& aPoint, const ScrollableLayerGuid& aGuid) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &ChromeProcessController::HandleDoubleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &ChromeProcessController::HandleDoubleTap, + aPoint, aModifiers, aGuid)); return; } @@ -161,12 +158,9 @@ ChromeProcessController::HandleSingleTap(const CSSPoint& aPoint, const ScrollableLayerGuid& aGuid) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &ChromeProcessController::HandleSingleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &ChromeProcessController::HandleSingleTap, + aPoint, aModifiers, aGuid)); return; } @@ -179,13 +173,9 @@ ChromeProcessController::HandleLongTap(const mozilla::CSSPoint& aPoint, Modifier uint64_t aInputBlockId) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &ChromeProcessController::HandleLongTap, - aPoint, aModifiers, aGuid, aInputBlockId); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &ChromeProcessController::HandleLongTap, + aPoint, aModifiers, aGuid, aInputBlockId)); return; } @@ -199,12 +189,9 @@ ChromeProcessController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, int aArg) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &ChromeProcessController::NotifyAPZStateChange, - aGuid, aChange, aArg); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &ChromeProcessController::NotifyAPZStateChange, + aGuid, aChange, aArg)); return; } @@ -215,11 +202,8 @@ void ChromeProcessController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &ChromeProcessController::NotifyMozMouseScrollEvent, - aScrollId, aEvent); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &ChromeProcessController::NotifyMozMouseScrollEvent, aScrollId, aEvent)); return; } diff --git a/gfx/layers/ipc/CompositorBridgeParent.cpp b/gfx/layers/ipc/CompositorBridgeParent.cpp index 00e6d032e47d..8d47d7720635 100644 --- a/gfx/layers/ipc/CompositorBridgeParent.cpp +++ b/gfx/layers/ipc/CompositorBridgeParent.cpp @@ -362,7 +362,7 @@ CompositorVsyncScheduler::SetDisplay(bool aDisplayEnable) MOZ_ASSERT(NS_IsMainThread()); MonitorAutoLock lock(mSetDisplayMonitor); RefPtr task = - NS_NewCancelableRunnableMethodWithArgs(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable); + NewRunnableMethod(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable); mSetDisplayTask = task; ScheduleTask(task.forget(), 0); return; @@ -982,8 +982,7 @@ CompositorBridgeParent::ActorDestroy(ActorDestroyReason why) // We must keep the compositor parent alive untill the code handling message // reception is finished on this thread. mSelfRef = this; - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask(NewRunnableMethod(this,&CompositorBridgeParent::DeferredDestroy)); } @@ -991,16 +990,14 @@ void CompositorBridgeParent::ScheduleRenderOnCompositorThread() { MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ScheduleComposition); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ScheduleComposition)); } void CompositorBridgeParent::InvalidateOnCompositorThread() { MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::Invalidate); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::Invalidate)); } void @@ -1091,8 +1088,7 @@ CompositorBridgeParent::SchedulePauseOnCompositorThread() MonitorAutoLock lock(mPauseCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - RefPtr 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(); @@ -1104,8 +1100,7 @@ CompositorBridgeParent::ScheduleResumeOnCompositorThread() MonitorAutoLock lock(mResumeCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - RefPtr 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(); @@ -1119,10 +1114,7 @@ CompositorBridgeParent::ScheduleResumeOnCompositorThread(int width, int height) MonitorAutoLock lock(mResumeCompositionMonitor); MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &CompositorBridgeParent::ResumeCompositionAndResize, - width, height); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ResumeCompositionAndResize, width, height)); // Wait until the resume has actually been processed by the compositor thread lock.Wait(); @@ -2115,13 +2107,11 @@ CompositorBridgeParent::ResetCompositor(const nsTArray& aBackendH { MonitorAutoLock lock(mResetCompositorMonitor); - RefPtr runnable = - NS_NewRunnableMethodWithArgs>, - Maybe*>(this, - &CompositorBridgeParent::ResetCompositorTask, - aBackendHints, - &newIdentifier); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask( + NewRunnableMethod(this, + &CompositorBridgeParent::ResetCompositorTask, + aBackendHints, + &newIdentifier)); mResetCompositorMonitor.Wait(); } @@ -2289,8 +2279,8 @@ CrossProcessCompositorBridgeParent::ActorDestroy(ActorDestroyReason aWhy) // We must keep this object alive untill the code handling message // reception is finished on this thread. - RefPtr runnable = NS_NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask( + NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy)); } PLayerTransactionParent* @@ -2535,8 +2525,7 @@ void CompositorBridgeParent::ScheduleShowAllPluginWindows() { MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ShowAllPluginWindows); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ShowAllPluginWindows)); } void @@ -2551,8 +2540,7 @@ void CompositorBridgeParent::ScheduleHideAllPluginWindows() { MOZ_ASSERT(CompositorLoop()); - RefPtr runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::HideAllPluginWindows); - CompositorLoop()->PostTask(runnable.forget()); + CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::HideAllPluginWindows)); } void diff --git a/gfx/layers/ipc/RemoteContentController.cpp b/gfx/layers/ipc/RemoteContentController.cpp index d86593476154..180ca065e30d 100644 --- a/gfx/layers/ipc/RemoteContentController.cpp +++ b/gfx/layers/ipc/RemoteContentController.cpp @@ -58,12 +58,9 @@ RemoteContentController::HandleDoubleTap(const CSSPoint& aPoint, if (MessageLoop::current() != mUILoop) { // We have to send this message from the "UI thread" (main // thread). - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &RemoteContentController::HandleDoubleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &RemoteContentController::HandleDoubleTap, + aPoint, aModifiers, aGuid)); return; } if (CanSend()) { @@ -80,12 +77,9 @@ RemoteContentController::HandleSingleTap(const CSSPoint& aPoint, if (MessageLoop::current() != mUILoop) { // We have to send this message from the "UI thread" (main // thread). - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &RemoteContentController::HandleSingleTap, - aPoint, aModifiers, aGuid); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &RemoteContentController::HandleSingleTap, + aPoint, aModifiers, aGuid)); return; } @@ -116,13 +110,9 @@ RemoteContentController::HandleLongTap(const CSSPoint& aPoint, if (MessageLoop::current() != mUILoop) { // We have to send this message from the "UI thread" (main // thread). - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &RemoteContentController::HandleLongTap, - aPoint, aModifiers, aGuid, aInputBlockId); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &RemoteContentController::HandleLongTap, + aPoint, aModifiers, aGuid, aInputBlockId)); return; } if (CanSend()) { @@ -160,12 +150,9 @@ RemoteContentController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid, int aArg) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &RemoteContentController::NotifyAPZStateChange, - aGuid, aChange, aArg); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &RemoteContentController::NotifyAPZStateChange, + aGuid, aChange, aArg)); return; } if (CanSend()) { @@ -178,11 +165,9 @@ RemoteContentController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& a const nsString& aEvent) { if (MessageLoop::current() != mUILoop) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(this, &RemoteContentController::NotifyMozMouseScrollEvent, - aScrollId, aEvent); - mUILoop->PostTask(runnable.forget()); + mUILoop->PostTask( + NewRunnableMethod(this, &RemoteContentController::NotifyMozMouseScrollEvent, + aScrollId, aEvent)); return; } @@ -232,13 +217,9 @@ RemoteContentController::RecvContentReceivedInputBlock(const ScrollableLayerGuid return false; } if (RefPtr apzcTreeManager = GetApzcTreeManager()) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs(apzcTreeManager, - &APZCTreeManager::ContentReceivedInputBlock, - aInputBlockId, aPreventDefault); - APZThreadUtils::RunOnControllerThread(runnable.forget()); - + APZThreadUtils::RunOnControllerThread(NewRunnableMethod( + apzcTreeManager.get(), &APZCTreeManager::ContentReceivedInputBlock, + aInputBlockId, aPreventDefault)); } return true; } @@ -250,12 +231,10 @@ RemoteContentController::RecvStartScrollbarDrag(const AsyncDragMetrics& aDragMet ScrollableLayerGuid guid(mLayersId, aDragMetrics.mPresShellId, aDragMetrics.mViewId); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(apzcTreeManager, - &APZCTreeManager::StartScrollbarDrag, - guid, aDragMetrics); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread( + NewRunnableMethod(apzcTreeManager.get(), + &APZCTreeManager::StartScrollbarDrag, + guid, aDragMetrics)); } return true; } @@ -275,12 +254,9 @@ RemoteContentController::RecvSetTargetAPZC(const uint64_t& aInputBlockId, // need a local var to disambiguate between the SetTargetAPZC overloads. void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray&) = &APZCTreeManager::SetTargetAPZC; - RefPtr runnable = - NS_NewRunnableMethodWithArgs>>(apzcTreeManager, setTargetApzcFunc, - aInputBlockId, aTargets); - APZThreadUtils::RunOnControllerThread(runnable.forget()); - + APZThreadUtils::RunOnControllerThread(NewRunnableMethod( + apzcTreeManager.get(), setTargetApzcFunc, + aInputBlockId, aTargets)); } return true; } @@ -290,12 +266,9 @@ RemoteContentController::RecvSetAllowedTouchBehavior(const uint64_t& aInputBlock nsTArray&& aFlags) { if (RefPtr apzcTreeManager = GetApzcTreeManager()) { - RefPtr runnable = - NS_NewRunnableMethodWithArgs>>(apzcTreeManager, - &APZCTreeManager::SetAllowedTouchBehavior, - aInputBlockId, Move(aFlags)); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod( + apzcTreeManager.get(), &APZCTreeManager::SetAllowedTouchBehavior, + aInputBlockId, Move(aFlags))); } return true; } diff --git a/gfx/thebes/SoftwareVsyncSource.cpp b/gfx/thebes/SoftwareVsyncSource.cpp index aa01013dc0fb..06a2232d7328 100644 --- a/gfx/thebes/SoftwareVsyncSource.cpp +++ b/gfx/thebes/SoftwareVsyncSource.cpp @@ -45,8 +45,8 @@ SoftwareDisplay::EnableVsync() } mVsyncEnabled = true; - RefPtr runnable = NS_NewRunnableMethod(this, &SoftwareDisplay::EnableVsync); - mVsyncThread->message_loop()->PostTask(runnable.forget()); + mVsyncThread->message_loop()->PostTask( + NewRunnableMethod(this, &SoftwareDisplay::EnableVsync)); return; } @@ -64,8 +64,8 @@ SoftwareDisplay::DisableVsync() } mVsyncEnabled = false; - RefPtr runnable = NS_NewRunnableMethod(this, &SoftwareDisplay::DisableVsync); - mVsyncThread->message_loop()->PostTask(runnable.forget()); + mVsyncThread->message_loop()->PostTask( + NewRunnableMethod(this, &SoftwareDisplay::DisableVsync)); return; } diff --git a/gfx/vr/ipc/VRManagerParent.cpp b/gfx/vr/ipc/VRManagerParent.cpp index f64119066bf8..b68baa817d33 100644 --- a/gfx/vr/ipc/VRManagerParent.cpp +++ b/gfx/vr/ipc/VRManagerParent.cpp @@ -112,8 +112,8 @@ void VRManagerParent::ActorDestroy(ActorDestroyReason why) { UnregisterFromManager(); - RefPtr runnable = NS_NewRunnableMethod(this, &VRManagerParent::DeferredDestroy); - MessageLoop::current()->PostTask(runnable.forget()); + MessageLoop::current()->PostTask( + NewRunnableMethod(this, &VRManagerParent::DeferredDestroy)); } mozilla::ipc::IToplevelProtocol* diff --git a/ipc/chromium/src/base/task.h b/ipc/chromium/src/base/task.h index 07787d64b13d..f3c4bb74eb8e 100644 --- a/ipc/chromium/src/base/task.h +++ b/ipc/chromium/src/base/task.h @@ -303,9 +303,6 @@ class RunnableMethod : public mozilla::CancelableRunnable, Params params_; }; -namespace dont_add_new_uses_of_this { - -// Don't add new uses of this!!!! template inline already_AddRefed NewRunnableMethod(T* object, Method method, Args&&... args) { @@ -316,8 +313,6 @@ NewRunnableMethod(T* object, Method method, Args&&... args) { return t.forget(); } -} // namespace dont_add_new_uses_of_this - // RunnableFunction and NewRunnableFunction implementation --------------------- template diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index dcb041f3444a..cb91a31c066c 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -966,10 +966,9 @@ void nsBaseWidget::ConfigureAPZCTreeManager() bool aPreventDefault) { MOZ_ASSERT(NS_IsMainThread()); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(treeManager, &APZCTreeManager::ContentReceivedInputBlock, - aInputBlockId, aPreventDefault); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod( + treeManager.get(), &APZCTreeManager::ContentReceivedInputBlock, + aInputBlockId, aPreventDefault)); }); mAPZEventState = new APZEventState(this, mozilla::Move(callback)); @@ -977,12 +976,9 @@ void nsBaseWidget::ConfigureAPZCTreeManager() const nsTArray& aFlags) { MOZ_ASSERT(NS_IsMainThread()); - RefPtr runnable = - NS_NewRunnableMethodWithArgs>>(treeManager, - &APZCTreeManager::SetAllowedTouchBehavior, - aInputBlockId, aFlags); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod( + treeManager.get(), &APZCTreeManager::SetAllowedTouchBehavior, + aInputBlockId, aFlags)); }; mRootContentController = CreateRootContentController(); @@ -1013,12 +1009,8 @@ nsBaseWidget::SetConfirmedTargetAPZC(uint64_t aInputBlockId, // Need to specifically bind this since it's overloaded. void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray&) = &APZCTreeManager::SetTargetAPZC; - RefPtr runnable = - NS_NewRunnableMethodWithArgs>>(mAPZC, - setTargetApzcFunc, - aInputBlockId, aTargets); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread(NewRunnableMethod( + mAPZC.get(), setTargetApzcFunc, aInputBlockId, aTargets)); } void @@ -1936,11 +1928,8 @@ nsBaseWidget::StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics) int layersId = mCompositorBridgeParent->RootLayerTreeId();; ScrollableLayerGuid guid(layersId, aDragMetrics.mPresShellId, aDragMetrics.mViewId); - RefPtr runnable = - NS_NewRunnableMethodWithArgs(mAPZC, &APZCTreeManager::StartScrollbarDrag, - guid, aDragMetrics); - APZThreadUtils::RunOnControllerThread(runnable.forget()); + APZThreadUtils::RunOnControllerThread( + NewRunnableMethod(mAPZC.get(), &APZCTreeManager::StartScrollbarDrag, guid, aDragMetrics)); } already_AddRefed diff --git a/xpcom/base/nsDumpUtils.cpp b/xpcom/base/nsDumpUtils.cpp index d2c33d5ccdb3..b9d9eb4f5c5c 100644 --- a/xpcom/base/nsDumpUtils.cpp +++ b/xpcom/base/nsDumpUtils.cpp @@ -74,8 +74,8 @@ FdWatcher::Init() nsCOMPtr os = services::GetObserverService(); os->AddObserver(this, "xpcom-shutdown", /* ownsWeak = */ false); - RefPtr runnable = NS_NewRunnableMethod(this, &FdWatcher::StartWatching); - XRE_GetIOMessageLoop()->PostTask(runnable.forget()); + XRE_GetIOMessageLoop()->PostTask( + NewRunnableMethod(this, &FdWatcher::StartWatching)); } // Implementations may call this function multiple times if they ensure that diff --git a/xpcom/base/nsDumpUtils.h b/xpcom/base/nsDumpUtils.h index 1d9c8cfb90f2..46951f59f8d0 100644 --- a/xpcom/base/nsDumpUtils.h +++ b/xpcom/base/nsDumpUtils.h @@ -89,9 +89,8 @@ public: MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(!strcmp(aTopic, "xpcom-shutdown")); - RefPtr runnable = - NS_NewRunnableMethod(this, &FdWatcher::StopWatching); - XRE_GetIOMessageLoop()->PostTask(runnable.forget()); + XRE_GetIOMessageLoop()->PostTask( + NewRunnableMethod(this, &FdWatcher::StopWatching)); return NS_OK; }