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..2a5956267d2622e38c56356c3a8ec264457c939e |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.h |
@@ -0,0 +1,65 @@ |
+// 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 "core/page/PageVisibilityObserver.h" |
+#include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h" |
+#include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h" |
+#include "modules/ModulesExport.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. It's created lazily for a frame and deleted if: |
+// - the frame is deleted |
+// - there are no left SensorProxies (i.e. there are no active Sensor |
+// instances within the frame). |
timvolodine
2016/08/25 17:52:32
->"no SensorProxies left"
Mikhail
2016/08/26 16:42:42
Done.
|
+// - a fatal error has occured (mojo IPC channel got broken) |
+class MODULES_EXPORT SensorProviderProxy final |
+ : public GarbageCollectedFinalized<SensorProviderProxy> |
+ , public Supplement<LocalFrame> |
+ , public PageVisibilityObserver { |
+ USING_GARBAGE_COLLECTED_MIXIN(SensorProviderProxy); |
+ WTF_MAKE_NONCOPYABLE(SensorProviderProxy); |
+public: |
+ static SensorProviderProxy* getOrCreateForFrame(LocalFrame*); |
+ |
+ ~SensorProviderProxy(); |
+ |
+ SensorProxy* getOrCreateSensor(device::mojom::blink::SensorType); |
+ |
+ DECLARE_VIRTUAL_TRACE(); |
+ |
+private: |
+ explicit SensorProviderProxy(LocalFrame*); |
+ |
+ // PageVisibilityObserver overrides. |
+ void pageVisibilityChanged() override; |
+ |
+ // To be called by SensorProxy. |
+ void removeSensor(SensorProxy*); |
+ device::mojom::blink::SensorProvider* sensorProvider() const { return m_sensorProvider.get(); } |
+ friend class SensorProxy; |
timvolodine
2016/08/25 17:52:32
pls put after "private:"
also, why does it need to
Mikhail
2016/08/26 16:42:42
Done.
|
+ |
+ void handleSensorError(); |
+ |
+ using SensorsSet = HeapHashSet<Member<SensorProxy>>; |
+ SensorsSet m_sensors; |
+ static const char s_supplementKey[]; |
+ |
+ WeakMember<LocalFrame> m_frame; |
+ |
+ device::mojom::blink::SensorProviderPtr m_sensorProvider; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // SensorProviderProxy_h |