Bug 1273520 - NS_NewRunnable* renaming and include task.h r?fabrice draft
authorAlexandre Lissy <lissyx@lissyx.dyndns.org>
Wed, 18 May 2016 18:25:35 +0200
changeset 368387 affb1be66c18649d28fbbc0c2d84ba4048640dc9
parent 368365 c4449eab07d39e20ea315603f1b1863eeed7dcfe
child 521259 591bcdf9f0b5eb0db09308e1793fa10cb346a44a
push id18521
push userbmo:lissyx+mozillians@lissyx.dyndns.org
push dateWed, 18 May 2016 17:34:15 +0000
reviewersfabrice
bugs1273520
milestone49.0a1
Bug 1273520 - NS_NewRunnable* renaming and include task.h r?fabrice MozReview-Commit-ID: BcAboKGMr3a
dom/camera/GonkCameraControl.cpp
dom/ipc/NuwaParent.cpp
dom/ipc/PreallocatedProcessManager.cpp
dom/system/gonk/AutoMounter.cpp
dom/system/gonk/GonkGPSGeolocationProvider.cpp
dom/system/gonk/NetworkUtils.cpp
dom/system/gonk/VolumeManager.cpp
dom/system/gonk/nsVolume.cpp
dom/system/gonk/nsVolumeService.cpp
hal/gonk/GonkDiskSpaceWatcher.cpp
hal/gonk/GonkHal.cpp
hal/gonk/GonkSensor.cpp
hal/gonk/GonkSwitch.cpp
hal/gonk/UeventPoller.cpp
ipc/netd/Netd.cpp
widget/gonk/GeckoTouchDispatcher.cpp
widget/gonk/nsScreenManagerGonk.cpp
--- a/dom/camera/GonkCameraControl.cpp
+++ b/dom/camera/GonkCameraControl.cpp
@@ -567,17 +567,17 @@ nsGonkCameraControl::PushParameters()
    * If we're already on the camera thread, call PushParametersImpl()
    * directly, so that it executes synchronously.  Some callers
    * require this so that changes take effect immediately before
    * we can proceed.
    */
   if (NS_GetCurrentThread() != mCameraThread) {
     DOM_CAMERA_LOGT("%s:%d - dispatching to Camera Thread\n", __func__, __LINE__);
     nsCOMPtr<nsIRunnable> pushParametersTask =
-      NS_NewRunnableMethod(this, &nsGonkCameraControl::PushParametersImpl);
+      NewRunnableMethod(this, &nsGonkCameraControl::PushParametersImpl);
     return mCameraThread->Dispatch(pushParametersTask, NS_DISPATCH_NORMAL);
   }
 
   DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
   return PushParametersImpl();
 }
 
 void
--- a/dom/ipc/NuwaParent.cpp
+++ b/dom/ipc/NuwaParent.cpp
@@ -164,17 +164,17 @@ NuwaParent::RecvNotifyReady()
     NS_ERROR("Received NotifyReady() message from a non-Nuwa process.");
     return false;
   }
 
   // Creating a NonOwningRunnableMethod here is safe because refcount changes of
   // mContentParent have to go the the main thread. The mContentParent will
   // be alive when the runnable runs.
   nsCOMPtr<nsIRunnable> runnable =
-    NS_NewNonOwningRunnableMethod(mContentParent.get(),
+    NewNonOwningRunnableMethod(mContentParent.get(),
                                   &ContentParent::OnNuwaReady);
   MOZ_ASSERT(runnable);
   MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable));
 
   return true;
 #else
   NS_ERROR("NuwaParent::RecvNotifyReady() not implemented!");
   return false;
