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