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 SensorProviderProxy_h | 5 #ifndef SensorProviderProxy_h |
6 #define SensorProviderProxy_h | 6 #define SensorProviderProxy_h |
7 | 7 |
8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
9 #include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h" | 9 #include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h" |
10 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h" | 10 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h" |
11 #include "platform/Supplementable.h" | 11 #include "platform/Supplementable.h" |
12 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
16 class SensorProxy; | 16 class SensorProxy; |
17 class SensorReadingFactory; | |
18 | 17 |
19 // This class wraps 'SensorProvider' mojo interface and it manages | 18 // This class wraps 'SensorProvider' mojo interface and it manages |
20 // 'SensorProxy' instances. | 19 // 'SensorProxy' instances. |
21 class SensorProviderProxy final | 20 class SensorProviderProxy final |
22 : public GarbageCollectedFinalized<SensorProviderProxy>, | 21 : public GarbageCollectedFinalized<SensorProviderProxy>, |
23 public Supplement<LocalFrame> { | 22 public Supplement<LocalFrame> { |
24 USING_GARBAGE_COLLECTED_MIXIN(SensorProviderProxy); | 23 USING_GARBAGE_COLLECTED_MIXIN(SensorProviderProxy); |
25 WTF_MAKE_NONCOPYABLE(SensorProviderProxy); | 24 WTF_MAKE_NONCOPYABLE(SensorProviderProxy); |
26 | 25 |
27 public: | 26 public: |
28 static SensorProviderProxy* from(LocalFrame*); | 27 static SensorProviderProxy* from(LocalFrame*); |
29 | 28 |
30 ~SensorProviderProxy(); | 29 ~SensorProviderProxy(); |
31 | 30 |
32 SensorProxy* createSensorProxy(device::mojom::blink::SensorType, | 31 SensorProxy* createSensorProxy(device::mojom::blink::SensorType, Page*); |
33 Page*, | |
34 std::unique_ptr<SensorReadingFactory>); | |
35 | 32 |
36 SensorProxy* getSensorProxy(device::mojom::blink::SensorType); | 33 SensorProxy* getSensorProxy(device::mojom::blink::SensorType); |
37 | 34 |
38 DECLARE_VIRTUAL_TRACE(); | 35 DECLARE_VIRTUAL_TRACE(); |
39 | 36 |
40 private: | 37 private: |
41 friend class SensorProxy; // To call getSensorProvider(). | 38 friend class SensorProxy; // To call getSensorProvider(). |
42 | 39 |
43 explicit SensorProviderProxy(LocalFrame&); | 40 explicit SensorProviderProxy(LocalFrame&); |
44 static const char* supplementName(); | 41 static const char* supplementName(); |
45 void initializeIfNeeded(LocalFrame*); | 42 void initializeIfNeeded(LocalFrame*); |
46 bool isInitialized() const { return m_sensorProvider; } | 43 bool isInitialized() const { return m_sensorProvider; } |
47 | 44 |
48 device::mojom::blink::SensorProvider* getSensorProvider() const { | 45 device::mojom::blink::SensorProvider* getSensorProvider() const { |
49 return m_sensorProvider.get(); | 46 return m_sensorProvider.get(); |
50 } | 47 } |
51 | 48 |
52 void onSensorProviderConnectionError(); | 49 void onSensorProviderConnectionError(); |
53 | 50 |
54 using SensorsSet = HeapHashSet<WeakMember<SensorProxy>>; | 51 using SensorsSet = HeapHashSet<WeakMember<SensorProxy>>; |
55 SensorsSet m_sensorProxies; | 52 SensorsSet m_sensorProxies; |
56 | 53 |
57 device::mojom::blink::SensorProviderPtr m_sensorProvider; | 54 device::mojom::blink::SensorProviderPtr m_sensorProvider; |
58 }; | 55 }; |
59 | 56 |
60 } // namespace blink | 57 } // namespace blink |
61 | 58 |
62 #endif // SensorProviderProxy_h | 59 #endif // SensorProviderProxy_h |
OLD | NEW |