Bug 1268313: Part 4 - Replace NewCancelableRunnableMethod with NS_NewCancelableRunnableMethod. r=froydnj
authorKyle Huey <khuey@kylehuey.com>
Thu, 05 May 2016 01:44:59 -0700
changeset 335207 25c97bee43583ff259bf8007a9909488d5e91273
parent 335206 9f23832812fd28d3a1d817247c875a149349017a
child 335208 4ae434c0a2c8b4535c1edb128ddf3e8ea6ebe17c
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1268313
milestone49.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
Bug 1268313: Part 4 - Replace NewCancelableRunnableMethod with NS_NewCancelableRunnableMethod. r=froydnj
gfx/layers/apz/src/GestureEventListener.cpp
gfx/layers/apz/util/ActiveElementManager.cpp
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/thebes/SoftwareVsyncSource.cpp
ipc/chromium/src/base/task.h
xpcom/glue/nsThreadUtils.h
--- 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 =
-    NewCancelableRunnableMethod(this, &GestureEventListener::HandleInputTimeoutLongTap);
+    NS_NewCancelableRunnableMethod(this, &GestureEventListener::HandleInputTimeoutLongTap);
 
   mLongTapTimeoutTask = task;
   mAsyncPanZoomController->PostDelayedTask(
     task.forget(),
     gfxPrefs::UiClickHoldContextMenusDelay());
 }
 
 void GestureEventListener::CancelMaxTapTimeoutTask()
@@ -520,18 +520,19 @@ void GestureEventListener::CancelMaxTapT
 }
 
 void GestureEventListener::CreateMaxTapTimeoutTask()
 {
   mLastTapInput = mLastTouchInput;
 
   TouchBlockState* block = mAsyncPanZoomController->GetInputQueue()->CurrentTouchBlock();
   RefPtr<CancelableRunnable> task =
-    NewCancelableRunnableMethod(this, &GestureEventListener::HandleInputTimeoutMaxTap,
-                                block->IsDuringFastFling());
+    NS_NewCancelableRunnableMethodWithArgs<bool>(this,
+                                                 &GestureEventListener::HandleInputTimeoutMaxTap,
+                                                 block->IsDuringFastFling());
 
   mMaxTapTimeoutTask = task;
   mAsyncPanZoomController->PostDelayedTask(
     task.forget(),
     MAX_TAP_TIME);
 }
 
 } // namespace layers
--- a/gfx/layers/apz/util/ActiveElementManager.cpp
+++ b/gfx/layers/apz/util/ActiveElementManager.cpp
@@ -89,18 +89,20 @@ ActiveElementManager::TriggerElementActi
   // Otherwise, wait a bit to see if the user will pan or not.
   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 = NewCancelableRunnableMethod(
-        this, &ActiveElementManager::SetActiveTask, mTarget);
+    RefPtr<CancelableRunnable> task =
+      NS_NewCancelableRunnableMethodWithArgs<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/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -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 =
-      NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::Composite,
-                                  aCompositeTimestamp);
+      NS_NewCancelableRunnableMethodWithArgs<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 =
-      NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::SetNeedsComposite);
+      NS_NewCancelableRunnableMethod(this, &CompositorVsyncScheduler::SetNeedsComposite);
     mSetNeedsCompositeTask = task;
     ScheduleTask(task.forget(), 0);
     return;
   } else {
     MonitorAutoLock lock(mSetNeedsCompositeMonitor);
     mSetNeedsCompositeTask = nullptr;
   }
 
@@ -1358,17 +1358,18 @@ CompositorBridgeParent::ScheduleRotation
   MOZ_ASSERT(IsInCompositorThread());
 
   if (!aIsFirstPaint &&
       !mCompositionManager->IsFirstPaint() &&
       mCompositionManager->RequiresReorientation(aTargetConfig.orientation())) {
     if (mForceCompositionTask != nullptr) {
       mForceCompositionTask->Cancel();
     }
-    RefPtr<CancelableRunnable> task = NewCancelableRunnableMethod(this, &CompositorBridgeParent::ForceComposition);
+    RefPtr<CancelableRunnable> task =
+      NS_NewCancelableRunnableMethod(this, &CompositorBridgeParent::ForceComposition);
     mForceCompositionTask = task;
     ScheduleTask(task.forget(), gfxPrefs::OrientationSyncMillis());
   }
 }
 
 void
 CompositorBridgeParent::ShadowLayersUpdated(LayerTransactionParent* aLayerTree,
                                             const uint64_t& aTransactionId,
--- a/gfx/thebes/SoftwareVsyncSource.cpp
+++ b/gfx/thebes/SoftwareVsyncSource.cpp
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
 #include "SoftwareVsyncSource.h"
 #include "base/task.h"
 #include "gfxPlatform.h"
@@ -123,24 +123,25 @@ SoftwareDisplay::ScheduleNextVsync(mozil
   MOZ_ASSERT(IsInSoftwareVsyncThread());
   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 = NewCancelableRunnableMethod(this,
-      &SoftwareDisplay::NotifyVsync,
-      nextVsync);
+  mCurrentVsyncTask =
+    NS_NewCancelableRunnableMethodWithArgs<mozilla::TimeStamp>(this,
+                                                               &SoftwareDisplay::NotifyVsync,
+                                                               nextVsync);
 
   RefPtr<mozilla::Runnable> addrefedTask = mCurrentVsyncTask;
   mVsyncThread->message_loop()->PostDelayedTask(
-      addrefedTask.forget(),
-      delay.ToMilliseconds());
+    addrefedTask.forget(),
+    delay.ToMilliseconds());
 }
 
 void
 SoftwareDisplay::Shutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
   DisableVsync();
   mVsyncThread->Stop();
