Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: third_party/WebKit/Source/modules/sensor/SensorProviderProxy.h

Issue 2121313002: [sensors] Generic Sensors Framework blink side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sensors_mojo_interfaces
Patch Set: Comments from Tim. Removed the default sensor configuration management (to be added with a separate… Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "platform/Supplementable.h"
12 #include "platform/heap/Handle.h"
13
14 namespace blink {
15
16 class LocalFrame;
17 class SensorProxy;
18
19 // This class wraps 'SensorProvider' mojo interface and it manages
20 // 'SensorProxy' instances. It's created lazily for a frame and deleted if:
21 // - the frame is deleted
22 // - there are no SensorProxies left (i.e. there are no active Sensor
23 // instances within the frame).
24 // - a fatal error has occured (mojo IPC channel got broken)
25 class SensorProviderProxy final
26 : public GarbageCollectedFinalized<SensorProviderProxy>
27 , public Supplement<LocalFrame>
28 , public PageVisibilityObserver {
haraken 2016/09/06 05:04:29 Do you really need to make both Sensor and SensorP
Mikhail 2016/09/06 07:13:58 when page goes invisible sensors stop polling from
29 USING_GARBAGE_COLLECTED_MIXIN(SensorProviderProxy);
30 WTF_MAKE_NONCOPYABLE(SensorProviderProxy);
31 public:
32 static SensorProviderProxy* getOrCreateForFrame(LocalFrame*);
33
34 ~SensorProviderProxy();
35
36 SensorProxy* getOrCreateSensor(device::mojom::blink::SensorType);
37
38 DECLARE_VIRTUAL_TRACE();
39
40 private:
41 friend class SensorProxy; // To call removeSensor().
42
43 explicit SensorProviderProxy(LocalFrame*);
44
45 // PageVisibilityObserver overrides.
46 void pageVisibilityChanged() override;
47
48 void removeSensor(SensorProxy*);
49 device::mojom::blink::SensorProvider* sensorProvider() const { return m_sens orProvider.get(); }
50
51 void handleSensorError();
52
53 using SensorsSet = HeapHashSet<Member<SensorProxy>>;
haraken 2016/09/06 05:04:29 I think this should be HeapHashSet<WeakMember<>>.
54 SensorsSet m_sensors;
55 static const char s_supplementKey[];
56
57 WeakMember<LocalFrame> m_frame;
haraken 2016/09/06 05:04:29 Why weak?
Mikhail 2016/09/06 07:13:58 Should it be just a member? I thought frame is own
58
59 device::mojom::blink::SensorProviderPtr m_sensorProvider;
60 };
61
62 } // namespace blink
63
64 #endif // SensorProviderProxy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698