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.
5 #include "content/browser/device_sensors/data_fetcher_shared_memory.h"
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"
15 DataFetcherSharedMemory::DataFetcherSharedMemory() {
18 DataFetcherSharedMemory::~DataFetcherSharedMemory() {
21 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type
, void* buffer
) {
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
));
42 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type
) {
43 switch (consumer_type
) {
44 case CONSUMER_TYPE_MOTION
:
45 SensorManagerAndroid::GetInstance()->StopFetchingDeviceMotionData();
47 case CONSUMER_TYPE_ORIENTATION
:
48 SensorManagerAndroid::GetInstance()->StopFetchingDeviceOrientationData();
50 case CONSUMER_TYPE_LIGHT
:
51 SensorManagerAndroid::GetInstance()->StopFetchingDeviceLightData();
59 void DataFetcherSharedMemory::Shutdown() {
60 DataFetcherSharedMemoryBase::Shutdown();
61 SensorManagerAndroid::GetInstance()->Shutdown();
64 } // namespace content