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 #ifndef DEVICE_SENSORS_PLATFORM_SENSOR_PROVIDER_H_ | |
|
timvolodine
2016/08/18 22:52:14
-> DEVICE_GENERIC_SENSOR_PLATFORM..
Mikhail
2016/08/19 09:29:55
Done.
| |
| 6 #define DEVICE_SENSORS_PLATFORM_SENSOR_PROVIDER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 | |
| 10 #include "base/threading/non_thread_safe.h" | |
| 11 #include "device/generic_sensor/platform_sensor.h" | |
| 12 | |
| 13 namespace device { | |
| 14 | |
| 15 // Base class that defines factory methods for PlatformSensor creation. | |
| 16 class PlatformSensorProvider : public base::NonThreadSafe { | |
| 17 public: | |
| 18 static PlatformSensorProvider* Create(uint64_t shared_buffer_size); | |
|
timvolodine
2016/08/18 22:52:14
is this a singleton? then seems better to have a G
Mikhail
2016/08/19 09:29:55
Done.
| |
| 19 | |
| 20 // Creates new instance of PlatformSensor. | |
| 21 scoped_refptr<PlatformSensor> CreateSensor(mojom::SensorType type, | |
| 22 uint64_t size, | |
| 23 uint64_t offset); | |
| 24 | |
| 25 // Gets previously created instance of PlatformSensor by sensor type |type|. | |
| 26 scoped_refptr<PlatformSensor> GetSensor(mojom::SensorType type); | |
| 27 | |
| 28 // Shared buffer getters. | |
| 29 mojo::ScopedSharedBufferHandle CloneSharedBufferHandle(); | |
| 30 | |
| 31 protected: | |
| 32 explicit PlatformSensorProvider(uint64_t shared_buffer_size); | |
| 33 virtual ~PlatformSensorProvider(); | |
| 34 | |
| 35 // Method that must be implemented by platform specific classes. | |
| 36 virtual scoped_refptr<PlatformSensor> CreateSensorInternal( | |
| 37 mojom::SensorType type, | |
| 38 mojo::ScopedSharedBufferMapping mapping, | |
| 39 uint64_t buffer_size) = 0; | |
| 40 | |
| 41 private: | |
| 42 friend class PlatformSensor; // To call RemoveSensor(); | |
| 43 | |
| 44 bool CreateSharedBufferIfNeeded(); | |
| 45 void RemoveSensor(mojom::SensorType type); | |
| 46 | |
| 47 private: | |
| 48 std::map<mojom::SensorType, PlatformSensor*> sensor_map_; | |
| 49 mojo::ScopedSharedBufferHandle shared_buffer_handle_; | |
| 50 uint64_t shared_buffer_size_; | |
| 51 DISALLOW_COPY_AND_ASSIGN(PlatformSensorProvider); | |
| 52 }; | |
| 53 | |
| 54 } // namespace device | |
| 55 | |
| 56 #endif // DEVICE_SENSORS_PLATFORM_SENSOR_PROVIDER_H_ | |
| OLD | NEW |