Bug 1469309 - Remove an unused sensor type; r=agaynor a=lizzard
authorGabriele Svelto <gsvelto@mozilla.com>
Tue, 19 Jun 2018 09:18:09 +0200
changeset 477829 0915e733540199880a1529f7c0cb0b9a4fef09ae
parent 477828 3da147dac512da9368fbe9179c5ad72dc8c759e4
child 477830 3a7a791ef4ff5f7c04c7eb2713e4a9104810e8d0
push id9441
push userarchaeopteryx@coole-files.de
push dateFri, 06 Jul 2018 15:09:28 +0000
treeherdermozilla-beta@3a7a791ef4ff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersagaynor, lizzard
bugs1469309
milestone62.0
Bug 1469309 - Remove an unused sensor type; r=agaynor a=lizzard
hal/Hal.cpp
hal/HalSensor.h
hal/sandbox/SandboxHal.cpp
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -421,16 +421,17 @@ RegisterSensorObserver(SensorType aSenso
   }
 }
 
 void
 UnregisterSensorObserver(SensorType aSensor, ISensorObserver *aObserver) {
   AssertMainThread();
 
   if (!gSensorObservers) {
+    HAL_ERR("Un-registering a sensor when none have been registered");
     return;
   }
 
   SensorObserverList &observers = GetSensorObservers(aSensor);
   if (!observers.RemoveObserver(aObserver) || observers.Length() > 0) {
     return;
   }
   DisableSensorNotifications(aSensor);
--- a/hal/HalSensor.h
+++ b/hal/HalSensor.h
@@ -13,17 +13,16 @@ namespace mozilla {
 namespace hal {
 
 /**
  * Enumeration of sensor types.  They are used to specify type while
  * register or unregister an observer for a sensor of given type.
  * If you add or change any here, do the same in GeckoHalDefines.java.
  */
 enum SensorType {
-  SENSOR_UNKNOWN = -1,
   SENSOR_ORIENTATION = 0,
   SENSOR_ACCELERATION = 1,
   SENSOR_PROXIMITY = 2,
   SENSOR_LINEAR_ACCELERATION = 3,
   SENSOR_GYROSCOPE = 4,
   SENSOR_LIGHT = 5,
   SENSOR_ROTATION_VECTOR = 6,
   SENSOR_GAME_ROTATION_VECTOR = 7,
@@ -58,17 +57,17 @@ typedef Observer<SensorAccuracy> ISensor
 namespace IPC {
   /**
    * Serializer for SensorType
    */
   template <>
   struct ParamTraits<mozilla::hal::SensorType>:
     public ContiguousEnumSerializer<
              mozilla::hal::SensorType,
-             mozilla::hal::SENSOR_UNKNOWN,
+             mozilla::hal::SENSOR_ORIENTATION,
              mozilla::hal::NUM_SENSOR_TYPE> {
   };
 
   template <>
   struct ParamTraits<mozilla::hal::SensorAccuracyType>:
     public ContiguousEnumSerializer<
              mozilla::hal::SensorAccuracyType,
              mozilla::hal::SENSOR_ACCURACY_UNKNOWN,
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -11,16 +11,17 @@
 #include "mozilla/hal_sandbox/PHalChild.h"
 #include "mozilla/hal_sandbox/PHalParent.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/battery/Types.h"
 #include "mozilla/dom/network/Types.h"
 #include "mozilla/dom/ScreenOrientation.h"
 #include "mozilla/fallback/FallbackScreenConfiguration.h"
+#include "mozilla/EnumeratedRange.h"
 #include "mozilla/Observer.h"
 #include "mozilla/Unused.h"
 #include "nsAutoPtr.h"
 #include "WindowIdentifier.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::hal;
@@ -227,19 +228,18 @@ public:
   virtual void
   ActorDestroy(ActorDestroyReason aWhy) override
   {
     // NB: you *must* unconditionally unregister your observer here,
     // if it *may* be registered below.
     hal::UnregisterBatteryObserver(this);
     hal::UnregisterNetworkObserver(this);
     hal::UnregisterScreenConfigurationObserver(this);
-    for (int32_t sensor = SENSOR_UNKNOWN + 1;
-         sensor < NUM_SENSOR_TYPE; ++sensor) {
-      hal::UnregisterSensorObserver(SensorType(sensor), this);
+    for (auto sensor : MakeEnumeratedRange(NUM_SENSOR_TYPE)) {
+      hal::UnregisterSensorObserver(sensor, this);
     }
     hal::UnregisterWakeLockObserver(this);
   }
 
   virtual mozilla::ipc::IPCResult
   RecvVibrate(InfallibleTArray<unsigned int>&& pattern,
               InfallibleTArray<uint64_t>&& id,
               PBrowserParent *browserParent) override