Chromium Code Reviews| 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_SENSOR_PROVIDER_IMPL_H_ | 5 #ifndef DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ |
| 6 #define DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ | 6 #define DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom.h" | 9 #include "device/generic_sensor/public/interfaces/sensor_provider.mojom.h" |
| 10 | 10 |
| 11 namespace device { | 11 namespace device { |
| 12 | 12 |
| 13 class PlatformSensorProvider; | 13 class PlatformSensorProvider; |
| 14 class PlatformSensor; | |
| 14 | 15 |
| 15 // Implementation of SensorProvider mojo interface. | 16 // Implementation of SensorProvider mojo interface. |
| 16 // Uses PlatformSensorProvider singleton to create platform specific instances | 17 // Uses PlatformSensorProvider singleton to create platform specific instances |
| 17 // of PlatformSensor which are used by SensorImpl. | 18 // of PlatformSensor which are used by SensorImpl. |
| 18 class SensorProviderImpl final : public mojom::SensorProvider { | 19 class SensorProviderImpl final : public mojom::SensorProvider { |
| 19 public: | 20 public: |
| 20 static void Create(mojom::SensorProviderRequest request); | 21 static void Create(mojom::SensorProviderRequest request); |
| 21 | 22 |
| 22 ~SensorProviderImpl() override; | 23 ~SensorProviderImpl() override; |
| 23 | 24 |
| 24 private: | 25 private: |
| 25 explicit SensorProviderImpl(PlatformSensorProvider* provider); | 26 explicit SensorProviderImpl(PlatformSensorProvider* provider); |
| 26 | 27 |
| 27 // SensorProvider implementation. | 28 // SensorProvider implementation. |
| 28 void GetSensor(mojom::SensorType type, | 29 void GetSensor(mojom::SensorType type, |
| 29 mojom::SensorRequest sensor_request, | 30 mojom::SensorRequest sensor_request, |
| 30 const GetSensorCallback& callback) override; | 31 const GetSensorCallback& callback) override; |
| 31 | 32 |
| 33 // Helper callback method to create sensors. | |
| 34 void CreateSensor(mojom::SensorType type, | |
| 35 mojo::ScopedSharedBufferHandle cloned_handle, | |
| 36 mojom::SensorRequest sensor_request, | |
| 37 const GetSensorCallback& callback, | |
| 38 scoped_refptr<PlatformSensor> sensor); | |
| 39 | |
| 40 using CreateSensorCallback = | |
|
Mikhail
2016/09/26 09:52:23
we don't need it in this header.
maksims (do not use this acc)
2016/09/27 10:17:25
Done.
| |
| 41 base::Callback<void(scoped_refptr<PlatformSensor>)>; | |
| 42 | |
| 32 PlatformSensorProvider* provider_; | 43 PlatformSensorProvider* provider_; |
| 33 | 44 |
| 45 base::WeakPtrFactory<SensorProviderImpl> weak_ptr_factory_; | |
| 46 | |
| 34 DISALLOW_COPY_AND_ASSIGN(SensorProviderImpl); | 47 DISALLOW_COPY_AND_ASSIGN(SensorProviderImpl); |
| 35 }; | 48 }; |
| 36 | 49 |
| 37 } // namespace device | 50 } // namespace device |
| 38 | 51 |
| 39 #endif // DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ | 52 #endif // DEVICE_GENERIC_SENSOR_SENSOR_PROVIDER_IMPL_H_ |
| OLD | NEW |