OLD | NEW |
---|---|
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 "data_fetcher_shared_memory.h" | 5 #include "data_fetcher_shared_memory.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 11 matching lines...) Expand all Loading... | |
22 static bool SetOrientationBuffer( | 22 static bool SetOrientationBuffer( |
23 content::DeviceOrientationHardwareBuffer* buffer, bool enabled) { | 23 content::DeviceOrientationHardwareBuffer* buffer, bool enabled) { |
24 if (!buffer) | 24 if (!buffer) |
25 return false; | 25 return false; |
26 buffer->seqlock.WriteBegin(); | 26 buffer->seqlock.WriteBegin(); |
27 buffer->data.allAvailableSensorsAreActive = enabled; | 27 buffer->data.allAvailableSensorsAreActive = enabled; |
28 buffer->seqlock.WriteEnd(); | 28 buffer->seqlock.WriteEnd(); |
29 return true; | 29 return true; |
30 } | 30 } |
31 | 31 |
32 static bool SetLightBuffer(content::DeviceLightHardwareBuffer* buffer) { | |
33 return buffer; | |
34 } | |
35 | |
32 } // namespace | 36 } // namespace |
33 | 37 |
34 namespace content { | 38 namespace content { |
35 | 39 |
36 DataFetcherSharedMemory::DataFetcherSharedMemory() | 40 DataFetcherSharedMemory::DataFetcherSharedMemory() |
37 : motion_buffer_(NULL), orientation_buffer_(NULL) { | 41 : motion_buffer_(NULL), orientation_buffer_(NULL), light_buffer_(NULL) { |
38 } | 42 } |
39 | 43 |
40 DataFetcherSharedMemory::~DataFetcherSharedMemory() { | 44 DataFetcherSharedMemory::~DataFetcherSharedMemory() { |
41 } | 45 } |
42 | 46 |
43 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { | 47 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { |
44 DCHECK(buffer); | 48 DCHECK(buffer); |
45 | 49 |
46 switch (consumer_type) { | 50 switch (consumer_type) { |
47 case CONSUMER_TYPE_MOTION: | 51 case CONSUMER_TYPE_MOTION: |
48 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); | 52 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); |
49 UMA_HISTOGRAM_BOOLEAN("InertialSensor.MotionDefaultAvailable", false); | 53 UMA_HISTOGRAM_BOOLEAN("InertialSensor.MotionDefaultAvailable", false); |
50 return SetMotionBuffer(motion_buffer_, true); | 54 return SetMotionBuffer(motion_buffer_, true); |
51 case CONSUMER_TYPE_ORIENTATION: | 55 case CONSUMER_TYPE_ORIENTATION: |
52 orientation_buffer_ = | 56 orientation_buffer_ = |
53 static_cast<DeviceOrientationHardwareBuffer*>(buffer); | 57 static_cast<DeviceOrientationHardwareBuffer*>(buffer); |
54 UMA_HISTOGRAM_BOOLEAN("InertialSensor.OrientationDefaultAvailable", | 58 UMA_HISTOGRAM_BOOLEAN("InertialSensor.OrientationDefaultAvailable", |
55 false); | 59 false); |
56 return SetOrientationBuffer(orientation_buffer_, true); | 60 return SetOrientationBuffer(orientation_buffer_, true); |
61 case CONSUMER_TYPE_LIGHT: | |
62 light_buffer_ = static_cast<DeviceLightHardwareBuffer*>(buffer); | |
63 return SetLightBuffer(light_buffer_); | |
timvolodine
2014/07/16 15:39:38
the function doesn't appear to do much, you could
riju_
2014/07/18 15:59:17
Done.
| |
57 default: | 64 default: |
58 NOTREACHED(); | 65 NOTREACHED(); |
59 } | 66 } |
60 return false; | 67 return false; |
61 } | 68 } |
62 | 69 |
63 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { | 70 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { |
64 switch (consumer_type) { | 71 switch (consumer_type) { |
65 case CONSUMER_TYPE_MOTION: | 72 case CONSUMER_TYPE_MOTION: |
66 return SetMotionBuffer(motion_buffer_, false); | 73 return SetMotionBuffer(motion_buffer_, false); |
67 case CONSUMER_TYPE_ORIENTATION: | 74 case CONSUMER_TYPE_ORIENTATION: |
68 return SetOrientationBuffer(orientation_buffer_, false); | 75 return SetOrientationBuffer(orientation_buffer_, false); |
76 case CONSUMER_TYPE_LIGHT: | |
77 return SetLightBuffer(light_buffer_); | |
69 default: | 78 default: |
70 NOTREACHED(); | 79 NOTREACHED(); |
71 } | 80 } |
72 return false; | 81 return false; |
73 } | 82 } |
74 | 83 |
75 } // namespace content | 84 } // namespace content |
OLD | NEW |