Bug 1268313: Part 6 - Replace NewRunnableMethod with NS_NewRunnableMethod. r=froydnj

This commit is contained in:
Kyle Huey 2016-05-05 01:45:00 -07:00
Родитель 7c2af31504
Коммит 44cee0989e
25 изменённых файлов: 247 добавлений и 149 удалений

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

@ -34,8 +34,8 @@ ContentBridgeChild::~ContentBridgeChild()
void
ContentBridgeChild::ActorDestroy(ActorDestroyReason aWhy)
{
MessageLoop::current()->PostTask(
NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ContentBridgeChild::DeferredDestroy);
MessageLoop::current()->PostTask(runnable.forget());
}
/*static*/ ContentBridgeChild*

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

@ -37,8 +37,8 @@ ContentBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
if (os) {
os->RemoveObserver(this, "content-child-shutdown");
}
MessageLoop::current()->PostTask(
NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ContentBridgeParent::DeferredDestroy);
MessageLoop::current()->PostTask(runnable.forget());
}
/*static*/ ContentBridgeParent*
@ -168,8 +168,8 @@ ContentBridgeParent::NotifyTabDestroyed()
{
int32_t numLiveTabs = ManagedPBrowserParent().Count();
if (numLiveTabs == 1) {
MessageLoop::current()->PostTask(
NewRunnableMethod(this, &ContentBridgeParent::Close));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ContentBridgeParent::Close);
MessageLoop::current()->PostTask(runnable.forget());
}
}

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

@ -79,6 +79,12 @@ protected:
mIsForBrowser = aIsForBrowser;
}
void Close()
{
// Trick NS_NewRunnableMethod
PContentBridgeParent::Close();
}
protected:
virtual bool
RecvSyncMessage(const nsString& aMsg,

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

@ -2180,9 +2180,10 @@ 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]);
MessageLoop::current()->PostTask(
NewRunnableMethod(cp, &ContentParent::ShutDownProcess,
SEND_SHUTDOWN_MESSAGE));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<ShutDownMethod>(cp, &ContentParent::ShutDownProcess,
SEND_SHUTDOWN_MESSAGE);
MessageLoop::current()->PostTask(runnable.forget());
}
cpm->RemoveContentProcess(this->ChildID());
@ -2263,9 +2264,10 @@ 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.
MessageLoop::current()->PostTask(
NewRunnableMethod(this, &ContentParent::ShutDownProcess,
SEND_SHUTDOWN_MESSAGE));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<ShutDownMethod>(this, &ContentParent::ShutDownProcess,
SEND_SHUTDOWN_MESSAGE);
MessageLoop::current()->PostTask(runnable.forget());
}
}

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

@ -204,8 +204,9 @@ PreallocatedProcessManagerImpl::AllocateAfterDelay()
return;
}
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle);
MessageLoop::current()->PostDelayedTask(
NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateOnIdle),
runnable.forget(),
Preferences::GetUint("dom.ipc.processPrelaunch.delayMs",
DEFAULT_ALLOCATE_DELAY));
}
@ -217,8 +218,8 @@ PreallocatedProcessManagerImpl::AllocateOnIdle()
return;
}
MessageLoop::current()->PostIdleTask(
NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &PreallocatedProcessManagerImpl::AllocateNow);
MessageLoop::current()->PostIdleTask(runnable.forget());
}
void
@ -243,7 +244,7 @@ PreallocatedProcessManagerImpl::ScheduleDelayedNuwaFork()
return;
}
RefPtr<CancelableRunnable> task = NewRunnableMethod(
RefPtr<CancelableRunnable> task = NS_NewCancelableRunnableMethod(
this, &PreallocatedProcessManagerImpl::DelayedNuwaFork);
mPreallocateAppProcessTask = task;
MessageLoop::current()->PostDelayedTask(task.forget(),

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

@ -61,7 +61,8 @@ GMPDecryptorChild::CallOnGMPThread(MethodType aMethod, ParamType&&... aParams)
// Use const reference when we have to.
auto m = &GMPDecryptorChild::CallMethod<
decltype(aMethod), typename AddConstReference<ParamType>::Type...>;
RefPtr<mozilla::Runnable> t = NewRunnableMethod(this, m, aMethod, Forward<ParamType>(aParams)...);
RefPtr<mozilla::Runnable> t =
dont_add_new_uses_of_this::NewRunnableMethod(this, m, aMethod, Forward<ParamType>(aParams)...);
mPlugin->GMPMessageLoop()->PostTask(t.forget());
}
}
@ -170,7 +171,11 @@ 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 = NewRunnableMethod(this, &GMPDecryptorChild::Decrypted, aBuffer, aResult);
RefPtr<Runnable> t =
NS_NewRunnableMethodWithArgs<GMPBuffer*,
GMPErr>(this,
&GMPDecryptorChild::Decrypted,
aBuffer, aResult);
mPlugin->GMPMessageLoop()->PostTask(t.forget());
return;
}

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

