Bug 1013097 - Remove IPC for switch event because only the chrome process can receive it. r=dhylands
authorKershaw Chang <kechang@mozilla.com>
Mon, 02 Jun 2014 19:25:00 -0400
changeset 186549 207facf2772f45af12c64882f5d07298ba0bb352
parent 186548 1815c34b697757544b8678b889a7b21593444f25
child 186550 7661bebd6d075b3601edcd675af63f274360c6ac
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdhylands
bugs1013097
milestone32.0a1
Bug 1013097 - Remove IPC for switch event because only the chrome process can receive it. r=dhylands
hal/Hal.cpp
hal/sandbox/PHal.ipdl
hal/sandbox/SandboxHal.cpp
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -759,16 +759,17 @@ DisableSwitchNotifications(SwitchDevice 
 SwitchState GetCurrentSwitchState(SwitchDevice aDevice)
 {
   AssertMainThread();
   RETURN_PROXY_IF_SANDBOXED(GetCurrentSwitchState(aDevice), SWITCH_STATE_UNKNOWN);
 }
 
 void NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState)
 {
+  AssertMainThread();
   PROXY_IF_SANDBOXED(NotifySwitchStateFromInputDevice(aDevice, aState));
 }
 
 typedef mozilla::ObserverList<SwitchEvent> SwitchObserverList;
 
 static SwitchObserverList *sSwitchObserverLists = nullptr;
 
 static SwitchObserverList&
--- a/hal/sandbox/PHal.ipdl
+++ b/hal/sandbox/PHal.ipdl
@@ -170,17 +170,16 @@ parent:
     sync LockScreenOrientation(ScreenOrientation aOrientation)
       returns (bool allowed);
     UnlockScreenOrientation();
  
     EnableSwitchNotifications(SwitchDevice aDevice);
     DisableSwitchNotifications(SwitchDevice aDevice);
     sync GetCurrentSwitchState(SwitchDevice aDevice)
       returns (SwitchState aState);
-    NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState);
 
     FactoryReset();
 
 child:
     NotifySensorChange(SensorData aSensorData);
 
 parent:
     EnableSensorNotifications(SensorType aSensor);
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -339,17 +339,19 @@ GetCurrentSwitchState(SwitchDevice aDevi
   SwitchState state;
   Hal()->SendGetCurrentSwitchState(aDevice, &state);
   return state;
 }
 
 void
 NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState)
 {
-  Hal()->SendNotifySwitchStateFromInputDevice(aDevice, aState);
+  unused << aDevice;
+  unused << aState;
+  NS_RUNTIMEABORT("Only the main process may notify switch state change.");
 }
 
 bool
 EnableAlarm()
 {
   NS_RUNTIMEABORT("Alarms can't be programmed from sandboxed contexts.  Yet.");
   return false;
 }
@@ -857,24 +859,16 @@ public:
   virtual bool
   RecvGetCurrentSwitchState(const SwitchDevice& aDevice, hal::SwitchState *aState) MOZ_OVERRIDE
   {
     // Content has no reason to listen to switch events currently.
     *aState = hal::GetCurrentSwitchState(aDevice);
     return true;
   }
 
-  virtual bool
-  RecvNotifySwitchStateFromInputDevice(const SwitchDevice& aDevice,
-                                       const SwitchState& aState) MOZ_OVERRIDE
-  {
-    hal::NotifySwitchStateFromInputDevice(aDevice, aState);
-    return true;
-  }
-
   void Notify(const int64_t& aClockDeltaMS)
   {
     unused << SendNotifySystemClockChange(aClockDeltaMS);
   }
 
   void Notify(const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo)
   {
     unused << SendNotifySystemTimezoneChange(aSystemTimezoneChangeInfo);