OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef Sensor_h |
| 6 #define Sensor_h |
| 7 |
| 8 #include "bindings/core/v8/ActiveScriptWrappable.h" |
| 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 10 #include "core/dom/ActiveDOMObject.h" |
| 11 #include "core/dom/ContextLifecycleObserver.h" |
| 12 #include "core/frame/PlatformEventController.h" |
| 13 #include "modules/EventTargetModules.h" |
| 14 #include "modules/ModulesExport.h" |
| 15 #include "modules/sensor/SensorOptions.h" |
| 16 #include "modules/sensor/SensorState.h" |
| 17 #include "platform/heap/Handle.h" |
| 18 |
| 19 namespace blink { |
| 20 |
| 21 class ExceptionState; |
| 22 class ScriptState; |
| 23 class SensorReading; |
| 24 |
| 25 class MODULES_EXPORT Sensor |
| 26 : public EventTargetWithInlineData |
| 27 , public ActiveScriptWrappable |
| 28 , public ActiveDOMObject |
| 29 , public PlatformEventController { |
| 30 USING_GARBAGE_COLLECTED_MIXIN(Sensor); |
| 31 DEFINE_WRAPPERTYPEINFO(); |
| 32 |
| 33 public: |
| 34 ~Sensor() override; |
| 35 |
| 36 void start(ScriptState*, ExceptionState&); |
| 37 void stop(ScriptState*, ExceptionState&); |
| 38 void updateState(SensorState); |
| 39 |
| 40 // EventTarget implementation. |
| 41 const AtomicString& interfaceName() const override { return EventTargetNames
::Sensor; } |
| 42 ExecutionContext* getExecutionContext() const override { return ContextLifec
ycleObserver::getExecutionContext(); } |
| 43 |
| 44 // Getters |
| 45 String state() const; |
| 46 // TODO(riju): crbug.com/614797 . |
| 47 SensorReading* reading() const; |
| 48 |
| 49 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 50 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
| 51 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
| 52 |
| 53 // ActiveDOMObject implementation. |
| 54 void suspend() override; |
| 55 void resume() override; |
| 56 void stop() override; |
| 57 bool hasPendingActivity() const override; |
| 58 |
| 59 DECLARE_VIRTUAL_TRACE(); |
| 60 |
| 61 protected: |
| 62 Sensor(ExecutionContext*, const SensorOptions&); |
| 63 SensorState m_sensorState; |
| 64 Member<SensorReading> m_sensorReading; |
| 65 SensorOptions m_sensorOptions; |
| 66 }; |
| 67 |
| 68 } // namespace blink |
| 69 |
| 70 #endif // Sensor_h |
OLD | NEW |