@@ -195,17 +195,17 @@ NuwaParent::RecvAddNewProcess(const uint
   mNewProcessFds->SwapElements(aFds);
   MonitorAutoLock lock(mMonitor);
   if (mBlocked) {
     // Unblock ForkNewProcess().
     mMonitor.Notify();
     mBlocked = false;
   } else {
     nsCOMPtr<nsIRunnable> runnable =
-      NS_NewNonOwningRunnableMethodWithArgs<
+      NewNonOwningRunnableMethod<
         uint32_t,
         UniquePtr<nsTArray<ProtocolFdMapping>>&& >(
           mContentParent.get(),
           &ContentParent::OnNewProcessCreated,
           mNewProcessPid,
           Move(mNewProcessFds));
     MOZ_ASSERT(runnable);
     MOZ_ALWAYS_SUCCEEDS(NS_DispatchToMainThread(runnable));
--- a/dom/ipc/PreallocatedProcessManager.cpp
+++ b/dom/ipc/PreallocatedProcessManager.cpp
@@ -237,17 +237,17 @@ PreallocatedProcessManagerImpl::Schedule
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (mPreallocateAppProcessTask) {
     // Make sure there is only one request running.
     return;
   }
 
-  RefPtr<CancelableRunnable> task = NS_NewCancelableRunnableMethod(
+  RefPtr<CancelableRunnable> task = NewCancelableRunnableMethod(
     this, &PreallocatedProcessManagerImpl::DelayedNuwaFork);
   mPreallocateAppProcessTask = task;
   MessageLoop::current()->PostDelayedTask(task.forget(),
     Preferences::GetUint("dom.ipc.processPrelaunch.delayMs",
                          DEFAULT_ALLOCATE_DELAY));
 }
 
 void
--- a/dom/system/gonk/AutoMounter.cpp
+++ b/dom/system/gonk/AutoMounter.cpp
@@ -18,16 +18,17 @@
 #include <sys/socket.h>
 #include <android/log.h>
 #include <cutils/properties.h>
 
 #include "AutoMounter.h"
 #include "nsVolumeService.h"
 #include "AutoMounterSetting.h"
 #include "base/message_loop.h"
+#include "base/task.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/Hal.h"
 #include "mozilla/StaticPtr.h"
 #include "MozMtpServer.h"
 #include "MozMtpStorage.h"
 #include "nsAutoPtr.h"
 #include "nsCharSeparatedTokenizer.h"
--- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp
@@ -15,16 +15,17 @@
  */
 
 #include "GonkGPSGeolocationProvider.h"
 
 #include <cmath>
 #include <pthread.h>
 #include <hardware/gps.h>
 
+#include "base/task.h"
 #include "GeolocationUtil.h"
 #include "mozstumbler/MozStumbler.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "nsContentUtils.h"
 #include "nsGeoPosition.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsINetworkInterface.h"
@@ -808,17 +809,17 @@ GonkGPSGeolocationProvider::Init()
 
   mAGpsRilInterface =
     static_cast<const AGpsRilInterface*>(mGpsInterface->get_extension(AGPS_RIL_INTERFACE));
   if (mAGpsRilInterface) {
     mAGpsRilInterface->init(&mAGPSRILCallbacks);
   }
 #endif
 
-  NS_DispatchToMainThread(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::StartGPS));
+  NS_DispatchToMainThread(NewRunnableMethod(this, &GonkGPSGeolocationProvider::StartGPS));
 }
 
 void
 GonkGPSGeolocationProvider::StartGPS()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mGpsInterface);
 
