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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 // The |SensorReading| instance which is shared between sensor instances | 80 // The |SensorReading| instance which is shared between sensor instances |
81 // of the same type. | 81 // of the same type. |
82 // Note: the returned value is reset after updateSensorReading() call. | 82 // Note: the returned value is reset after updateSensorReading() call. |
83 SensorReading* sensorReading() const { return m_reading; } | 83 SensorReading* sensorReading() const { return m_reading; } |
84 | 84 |
85 const device::mojom::blink::SensorConfiguration* defaultConfig() const; | 85 const device::mojom::blink::SensorConfiguration* defaultConfig() const; |
86 | 86 |
87 double maximumFrequency() const { return m_maximumFrequency; } | 87 double maximumFrequency() const { return m_maximumFrequency; } |
88 | 88 |
89 Document* document() const { return m_document; } | 89 Document* document() const; |
90 const WTF::Vector<double>& frequenciesUsed() const { | 90 const WTF::Vector<double>& frequenciesUsed() const { |
91 return m_frequenciesUsed; | 91 return m_frequenciesUsed; |
92 } | 92 } |
93 | 93 |
94 DECLARE_VIRTUAL_TRACE(); | 94 DECLARE_VIRTUAL_TRACE(); |
95 | 95 |
96 private: | 96 private: |
97 friend class SensorProviderProxy; | 97 friend class SensorProviderProxy; |
98 friend class SensorReadingUpdaterContinuous; | 98 friend class SensorReadingUpdaterContinuous; |
99 friend class SensorReadingUpdaterOnChange; | 99 friend class SensorReadingUpdaterOnChange; |
100 SensorProxy(device::mojom::blink::SensorType, | 100 SensorProxy(device::mojom::blink::SensorType, |
101 SensorProviderProxy*, | 101 SensorProviderProxy*, |
102 Document*, | 102 Page*, |
103 std::unique_ptr<SensorReadingFactory>); | 103 std::unique_ptr<SensorReadingFactory>); |
104 | 104 |
105 // Updates sensor reading from shared buffer. | 105 // Updates sensor reading from shared buffer. |
106 void updateSensorReading(); | 106 void updateSensorReading(); |
107 void notifySensorChanged(double timestamp); | 107 void notifySensorChanged(double timestamp); |
108 | 108 |
109 // device::mojom::blink::SensorClient overrides. | 109 // device::mojom::blink::SensorClient overrides. |
110 void RaiseError() override; | 110 void RaiseError() override; |
111 void SensorReadingChanged() override; | 111 void SensorReadingChanged() override; |
112 | 112 |
(...skipping 25 matching lines...) Expand all Loading... |
138 | 138 |
139 device::mojom::blink::SensorPtr m_sensor; | 139 device::mojom::blink::SensorPtr m_sensor; |
140 device::mojom::blink::SensorConfigurationPtr m_defaultConfig; | 140 device::mojom::blink::SensorConfigurationPtr m_defaultConfig; |
141 mojo::Binding<device::mojom::blink::SensorClient> m_clientBinding; | 141 mojo::Binding<device::mojom::blink::SensorClient> m_clientBinding; |
142 | 142 |
143 enum State { Uninitialized, Initializing, Initialized }; | 143 enum State { Uninitialized, Initializing, Initialized }; |
144 State m_state; | 144 State m_state; |
145 mojo::ScopedSharedBufferHandle m_sharedBufferHandle; | 145 mojo::ScopedSharedBufferHandle m_sharedBufferHandle; |
146 mojo::ScopedSharedBufferMapping m_sharedBuffer; | 146 mojo::ScopedSharedBufferMapping m_sharedBuffer; |
147 bool m_suspended; | 147 bool m_suspended; |
148 Member<Document> m_document; | |
149 Member<SensorReading> m_reading; | 148 Member<SensorReading> m_reading; |
150 std::unique_ptr<SensorReadingFactory> m_readingFactory; | 149 std::unique_ptr<SensorReadingFactory> m_readingFactory; |
151 double m_maximumFrequency; | 150 double m_maximumFrequency; |
152 | 151 |
153 Member<SensorReadingUpdater> m_readingUpdater; | 152 Member<SensorReadingUpdater> m_readingUpdater; |
154 WTF::Vector<double> m_frequenciesUsed; | 153 WTF::Vector<double> m_frequenciesUsed; |
155 double m_lastRafTimestamp; | 154 double m_lastRafTimestamp; |
156 | 155 |
157 using ReadingBuffer = device::SensorReadingSharedBuffer; | 156 using ReadingBuffer = device::SensorReadingSharedBuffer; |
158 static_assert( | 157 static_assert( |
159 sizeof(ReadingBuffer) == | 158 sizeof(ReadingBuffer) == |
160 device::mojom::blink::SensorInitParams::kReadBufferSizeForTests, | 159 device::mojom::blink::SensorInitParams::kReadBufferSizeForTests, |
161 "Check reading buffer size for tests"); | 160 "Check reading buffer size for tests"); |
162 }; | 161 }; |
163 | 162 |
164 } // namespace blink | 163 } // namespace blink |
165 | 164 |
166 #endif // SensorProxy_h | 165 #endif // SensorProxy_h |
OLD | NEW |