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

Unified Diff: Source/modules/device_light/DeviceLightDispatcher.h

Issue 143823004: Implement DeviceLight (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Initialize m_lastDeviceLightData to -1 Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/device_light/DeviceLightDispatcher.h
diff --git a/Source/modules/device_light/DeviceLightDispatcher.h b/Source/modules/device_light/DeviceLightDispatcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..d51156449f74f0425a26a713a70fb5b28e93f972
--- /dev/null
+++ b/Source/modules/device_light/DeviceLightDispatcher.h
@@ -0,0 +1,41 @@
+// Copyright 2014 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 DeviceLightDispatcher_h
+#define DeviceLightDispatcher_h
+
+#include "core/frame/DeviceSensorEventDispatcher.h"
+#include "public/platform/WebDeviceLightListener.h"
+#include "wtf/RefPtr.h"
+
+namespace WebCore {
+
+class DeviceLightController;
+
+// This class listens to device light data and dispatches it to all
+// listening controllers
+class DeviceLightDispatcher FINAL : public DeviceSensorEventDispatcher, public blink::WebDeviceLightListener {
+public:
+ static DeviceLightDispatcher& instance();
+
+ double latestDeviceLightData() const;
+
+ // This method is called every time new device light data is available.
+ virtual void didChangeDeviceLight(const double) OVERRIDE;
+ void addDeviceLightController(DeviceLightController*);
+ void removeDeviceLightController(DeviceLightController*);
+
+private:
+ DeviceLightDispatcher();
+ virtual ~DeviceLightDispatcher();
+
+ virtual void startListening() OVERRIDE;
+ virtual void stopListening() OVERRIDE;
+
+ double m_lastDeviceLightData;
+};
+
+} // namespace WebCore
+
+#endif // DeviceLightDispatcher_h

Powered by Google App Engine
This is Rietveld 408576698