OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 } | 32 } // namespace |
33 | 33 |
34 namespace content { | 34 namespace content { |
35 | 35 |
36 DataFetcherSharedMemory::DataFetcherSharedMemory() | 36 DataFetcherSharedMemory::DataFetcherSharedMemory() |
37 : motion_buffer_(NULL), orientation_buffer_(NULL) { | 37 : motion_buffer_(NULL), orientation_buffer_(NULL) { |
38 } | 38 } |
39 | 39 |
40 DataFetcherSharedMemory::~DataFetcherSharedMemory() { | 40 DataFetcherSharedMemory::~DataFetcherSharedMemory() { |
41 } | 41 } |
42 | 42 |
(...skipping 11 matching lines...) Expand all Loading... |
54 UMA_HISTOGRAM_BOOLEAN("InertialSensor.OrientationDefaultAvailable", | 54 UMA_HISTOGRAM_BOOLEAN("InertialSensor.OrientationDefaultAvailable", |
55 false); | 55 false); |
56 return SetOrientationBuffer(orientation_buffer_, true); | 56 return SetOrientationBuffer(orientation_buffer_, true); |
57 default: | 57 default: |
58 NOTREACHED(); | 58 NOTREACHED(); |
59 } | 59 } |
60 return false; | 60 return false; |
61 } | 61 } |
62 | 62 |
63 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { | 63 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { |
64 | |
65 switch (consumer_type) { | 64 switch (consumer_type) { |
66 case CONSUMER_TYPE_MOTION: | 65 case CONSUMER_TYPE_MOTION: |
67 return SetMotionBuffer(motion_buffer_, false); | 66 return SetMotionBuffer(motion_buffer_, false); |
68 case CONSUMER_TYPE_ORIENTATION: | 67 case CONSUMER_TYPE_ORIENTATION: |
69 return SetOrientationBuffer(orientation_buffer_, false); | 68 return SetOrientationBuffer(orientation_buffer_, false); |
70 default: | 69 default: |
71 NOTREACHED(); | 70 NOTREACHED(); |
72 } | 71 } |
73 return false; | 72 return false; |
74 } | 73 } |
75 | 74 |
76 } // namespace content | 75 } // namespace content |
OLD | NEW |