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

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

Issue 1892083002: Generic Sensor API : Ambient Light Sensor API. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: re entrancy fix Created 4 years, 6 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 AmbientLightSensorDispatcher_h
6 #define AmbientLightSensorDispatcher_h
7
8 #include "core/frame/PlatformEventDispatcher.h"
9 #include "device/sensor/als_reading.mojom-blink.h"
10 #include "device/sensor/sensor.mojom-blink.h"
11 #include "modules/ModulesExport.h"
12 #include "modules/sensor/AmbientLightSensor.h"
13 #include "modules/sensor/als_reading.h"
14 #include "wtf/OwnPtr.h"
15
16 namespace blink {
17
18 class MODULES_EXPORT AmbientLightSensorDispatcher final : public GarbageCollecte dFinalized<AmbientLightSensorDispatcher>, public PlatformEventDispatcher {
19 USING_GARBAGE_COLLECTED_MIXIN(AmbientLightSensorDispatcher);
20 WTF_MAKE_NONCOPYABLE(AmbientLightSensorDispatcher);
21
22 public:
23 static AmbientLightSensorDispatcher& instance();
24
25 const AmbientLightSensorReadingProxy* latestData() const
26 {
27 return m_hasLatestData ? &m_alsReading : nullptr;
28 }
29
30 private:
31 AmbientLightSensorDispatcher();
32
33 void queryNextReading();
34 void onDidChange(device::blink::AmbientLightSensorReadingPtr);
35 void updateSensorReading(const AmbientLightSensorReadingProxy&);
36 void startReading();
37 void stopReading();
38
39 // Inherited from PlatformEventDispatcher.
40 void startListening() override;
41 void stopListening() override;
42
43 device::blink::AmbientLightSensorPtr m_lightSensor;
44 AmbientLightSensorReadingProxy m_alsReading;
45 bool m_hasLatestData;
46 };
47
48 } // namespace blink
49
50 #endif // AmbientLightSensorDispatcher_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698