@ -73,7 +73,8 @@ public:
// main thread tries to do a sync call back to the calling thread.
MOZ_ASSERT(!IsOnChildMainThread());
mMessageLoop->PostTask(NewRunnableMethod(this, &GMPSyncRunnable::Run));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &GMPSyncRunnable::Run);
mMessageLoop->PostTask(runnable.forget());
MonitorAutoLock lock(mMonitor);
while (!mDone) {
lock.Wait();
@ -121,7 +122,8 @@ RunOnMainThread(GMPTask* aTask)
}
RefPtr<GMPRunnable> r = new GMPRunnable(aTask);
sMainLoop->PostTask(NewRunnableMethod(r.get(), &GMPRunnable::Run));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(r, &GMPRunnable::Run);
sMainLoop->PostTask(runnable.forget());
return GMPNoErr;
}
@ -253,8 +255,8 @@ GMPThreadImpl::Post(GMPTask* aTask)
}
RefPtr<GMPRunnable> r = new GMPRunnable(aTask);
mThread.message_loop()->PostTask(NewRunnableMethod(r.get(), &GMPRunnable::Run));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(r.get(), &GMPRunnable::Run);
mThread.message_loop()->PostTask(runnable.forget());
}
void

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

@ -15,7 +15,7 @@
_func(__VA_ARGS__); \
} else { \
mPlugin->GMPMessageLoop()->PostTask( \
NewRunnableMethod(this, &GMPStorageChild::_func, ##__VA_ARGS__) \
dont_add_new_uses_of_this::NewRunnableMethod(this, &GMPStorageChild::_func, ##__VA_ARGS__) \
); \
} \
} while(false)

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

@ -226,7 +226,8 @@ GMPVideoDecoderChild::Alloc(size_t aSize,
rv = CallNeedShmem(aSize, aMem);
--mNeedShmemIntrCount;
if (mPendingDecodeComplete) {
mPlugin->GMPMessageLoop()->PostTask(NewRunnableMethod(this, &GMPVideoDecoderChild::RecvDecodingComplete));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &GMPVideoDecoderChild::RecvDecodingComplete);
mPlugin->GMPMessageLoop()->PostTask(runnable.forget());
}
#else
#ifdef GMP_SAFE_SHMEM

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

@ -207,7 +207,8 @@ GMPVideoEncoderChild::Alloc(size_t aSize,
rv = CallNeedShmem(aSize, aMem);
--mNeedShmemIntrCount;
if (mPendingEncodeComplete) {
mPlugin->GMPMessageLoop()->PostTask(NewRunnableMethod(this, &GMPVideoEncoderChild::RecvEncodingComplete));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &GMPVideoEncoderChild::RecvEncodingComplete);
mPlugin->GMPMessageLoop()->PostTask(runnable.forget());
}
#else
#ifdef GMP_SAFE_SHMEM

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

@ -198,11 +198,12 @@ MediaSystemResourceManager::Acquire(MediaSystemResourceClient* aClient)
return;
}
aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING;
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
NewRunnableMethod(
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<uint32_t>(
this,
&MediaSystemResourceManager::DoAcquire,
aClient->mId));
aClient->mId);
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget());
}
bool
@ -241,11 +242,12 @@ MediaSystemResourceManager::AcquireSyncNoWait(MediaSystemResourceClient* aClient
aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_WAITING;
}
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
NewRunnableMethod(
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<uint32_t>(
this,
&MediaSystemResourceManager::DoAcquire,
aClient->mId));
aClient->mId);
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget());
// should stop the thread until done.
while (!done) {
@ -308,11 +310,12 @@ MediaSystemResourceManager::ReleaseResource(MediaSystemResourceClient* aClient)
aClient->mResourceState = MediaSystemResourceClient::RESOURCE_STATE_END;
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
NewRunnableMethod(
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<uint32_t>(
this,
&MediaSystemResourceManager::DoRelease,
aClient->mId));
aClient->mId);
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget());
}
}
@ -336,12 +339,13 @@ void
MediaSystemResourceManager::HandleAcquireResult(uint32_t aId, bool aSuccess)
{
if (!InImageBridgeChildThread()) {
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(
NewRunnableMethod(
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<uint32_t, bool>(
this,
&MediaSystemResourceManager::HandleAcquireResult,
aId,
aSuccess));
aSuccess);
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(runnable.forget());
return;
}

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

@ -1345,8 +1345,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.
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
mInputQueue.get(), &InputQueue::Clear));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(mInputQueue.get(), &InputQueue::Clear);
APZThreadUtils::RunOnControllerThread(runnable.forget());
MutexAutoLock lock(mTreeLock);

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

