| 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 "content/browser/device_sensors/data_fetcher_shared_memory.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "content/browser/device_sensors/sensor_manager_android.h" | |
| 9 #include "content/common/device_sensors/device_light_hardware_buffer.h" | |
| 10 #include "content/common/device_sensors/device_motion_hardware_buffer.h" | |
| 11 #include "content/common/device_sensors/device_orientation_hardware_buffer.h" | |
| 12 | |
| 13 namespace content { | |
| 14 | |
| 15 DataFetcherSharedMemory::DataFetcherSharedMemory() { | |
| 16 } | |
| 17 | |
| 18 DataFetcherSharedMemory::~DataFetcherSharedMemory() { | |
| 19 } | |
| 20 | |
| 21 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { | |
| 22 DCHECK(buffer); | |
| 23 | |
| 24 switch (consumer_type) { | |
| 25 case CONSUMER_TYPE_MOTION: | |
| 26 return SensorManagerAndroid::GetInstance()-> | |
| 27 StartFetchingDeviceMotionData( | |
| 28 static_cast<DeviceMotionHardwareBuffer*>(buffer)); | |
| 29 case CONSUMER_TYPE_ORIENTATION: | |
| 30 return SensorManagerAndroid::GetInstance()-> | |
| 31 StartFetchingDeviceOrientationData( | |
| 32 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); | |
| 33 case CONSUMER_TYPE_LIGHT: | |
| 34 return SensorManagerAndroid::GetInstance()->StartFetchingDeviceLightData( | |
| 35 static_cast<DeviceLightHardwareBuffer*>(buffer)); | |
| 36 default: | |
| 37 NOTREACHED(); | |
| 38 } | |
| 39 return false; | |
| 40 } | |
| 41 | |
| 42 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { | |
| 43 switch (consumer_type) { | |
| 44 case CONSUMER_TYPE_MOTION: | |
| 45 SensorManagerAndroid::GetInstance()->StopFetchingDeviceMotionData(); | |
| 46 return true; | |
| 47 case CONSUMER_TYPE_ORIENTATION: | |
| 48 SensorManagerAndroid::GetInstance()->StopFetchingDeviceOrientationData(); | |
| 49 return true; | |
| 50 case CONSUMER_TYPE_LIGHT: | |
| 51 SensorManagerAndroid::GetInstance()->StopFetchingDeviceLightData(); | |
| 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 content | |
| OLD | NEW |