OLD | NEW |
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 Loading... |
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 void NotifySensorCreated(mojom::SensorType type, |
| 57 scoped_refptr<PlatformSensor> sensor); |
| 58 |
| 59 std::vector<mojom::SensorType> GetPendingRequestTypes(); |
| 60 |
| 61 mojo::ScopedSharedBufferMapping MapSharedBufferForType( |
| 62 mojom::SensorType type); |
| 63 |
56 private: | 64 private: |
57 friend class PlatformSensor; // To call RemoveSensor(); | 65 friend class PlatformSensor; // To call RemoveSensor(); |
58 | 66 |
59 bool CreateSharedBufferIfNeeded(); | 67 bool CreateSharedBufferIfNeeded(); |
60 void RemoveSensor(mojom::SensorType type); | 68 void RemoveSensor(mojom::SensorType type); |
61 void NotifySensorCreated(mojom::SensorType type, | |
62 scoped_refptr<PlatformSensor> sensor); | |
63 | 69 |
64 private: | 70 private: |
65 using CallbackQueue = std::vector<CreateSensorCallback>; | 71 using CallbackQueue = std::vector<CreateSensorCallback>; |
66 | 72 |
67 std::map<mojom::SensorType, PlatformSensor*> sensor_map_; | 73 std::map<mojom::SensorType, PlatformSensor*> sensor_map_; |
68 std::map<mojom::SensorType, CallbackQueue> requests_map_; | 74 std::map<mojom::SensorType, CallbackQueue> requests_map_; |
69 mojo::ScopedSharedBufferHandle shared_buffer_handle_; | 75 mojo::ScopedSharedBufferHandle shared_buffer_handle_; |
70 | 76 |
71 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderBase); | 77 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProviderBase); |
72 }; | 78 }; |
73 | 79 |
74 } // namespace device | 80 } // namespace device |
75 | 81 |
76 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_ | 82 #endif // DEVICE_GENERIC_SENSOR_PLATFORM_SENSOR_PROVIDER_BASE_H_ |
OLD | NEW |