| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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/sensors/data_fetcher_shared_memory.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "device/sensors/public/cpp/device_motion_hardware_buffer.h" | |
| 9 #include "device/sensors/public/cpp/device_orientation_hardware_buffer.h" | |
| 10 #include "device/sensors/sensor_manager_android.h" | |
| 11 | |
| 12 namespace device { | |
| 13 | |
| 14 DataFetcherSharedMemory::DataFetcherSharedMemory() {} | |
| 15 | |
| 16 DataFetcherSharedMemory::~DataFetcherSharedMemory() {} | |
| 17 | |
| 18 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { | |
| 19 DCHECK(buffer); | |
| 20 | |
| 21 switch (consumer_type) { | |
| 22 case CONSUMER_TYPE_MOTION: | |
| 23 SensorManagerAndroid::GetInstance()->StartFetchingDeviceMotionData( | |
| 24 static_cast<DeviceMotionHardwareBuffer*>(buffer)); | |
| 25 return true; | |
| 26 case CONSUMER_TYPE_ORIENTATION: | |
| 27 SensorManagerAndroid::GetInstance()->StartFetchingDeviceOrientationData( | |
| 28 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); | |
| 29 return true; | |
| 30 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: | |
| 31 SensorManagerAndroid::GetInstance() | |
| 32 ->StartFetchingDeviceOrientationAbsoluteData( | |
| 33 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); | |
| 34 return true; | |
| 35 default: | |
| 36 NOTREACHED(); | |
| 37 } | |
| 38 return false; | |
| 39 } | |
| 40 | |
| 41 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { | |
| 42 switch (consumer_type) { | |
| 43 case CONSUMER_TYPE_MOTION: | |
| 44 SensorManagerAndroid::GetInstance()->StopFetchingDeviceMotionData(); | |
| 45 return true; | |
| 46 case CONSUMER_TYPE_ORIENTATION: | |
| 47 SensorManagerAndroid::GetInstance()->StopFetchingDeviceOrientationData(); | |
| 48 return true; | |
| 49 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: | |
| 50 SensorManagerAndroid::GetInstance() | |
| 51 ->StopFetchingDeviceOrientationAbsoluteData(); | |
| 52 return true; | |
| 53 default: | |
| 54 NOTREACHED(); | |
| 55 } | |
| 56 return false; | |
| 57 } | |
| 58 | |
| 59 void DataFetcherSharedMemory::Shutdown() { | |
| 60 DataFetcherSharedMemoryBase::Shutdown(); | |
| 61 SensorManagerAndroid::GetInstance()->Shutdown(); | |
| 62 } | |
| 63 | |
| 64 } // namespace device | |
| OLD | NEW |