@@ -996,17 +997,17 @@ GonkGPSGeolocationProvider::Startup()
     }
   }
 
   if (!mInitThread) {
     nsresult rv = NS_NewThread(getter_AddRefs(mInitThread));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  mInitThread->Dispatch(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::Init),
+  mInitThread->Dispatch(NewRunnableMethod(this, &GonkGPSGeolocationProvider::Init),
                         NS_DISPATCH_NORMAL);
 
   mNetworkLocationProvider = do_CreateInstance("@mozilla.org/geolocation/mls-provider;1");
   if (mNetworkLocationProvider) {
     nsresult rv = mNetworkLocationProvider->Startup();
     if (NS_SUCCEEDED(rv)) {
       RefPtr<NetworkLocationUpdate> update = new NetworkLocationUpdate();
       mNetworkLocationProvider->Watch(update);
@@ -1058,17 +1059,17 @@ GonkGPSGeolocationProvider::Shutdown()
     rv = obs->RemoveObserver(this, kMozSettingsChangedTopic);
     if (NS_FAILED(rv)) {
       NS_WARNING("geo: Gonk GPS mozsettings RemoveObserver failed");
     } else {
       mObservingSettingsChange = false;
     }
   }
 
-  mInitThread->Dispatch(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::ShutdownGPS),
+  mInitThread->Dispatch(NewRunnableMethod(this, &GonkGPSGeolocationProvider::ShutdownGPS),
                         NS_DISPATCH_NORMAL);
 
   return NS_OK;
 }
 
 void
 GonkGPSGeolocationProvider::ShutdownGPS()
 {
--- a/dom/system/gonk/NetworkUtils.cpp
+++ b/dom/system/gonk/NetworkUtils.cpp
@@ -17,16 +17,17 @@
 
 #include "mozilla/Snprintf.h"
 #include "SystemProperty.h"
 
 #include <android/log.h>
 #include <limits>
 #include "mozilla/dom/network/NetUtils.h"
 #include "mozilla/fallible.h"
+#include "base/task.h"
 
 #include <errno.h>
 #include <string.h>
 #include <sys/types.h>  // struct addrinfo
 #include <sys/socket.h> // getaddrinfo(), freeaddrinfo()
 #include <netdb.h>
 #include <arpa/inet.h>  // inet_ntop()
 
--- a/dom/system/gonk/VolumeManager.cpp
+++ b/dom/system/gonk/VolumeManager.cpp
@@ -8,16 +8,17 @@
 #include "VolumeCommand.h"
 #include "VolumeManagerLog.h"
 #include "VolumeServiceTest.h"
 
 #include "nsWhitespaceTokenizer.h"
 #include "nsXULAppAPI.h"
 
 #include "base/message_loop.h"
+#include "base/task.h"
 #include "mozilla/Scoped.h"
 #include "mozilla/StaticPtr.h"
 
 #include <android/log.h>
 #include <cutils/sockets.h>
 #include <fcntl.h>
 #include <sys/socket.h>
 
--- a/dom/system/gonk/nsVolume.cpp
+++ b/dom/system/gonk/nsVolume.cpp
@@ -1,15 +1,16 @@
 /* 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 "nsVolume.h"
 
 #include "base/message_loop.h"
+#include "base/task.h"
 #include "nsIPowerManagerService.h"
 #include "nsISupportsUtils.h"
 #include "nsIVolume.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "nsVolumeStat.h"
 #include "nsXULAppAPI.h"
 #include "Volume.h"
--- a/dom/system/gonk/nsVolumeService.cpp
+++ b/dom/system/gonk/nsVolumeService.cpp
@@ -24,16 +24,17 @@
 #include "nsServiceManagerUtils.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
 #include "nsVolumeMountLock.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/Services.h"
+#include "base/task.h"
 
 #undef VOLUME_MANAGER_LOG_TAG
 #define VOLUME_MANAGER_LOG_TAG  "nsVolumeService"
 #include "VolumeManagerLog.h"
 
 #include <stdlib.h>
 
 using namespace mozilla::dom;
--- a/hal/gonk/GonkDiskSpaceWatcher.cpp
+++ b/hal/gonk/GonkDiskSpaceWatcher.cpp
@@ -3,39 +3,33 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "Hal.h"
 #include <sys/syscall.h>
 #include <sys/vfs.h>
 #include <fcntl.h>
 #include <errno.h>
 #include "base/message_loop.h"
+#include "base/task.h"
 #include "DiskSpaceWatcher.h"
 #include "fanotify.h"
 #include "nsIObserverService.h"
 #include "nsIDiskSpaceWatcher.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/ModuleUtils.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 
 using namespace mozilla;
 
 namespace mozilla { namespace hal_impl { class GonkDiskSpaceWatcher; } }
 
 using namespace mozilla::hal_impl;
 
-template<>
-struct RunnableMethodTraits<GonkDiskSpaceWatcher>
-{
-  static void RetainCallee(GonkDiskSpaceWatcher* obj) { }
-  static void ReleaseCallee(GonkDiskSpaceWatcher* obj) { }
-};
-
 namespace mozilla {
 namespace hal_impl {
 
 // NOTE: this should be unnecessary once we no longer support ICS.
 #ifndef __NR_fanotify_init
 #if defined(__ARM_EABI__)
 #define __NR_fanotify_init 367
 #define __NR_fanotify_mark 368
@@ -306,25 +300,25 @@ StartDiskSpaceWatcher()
   // Bail out if called several times.
   if (gHalDiskSpaceWatcher != nullptr) {
     return;
   }
 
   gHalDiskSpaceWatcher = new GonkDiskSpaceWatcher();
 
   XRE_GetIOMessageLoop()->PostTask(
-    NewRunnableMethod(gHalDiskSpaceWatcher, &GonkDiskSpaceWatcher::DoStart));
+    NewNonOwningRunnableMethod(gHalDiskSpaceWatcher, &GonkDiskSpaceWatcher::DoStart));
 }
 
 void
 StopDiskSpaceWatcher()
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (!gHalDiskSpaceWatcher) {
     return;
   }
 
   XRE_GetIOMessageLoop()->PostTask(
-    NewRunnableMethod(gHalDiskSpaceWatcher, &GonkDiskSpaceWatcher::DoStop));
+    NewNonOwningRunnableMethod(gHalDiskSpaceWatcher, &GonkDiskSpaceWatcher::DoStop));
 }
 
 } // namespace hal_impl
 } // namespace mozilla
--- a/hal/gonk/GonkHal.cpp
+++ b/hal/gonk/GonkHal.cpp
@@ -38,16 +38,17 @@
 #include "hardware/lights.h"
 #include "hardware_legacy/uevent.h"
 #include "hardware_legacy/vibrator.h"
 #include "hardware_legacy/power.h"
 #include "libdisplay/GonkDisplay.h"
 #include "utils/threads.h"
 
 #include "base/message_loop.h"
+#include "base/task.h"
 
 #include "Hal.h"
 #include "HalImpl.h"
 #include "HalLog.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/dom/battery/Constants.h"
 #include "mozilla/DebugOnly.h"
--- a/hal/gonk/GonkSensor.cpp
+++ b/hal/gonk/GonkSensor.cpp
@@ -17,16 +17,17 @@
 #include <pthread.h>
 #include <stdio.h>
 
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Saturate.h"
 
 #include "base/basictypes.h"
 #include "base/thread.h"
+#include "base/task.h"
 
 #include "GonkSensorsInterface.h"
 #include "GonkSensorsPollInterface.h"
 #include "GonkSensorsRegistryInterface.h"
 #include "Hal.h"
 #include "HalLog.h"
 #include "HalSensor.h"
 #include "hardware/sensors.h"
--- a/hal/gonk/GonkSwitch.cpp
+++ b/hal/gonk/GonkSwitch.cpp
@@ -13,16 +13,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #include <fcntl.h>
 #include <sysutils/NetlinkEvent.h>
 
 #include "base/message_loop.h"
+#include "base/task.h"
 
 #include "Hal.h"
 #include "HalLog.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/Monitor.h"
 #include "nsPrintfCString.h"
 #include "nsXULAppAPI.h"
--- a/hal/gonk/UeventPoller.cpp
+++ b/hal/gonk/UeventPoller.cpp
@@ -26,16 +26,17 @@
 #include <linux/types.h>
 #include <linux/netlink.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
 
 #include "HalLog.h"
 #include "nsDebug.h"
 #include "base/message_loop.h"
+#include "base/task.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/FileUtils.h"
 #include "mozilla/Monitor.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 
 #include "UeventPoller.h"
 
--- a/ipc/netd/Netd.cpp
+++ b/ipc/netd/Netd.cpp
@@ -4,16 +4,17 @@
 
 #include "Netd.h"
 #include <android/log.h>
 #include <cutils/sockets.h>
 #include <fcntl.h>
 #include <sys/socket.h>
 
 #include "android/log.h"
+#include "base/task.h"
 
 #include "nsWhitespaceTokenizer.h"
 #include "nsXULAppAPI.h"
 #include "nsAutoPtr.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/Snprintf.h"
--- a/widget/gonk/GeckoTouchDispatcher.cpp
+++ b/widget/gonk/GeckoTouchDispatcher.cpp
@@ -110,29 +110,29 @@ GeckoTouchDispatcher::NotifyTouch(MultiT
 
   if (aTouch.mType == MultiTouchInput::MULTITOUCH_MOVE) {
     MutexAutoLock lock(mTouchQueueLock);
     if (mInflightNonMoveEvents > 0) {
       // If we have any pending non-move events, we shouldn't resample the
       // move events because we might end up dispatching events out of order.
       // Instead, fall back to a non-resampling in-order dispatch until we're
       // done processing the non-move events.
-      layers::APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
+      layers::APZThreadUtils::RunOnControllerThread(NewRunnableMethod<MultiTouchInput>(
         this, &GeckoTouchDispatcher::DispatchTouchEvent, aTouch));
       return;
     }
 
     mTouchMoveEvents.push_back(aTouch);
     mHavePendingTouchMoves = true;
   } else {
     { // scope lock
       MutexAutoLock lock(mTouchQueueLock);
       mInflightNonMoveEvents++;
     }
-    layers::APZThreadUtils::RunOnControllerThread(NewRunnableMethod(
+    layers::APZThreadUtils::RunOnControllerThread(NewRunnableMethod<MultiTouchInput>(
       this, &GeckoTouchDispatcher::DispatchTouchNonMoveEvent, aTouch));
   }
 }
 
 void
 GeckoTouchDispatcher::DispatchTouchNonMoveEvent(MultiTouchInput aInput)
 {
   layers::APZThreadUtils::AssertOnControllerThread();
--- a/widget/gonk/nsScreenManagerGonk.cpp
+++ b/widget/gonk/nsScreenManagerGonk.cpp
@@ -895,19 +895,19 @@ nsScreenManagerGonk::GetSystemDefaultSca
     return NS_OK;
 }
 
 void
 nsScreenManagerGonk::VsyncControl(bool aEnabled)
 {
     if (!NS_IsMainThread()) {
         NS_DispatchToMainThread(
-            NS_NewRunnableMethodWithArgs<bool>(this,
-                                               &nsScreenManagerGonk::VsyncControl,
-                                               aEnabled));
+            NewRunnableMethod<bool>(this,
+                                    &nsScreenManagerGonk::VsyncControl,
+                                    aEnabled));
         return;
     }
 
     MOZ_ASSERT(NS_IsMainThread());
     VsyncSource::Display &display = gfxPlatform::GetPlatform()->GetHardwareVsync()->GetGlobalDisplay();
     if (aEnabled) {
         display.EnableVsync();
     } else {