@ -516,7 +516,7 @@ public:
// is this one, then the SetState(NOTHING) in UpdateAnimation will
// stomp on the SetState(SNAP_BACK) it does.
mDeferredTasks.AppendElement(
NewRunnableMethod(mOverscrollHandoffChain.get(),
NS_NewRunnableMethodWithArg<AsyncPanZoomController*>(mOverscrollHandoffChain.get(),
&OverscrollHandoffChain::SnapBackOverscrolledApzc,
&mApzc));
return false;
@ -568,7 +568,9 @@ 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(
NewRunnableMethod(&mApzc,
NS_NewRunnableMethodWithArgs<ParentLayerPoint,
RefPtr<const OverscrollHandoffChain>,
RefPtr<const AsyncPanZoomController>>(&mApzc,
&AsyncPanZoomController::HandleFlingOverscroll,
velocity,
mOverscrollHandoffChain,
@ -700,9 +702,7 @@ 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(
NewRunnableMethod(&mApzc,
&AsyncPanZoomController::ScrollSnap));
mDeferredTasks.AppendElement(NS_NewRunnableMethod(&mApzc, &AsyncPanZoomController::ScrollSnap));
return false;
}
return true;
@ -819,7 +819,7 @@ public:
// the lock ordering. Instead we schedule HandleSmoothScrollOverscroll() to be
// called after mMonitor is released.
mDeferredTasks.AppendElement(
NewRunnableMethod(&mApzc,
NS_NewRunnableMethodWithArgs<ParentLayerPoint>(&mApzc,
&AsyncPanZoomController::HandleSmoothScrollOverscroll,
velocity));
return false;
@ -2180,11 +2180,14 @@ 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.
controller->PostDelayedTask(
NewRunnableMethod(controller.get(), &GeckoContentController::HandleSingleTap,
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<CSSPoint,
mozilla::Modifiers,
ScrollableLayerGuid>(controller, &GeckoContentController::HandleSingleTap,
geckoScreenPoint, aModifiers,
GetGuid()),
0);
GetGuid());
controller->PostDelayedTask(runnable.forget(), 0);
return nsEventStatus_eConsumeNoDefault;
}
}

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

@ -570,8 +570,9 @@ InputQueue::ScheduleMainThreadTimeout(const RefPtr<AsyncPanZoomController>& aTar
CancelableBlockState* aBlock) {
INPQ_LOG("scheduling main thread timeout for target %p\n", aTarget.get());
aBlock->StartContentResponseTimer();
aTarget->PostDelayedTask(
NewRunnableMethod(this, &InputQueue::MainThreadTimeout, aBlock->GetBlockId()),
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<uint64_t>(this, &InputQueue::MainThreadTimeout, aBlock->GetBlockId());
aTarget->PostDelayedTask(runnable.forget(),
gfxPrefs::APZContentResponseTimeout());
}

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

@ -688,7 +688,7 @@ public:
}
APZCCH_LOG("Got refresh, sending target APZCs for input block %" PRIu64 "\n", mInputBlockId);
SendLayersDependentApzcTargetConfirmation(mPresShell, mInputBlockId, mTargets);
SendLayersDependentApzcTargetConfirmation(mPresShell, mInputBlockId, Move(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, aTargets));
new DisplayportSetListener(aShell, aInputBlockId, Move(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,
targets,
Move(targets),
waitForRefresh);
}
}
@ -790,7 +790,7 @@ APZCCallbackHelper::SendSetAllowedTouchBehaviorNotification(
widget::ContentHelper::GetAllowedTouchBehavior(
aWidget, aEvent.mTouches[i]->mRefPoint));
}
aCallback(aInputBlockId, flags);
aCallback(aInputBlockId, Move(flags));
}
void

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

