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

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

Issue 2646093002: Move //content/browser/device_sensor/ into device/sensors (Closed)
Patch Set: gn format & code rebase Created 3 years, 10 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 "content/browser/device_sensors/sensor_manager_android.h" 5 #include "device/sensors/sensor_manager_android.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/android/context_utils.h" 9 #include "base/android/context_utils.h"
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "jni/DeviceSensors_jni.h" 15 #include "jni/DeviceSensors_jni.h"
16 16
17 using base::android::AttachCurrentThread; 17 using base::android::AttachCurrentThread;
18 using base::android::JavaParamRef; 18 using base::android::JavaParamRef;
19 19
20 namespace { 20 namespace {
21 21
22 void UpdateDeviceOrientationHistogram( 22 void UpdateDeviceOrientationHistogram(
23 content::SensorManagerAndroid::OrientationSensorType type) { 23 device::SensorManagerAndroid::OrientationSensorType type) {
24 UMA_HISTOGRAM_ENUMERATION("InertialSensor.DeviceOrientationSensorAndroid", 24 UMA_HISTOGRAM_ENUMERATION(
25 type, content::SensorManagerAndroid::ORIENTATION_SENSOR_MAX); 25 "InertialSensor.DeviceOrientationSensorAndroid", type,
26 device::SensorManagerAndroid::ORIENTATION_SENSOR_MAX);
26 } 27 }
27 28
28 void SetOrientation(content::DeviceOrientationHardwareBuffer* buffer, 29 void SetOrientation(device::DeviceOrientationHardwareBuffer* buffer,
29 double alpha, double beta, double gamma) { 30 double alpha, double beta, double gamma) {
30 buffer->seqlock.WriteBegin(); 31 buffer->seqlock.WriteBegin();
31 buffer->data.alpha = alpha; 32 buffer->data.alpha = alpha;
32 buffer->data.hasAlpha = true; 33 buffer->data.hasAlpha = true;
33 buffer->data.beta = beta; 34 buffer->data.beta = beta;
34 buffer->data.hasBeta = true; 35 buffer->data.hasBeta = true;
35 buffer->data.gamma = gamma; 36 buffer->data.gamma = gamma;
36 buffer->data.hasGamma = true; 37 buffer->data.hasGamma = true;
37 buffer->seqlock.WriteEnd(); 38 buffer->seqlock.WriteEnd();
38 } 39 }
39 40
40 void SetOrientationBufferStatus( 41 void SetOrientationBufferStatus(device::DeviceOrientationHardwareBuffer* buffer,
41 content::DeviceOrientationHardwareBuffer* buffer, 42 bool ready,
42 bool ready, bool absolute) { 43 bool absolute) {
43 buffer->seqlock.WriteBegin(); 44 buffer->seqlock.WriteBegin();
44 buffer->data.absolute = absolute; 45 buffer->data.absolute = absolute;
45 buffer->data.allAvailableSensorsAreActive = ready; 46 buffer->data.allAvailableSensorsAreActive = ready;
46 buffer->seqlock.WriteEnd(); 47 buffer->seqlock.WriteEnd();
47 } 48 }
48 49
49 } // namespace 50 } // namespace
50 51
51 namespace content { 52 namespace device {
52 53
53 SensorManagerAndroid::SensorManagerAndroid() 54 SensorManagerAndroid::SensorManagerAndroid()
54 : number_active_device_motion_sensors_(0), 55 : number_active_device_motion_sensors_(0),
55 device_light_buffer_(nullptr), 56 device_light_buffer_(nullptr),
56 device_motion_buffer_(nullptr), 57 device_motion_buffer_(nullptr),
57 device_orientation_buffer_(nullptr), 58 device_orientation_buffer_(nullptr),
58 motion_buffer_initialized_(false), 59 motion_buffer_initialized_(false),
59 orientation_buffer_initialized_(false), 60 orientation_buffer_initialized_(false),
60 is_shutdown_(false) { 61 is_shutdown_(false) {
61 DCHECK(thread_checker_.CalledOnValidThread()); 62 DCHECK(thread_checker_.CalledOnValidThread());
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 device_orientation_absolute_buffer_ = nullptr; 445 device_orientation_absolute_buffer_ = nullptr;
445 } 446 }
446 } 447 }
447 } 448 }
448 449
449 void SensorManagerAndroid::Shutdown() { 450 void SensorManagerAndroid::Shutdown() {
450 DCHECK(thread_checker_.CalledOnValidThread()); 451 DCHECK(thread_checker_.CalledOnValidThread());
451 is_shutdown_ = true; 452 is_shutdown_ = true;
452 } 453 }
453 454
454 } // namespace content 455 } // namespace device
OLDNEW
« no previous file with comments | « device/sensors/sensor_manager_android.h ('k') | device/sensors/sensor_manager_android_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698