Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Side by Side Diff: third_party/WebKit/Source/modules/sensor/SensorProxy.h

Issue 2668173003: [Sensors] Remove SensorReading interfaces (Closed)
Patch Set: updated global-interface-listing.html Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h" 11 #include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h"
12 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h" 12 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h"
13 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/binding.h"
14 #include "platform/Supplementable.h" 14 #include "platform/Supplementable.h"
15 #include "platform/heap/Handle.h" 15 #include "platform/heap/Handle.h"
16 #include "wtf/Vector.h" 16 #include "wtf/Vector.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 class SensorProviderProxy; 20 class SensorProviderProxy;
21 class SensorReading; 21 class SensorReading;
22 class SensorReadingFactory;
23 class SensorReadingUpdater; 22 class SensorReadingUpdater;
24 23
25 // This class wraps 'Sensor' mojo interface and used by multiple 24 // This class wraps 'Sensor' mojo interface and used by multiple
26 // JS sensor instances of the same type (within a single frame). 25 // JS sensor instances of the same type (within a single frame).
27 class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>, 26 class SensorProxy final : public GarbageCollectedFinalized<SensorProxy>,
28 public device::mojom::blink::SensorClient, 27 public device::mojom::blink::SensorClient,
29 public PageVisibilityObserver { 28 public PageVisibilityObserver {
30 USING_GARBAGE_COLLECTED_MIXIN(SensorProxy); 29 USING_GARBAGE_COLLECTED_MIXIN(SensorProxy);
31 USING_PRE_FINALIZER(SensorProxy, dispose); 30 USING_PRE_FINALIZER(SensorProxy, dispose);
32 WTF_MAKE_NONCOPYABLE(SensorProxy); 31 WTF_MAKE_NONCOPYABLE(SensorProxy);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 std::unique_ptr<Function<void(bool)>>); 69 std::unique_ptr<Function<void(bool)>>);
71 70
72 void removeConfiguration(device::mojom::blink::SensorConfigurationPtr); 71 void removeConfiguration(device::mojom::blink::SensorConfigurationPtr);
73 72
74 void suspend(); 73 void suspend();
75 void resume(); 74 void resume();
76 75
77 device::mojom::blink::SensorType type() const { return m_type; } 76 device::mojom::blink::SensorType type() const { return m_type; }
78 device::mojom::blink::ReportingMode reportingMode() const { return m_mode; } 77 device::mojom::blink::ReportingMode reportingMode() const { return m_mode; }
79 78
80 // The |SensorReading| instance which is shared between sensor instances
81 // of the same type.
82 // Note: the returned value is reset after updateSensorReading() call. 79 // Note: the returned value is reset after updateSensorReading() call.
83 SensorReading* sensorReading() const { return m_reading; } 80 const device::SensorReading& reading() const { return m_reading; }
84 81
85 const device::mojom::blink::SensorConfiguration* defaultConfig() const; 82 const device::mojom::blink::SensorConfiguration* defaultConfig() const;
86 83
87 double maximumFrequency() const { return m_maximumFrequency; } 84 double maximumFrequency() const { return m_maximumFrequency; }
88 85
89 Document* document() const; 86 Document* document() const;
90 const WTF::Vector<double>& frequenciesUsed() const { 87 const WTF::Vector<double>& frequenciesUsed() const {
91 return m_frequenciesUsed; 88 return m_frequenciesUsed;
92 } 89 }
93 90
94 DECLARE_VIRTUAL_TRACE(); 91 DECLARE_VIRTUAL_TRACE();
95 92
96 private: 93 private:
97 friend class SensorProviderProxy; 94 friend class SensorProviderProxy;
98 friend class SensorReadingUpdaterContinuous; 95 friend class SensorReadingUpdaterContinuous;
99 friend class SensorReadingUpdaterOnChange; 96 friend class SensorReadingUpdaterOnChange;
100 SensorProxy(device::mojom::blink::SensorType, 97 SensorProxy(device::mojom::blink::SensorType, SensorProviderProxy*, Page*);
101 SensorProviderProxy*,
102 Page*,
103 std::unique_ptr<SensorReadingFactory>);
104 98
105 // Updates sensor reading from shared buffer. 99 // Updates sensor reading from shared buffer.
106 void updateSensorReading(); 100 void updateSensorReading();
107 void notifySensorChanged(double timestamp); 101 void notifySensorChanged(double timestamp);
108 102
109 // device::mojom::blink::SensorClient overrides. 103 // device::mojom::blink::SensorClient overrides.
110 void RaiseError() override; 104 void RaiseError() override;
111 void SensorReadingChanged() override; 105 void SensorReadingChanged() override;
112 106
113 // PageVisibilityObserver overrides. 107 // PageVisibilityObserver overrides.
(...skipping 24 matching lines...) Expand all
138 132
139 device::mojom::blink::SensorPtr m_sensor; 133 device::mojom::blink::SensorPtr m_sensor;
140 device::mojom::blink::SensorConfigurationPtr m_defaultConfig; 134 device::mojom::blink::SensorConfigurationPtr m_defaultConfig;
141 mojo::Binding<device::mojom::blink::SensorClient> m_clientBinding; 135 mojo::Binding<device::mojom::blink::SensorClient> m_clientBinding;
142 136
143 enum State { Uninitialized, Initializing, Initialized }; 137 enum State { Uninitialized, Initializing, Initialized };
144 State m_state; 138 State m_state;
145 mojo::ScopedSharedBufferHandle m_sharedBufferHandle; 139 mojo::ScopedSharedBufferHandle m_sharedBufferHandle;
146 mojo::ScopedSharedBufferMapping m_sharedBuffer; 140 mojo::ScopedSharedBufferMapping m_sharedBuffer;
147 bool m_suspended; 141 bool m_suspended;
148 Member<SensorReading> m_reading; 142 device::SensorReading m_reading;
149 std::unique_ptr<SensorReadingFactory> m_readingFactory;
150 double m_maximumFrequency; 143 double m_maximumFrequency;
151 144
152 Member<SensorReadingUpdater> m_readingUpdater; 145 Member<SensorReadingUpdater> m_readingUpdater;
153 WTF::Vector<double> m_frequenciesUsed; 146 WTF::Vector<double> m_frequenciesUsed;
154 double m_lastRafTimestamp; 147 double m_lastRafTimestamp;
155 148
156 using ReadingBuffer = device::SensorReadingSharedBuffer; 149 using ReadingBuffer = device::SensorReadingSharedBuffer;
157 static_assert( 150 static_assert(
158 sizeof(ReadingBuffer) == 151 sizeof(ReadingBuffer) ==
159 device::mojom::blink::SensorInitParams::kReadBufferSizeForTests, 152 device::mojom::blink::SensorInitParams::kReadBufferSizeForTests,
160 "Check reading buffer size for tests"); 153 "Check reading buffer size for tests");
161 }; 154 };
162 155
163 } // namespace blink 156 } // namespace blink
164 157
165 #endif // SensorProxy_h 158 #endif // SensorProxy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698