@ -36,8 +36,8 @@ ChromeProcessController::ChromeProcessController(nsIWidget* aWidget,
MOZ_ASSERT(aAPZEventState);
MOZ_ASSERT(aAPZCTreeManager);
mUILoop->PostTask(
NewRunnableMethod(this, &ChromeProcessController::InitializeRoot));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ChromeProcessController::InitializeRoot);
mUILoop->PostTask(runnable.forget());
}
ChromeProcessController::~ChromeProcessController() {}
@ -71,8 +71,8 @@ void
ChromeProcessController::Destroy()
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
NewRunnableMethod(this, &ChromeProcessController::Destroy));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &ChromeProcessController::Destroy);
mUILoop->PostTask(runnable.forget());
return;
}
@ -121,9 +121,12 @@ ChromeProcessController::HandleDoubleTap(const mozilla::CSSPoint& aPoint,
const ScrollableLayerGuid& aGuid)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
NewRunnableMethod(this, &ChromeProcessController::HandleDoubleTap,
aPoint, aModifiers, aGuid));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<CSSPoint,
Modifiers,
ScrollableLayerGuid>(this, &ChromeProcessController::HandleDoubleTap,
aPoint, aModifiers, aGuid);
mUILoop->PostTask(runnable.forget());
return;
}
@ -158,9 +161,12 @@ ChromeProcessController::HandleSingleTap(const CSSPoint& aPoint,
const ScrollableLayerGuid& aGuid)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
NewRunnableMethod(this, &ChromeProcessController::HandleSingleTap,
aPoint, aModifiers, aGuid));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<CSSPoint,
Modifiers,
ScrollableLayerGuid>(this, &ChromeProcessController::HandleSingleTap,
aPoint, aModifiers, aGuid);
mUILoop->PostTask(runnable.forget());
return;
}
@ -173,9 +179,13 @@ ChromeProcessController::HandleLongTap(const mozilla::CSSPoint& aPoint, Modifier
uint64_t aInputBlockId)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
NewRunnableMethod(this, &ChromeProcessController::HandleLongTap,
aPoint, aModifiers, aGuid, aInputBlockId));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<mozilla::CSSPoint,
Modifiers,
ScrollableLayerGuid,
uint64_t>(this, &ChromeProcessController::HandleLongTap,
aPoint, aModifiers, aGuid, aInputBlockId);
mUILoop->PostTask(runnable.forget());
return;
}
@ -189,9 +199,12 @@ ChromeProcessController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
int aArg)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
NewRunnableMethod(this, &ChromeProcessController::NotifyAPZStateChange,
aGuid, aChange, aArg));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<ScrollableLayerGuid,
APZStateChange,
int>(this, &ChromeProcessController::NotifyAPZStateChange,
aGuid, aChange, aArg);
mUILoop->PostTask(runnable.forget());
return;
}
@ -202,8 +215,11 @@ void
ChromeProcessController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& aScrollId, const nsString& aEvent)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
NewRunnableMethod(this, &ChromeProcessController::NotifyMozMouseScrollEvent, aScrollId, aEvent));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<FrameMetrics::ViewID,
nsString>(this, &ChromeProcessController::NotifyMozMouseScrollEvent,
aScrollId, aEvent);
mUILoop->PostTask(runnable.forget());
return;
}

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

