OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/device_sensors/data_fetcher_shared_memory.h" | 5 #include "content/browser/device_sensors/data_fetcher_shared_memory.h" |
6 | 6 |
7 #include "content/browser/device_sensors/sensor_manager_chromeos.h" | 7 #include "content/browser/device_sensors/sensor_manager_chromeos.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
11 DataFetcherSharedMemory::DataFetcherSharedMemory() { | 11 DataFetcherSharedMemory::DataFetcherSharedMemory() { |
12 } | 12 } |
13 | 13 |
14 DataFetcherSharedMemory::~DataFetcherSharedMemory() { | 14 DataFetcherSharedMemory::~DataFetcherSharedMemory() { |
15 } | 15 } |
16 | 16 |
17 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { | 17 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { |
18 DCHECK(buffer); | 18 DCHECK(buffer); |
19 if (!sensor_manager_) | 19 if (!sensor_manager_) |
20 sensor_manager_.reset(new SensorManagerChromeOS); | 20 sensor_manager_.reset(new SensorManagerChromeOS); |
21 | 21 |
22 switch (consumer_type) { | 22 switch (consumer_type) { |
23 case CONSUMER_TYPE_MOTION: | 23 case CONSUMER_TYPE_MOTION: |
24 // TODO(jonross): Implement Device Motion API. (crbug.com/427662) | 24 sensor_manager_->StartFetchingDeviceMotionData( |
25 NOTIMPLEMENTED(); | 25 static_cast<DeviceMotionHardwareBuffer*>(buffer)); |
26 return false; | 26 return true; |
timvolodine
2015/03/09 15:55:57
is there any reason to ignore the return value of
flackr
2015/03/09 16:21:19
Oh, I had suggested since the function could not r
jonross
2015/03/09 16:35:26
I'll update the functions to be void
jonross
2015/03/09 20:46:24
Done.
timvolodine
2015/03/10 13:03:08
curious: so there is always an accelerometer avail
jonross
2015/03/10 15:03:58
It is possible for there to be no sensor on Chrome
flackr
2015/03/10 17:21:11
If this *should* fail (return false) when there is
timvolodine
2015/03/10 17:31:32
Yes so in case there is no sensor the API should a
| |
27 case CONSUMER_TYPE_ORIENTATION: | 27 case CONSUMER_TYPE_ORIENTATION: |
28 return sensor_manager_->StartFetchingDeviceOrientationData( | 28 sensor_manager_->StartFetchingDeviceOrientationData( |
29 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); | 29 static_cast<DeviceOrientationHardwareBuffer*>(buffer)); |
30 return true; | |
timvolodine
2015/03/09 15:55:57
same question here
jonross
2015/03/09 20:46:24
Done.
| |
30 case CONSUMER_TYPE_LIGHT: | 31 case CONSUMER_TYPE_LIGHT: |
31 NOTIMPLEMENTED(); | 32 NOTIMPLEMENTED(); |
32 return false; | 33 return false; |
33 } | 34 } |
34 NOTREACHED(); | 35 NOTREACHED(); |
35 return false; | 36 return false; |
36 } | 37 } |
37 | 38 |
38 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { | 39 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { |
39 switch (consumer_type) { | 40 switch (consumer_type) { |
40 case CONSUMER_TYPE_MOTION: | 41 case CONSUMER_TYPE_MOTION: |
41 NOTIMPLEMENTED(); | 42 return sensor_manager_->StopFetchingDeviceMotionData(); |
42 return false; | |
43 case CONSUMER_TYPE_ORIENTATION: | 43 case CONSUMER_TYPE_ORIENTATION: |
44 return sensor_manager_->StopFetchingDeviceOrientationData(); | 44 return sensor_manager_->StopFetchingDeviceOrientationData(); |
45 case CONSUMER_TYPE_LIGHT: | 45 case CONSUMER_TYPE_LIGHT: |
46 NOTIMPLEMENTED(); | 46 NOTIMPLEMENTED(); |
47 return false; | 47 return false; |
48 } | 48 } |
49 NOTREACHED(); | 49 NOTREACHED(); |
50 return false; | 50 return false; |
51 } | 51 } |
52 | 52 |
53 } // namespace content | 53 } // namespace content |
OLD | NEW |