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

Unified Diff: device/generic_sensor/polling_platform_sensor.h

Issue 2332903002: [sensors] [mac] Implement ambient light sensor for macOS (Closed)
Patch Set: Fix comments from Mikhail 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 side-by-side diff with in-line comments
Download patch
Index: device/generic_sensor/polling_platform_sensor.h
diff --git a/device/generic_sensor/polling_platform_sensor.h b/device/generic_sensor/polling_platform_sensor.h
new file mode 100644
index 0000000000000000000000000000000000000000..ddbac68ecd4ae1cecf95e19210c24cee73fbbb6e
--- /dev/null
+++ b/device/generic_sensor/polling_platform_sensor.h
@@ -0,0 +1,44 @@
+// 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 DEVICE_GENERIC_SENSOR_POLLING_PLATFORM_SENSOR_H_
+#define DEVICE_GENERIC_SENSOR_POLLING_PLATFORM_SENSOR_H_
+
+#include "base/timer/timer.h"
+#include "device/generic_sensor/platform_sensor.h"
+
+namespace base {
+class SingleThreadTaskRunner;
+}
+
+namespace device {
+
+class PollingPlatformSensor : public PlatformSensor {
+ public:
+ PollingPlatformSensor(
+ mojom::SensorType type,
+ mojo::ScopedSharedBufferMapping mapping,
+ PlatformSensorProvider* provider,
+ scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner);
+
+ virtual void UpdateReading() = 0;
+
+ protected:
+ ~PollingPlatformSensor() override;
+ bool StartSensor(const PlatformSensorConfiguration& configuration) override;
+ void StopSensor() override;
+ scoped_refptr<base::SingleThreadTaskRunner> polling_thread_task_runner_;
+ scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
+ base::RepeatingTimer timer_;
+
+ private:
+ void BeginPoll(const PlatformSensorConfiguration& configuration);
+ void StopPoll();
+
+ DISALLOW_COPY_AND_ASSIGN(PollingPlatformSensor);
+};
+
+} // namespace device
+
+#endif // DEVICE_GENERIC_SENSOR_POLLING_PLATFORM_SENSOR_H_

Powered by Google App Engine
This is Rietveld 408576698