@ -361,7 +361,7 @@ CompositorVsyncScheduler::SetDisplay(bool aDisplayEnable)
MOZ_ASSERT(NS_IsMainThread());
MonitorAutoLock lock(mSetDisplayMonitor);
RefPtr<CancelableRunnable> task =
NewRunnableMethod(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable);
NS_NewCancelableRunnableMethodWithArgs<bool>(this, &CompositorVsyncScheduler::SetDisplay, aDisplayEnable);
mSetDisplayTask = task;
ScheduleTask(task.forget(), 0);
return;
@ -980,7 +980,8 @@ CompositorBridgeParent::ActorDestroy(ActorDestroyReason why)
// We must keep the compositor parent alive untill the code handling message
// reception is finished on this thread.
mSelfRef = this;
MessageLoop::current()->PostTask(NewRunnableMethod(this,&CompositorBridgeParent::DeferredDestroy));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::DeferredDestroy);
MessageLoop::current()->PostTask(runnable.forget());
}
@ -988,14 +989,16 @@ void
CompositorBridgeParent::ScheduleRenderOnCompositorThread()
{
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ScheduleComposition));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ScheduleComposition);
CompositorLoop()->PostTask(runnable.forget());
}
void
CompositorBridgeParent::InvalidateOnCompositorThread()
{
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::Invalidate));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::Invalidate);
CompositorLoop()->PostTask(runnable.forget());
}
void
@ -1086,7 +1089,8 @@ CompositorBridgeParent::SchedulePauseOnCompositorThread()
MonitorAutoLock lock(mPauseCompositionMonitor);
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::PauseComposition));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::PauseComposition);
CompositorLoop()->PostTask(runnable.forget());
// Wait until the pause has actually been processed by the compositor thread
lock.Wait();
@ -1098,7 +1102,8 @@ CompositorBridgeParent::ScheduleResumeOnCompositorThread()
MonitorAutoLock lock(mResumeCompositionMonitor);
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ResumeComposition));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ResumeComposition);
CompositorLoop()->PostTask(runnable.forget());
// Wait until the resume has actually been processed by the compositor thread
lock.Wait();
@ -1112,7 +1117,10 @@ CompositorBridgeParent::ScheduleResumeOnCompositorThread(int width, int height)
MonitorAutoLock lock(mResumeCompositionMonitor);
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ResumeCompositionAndResize, width, height));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<int, int>(this, &CompositorBridgeParent::ResumeCompositionAndResize,
width, height);
CompositorLoop()->PostTask(runnable.forget());
// Wait until the resume has actually been processed by the compositor thread
lock.Wait();
@ -2105,11 +2113,13 @@ CompositorBridgeParent::ResetCompositor(const nsTArray<LayersBackend>& aBackendH
{
MonitorAutoLock lock(mResetCompositorMonitor);
CompositorLoop()->PostTask(
NewRunnableMethod(this,
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<StoreCopyPassByConstLRef<nsTArray<LayersBackend>>,
Maybe<TextureFactoryIdentifier>*>(this,
&CompositorBridgeParent::ResetCompositorTask,
aBackendHints,
&newIdentifier));
&newIdentifier);
CompositorLoop()->PostTask(runnable.forget());
mResetCompositorMonitor.Wait();
}
@ -2277,8 +2287,8 @@ CrossProcessCompositorBridgeParent::ActorDestroy(ActorDestroyReason aWhy)
// We must keep this object alive untill the code handling message
// reception is finished on this thread.
MessageLoop::current()->PostTask(
NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CrossProcessCompositorBridgeParent::DeferredDestroy);
MessageLoop::current()->PostTask(runnable.forget());
}
PLayerTransactionParent*
@ -2525,7 +2535,8 @@ void
CompositorBridgeParent::ScheduleShowAllPluginWindows()
{
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::ShowAllPluginWindows));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::ShowAllPluginWindows);
CompositorLoop()->PostTask(runnable.forget());
}
void
@ -2540,7 +2551,8 @@ void
CompositorBridgeParent::ScheduleHideAllPluginWindows()
{
MOZ_ASSERT(CompositorLoop());
CompositorLoop()->PostTask(NewRunnableMethod(this, &CompositorBridgeParent::HideAllPluginWindows));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &CompositorBridgeParent::HideAllPluginWindows);
CompositorLoop()->PostTask(runnable.forget());
}
void

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

