Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / browser / device_sensors / data_fetcher_shared_memory_android.cc
blobe2676a14d72ef2efe62c5eb41c3334b5ab784c89
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"
13 namespace content {
15 DataFetcherSharedMemory::DataFetcherSharedMemory() {
18 DataFetcherSharedMemory::~DataFetcherSharedMemory() {
21 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
22 DCHECK(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));
36 default:
37 NOTREACHED();
39 return false;
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();
56 return false;
59 void DataFetcherSharedMemory::Shutdown() {
60 DataFetcherSharedMemoryBase::Shutdown();
61 SensorManagerAndroid::GetInstance()->Shutdown();
64 } // namespace content