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

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

Issue 2929603003: Add RELATIVE_ORIENTATION sensor implementation on macOS to //device/generic_sensor (Closed)
Patch Set: updated OnSensorError() Created 3 years, 6 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_H_ 5 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_H_
6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_H_ 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 10
(...skipping 23 matching lines...) Expand all
34 virtual void OnSensorReadingChanged() = 0; 34 virtual void OnSensorReadingChanged() = 0;
35 virtual void OnSensorError() = 0; 35 virtual void OnSensorError() = 0;
36 virtual bool IsNotificationSuspended() = 0; 36 virtual bool IsNotificationSuspended() = 0;
37 37
38 protected: 38 protected:
39 virtual ~Client() {} 39 virtual ~Client() {}
40 }; 40 };
41 41
42 virtual mojom::ReportingMode GetReportingMode() = 0; 42 virtual mojom::ReportingMode GetReportingMode() = 0;
43 virtual PlatformSensorConfiguration GetDefaultConfiguration() = 0; 43 virtual PlatformSensorConfiguration GetDefaultConfiguration() = 0;
44 virtual bool StartSensor(
45 const PlatformSensorConfiguration& configuration) = 0;
46 virtual void StopSensor() = 0;
44 47
45 // Can be overriden to return the sensor maximum sampling frequency 48 // Can be overriden to return the sensor maximum sampling frequency
46 // value obtained from the platform if it is available. If platfrom 49 // value obtained from the platform if it is available. If platfrom
47 // does not provide maximum sampling frequency this method must 50 // does not provide maximum sampling frequency this method must
48 // return default frequency. 51 // return default frequency.
49 // The default implementation returns default frequency. 52 // The default implementation returns default frequency.
50 virtual double GetMaximumSupportedFrequency(); 53 virtual double GetMaximumSupportedFrequency();
51 54
52 // Can be overriden to return the sensor minimum sampling frequency. 55 // Can be overriden to return the sensor minimum sampling frequency.
53 // The default implementation returns '1.0 / (60 * 60)', i.e. once per hour. 56 // The default implementation returns '1.0 / (60 * 60)', i.e. once per hour.
54 virtual double GetMinimumSupportedFrequency(); 57 virtual double GetMinimumSupportedFrequency();
55 58
56 mojom::SensorType GetType() const; 59 mojom::SensorType GetType() const;
57 60
58 bool StartListening(Client* client, 61 bool StartListening(Client* client,
59 const PlatformSensorConfiguration& config); 62 const PlatformSensorConfiguration& config);
60 bool StopListening(Client* client, const PlatformSensorConfiguration& config); 63 bool StopListening(Client* client, const PlatformSensorConfiguration& config);
61 64
62 void UpdateSensor(); 65 void UpdateSensor();
63 66
64 void AddClient(Client*); 67 void AddClient(Client*);
65 void RemoveClient(Client*); 68 void RemoveClient(Client*);
66 69
70 const mojo::ScopedSharedBufferMapping& shared_buffer_mapping() {
71 return shared_buffer_mapping_;
72 }
73
67 protected: 74 protected:
68 virtual ~PlatformSensor(); 75 virtual ~PlatformSensor();
69 PlatformSensor(mojom::SensorType type, 76 PlatformSensor(mojom::SensorType type,
70 mojo::ScopedSharedBufferMapping mapping, 77 mojo::ScopedSharedBufferMapping mapping,
71 PlatformSensorProvider* provider); 78 PlatformSensorProvider* provider);
72 79
73 using ConfigMap = std::map<Client*, std::list<PlatformSensorConfiguration>>; 80 using ConfigMap = std::map<Client*, std::list<PlatformSensorConfiguration>>;
74 using ReadingBuffer = SensorReadingSharedBuffer; 81 using ReadingBuffer = SensorReadingSharedBuffer;
75 82
76 virtual bool UpdateSensorInternal(const ConfigMap& configurations); 83 virtual bool UpdateSensorInternal(const ConfigMap& configurations);
77 virtual bool StartSensor(
78 const PlatformSensorConfiguration& configuration) = 0;
79 virtual void StopSensor() = 0;
80 virtual bool CheckSensorConfiguration( 84 virtual bool CheckSensorConfiguration(
81 const PlatformSensorConfiguration& configuration) = 0; 85 const PlatformSensorConfiguration& configuration) = 0;
82 86
83 // Updates shared buffer with new sensor reading data. 87 // Updates shared buffer with new sensor reading data.
84 // Note: this method is thread-safe. 88 // Note: this method is thread-safe.
85 void UpdateSensorReading(const SensorReading& reading, bool notify_clients); 89 void UpdateSensorReading(const SensorReading& reading, bool notify_clients);
86 90
87 void NotifySensorReadingChanged(); 91 void NotifySensorReadingChanged();
88 void NotifySensorError(); 92 void NotifySensorError();
89 93
(...skipping 12 matching lines...) Expand all
102 base::ObserverList<Client, true> clients_; 106 base::ObserverList<Client, true> clients_;
103 ConfigMap config_map_; 107 ConfigMap config_map_;
104 PlatformSensorProvider* provider_; 108 PlatformSensorProvider* provider_;
105 base::WeakPtrFactory<PlatformSensor> weak_factory_; 109 base::WeakPtrFactory<PlatformSensor> weak_factory_;
106 DISALLOW_COPY_AND_ASSIGN(PlatformSensor); 110 DISALLOW_COPY_AND_ASSIGN(PlatformSensor);
107 }; 111 };
108 112
109 } // namespace device 113 } // namespace device
110 114
111 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_H_ 115 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698