@ -58,9 +58,12 @@ RemoteContentController::HandleDoubleTap(const CSSPoint& aPoint,
if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main
// thread).
mUILoop->PostTask(
NewRunnableMethod(this, &RemoteContentController::HandleDoubleTap,
aPoint, aModifiers, aGuid));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<CSSPoint,
Modifiers,
ScrollableLayerGuid>(this, &RemoteContentController::HandleDoubleTap,
aPoint, aModifiers, aGuid);
mUILoop->PostTask(runnable.forget());
return;
}
if (CanSend()) {
@ -77,9 +80,12 @@ RemoteContentController::HandleSingleTap(const CSSPoint& aPoint,
if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main
// thread).
mUILoop->PostTask(
NewRunnableMethod(this, &RemoteContentController::HandleSingleTap,
aPoint, aModifiers, aGuid));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<CSSPoint,
Modifiers,
ScrollableLayerGuid>(this, &RemoteContentController::HandleSingleTap,
aPoint, aModifiers, aGuid);
mUILoop->PostTask(runnable.forget());
return;
}
@ -110,9 +116,13 @@ RemoteContentController::HandleLongTap(const CSSPoint& aPoint,
if (MessageLoop::current() != mUILoop) {
// We have to send this message from the "UI thread" (main
// thread).
mUILoop->PostTask(
NewRunnableMethod(this, &RemoteContentController::HandleLongTap,
aPoint, aModifiers, aGuid, aInputBlockId));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<CSSPoint,
Modifiers,
ScrollableLayerGuid,
uint64_t>(this, &RemoteContentController::HandleLongTap,
aPoint, aModifiers, aGuid, aInputBlockId);
mUILoop->PostTask(runnable.forget());
return;
}
if (CanSend()) {
@ -150,9 +160,12 @@ RemoteContentController::NotifyAPZStateChange(const ScrollableLayerGuid& aGuid,
int aArg)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
NewRunnableMethod(this, &RemoteContentController::NotifyAPZStateChange,
aGuid, aChange, aArg));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<ScrollableLayerGuid,
APZStateChange,
int>(this, &RemoteContentController::NotifyAPZStateChange,
aGuid, aChange, aArg);
mUILoop->PostTask(runnable.forget());
return;
}
if (CanSend()) {
@ -165,9 +178,11 @@ RemoteContentController::NotifyMozMouseScrollEvent(const FrameMetrics::ViewID& a
const nsString& aEvent)
{
if (MessageLoop::current() != mUILoop) {
mUILoop->PostTask(
NewRunnableMethod(this, &RemoteContentController::NotifyMozMouseScrollEvent,
aScrollId, aEvent));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<FrameMetrics::ViewID,
nsString>(this, &RemoteContentController::NotifyMozMouseScrollEvent,
aScrollId, aEvent);
mUILoop->PostTask(runnable.forget());
return;
}
@ -217,9 +232,13 @@ RemoteContentController::RecvContentReceivedInputBlock(const ScrollableLayerGuid
return false;
}
if (RefPtr<APZCTreeManager> apzcTreeManager = GetApzcTreeManager()) {
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
apzcTreeManager.get(), &APZCTreeManager::ContentReceivedInputBlock,
aInputBlockId, aPreventDefault));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<uint64_t,
bool>(apzcTreeManager,
&APZCTreeManager::ContentReceivedInputBlock,
aInputBlockId, aPreventDefault);
APZThreadUtils::RunOnControllerThread(runnable.forget());
}
return true;
}
@ -231,10 +250,12 @@ RemoteContentController::RecvStartScrollbarDrag(const AsyncDragMetrics& aDragMet
ScrollableLayerGuid guid(mLayersId, aDragMetrics.mPresShellId,
aDragMetrics.mViewId);
APZThreadUtils::RunOnControllerThread(
NewRunnableMethod(apzcTreeManager.get(),
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<ScrollableLayerGuid,
AsyncDragMetrics>(apzcTreeManager,
&APZCTreeManager::StartScrollbarDrag,
guid, aDragMetrics));
guid, aDragMetrics);
APZThreadUtils::RunOnControllerThread(runnable.forget());
}
return true;
}
@ -254,9 +275,12 @@ RemoteContentController::RecvSetTargetAPZC(const uint64_t& aInputBlockId,
// need a local var to disambiguate between the SetTargetAPZC overloads.
void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray<ScrollableLayerGuid>&)
= &APZCTreeManager::SetTargetAPZC;
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
apzcTreeManager.get(), setTargetApzcFunc,
aInputBlockId, aTargets));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<uint64_t,
StoreCopyPassByRRef<nsTArray<ScrollableLayerGuid>>>(apzcTreeManager, setTargetApzcFunc,
aInputBlockId, aTargets);
APZThreadUtils::RunOnControllerThread(runnable.forget());
}
return true;
}
@ -266,9 +290,12 @@ RemoteContentController::RecvSetAllowedTouchBehavior(const uint64_t& aInputBlock
nsTArray<TouchBehaviorFlags>&& aFlags)
{
if (RefPtr<APZCTreeManager> apzcTreeManager = GetApzcTreeManager()) {
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
apzcTreeManager.get(), &APZCTreeManager::SetAllowedTouchBehavior,
aInputBlockId, Move(aFlags)));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<uint64_t,
StoreCopyPassByRRef<nsTArray<TouchBehaviorFlags>>>(apzcTreeManager,
&APZCTreeManager::SetAllowedTouchBehavior,
aInputBlockId, Move(aFlags));
APZThreadUtils::RunOnControllerThread(runnable.forget());
}
return true;
}

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

