Chromium Code Reviews| Index: third_party/WebKit/Source/modules/sensor/SensorProviderProxy.h |
| diff --git a/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.h b/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2adc87df14426552089c3379c814fb8780bf0447 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.h |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef SensorProviderProxy_h |
| +#define SensorProviderProxy_h |
| + |
| +#include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h" |
| +#include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h" |
| +#include "platform/Supplementable.h" |
| +#include "platform/heap/Handle.h" |
| + |
| +namespace blink { |
| + |
| +class LocalFrame; |
| +class SensorProxy; |
| + |
| +// This class wraps 'SensorProvider' mojo interface and it manages |
| +// 'SensorProxy' instances. |
| +class SensorProviderProxy final |
| + : public GarbageCollectedFinalized<SensorProviderProxy> |
| + , public Supplement<LocalFrame> { |
| + USING_GARBAGE_COLLECTED_MIXIN(SensorProviderProxy); |
| + WTF_MAKE_NONCOPYABLE(SensorProviderProxy); |
| +public: |
| + static SensorProviderProxy* from(LocalFrame*); |
| + |
| + ~SensorProviderProxy(); |
| + |
| + SensorProxy* getOrCreateSensor(device::mojom::blink::SensorType); |
| + |
| + DECLARE_VIRTUAL_TRACE(); |
| + |
| +private: |
| + friend class SensorProxy; // To call sensorProvider(). |
| + |
| + explicit SensorProviderProxy(LocalFrame*); |
| + static const char* supplementName(); |
| + |
| + device::mojom::blink::SensorProvider* sensorProvider() const { return m_sensorProvider.get(); } |
| + |
| + void onSensorProviderConnectionError(); |
| + |
| + using SensorsSet = HeapHashSet<Member<SensorProxy>>; |
|
haraken
2016/09/07 02:21:56
I'm guessing that this should be WeakMembers thoug
Mikhail
2016/09/07 07:55:15
Indeed, thanks for pointing that out!
|
| + SensorsSet m_sensors; |
| + |
| + device::mojom::blink::SensorProviderPtr m_sensorProvider; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // SensorProviderProxy_h |