| 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 SensorProxy_h | 5 #ifndef SensorProxy_h |
| 6 #define SensorProxy_h | 6 #define SensorProxy_h |
| 7 | 7 |
| 8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
| 9 #include "core/page/PageVisibilityObserver.h" | 9 #include "core/page/PageVisibilityObserver.h" |
| 10 #include "device/generic_sensor/public/cpp/sensor_reading.h" | 10 #include "device/generic_sensor/public/cpp/sensor_reading.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 USING_GARBAGE_COLLECTED_MIXIN(SensorProxy); | 29 USING_GARBAGE_COLLECTED_MIXIN(SensorProxy); |
| 30 USING_PRE_FINALIZER(SensorProxy, dispose); | 30 USING_PRE_FINALIZER(SensorProxy, dispose); |
| 31 WTF_MAKE_NONCOPYABLE(SensorProxy); | 31 WTF_MAKE_NONCOPYABLE(SensorProxy); |
| 32 | 32 |
| 33 public: | 33 public: |
| 34 class Observer : public GarbageCollectedMixin { | 34 class Observer : public GarbageCollectedMixin { |
| 35 public: | 35 public: |
| 36 // Has valid 'Sensor' binding, {add, remove}Configuration() | 36 // Has valid 'Sensor' binding, {add, remove}Configuration() |
| 37 // methods can be called. | 37 // methods can be called. |
| 38 virtual void onSensorInitialized() {} | 38 virtual void onSensorInitialized() {} |
| 39 // Platfrom sensort reading has changed. | 39 // Platfrom sensor reading has changed. |
| 40 virtual void onSensorReadingChanged() {} |
| 41 // Observer should send 'onchange' event if needed. |
| 42 // The 'notifySensorChanged' calls are in sync with rAF. |
| 43 // Currently, we decide whether to send 'onchange' event based on the |
| 44 // time elapsed from the previous notification. |
| 45 // TODO: Reconsider this after https://github.com/w3c/sensors/issues/152 |
| 46 // is resolved. |
| 40 // |timestamp| Reference timestamp in seconds of the moment when | 47 // |timestamp| Reference timestamp in seconds of the moment when |
| 41 // sensor reading was updated from the buffer. | 48 // sensor reading was updated from the buffer. |
| 42 // Note: |timestamp| values are only used to calculate elapsed time | 49 // Note: |timestamp| values are only used to calculate elapsed time |
| 43 // between shared buffer readings. These values *do not* correspond | 50 // between shared buffer readings. These values *do not* correspond |
| 44 // to sensor reading timestamps which are obtained on platform side. | 51 // to sensor reading timestamps which are obtained on platform side. |
| 45 virtual void onSensorReadingChanged(double timestamp) {} | 52 virtual void notifySensorChanged(double timestamp) {} |
| 46 // An error has occurred. | 53 // An error has occurred. |
| 47 virtual void onSensorError(ExceptionCode, | 54 virtual void onSensorError(ExceptionCode, |
| 48 const String& sanitizedMessage, | 55 const String& sanitizedMessage, |
| 49 const String& unsanitizedMessage) {} | 56 const String& unsanitizedMessage) {} |
| 50 }; | 57 }; |
| 51 | 58 |
| 52 ~SensorProxy(); | 59 ~SensorProxy(); |
| 53 | 60 |
| 54 void dispose(); | 61 void dispose(); |
| 55 | 62 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 using ReadingBuffer = device::SensorReadingSharedBuffer; | 156 using ReadingBuffer = device::SensorReadingSharedBuffer; |
| 150 static_assert( | 157 static_assert( |
| 151 sizeof(ReadingBuffer) == | 158 sizeof(ReadingBuffer) == |
| 152 device::mojom::blink::SensorInitParams::kReadBufferSizeForTests, | 159 device::mojom::blink::SensorInitParams::kReadBufferSizeForTests, |
| 153 "Check reading buffer size for tests"); | 160 "Check reading buffer size for tests"); |
| 154 }; | 161 }; |
| 155 | 162 |
| 156 } // namespace blink | 163 } // namespace blink |
| 157 | 164 |
| 158 #endif // SensorProxy_h | 165 #endif // SensorProxy_h |
| OLD | NEW |