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