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 "content/browser/device_sensors/data_fetcher_shared_memory.h" | 5 #include "content/browser/device_sensors/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 25 matching lines...) Expand all Loading... |
36 buffer->seqlock.WriteBegin(); | 36 buffer->seqlock.WriteBegin(); |
37 buffer->data.value = lux; | 37 buffer->data.value = lux; |
38 buffer->seqlock.WriteEnd(); | 38 buffer->seqlock.WriteEnd(); |
39 return true; | 39 return true; |
40 } | 40 } |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 namespace content { | 44 namespace content { |
45 | 45 |
46 DataFetcherSharedMemory::DataFetcherSharedMemory() | 46 DataFetcherSharedMemory::DataFetcherSharedMemory() {} |
47 : motion_buffer_(nullptr), | |
48 orientation_buffer_(nullptr), | |
49 orientation_absolute_buffer_(nullptr), | |
50 light_buffer_(nullptr) { | |
51 } | |
52 | 47 |
53 DataFetcherSharedMemory::~DataFetcherSharedMemory() { | 48 DataFetcherSharedMemory::~DataFetcherSharedMemory() { |
54 } | 49 } |
55 | 50 |
56 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { | 51 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { |
57 DCHECK(buffer); | 52 DCHECK(buffer); |
58 | 53 |
59 switch (consumer_type) { | 54 switch (consumer_type) { |
60 case CONSUMER_TYPE_MOTION: | 55 case CONSUMER_TYPE_MOTION: |
61 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); | 56 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); |
(...skipping 29 matching lines...) Expand all Loading... |
91 return SetOrientationBuffer(orientation_absolute_buffer_, false); | 86 return SetOrientationBuffer(orientation_absolute_buffer_, false); |
92 case CONSUMER_TYPE_LIGHT: | 87 case CONSUMER_TYPE_LIGHT: |
93 return SetLightBuffer(light_buffer_, -1); | 88 return SetLightBuffer(light_buffer_, -1); |
94 default: | 89 default: |
95 NOTREACHED(); | 90 NOTREACHED(); |
96 } | 91 } |
97 return false; | 92 return false; |
98 } | 93 } |
99 | 94 |
100 } // namespace content | 95 } // namespace content |
OLD | NEW |