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

Side by Side Diff: device/sensors/public/interfaces/sensor.mojom

Issue 2144623003: [sensors] Introduce Generic Sensor API interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dcheng comments Created 4 years, 5 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 module device.mojom;
6
7 // Types of supported sensors
8 enum SensorType {
9 FIRST = 1,
10 AMBIENT_LIGHT = FIRST,
11 PROXIMITY,
12 ACCELEROMETER,
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 // Frequency in Hz
timvolodine 2016/07/22 19:31:45 add a comment that this is the requested frequency
Mikhail 2016/08/09 19:38:28 Done.
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/07/22 19:31:45 Does the browser really need to know all 'javascri
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);
53 };
54
55 // Interface that client of the Sensor interface must implement to observe
56 // sensor reading changes and error conditions.
57 interface SensorClient {
58 // Signals SensorClient when there is an error.
59 RaiseError();
60
61 // Signals SensorClient when reading has been changed (only for sensors with
62 // ReportingMode::ON_CHANGE).
63 SensorReadingChanged();
64 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698