Chromium Code Reviews| Index: device/generic_sensor/platform_sensor_provider.h |
| diff --git a/device/generic_sensor/platform_sensor_provider.h b/device/generic_sensor/platform_sensor_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eec6ec9d98159b61116ac3484c2a03f39e13f695 |
| --- /dev/null |
| +++ b/device/generic_sensor/platform_sensor_provider.h |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#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.
|
| +#define DEVICE_SENSORS_PLATFORM_SENSOR_PROVIDER_H_ |
| + |
| +#include "base/macros.h" |
| + |
| +#include "base/threading/non_thread_safe.h" |
| +#include "device/generic_sensor/platform_sensor.h" |
| + |
| +namespace device { |
| + |
| +// Base class that defines factory methods for PlatformSensor creation. |
| +class PlatformSensorProvider : public base::NonThreadSafe { |
| + public: |
| + 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.
|
| + |
| + // Creates new instance of PlatformSensor. |
| + scoped_refptr<PlatformSensor> CreateSensor(mojom::SensorType type, |
| + uint64_t size, |
| + uint64_t offset); |
| + |
| + // Gets previously created instance of PlatformSensor by sensor type |type|. |
| + scoped_refptr<PlatformSensor> GetSensor(mojom::SensorType type); |
| + |
| + // Shared buffer getters. |
| + mojo::ScopedSharedBufferHandle CloneSharedBufferHandle(); |
| + |
| + protected: |
| + explicit PlatformSensorProvider(uint64_t shared_buffer_size); |
| + virtual ~PlatformSensorProvider(); |
| + |
| + // Method that must be implemented by platform specific classes. |
| + virtual scoped_refptr<PlatformSensor> CreateSensorInternal( |
| + mojom::SensorType type, |
| + mojo::ScopedSharedBufferMapping mapping, |
| + uint64_t buffer_size) = 0; |
| + |
| + private: |
| + friend class PlatformSensor; // To call RemoveSensor(); |
| + |
| + bool CreateSharedBufferIfNeeded(); |
| + void RemoveSensor(mojom::SensorType type); |
| + |
| + private: |
| + std::map<mojom::SensorType, PlatformSensor*> sensor_map_; |
| + mojo::ScopedSharedBufferHandle shared_buffer_handle_; |
| + uint64_t shared_buffer_size_; |
| + DISALLOW_COPY_AND_ASSIGN(PlatformSensorProvider); |
| +}; |
| + |
| +} // namespace device |
| + |
| +#endif // DEVICE_SENSORS_PLATFORM_SENSOR_PROVIDER_H_ |