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 "device/base/synchronization/shared_memory_seqlock_buffer.h" |
8 #include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h" | 9 #include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h" |
9 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h" | 10 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h" |
10 #include "mojo/public/cpp/bindings/binding.h" | 11 #include "mojo/public/cpp/bindings/binding.h" |
11 #include "platform/Supplementable.h" | 12 #include "platform/Supplementable.h" |
12 #include "platform/heap/Handle.h" | 13 #include "platform/heap/Handle.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
16 class SensorProviderProxy; | 17 class SensorProviderProxy; |
17 | 18 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 std::unique_ptr<Function<void(bool)>>); | 51 std::unique_ptr<Function<void(bool)>>); |
51 void removeConfiguration(device::mojom::blink::SensorConfigurationPtr, | 52 void removeConfiguration(device::mojom::blink::SensorConfigurationPtr, |
52 std::unique_ptr<Function<void(bool)>>); | 53 std::unique_ptr<Function<void(bool)>>); |
53 | 54 |
54 void suspend(); | 55 void suspend(); |
55 void resume(); | 56 void resume(); |
56 | 57 |
57 device::mojom::blink::SensorType type() const { return m_type; } | 58 device::mojom::blink::SensorType type() const { return m_type; } |
58 device::mojom::blink::ReportingMode reportingMode() const { return m_mode; } | 59 device::mojom::blink::ReportingMode reportingMode() const { return m_mode; } |
59 | 60 |
60 struct Reading { | 61 using Reading = device::mojom::blink::SensorReading; |
61 double timestamp; | |
62 double reading[3]; | |
63 }; | |
64 static_assert(sizeof(Reading) == | |
65 device::mojom::blink::SensorInitParams::kReadBufferSize, | |
66 "Check reading size"); | |
67 | 62 |
68 const Reading& reading() const { return m_reading; } | 63 const Reading& reading() const { return m_reading; } |
69 | 64 |
70 const device::mojom::blink::SensorConfiguration* defaultConfig() const; | 65 const device::mojom::blink::SensorConfiguration* defaultConfig() const; |
71 | 66 |
72 // Updates internal reading from shared buffer. | 67 // Updates internal reading from shared buffer. |
73 void updateInternalReading(); | 68 void updateInternalReading(); |
74 | 69 |
75 DECLARE_VIRTUAL_TRACE(); | 70 DECLARE_VIRTUAL_TRACE(); |
76 | 71 |
(...skipping 20 matching lines...) Expand all Loading... |
97 device::mojom::blink::SensorPtr m_sensor; | 92 device::mojom::blink::SensorPtr m_sensor; |
98 device::mojom::blink::SensorConfigurationPtr m_defaultConfig; | 93 device::mojom::blink::SensorConfigurationPtr m_defaultConfig; |
99 mojo::Binding<device::mojom::blink::SensorClient> m_clientBinding; | 94 mojo::Binding<device::mojom::blink::SensorClient> m_clientBinding; |
100 | 95 |
101 enum State { Uninitialized, Initializing, Initialized }; | 96 enum State { Uninitialized, Initializing, Initialized }; |
102 State m_state; | 97 State m_state; |
103 mojo::ScopedSharedBufferHandle m_sharedBufferHandle; | 98 mojo::ScopedSharedBufferHandle m_sharedBufferHandle; |
104 mojo::ScopedSharedBufferMapping m_sharedBuffer; | 99 mojo::ScopedSharedBufferMapping m_sharedBuffer; |
105 Reading m_reading; | 100 Reading m_reading; |
106 bool m_suspended; | 101 bool m_suspended; |
| 102 using ReadingBuffer = device::SharedMemorySeqLockBuffer<Reading>; |
107 }; | 103 }; |
108 | 104 |
109 } // namespace blink | 105 } // namespace blink |
110 | 106 |
111 #endif // SensorProxy_h | 107 #endif // SensorProxy_h |
OLD | NEW |