OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SensorProviderProxy_h | |
6 #define SensorProviderProxy_h | |
7 | |
8 #include "core/page/PageVisibilityObserver.h" | |
9 #include "device/generic_sensor/public/interfaces/sensor.mojom-blink.h" | |
10 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom-blink.h" | |
11 #include "modules/ModulesExport.h" | |
12 #include "platform/Supplementable.h" | |
13 #include "platform/heap/Handle.h" | |
14 | |
15 namespace blink { | |
16 | |
17 class LocalFrame; | |
18 class SensorProxy; | |
19 | |
20 // This class wraps 'SensorProvider' mojo interface and it manages | |
21 // 'SensorProxy' instances. It's created lazily for a frame and deleted if: | |
22 // - the frame is deleted | |
23 // - there are no left SensorProxies (i.e. there are no active Sensor | |
24 // instances within the frame). | |
timvolodine
2016/08/25 17:52:32
->"no SensorProxies left"
Mikhail
2016/08/26 16:42:42
Done.
| |
25 // - a fatal error has occured (mojo IPC channel got broken) | |
26 class MODULES_EXPORT SensorProviderProxy final | |
27 : public GarbageCollectedFinalized<SensorProviderProxy> | |
28 , public Supplement<LocalFrame> | |
29 , public PageVisibilityObserver { | |
30 USING_GARBAGE_COLLECTED_MIXIN(SensorProviderProxy); | |
31 WTF_MAKE_NONCOPYABLE(SensorProviderProxy); | |
32 public: | |
33 static SensorProviderProxy* getOrCreateForFrame(LocalFrame*); | |
34 | |
35 ~SensorProviderProxy(); | |
36 | |
37 SensorProxy* getOrCreateSensor(device::mojom::blink::SensorType); | |
38 | |
39 DECLARE_VIRTUAL_TRACE(); | |
40 | |
41 private: | |
42 explicit SensorProviderProxy(LocalFrame*); | |
43 | |
44 // PageVisibilityObserver overrides. | |
45 void pageVisibilityChanged() override; | |
46 | |
47 // To be called by SensorProxy. | |
48 void removeSensor(SensorProxy*); | |
49 device::mojom::blink::SensorProvider* sensorProvider() const { return m_sens orProvider.get(); } | |
50 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.
| |
51 | |
52 void handleSensorError(); | |
53 | |
54 using SensorsSet = HeapHashSet<Member<SensorProxy>>; | |
55 SensorsSet m_sensors; | |
56 static const char s_supplementKey[]; | |
57 | |
58 WeakMember<LocalFrame> m_frame; | |
59 | |
60 device::mojom::blink::SensorProviderPtr m_sensorProvider; | |
61 }; | |
62 | |
63 } // namespace blink | |
64 | |
65 #endif // SensorProviderProxy_h | |
OLD | NEW |