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

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

Issue 2845763002: Remove DeviceLightEvent implementation (Closed)
Patch Set: same as previous patch Created 3 years, 7 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 "device/sensors/data_fetcher_shared_memory.h" 5 #include "device/sensors/data_fetcher_shared_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 9
10 namespace { 10 namespace {
(...skipping 10 matching lines...) Expand all
21 bool SetOrientationBuffer(device::DeviceOrientationHardwareBuffer* buffer, 21 bool SetOrientationBuffer(device::DeviceOrientationHardwareBuffer* buffer,
22 bool enabled) { 22 bool enabled) {
23 if (!buffer) 23 if (!buffer)
24 return false; 24 return false;
25 buffer->seqlock.WriteBegin(); 25 buffer->seqlock.WriteBegin();
26 buffer->data.all_available_sensors_are_active = enabled; 26 buffer->data.all_available_sensors_are_active = enabled;
27 buffer->seqlock.WriteEnd(); 27 buffer->seqlock.WriteEnd();
28 return true; 28 return true;
29 } 29 }
30 30
31 bool SetLightBuffer(device::DeviceLightHardwareBuffer* buffer, double lux) {
32 if (!buffer)
33 return false;
34 buffer->seqlock.WriteBegin();
35 buffer->data.value = lux;
36 buffer->seqlock.WriteEnd();
37 return true;
38 }
39
40 } // namespace 31 } // namespace
41 32
42 namespace device { 33 namespace device {
43 34
44 DataFetcherSharedMemory::DataFetcherSharedMemory() {} 35 DataFetcherSharedMemory::DataFetcherSharedMemory() {}
45 36
46 DataFetcherSharedMemory::~DataFetcherSharedMemory() {} 37 DataFetcherSharedMemory::~DataFetcherSharedMemory() {}
47 38
48 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { 39 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
49 DCHECK(buffer); 40 DCHECK(buffer);
50 41
51 switch (consumer_type) { 42 switch (consumer_type) {
52 case CONSUMER_TYPE_MOTION: 43 case CONSUMER_TYPE_MOTION:
53 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); 44 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer);
54 UMA_HISTOGRAM_BOOLEAN("InertialSensor.MotionDefaultAvailable", false); 45 UMA_HISTOGRAM_BOOLEAN("InertialSensor.MotionDefaultAvailable", false);
55 return SetMotionBuffer(motion_buffer_, true); 46 return SetMotionBuffer(motion_buffer_, true);
56 case CONSUMER_TYPE_ORIENTATION: 47 case CONSUMER_TYPE_ORIENTATION:
57 orientation_buffer_ = 48 orientation_buffer_ =
58 static_cast<DeviceOrientationHardwareBuffer*>(buffer); 49 static_cast<DeviceOrientationHardwareBuffer*>(buffer);
59 UMA_HISTOGRAM_BOOLEAN("InertialSensor.OrientationDefaultAvailable", 50 UMA_HISTOGRAM_BOOLEAN("InertialSensor.OrientationDefaultAvailable",
60 false); 51 false);
61 return SetOrientationBuffer(orientation_buffer_, true); 52 return SetOrientationBuffer(orientation_buffer_, true);
62 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: 53 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE:
63 orientation_absolute_buffer_ = 54 orientation_absolute_buffer_ =
64 static_cast<DeviceOrientationHardwareBuffer*>(buffer); 55 static_cast<DeviceOrientationHardwareBuffer*>(buffer);
65 return SetOrientationBuffer(orientation_absolute_buffer_, true); 56 return SetOrientationBuffer(orientation_absolute_buffer_, true);
66 case CONSUMER_TYPE_LIGHT:
67 light_buffer_ = static_cast<DeviceLightHardwareBuffer*>(buffer);
68 return SetLightBuffer(light_buffer_,
69 std::numeric_limits<double>::infinity());
70 default: 57 default:
71 NOTREACHED(); 58 NOTREACHED();
72 } 59 }
73 return false; 60 return false;
74 } 61 }
75 62
76 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { 63 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) {
77 switch (consumer_type) { 64 switch (consumer_type) {
78 case CONSUMER_TYPE_MOTION: 65 case CONSUMER_TYPE_MOTION:
79 return SetMotionBuffer(motion_buffer_, false); 66 return SetMotionBuffer(motion_buffer_, false);
80 case CONSUMER_TYPE_ORIENTATION: 67 case CONSUMER_TYPE_ORIENTATION:
81 return SetOrientationBuffer(orientation_buffer_, false); 68 return SetOrientationBuffer(orientation_buffer_, false);
82 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE: 69 case CONSUMER_TYPE_ORIENTATION_ABSOLUTE:
83 return SetOrientationBuffer(orientation_absolute_buffer_, false); 70 return SetOrientationBuffer(orientation_absolute_buffer_, false);
84 case CONSUMER_TYPE_LIGHT:
85 return SetLightBuffer(light_buffer_, -1);
86 default: 71 default:
87 NOTREACHED(); 72 NOTREACHED();
88 } 73 }
89 return false; 74 return false;
90 } 75 }
91 76
92 } // namespace device 77 } // namespace device
OLDNEW
« no previous file with comments | « device/sensors/data_fetcher_shared_memory_chromeos.cc ('k') | device/sensors/data_fetcher_shared_memory_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698