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

Side by Side Diff: content/browser/device_sensors/data_fetcher_shared_memory_default.cc

Issue 292693004: [DeviceLight] Browser+java part (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change frequency in sensor_consts Created 6 years, 3 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 "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 16 matching lines...) Expand all
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 } // namespace 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), light_buffer_(NULL) {
38 } 38 }
39 39
40 DataFetcherSharedMemory::~DataFetcherSharedMemory() { 40 DataFetcherSharedMemory::~DataFetcherSharedMemory() {
41 } 41 }
42 42
43 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) { 43 bool DataFetcherSharedMemory::Start(ConsumerType consumer_type, void* buffer) {
44 DCHECK(buffer); 44 DCHECK(buffer);
45 45
46 switch (consumer_type) { 46 switch (consumer_type) {
47 case CONSUMER_TYPE_MOTION: 47 case CONSUMER_TYPE_MOTION:
48 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer); 48 motion_buffer_ = static_cast<DeviceMotionHardwareBuffer*>(buffer);
49 UMA_HISTOGRAM_BOOLEAN("InertialSensor.MotionDefaultAvailable", false); 49 UMA_HISTOGRAM_BOOLEAN("InertialSensor.MotionDefaultAvailable", false);
50 return SetMotionBuffer(motion_buffer_, true); 50 return SetMotionBuffer(motion_buffer_, true);
51 case CONSUMER_TYPE_ORIENTATION: 51 case CONSUMER_TYPE_ORIENTATION:
52 orientation_buffer_ = 52 orientation_buffer_ =
53 static_cast<DeviceOrientationHardwareBuffer*>(buffer); 53 static_cast<DeviceOrientationHardwareBuffer*>(buffer);
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 case CONSUMER_TYPE_LIGHT:
58 return true;
timvolodine 2014/09/04 17:16:57 I assume this is for non-android platforms. Should
riju_ 2014/09/08 09:26:17 Ok, putting inf in the light buffer.
57 default: 59 default:
58 NOTREACHED(); 60 NOTREACHED();
59 } 61 }
60 return false; 62 return false;
61 } 63 }
62 64
63 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) { 65 bool DataFetcherSharedMemory::Stop(ConsumerType consumer_type) {
64 switch (consumer_type) { 66 switch (consumer_type) {
65 case CONSUMER_TYPE_MOTION: 67 case CONSUMER_TYPE_MOTION:
66 return SetMotionBuffer(motion_buffer_, false); 68 return SetMotionBuffer(motion_buffer_, false);
67 case CONSUMER_TYPE_ORIENTATION: 69 case CONSUMER_TYPE_ORIENTATION:
68 return SetOrientationBuffer(orientation_buffer_, false); 70 return SetOrientationBuffer(orientation_buffer_, false);
71 case CONSUMER_TYPE_LIGHT:
72 return light_buffer_;
timvolodine 2014/09/04 17:16:57 so this will return false because light_buffer_==0
riju_ 2014/09/08 09:26:17 Done.
69 default: 73 default:
70 NOTREACHED(); 74 NOTREACHED();
71 } 75 }
72 return false; 76 return false;
73 } 77 }
74 78
75 } // namespace content 79 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698