| 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/ActiveDOMObject.h" | 10 #include "core/dom/ActiveDOMObject.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 class Sensor : public EventTargetWithInlineData, | 26 class Sensor : public EventTargetWithInlineData, |
| 27 public ActiveScriptWrappable, | 27 public ActiveScriptWrappable, |
| 28 public ContextLifecycleObserver, | 28 public ContextLifecycleObserver, |
| 29 public PageVisibilityObserver, | 29 public PageVisibilityObserver, |
| 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 { IDLE, ACTIVATING, ACTIVE, ERRORED }; | 35 enum class SensorState { Idle, Activating, Active, Errored }; |
| 36 | 36 |
| 37 ~Sensor() override; | 37 ~Sensor() override; |
| 38 | 38 |
| 39 void start(ScriptState*, ExceptionState&); | 39 void start(ScriptState*, ExceptionState&); |
| 40 void stop(ScriptState*, ExceptionState&); | 40 void stop(ScriptState*, ExceptionState&); |
| 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 String state() const; |
| 52 // TODO(riju): crbug.com/614797 . | 52 // TODO(riju): crbug.com/614797 . |
| 53 SensorReading* reading() const; | 53 SensorReading* reading() const; |
| 54 | 54 |
| 55 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | 55 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); |
| 56 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); | 56 DEFINE_ATTRIBUTE_EVENT_LISTENER(change); |
| 57 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 57 DEFINE_ATTRIBUTE_EVENT_LISTENER(activate); |
| 58 | 58 |
| 59 // ActiveScriptWrappable overrides. | 59 // ActiveScriptWrappable overrides. |
| 60 bool hasPendingActivity() const override; | 60 bool hasPendingActivity() const override; |
| 61 | 61 |
| 62 DECLARE_VIRTUAL_TRACE(); | 62 DECLARE_VIRTUAL_TRACE(); |
| 63 | 63 |
| 64 protected: | 64 protected: |
| 65 Sensor(ScriptState*, | 65 Sensor(ScriptState*, |
| 66 const SensorOptions&, | 66 const SensorOptions&, |
| 67 ExceptionState&, | 67 ExceptionState&, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 void pollForData(); | 103 void pollForData(); |
| 104 | 104 |
| 105 void updateState(SensorState newState); | 105 void updateState(SensorState newState); |
| 106 void reportError(ExceptionCode = UnknownError, | 106 void reportError(ExceptionCode = UnknownError, |
| 107 const String& sanitizedMessage = String(), | 107 const String& sanitizedMessage = String(), |
| 108 const String& unsanitizedMessage = String()); | 108 const String& unsanitizedMessage = String()); |
| 109 | 109 |
| 110 void updatePollingStatus(); | 110 void updatePollingStatus(); |
| 111 | 111 |
| 112 void notifySensorReadingChanged(); | 112 void notifySensorReadingChanged(); |
| 113 void notifyStateChanged(); | 113 void notifyOnActivate(); |
| 114 void notifyError(DOMException* error); | 114 void notifyError(DOMException* error); |
| 115 | 115 |
| 116 private: | 116 private: |
| 117 SensorOptions m_sensorOptions; | 117 SensorOptions m_sensorOptions; |
| 118 device::mojom::blink::SensorType m_type; | 118 device::mojom::blink::SensorType m_type; |
| 119 SensorState m_state; | 119 SensorState m_state; |
| 120 Member<SensorProxy> m_sensorProxy; | 120 Member<SensorProxy> m_sensorProxy; |
| 121 std::unique_ptr<SensorPollingStrategy> m_polling; | 121 std::unique_ptr<SensorPollingStrategy> m_polling; |
| 122 device::SensorReading m_storedData; | 122 device::SensorReading m_storedData; |
| 123 SensorConfigurationPtr m_configuration; | 123 SensorConfigurationPtr m_configuration; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 } // namespace blink | 126 } // namespace blink |
| 127 | 127 |
| 128 #endif // Sensor_h | 128 #endif // Sensor_h |
| OLD | NEW |