Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / system / nsDeviceSensors.h
blob95f558ba72617227fc800a36599d3d88977a45d1
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsDeviceSensors_h
6 #define nsDeviceSensors_h
8 #include "nsIDeviceSensors.h"
9 #include "nsCOMArray.h"
10 #include "nsTArray.h"
11 #include "nsCOMPtr.h"
12 #include "nsITimer.h"
13 #include "mozilla/dom/DeviceMotionEvent.h"
14 #include "mozilla/TimeStamp.h"
15 #include "mozilla/HalSensor.h"
16 #include "nsDataHashtable.h"
18 class nsIDOMWindow;
20 namespace mozilla {
21 namespace dom {
22 class EventTarget;
26 class nsDeviceSensors : public nsIDeviceSensors, public mozilla::hal::ISensorObserver
28 typedef mozilla::dom::DeviceAccelerationInit DeviceAccelerationInit;
29 typedef mozilla::dom::DeviceRotationRateInit DeviceRotationRateInit;
30 public:
31 NS_DECL_ISUPPORTS
32 NS_DECL_NSIDEVICESENSORS
34 nsDeviceSensors();
36 void Notify(const mozilla::hal::SensorData& aSensorData);
38 private:
39 virtual ~nsDeviceSensors();
41 // sensor -> window listener
42 nsTArray<nsTArray<nsIDOMWindow*>* > mWindowListeners;
44 void FireDOMLightEvent(mozilla::dom::EventTarget* aTarget,
45 double value);
47 void FireDOMProximityEvent(mozilla::dom::EventTarget* aTarget,
48 double aValue,
49 double aMin,
50 double aMax);
52 void FireDOMUserProximityEvent(mozilla::dom::EventTarget* aTarget,
53 bool aNear);
55 void FireDOMOrientationEvent(mozilla::dom::EventTarget* target,
56 double alpha,
57 double beta,
58 double gamma);
60 void FireDOMMotionEvent(class nsIDOMDocument *domDoc,
61 mozilla::dom::EventTarget* target,
62 uint32_t type,
63 double x,
64 double y,
65 double z);
67 bool mEnabled;
69 inline bool IsSensorEnabled(uint32_t aType) {
70 return mWindowListeners[aType]->Length() > 0;
73 mozilla::TimeStamp mLastDOMMotionEventTime;
74 bool mIsUserProximityNear;
75 mozilla::Maybe<DeviceAccelerationInit> mLastAcceleration;
76 mozilla::Maybe<DeviceAccelerationInit> mLastAccelerationIncluduingGravity;
77 mozilla::Maybe<DeviceRotationRateInit> mLastRotationRate;
80 #endif