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

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

Issue 2533793002: [sensors](CrOS/Linux) Implement Sensor device manager for sensors (Closed)
Patch Set: fix build.gn Created 4 years 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_PROVIDER_BASE_H_ 5 #ifndef DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_
6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_ 6 #define DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 9
10 #include "base/threading/non_thread_safe.h" 10 #include "base/threading/non_thread_safe.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // Method that must be implemented by platform specific classes. 47 // Method that must be implemented by platform specific classes.
48 virtual void CreateSensorInternal(mojom::SensorType type, 48 virtual void CreateSensorInternal(mojom::SensorType type,
49 mojo::ScopedSharedBufferMapping mapping, 49 mojo::ScopedSharedBufferMapping mapping,
50 const CreateSensorCallback& callback) = 0; 50 const CreateSensorCallback& callback) = 0;
51 51
52 // Implementations might override this method to free resources when there 52 // Implementations might override this method to free resources when there
53 // are no sensors left. 53 // are no sensors left.
54 virtual void AllSensorsRemoved() {} 54 virtual void AllSensorsRemoved() {}
55 55
56 // Implementations might override this method to know what type of sensor
57 // has been removed.
58 virtual void SensorRemoved(mojom::SensorType type) {}
59
56 private: 60 private:
57 friend class PlatformSensor; // To call RemoveSensor(); 61 friend class PlatformSensor; // To call RemoveSensor();
58 62
59 bool CreateSharedBufferIfNeeded(); 63 bool CreateSharedBufferIfNeeded();
60 void RemoveSensor(mojom::SensorType type); 64 void RemoveSensor(mojom::SensorType type);
61 void NotifySensorCreated(mojom::SensorType type, 65 void NotifySensorCreated(mojom::SensorType type,
62 scoped_refptr<PlatformSensor> sensor); 66 scoped_refptr<PlatformSensor> sensor);
63 67
64 private: 68 private:
65 using CallbackQueue = std::vector<CreateSensorCallback>; 69 using CallbackQueue = std::vector<CreateSensorCallback>;
66 70
67 std::map<mojom::SensorType, PlatformSensor*> sensor_map_; 71 std::map<mojom::SensorType, PlatformSensor*> sensor_map_;
68 std::map<mojom::SensorType, CallbackQueue> requests_map_; 72 std::map<mojom::SensorType, CallbackQueue> requests_map_;
69 mojo::ScopedSharedBufferHandle shared_buffer_handle_; 73 mojo::ScopedSharedBufferHandle shared_buffer_handle_;
70 74
71 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderBase); 75 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderBase);
72 }; 76 };
73 77
74 } // namespace device 78 } // namespace device
75 79
76 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_ 80 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698