--- a/ipc/chromium/src/base/task.h
+++ b/ipc/chromium/src/base/task.h
@@ -299,26 +299,16 @@ class RunnableMethod : public mozilla::C
   // This is owning because of the RetainCallee and ReleaseCallee calls in the
   // constructor and destructor.
   T* MOZ_OWNING_REF obj_;
   Method meth_;
   Params params_;
 };
 
 template <class T, class Method, typename... Args>
-inline already_AddRefed<mozilla::CancelableRunnable>
-NewCancelableRunnableMethod(T* object, Method method, Args&&... args) {
-  typedef mozilla::Tuple<typename mozilla::Decay<Args>::Type...> ArgsTuple;
-  RefPtr<mozilla::CancelableRunnable> t =
-    new RunnableMethod<T, Method, ArgsTuple>(object, method,
-                                             mozilla::MakeTuple(mozilla::Forward<Args>(args)...));
-  return t.forget();
-}
-
-template <class T, class Method, typename... Args>
 inline already_AddRefed<mozilla::Runnable>
 NewRunnableMethod(T* object, Method method, Args&&... args) {
   typedef mozilla::Tuple<typename mozilla::Decay<Args>::Type...> ArgsTuple;
   RefPtr<mozilla::Runnable> t =
     new RunnableMethod<T, Method, ArgsTuple>(object, method,
                                              mozilla::MakeTuple(mozilla::Forward<Args>(args)...));
   return t.forget();
 }
--- a/xpcom/glue/nsThreadUtils.h
+++ b/xpcom/glue/nsThreadUtils.h
@@ -737,16 +737,23 @@ public:
 template<typename PtrType, typename Method>
 typename nsRunnableMethodTraits<Method, true, false>::base_type*
 NS_NewRunnableMethod(PtrType aPtr, Method aMethod)
 {
   return new nsRunnableMethodImpl<Method, true, false>(aPtr, aMethod);
 }
 
 template<typename PtrType, typename Method>
+typename nsRunnableMethodTraits<Method, true, true>::base_type*
+NS_NewCancelableRunnableMethod(PtrType aPtr, Method aMethod)
+{
+  return new nsRunnableMethodImpl<Method, true, true>(aPtr, aMethod);
+}
+
+template<typename PtrType, typename Method>
 typename nsRunnableMethodTraits<Method, false, false>::base_type*
 NS_NewNonOwningRunnableMethod(PtrType&& aPtr, Method aMethod)
 {
   return new nsRunnableMethodImpl<Method, false, false>(aPtr, aMethod);
 }
 
 template<typename PtrType, typename Method>
 typename nsRunnableMethodTraits<Method, false, true>::base_type*
@@ -788,16 +795,26 @@ NS_NewNonOwningRunnableMethodWithArgs(Pt
 {
   static_assert(sizeof...(Storages) == sizeof...(Args),
                 "<Storages...> size should be equal to number of arguments");
   return new nsRunnableMethodImpl<Method, false, false, Storages...>(
       aPtr, aMethod, mozilla::Forward<Args>(aArgs)...);
 }
 
 template<typename... Storages, typename Method, typename PtrType, typename... Args>
+typename nsRunnableMethodTraits<Method, true, true>::base_type*
+NS_NewCancelableRunnableMethodWithArgs(PtrType&& aPtr, Method aMethod, Args&&... aArgs)
+{
+  static_assert(sizeof...(Storages) == sizeof...(Args),
+                "<Storages...> size should be equal to number of arguments");
+  return new nsRunnableMethodImpl<Method, true, true, Storages...>(
+      aPtr, aMethod, mozilla::Forward<Args>(aArgs)...);
+}
+
+template<typename... Storages, typename Method, typename PtrType, typename... Args>
 typename nsRunnableMethodTraits<Method, false, true>::base_type*
 NS_NewNonOwningCancelableRunnableMethodWithArgs(PtrType&& aPtr, Method aMethod,
                                                 Args&&... aArgs)
 {
   static_assert(sizeof...(Storages) == sizeof...(Args),
                 "<Storages...> size should be equal to number of arguments");
   return new nsRunnableMethodImpl<Method, false, true, Storages...>(
       aPtr, aMethod, mozilla::Forward<Args>(aArgs)...);