Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: device/sensors/data_fetcher_shared_memory_chromeos.cc

Issue 2819273006: Move //device/sensor impl to be part of the internal implemenation of the Device Service. (Closed)
Patch Set: Move //device/sensor impl to be part of the internal implemenation of the Device Service Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "device/sensors/data_fetcher_shared_memory.h"
6
7 #include "device/sensors/sensor_manager_chromeos.h"
8
9 namespace device {
10
11 DataFetcherSharedMemory::DataFetcherSharedMemory() {}
12
13 DataFetcherSharedMemory::~DataFetcherSharedMemory() {}
14
15 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
16 DCHECK(buffer);
17 if (!sensor_manager_)
18 sensor_manager_.reset(new SensorManagerChromeOS);
19
20 switch (consumer_type) {
21 case CONSUMER_TYPE_MOTION:
22 sensor_manager_->StartFetchingDeviceMotionData(
23 static_cast<DeviceMotionHardwareBuffer*>(buffer));
24 return true;
25 case CONSUMER_TYPE_ORIENTATION:
26 sensor_manager_->StartFetchingDeviceOrientationData(
27 static_cast<DeviceOrientationHardwareBuffer*>(buffer));
28 return true;
29 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: {
30 orientation_absolute_buffer_ =
31 static_cast<DeviceOrientationHardwareBuffer*>(buffer);
32 // Absolute device orientation not available on Chrome OS, let the
33 // implementation fire an all-null event to signal this to blink.
34 orientation_absolute_buffer_->seqlock.WriteBegin();
35 orientation_absolute_buffer_->data.absolute = true;
36 orientation_absolute_buffer_->data.all_available_sensors_are_active =
37 true;
38 orientation_absolute_buffer_->seqlock.WriteEnd();
39 return false;
40 }
41 case CONSUMER_TYPE_LIGHT:
42 NOTIMPLEMENTED();
43 return false;
44 }
45 NOTREACHED();
46 return false;
47 }
48
49 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) {
50 switch (consumer_type) {
51 case CONSUMER_TYPE_MOTION:
52 return sensor_manager_->StopFetchingDeviceMotionData();
53 case CONSUMER_TYPE_ORIENTATION:
54 return sensor_manager_->StopFetchingDeviceOrientationData();
55 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE:
56 if (orientation_absolute_buffer_) {
57 orientation_absolute_buffer_->seqlock.WriteBegin();
58 orientation_absolute_buffer_->data.all_available_sensors_are_active =
59 false;
60 orientation_absolute_buffer_->seqlock.WriteEnd();
61 orientation_absolute_buffer_ = nullptr;
62 }
63 return true;
64 case CONSUMER_TYPE_LIGHT:
65 NOTIMPLEMENTED();
66 return false;
67 }
68 NOTREACHED();
69 return false;
70 }
71
72 } // namespace device
OLDNEW
« no previous file with comments | « device/sensors/data_fetcher_shared_memory_base_unittest.cc ('k') | device/sensors/data_fetcher_shared_memory_default.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698