OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 "content/browser/device_sensors/sensor_manager_chromeos.h" | |
8 | |
9 namespace content { | |
10 | |
11 DataFetcherSharedMemory::DataFetcherSharedMemory() { | |
12 } | |
13 | |
14 DataFetcherSharedMemory::~DataFetcherSharedMemory() { | |
15 } | |
16 | |
17 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { | |
18 DCHECK(buffer); | |
19 if (!sensor_manager_) | |
20 sensor_manager_.reset(new SensorManagerChromeOS); | |
21 | |
22 switch (consumer_type) { | |
23 case CONSUMER_TYPE_MOTION: | |
24 sensor_manager_->StartFetchingDeviceMotionData( | |
25 static_cast<DeviceMotionHardwareBuffer*>(buffer)); | |
26 return true; | |
27 case CONSUMER_TYPE_ORIENTATION: | |
28 sensor_manager_->StartFetchingDeviceOrientationData( | |
29 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); | |
30 return true; | |
31 case CONSUMER_TYPE_LIGHT: | |
32 NOTIMPLEMENTED(); | |
33 return false; | |
34 } | |
35 NOTREACHED(); | |
36 return false; | |
37 } | |
38 | |
39 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { | |
40 switch (consumer_type) { | |
41 case CONSUMER_TYPE_MOTION: | |
42 return sensor_manager_->StopFetchingDeviceMotionData(); | |
43 case CONSUMER_TYPE_ORIENTATION: | |
44 return sensor_manager_->StopFetchingDeviceOrientationData(); | |
45 case CONSUMER_TYPE_LIGHT: | |
46 NOTIMPLEMENTED(); | |
47 return false; | |
48 } | |
49 NOTREACHED(); | |
50 return false; | |
51 } | |
52 | |
53 } // namespace content | |
OLD | NEW |