@ -45,8 +45,8 @@ SoftwareDisplay::EnableVsync()
}
mVsyncEnabled = true;
mVsyncThread->message_loop()->PostTask(
NewRunnableMethod(this, &SoftwareDisplay::EnableVsync));
RefPtr<mozilla::Runnable> runnable = NS_NewRunnableMethod(this, &SoftwareDisplay::EnableVsync);
mVsyncThread->message_loop()->PostTask(runnable.forget());
return;
}
@ -64,8 +64,8 @@ SoftwareDisplay::DisableVsync()
}
mVsyncEnabled = false;
mVsyncThread->message_loop()->PostTask(
NewRunnableMethod(this, &SoftwareDisplay::DisableVsync));
RefPtr<mozilla::Runnable> runnable = NS_NewRunnableMethod(this, &SoftwareDisplay::DisableVsync);
mVsyncThread->message_loop()->PostTask(runnable.forget());
return;
}

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

@ -112,8 +112,8 @@ void
VRManagerParent::ActorDestroy(ActorDestroyReason why)
{
UnregisterFromManager();
MessageLoop::current()->PostTask(
NewRunnableMethod(this, &VRManagerParent::DeferredDestroy));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &VRManagerParent::DeferredDestroy);
MessageLoop::current()->PostTask(runnable.forget());
}
mozilla::ipc::IToplevelProtocol*

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

