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 #include "device/generic_sensor/platform_sensor_provider_mac.h" |
| 6 |
| 7 #include "base/memory/singleton.h" |
| 8 #include "device/generic_sensor/platform_sensor_accelerometer_mac.h" |
| 9 #include "device/generic_sensor/platform_sensor_ambient_light_mac.h" |
| 10 |
| 11 namespace device { |
| 12 |
| 13 // static |
| 14 PlatformSensorProviderMac* PlatformSensorProviderMac::GetInstance() { |
| 15 return base::Singleton< |
| 16 PlatformSensorProviderMac, |
| 17 base::LeakySingletonTraits<PlatformSensorProviderMac>>::get(); |
| 18 } |
| 19 |
| 20 PlatformSensorProviderMac::PlatformSensorProviderMac() = default; |
| 21 |
| 22 PlatformSensorProviderMac::~PlatformSensorProviderMac() = default; |
| 23 |
| 24 void PlatformSensorProviderMac::CreateSensorInternal( |
| 25 mojom::SensorType type, |
| 26 mojo::ScopedSharedBufferMapping mapping, |
| 27 const CreateSensorCallback& callback) { |
| 28 // Create Sensors here. |
| 29 switch (type) { |
| 30 case mojom::SensorType::AMBIENT_LIGHT: { |
| 31 scoped_refptr<PlatformSensor> sensor = |
| 32 new PlatformSensorAmbientLightMac(std::move(mapping), this); |
| 33 callback.Run(std::move(sensor)); |
| 34 break; |
| 35 } |
| 36 case mojom::SensorType::ACCELEROMETER: { |
| 37 callback.Run(base::MakeRefCounted<PlatformSensorAccelerometerMac>( |
| 38 std::move(mapping), this)); |
| 39 break; |
| 40 } |
| 41 default: |
| 42 NOTIMPLEMENTED(); |
| 43 callback.Run(nullptr); |
| 44 } |
| 45 } |
| 46 |
| 47 } // namespace device |
OLD | NEW |