Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 module device.mojom; | |
| 6 | |
| 7 // Types of supported sensors | |
| 8 enum SensorType { | |
| 9 FIRST = 1, | |
| 10 AMBIENT_LIGHT = FIRST, | |
| 11 PROXIMITY, | |
| 12 ACCELEROMETER, | |
|
timvolodine
2016/08/18 22:52:14
maybe distinguish accelerometer with including/exc
Mikhail
2016/08/19 09:29:55
yeah, this list will be updated when implementatio
| |
| 13 GYROSCOPE, | |
| 14 PRESSURE, | |
| 15 LAST = PRESSURE // Note: LAST is also equal to the types count. | |
| 16 }; | |
| 17 | |
| 18 // Reporting mode supported by the Sensor. | |
| 19 // ON_CHANGE - client will be notified through OnSensorReadingChanged() signal | |
| 20 // whenever sensor reading is changed. | |
| 21 // CONTINUOUS - sensor will continuously update its reading with frequency | |
| 22 // specified in SensorConfiguration.frequency. | |
| 23 // OnSensorReadingChanged() signal is not sent to the client for | |
| 24 // sensors with CONTINUOUS reporting mode. | |
| 25 enum ReportingMode { | |
| 26 ON_CHANGE, | |
| 27 CONTINUOUS | |
| 28 }; | |
| 29 | |
| 30 struct SensorConfiguration { | |
| 31 // Requested frequency in Hz (max is 60 Hz). | |
| 32 double frequency; | |
| 33 // TODO(shalamov): Add map<string, union> for sensor specific configuration. | |
| 34 }; | |
| 35 | |
| 36 // Interface for controlling the Sensor. | |
| 37 interface Sensor { | |
| 38 // Requests sensor to start reading sensor data with specified | |
| 39 // SensorConfiguration. | |
| 40 // Sensor holds the list of added configurations and it always polls | |
| 41 // the platform (and updates the shared buffer) at the maxiumum frequency | |
| 42 // among the obtained from the stored configurations, so that all clients | |
| 43 // can have sensor data in time. | |
| 44 AddConfiguration(SensorConfiguration configuration) => (bool success); | |
|
timvolodine
2016/08/18 22:52:14
maybe mention that this can fail if the config is
Mikhail
2016/08/19 09:29:55
Done.
| |
| 45 | |
| 46 // Requests sensor to stop reading sensor data for specified | |
| 47 // SensorConfiguration. | |
| 48 // This call excludes |configuration| from the Sensor's list making it | |
| 49 // reconsider the the shared buffer udpate frequency. If there are no | |
| 50 // configurations left in the Sensor's configuration list it stops polling | |
| 51 // sensor data from the platform and update the shared buffer. | |
| 52 RemoveConfiguration(SensorConfiguration configuration) => (bool success); | |
|
timvolodine
2016/08/18 22:52:14
not sure if a return value (=> bool success) is us
Mikhail
2016/08/19 09:29:55
Go to 'errored' state.
| |
| 53 | |
| 54 // Temporary suppresses sensor reading changes notification. | |
| 55 SuspendNotification(); | |
|
timvolodine
2016/08/18 22:52:14
maybe just "Suspend()"? I understand this will sto
Mikhail
2016/08/19 09:29:55
Agree 'Suspend' is better as this call would affec
| |
| 56 | |
| 57 // Resumes previously suspended sensor reading changes notification. | |
| 58 ResumeNotification(); | |
| 59 }; | |
| 60 | |
| 61 // Interface that client of the Sensor interface must implement to observe | |
| 62 // sensor reading changes and error conditions. | |
| 63 interface SensorClient { | |
| 64 // Signals SensorClient when there is an error. | |
| 65 RaiseError(); | |
| 66 | |
| 67 // Signals SensorClient when reading has been changed (only for sensors with | |
| 68 // ReportingMode::ON_CHANGE). | |
| 69 SensorReadingChanged(); | |
| 70 }; | |
| OLD | NEW |