OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef Sensor_h | 5 #ifndef Sensor_h |
6 #define Sensor_h | 6 #define Sensor_h |
7 | 7 |
8 #include "bindings/core/v8/ActiveScriptWrappable.h" | 8 #include "bindings/core/v8/ActiveScriptWrappable.h" |
9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
10 #include "core/dom/ContextLifecycleObserver.h" | 10 #include "core/dom/ContextLifecycleObserver.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 class SensorReading; | 25 class SensorReading; |
26 | 26 |
27 class Sensor : public EventTargetWithInlineData, | 27 class Sensor : public EventTargetWithInlineData, |
28 public ActiveScriptWrappable<Sensor>, | 28 public ActiveScriptWrappable<Sensor>, |
29 public ContextLifecycleObserver, | 29 public ContextLifecycleObserver, |
30 public SensorProxy::Observer { | 30 public SensorProxy::Observer { |
31 USING_GARBAGE_COLLECTED_MIXIN(Sensor); | 31 USING_GARBAGE_COLLECTED_MIXIN(Sensor); |
32 DEFINE_WRAPPERTYPEINFO(); | 32 DEFINE_WRAPPERTYPEINFO(); |
33 | 33 |
34 public: | 34 public: |
35 enum class SensorState { Unconnected, Activating, Activated, Idle, Errored }; | 35 enum class SensorState { Idle, Activating, Activated }; |
36 | 36 |
37 ~Sensor() override; | 37 ~Sensor() override; |
38 | 38 |
39 void start(); | 39 void start(); |
40 void stop(); | 40 void stop(); |
41 | 41 |
42 // EventTarget overrides. | 42 // EventTarget overrides. |
43 const AtomicString& interfaceName() const override { | 43 const AtomicString& interfaceName() const override { |
44 return EventTargetNames::Sensor; | 44 return EventTargetNames::Sensor; |
45 } | 45 } |
46 ExecutionContext* getExecutionContext() const override { | 46 ExecutionContext* getExecutionContext() const override { |
47 return ContextLifecycleObserver::getExecutionContext(); | 47 return ContextLifecycleObserver::getExecutionContext(); |
48 } | 48 } |
49 | 49 |
50 // Getters | 50 // Getters |
51 String state() const; | 51 bool activated() const; |
52 DOMHighResTimeStamp timestamp(ScriptState*, bool& isNull) const; | 52 DOMHighResTimeStamp timestamp(ScriptState*, bool& isNull) const; |
53 | 53 |
54 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 54 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
55 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); | 55 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
56 DEFINE_ATTRIBUTE_EVENT_LISTENER(activate); | 56 DEFINE_ATTRIBUTE_EVENT_LISTENER(activate); |
57 | 57 |
58 // ActiveScriptWrappable overrides. | 58 // ActiveScriptWrappable overrides. |
59 bool hasPendingActivity() const override; | 59 bool hasPendingActivity() const override; |
60 | 60 |
61 DECLARE_VIRTUAL_TRACE(); | 61 DECLARE_VIRTUAL_TRACE(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 SensorState m_state; | 113 SensorState m_state; |
114 Member<SensorProxy> m_sensorProxy; | 114 Member<SensorProxy> m_sensorProxy; |
115 device::SensorReading m_storedData; | 115 device::SensorReading m_storedData; |
116 SensorConfigurationPtr m_configuration; | 116 SensorConfigurationPtr m_configuration; |
117 double m_lastUpdateTimestamp; | 117 double m_lastUpdateTimestamp; |
118 }; | 118 }; |
119 | 119 |
120 } // namespace blink | 120 } // namespace blink |
121 | 121 |
122 #endif // Sensor_h | 122 #endif // Sensor_h |
OLD | NEW |