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

Side by Side Diff: device/generic_sensor/platform_sensor_ambient_light_mac.h

Issue 2332903002: [sensors] [mac] Implement ambient light sensor for macOS (Closed)
Patch Set: Update commit message Created 4 years, 2 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
« no previous file with comments | « device/generic_sensor/DEPS ('k') | device/generic_sensor/platform_sensor_ambient_light_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 DEVICE_GENERIC_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_
6 #define DEVICE_GENERIC_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_
7
8 #include <IOKit/IOKitLib.h>
9
10 #include "base/mac/scoped_ionotificationportref.h"
11 #include "base/mac/scoped_ioobject.h"
12 #include "device/generic_sensor/platform_sensor.h"
13
14 namespace base {
15 class SingleThreadTaskRunner;
16 }
17
18 namespace device {
19
20 // Implementation of PlatformSensor for macOS to query the ambient light sensor.
21 // This is a single instance object per browser process which is created by
22 // The singleton PlatformSensorProviderMac. If there are no clients, this
23 // instance is not created.
24 class PlatformSensorAmbientLightMac : public PlatformSensor {
25 public:
26 // Construct a platform sensor of |type| AMBIENT_LIGHT, given
27 // a buffer |mapping| to write the result back. |task_runner| is
28 // used to post the notification that the sensor reading has changed.
29 PlatformSensorAmbientLightMac(mojom::SensorType type,
30 mojo::ScopedSharedBufferMapping mapping,
31 PlatformSensorProvider* provider);
32
33 mojom::ReportingMode GetReportingMode() override;
34 // Can only be called once, the first time or after a StopSensor call.
35 bool StartSensor(const PlatformSensorConfiguration& configuration) override;
36 void StopSensor() override;
37
38 protected:
39 ~PlatformSensorAmbientLightMac() override;
40 bool CheckSensorConfiguration(
41 const PlatformSensorConfiguration& configuration) override;
42 PlatformSensorConfiguration GetDefaultConfiguration() override;
43 void UpdateReading(uint64_t lux_values[2]);
44
45 private:
46 static void IOServiceCallback(void* context,
47 io_service_t service,
48 natural_t message_type,
49 void* message_argument);
50
51 // IOService representing the LMU sensor.
52 base::mac::ScopedIOObject<io_service_t> light_sensor_service_;
53 // Port used to get the notifications from the sensor.
54 base::mac::ScopedIONotificationPortRef light_sensor_port_;
55 // IO Object used to query the value of the sensor.
56 base::mac::ScopedIOObject<io_object_t> light_sensor_object_;
57 // IO Notifications created by IOServiceAddInterestNotification.
58 base::mac::ScopedIOObject<io_object_t> light_sensor_notification_;
59 double current_lux_;
60
61 DISALLOW_COPY_AND_ASSIGN(PlatformSensorAmbientLightMac);
62 };
63
64 } // namespace device
65
66 #endif // DEVICE_GENERIC_PLATFORM_SENSOR_AMBIENT_LIGHT_SENSOR_MAC_H_
OLDNEW
« no previous file with comments | « device/generic_sensor/DEPS ('k') | device/generic_sensor/platform_sensor_ambient_light_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698