@ -303,6 +303,9 @@ class RunnableMethod : public mozilla::CancelableRunnable,
Params params_;
};
namespace dont_add_new_uses_of_this {
// Don't add new uses of this!!!!
template <class T, class Method, typename... Args>
inline already_AddRefed<mozilla::Runnable>
NewRunnableMethod(T* object, Method method, Args&&... args) {
@ -313,6 +316,8 @@ NewRunnableMethod(T* object, Method method, Args&&... args) {
return t.forget();
}
} // namespace dont_add_new_uses_of_this
// RunnableFunction and NewRunnableFunction implementation ---------------------
template <class Function, class Params>

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

@ -981,9 +981,10 @@ void nsBaseWidget::ConfigureAPZCTreeManager()
bool aPreventDefault)
{
MOZ_ASSERT(NS_IsMainThread());
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
treeManager.get(), &APZCTreeManager::ContentReceivedInputBlock,
aInputBlockId, aPreventDefault));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<uint64_t, bool>(treeManager, &APZCTreeManager::ContentReceivedInputBlock,
aInputBlockId, aPreventDefault);
APZThreadUtils::RunOnControllerThread(runnable.forget());
});
mAPZEventState = new APZEventState(this, mozilla::Move(callback));
@ -991,9 +992,12 @@ void nsBaseWidget::ConfigureAPZCTreeManager()
const nsTArray<TouchBehaviorFlags>& aFlags)
{
MOZ_ASSERT(NS_IsMainThread());
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
treeManager.get(), &APZCTreeManager::SetAllowedTouchBehavior,
aInputBlockId, aFlags));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<uint64_t,
StoreCopyPassByLRef<nsTArray<TouchBehaviorFlags>>>(treeManager,
&APZCTreeManager::SetAllowedTouchBehavior,
aInputBlockId, aFlags);
APZThreadUtils::RunOnControllerThread(runnable.forget());
};
mRootContentController = CreateRootContentController();
@ -1024,8 +1028,12 @@ nsBaseWidget::SetConfirmedTargetAPZC(uint64_t aInputBlockId,
// Need to specifically bind this since it's overloaded.
void (APZCTreeManager::*setTargetApzcFunc)(uint64_t, const nsTArray<ScrollableLayerGuid>&)
= &APZCTreeManager::SetTargetAPZC;
APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
mAPZC.get(), setTargetApzcFunc, aInputBlockId, aTargets));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<uint64_t,
StoreCopyPassByRRef<nsTArray<ScrollableLayerGuid>>>(mAPZC,
setTargetApzcFunc,
aInputBlockId, aTargets);
APZThreadUtils::RunOnControllerThread(runnable.forget());
}
void
@ -1913,8 +1921,11 @@ nsBaseWidget::StartAsyncScrollbarDrag(const AsyncDragMetrics& aDragMetrics)
int layersId = mCompositorBridgeParent->RootLayerTreeId();;
ScrollableLayerGuid guid(layersId, aDragMetrics.mPresShellId, aDragMetrics.mViewId);
APZThreadUtils::RunOnControllerThread(
NewRunnableMethod(mAPZC.get(), &APZCTreeManager::StartScrollbarDrag, guid, aDragMetrics));
RefPtr<Runnable> runnable =
NS_NewRunnableMethodWithArgs<ScrollableLayerGuid,
AsyncDragMetrics>(mAPZC, &APZCTreeManager::StartScrollbarDrag,
guid, aDragMetrics);
APZThreadUtils::RunOnControllerThread(runnable.forget());
}
already_AddRefed<nsIScreen>

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

@ -74,8 +74,8 @@ FdWatcher::Init()
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
os->AddObserver(this, "xpcom-shutdown", /* ownsWeak = */ false);
XRE_GetIOMessageLoop()->PostTask(
NewRunnableMethod(this, &FdWatcher::StartWatching));
RefPtr<Runnable> runnable = NS_NewRunnableMethod(this, &FdWatcher::StartWatching);
XRE_GetIOMessageLoop()->PostTask(runnable.forget());
}
// Implementations may call this function multiple times if they ensure that

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

@ -89,8 +89,9 @@ public:
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!strcmp(aTopic, "xpcom-shutdown"));
XRE_GetIOMessageLoop()->PostTask(
NewRunnableMethod(this, &FdWatcher::StopWatching));
RefPtr<mozilla::Runnable> runnable =
NS_NewRunnableMethod(this, &FdWatcher::StopWatching);
XRE_GetIOMessageLoop()->PostTask(runnable.forget());
return NS_OK;
}