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