diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-07-18 08:24:24 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-07-18 08:24:24 +0200 |
commit | fc61780b35af913801d72086456f493f63197da6 (patch) | |
tree | f85891288a7bd988da9f0f15ae64e5c63f00d493 /hal/Hal.cpp | |
parent | 69f7f9e5f1475891ce11cc4f431692f965b0cd30 (diff) | |
parent | 50d3e596bbe89c95615f96eb71f6bc5be737a1db (diff) | |
download | UXP-2018.07.18.tar UXP-2018.07.18.tar.gz UXP-2018.07.18.tar.lz UXP-2018.07.18.tar.xz UXP-2018.07.18.zip |
Merge commit '50d3e596bbe89c95615f96eb71f6bc5be737a1db' into Basilisk-releasev2018.07.18
# Conflicts:
# browser/app/profile/firefox.js
# browser/components/preferences/jar.mn
Diffstat (limited to 'hal/Hal.cpp')
-rw-r--r-- | hal/Hal.cpp | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/hal/Hal.cpp b/hal/Hal.cpp index 8ac9e6847..16201a2d8 100644 --- a/hal/Hal.cpp +++ b/hal/Hal.cpp @@ -754,96 +754,6 @@ UnlockScreenOrientation() PROXY_IF_SANDBOXED(UnlockScreenOrientation()); } -void -EnableSwitchNotifications(SwitchDevice aDevice) { - AssertMainThread(); - PROXY_IF_SANDBOXED(EnableSwitchNotifications(aDevice)); -} - -void -DisableSwitchNotifications(SwitchDevice aDevice) { - AssertMainThread(); - PROXY_IF_SANDBOXED(DisableSwitchNotifications(aDevice)); -} - -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& -GetSwitchObserverList(SwitchDevice aDevice) { - MOZ_ASSERT(0 <= aDevice && aDevice < NUM_SWITCH_DEVICE); - if (sSwitchObserverLists == nullptr) { - sSwitchObserverLists = new SwitchObserverList[NUM_SWITCH_DEVICE]; - } - return sSwitchObserverLists[aDevice]; -} - -static void -ReleaseObserversIfNeeded() { - for (int i = 0; i < NUM_SWITCH_DEVICE; i++) { - if (sSwitchObserverLists[i].Length() != 0) - return; - } - - //The length of every list is 0, no observer in the list. - delete [] sSwitchObserverLists; - sSwitchObserverLists = nullptr; -} - -void -RegisterSwitchObserver(SwitchDevice aDevice, SwitchObserver *aObserver) -{ - AssertMainThread(); - SwitchObserverList& observer = GetSwitchObserverList(aDevice); - observer.AddObserver(aObserver); - if (observer.Length() == 1) { - EnableSwitchNotifications(aDevice); - } -} - -void -UnregisterSwitchObserver(SwitchDevice aDevice, SwitchObserver *aObserver) -{ - AssertMainThread(); - - if (!sSwitchObserverLists) { - return; - } - - SwitchObserverList& observer = GetSwitchObserverList(aDevice); - if (!observer.RemoveObserver(aObserver) || observer.Length() > 0) { - return; - } - - DisableSwitchNotifications(aDevice); - ReleaseObserversIfNeeded(); -} - -void -NotifySwitchChange(const SwitchEvent& aEvent) -{ - // When callback this notification, main thread may call unregister function - // first. We should check if this pointer is valid. - if (!sSwitchObserverLists) - return; - - SwitchObserverList& observer = GetSwitchObserverList(aEvent.device()); - observer.Broadcast(aEvent); -} - static AlarmObserver* sAlarmObserver; bool |