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

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

Issue 604483003: Increase device orientation event frequency to 60 Hz. Change constants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 "content/browser/device_sensors/sensor_manager_android.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 if (!device_light_buffer_) 143 if (!device_light_buffer_)
144 return; 144 return;
145 145
146 device_light_buffer_->seqlock.WriteBegin(); 146 device_light_buffer_->seqlock.WriteBegin();
147 device_light_buffer_->data.value = value; 147 device_light_buffer_->data.value = value;
148 device_light_buffer_->seqlock.WriteEnd(); 148 device_light_buffer_->seqlock.WriteEnd();
149 } 149 }
150 150
151 bool SensorManagerAndroid::Start(EventType event_type) { 151 bool SensorManagerAndroid::Start(EventType event_type) {
152 DCHECK(!device_sensors_.is_null()); 152 DCHECK(!device_sensors_.is_null());
153 int rate_in_milliseconds = (event_type == kTypeLight) 153 int rate_in_microseconds = (event_type == kTypeLight)
timvolodine 2014/09/26 13:09:16 int64?
154 ? kLightSensorIntervalMillis 154 ? kLightSensorIntervalMicroseconds
155 : kInertialSensorIntervalMillis; 155 : kInertialSensorIntervalMicroseconds;
156 return Java_DeviceSensors_start(AttachCurrentThread(), 156 return Java_DeviceSensors_start(AttachCurrentThread(),
157 device_sensors_.obj(), 157 device_sensors_.obj(),
158 reinterpret_cast<intptr_t>(this), 158 reinterpret_cast<intptr_t>(this),
159 static_cast<jint>(event_type), 159 static_cast<jint>(event_type),
160 rate_in_milliseconds); 160 rate_in_microseconds);
timvolodine 2014/09/26 13:09:16 also if you are using int64, the java interface sh
161 } 161 }
162 162
163 void SensorManagerAndroid::Stop(EventType event_type) { 163 void SensorManagerAndroid::Stop(EventType event_type) {
164 DCHECK(!device_sensors_.is_null()); 164 DCHECK(!device_sensors_.is_null());
165 Java_DeviceSensors_stop(AttachCurrentThread(), 165 Java_DeviceSensors_stop(AttachCurrentThread(),
166 device_sensors_.obj(), 166 device_sensors_.obj(),
167 static_cast<jint>(event_type)); 167 static_cast<jint>(event_type));
168 } 168 }
169 169
170 int SensorManagerAndroid::GetNumberActiveDeviceMotionSensors() { 170 int SensorManagerAndroid::GetNumberActiveDeviceMotionSensors() {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 243 }
244 } 244 }
245 } 245 }
246 246
247 void SensorManagerAndroid::CheckMotionBufferReadyToRead() { 247 void SensorManagerAndroid::CheckMotionBufferReadyToRead() {
248 if (received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] + 248 if (received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] +
249 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] + 249 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] +
250 received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] == 250 received_motion_data_[RECEIVED_MOTION_DATA_ROTATION_RATE] ==
251 number_active_device_motion_sensors_) { 251 number_active_device_motion_sensors_) {
252 device_motion_buffer_->seqlock.WriteBegin(); 252 device_motion_buffer_->seqlock.WriteBegin();
253 device_motion_buffer_->data.interval = kInertialSensorIntervalMillis; 253 device_motion_buffer_->data.interval =
254 kInertialSensorIntervalMicroseconds / 1000.;
254 device_motion_buffer_->seqlock.WriteEnd(); 255 device_motion_buffer_->seqlock.WriteEnd();
255 SetMotionBufferReadyStatus(true); 256 SetMotionBufferReadyStatus(true);
256 257
257 UMA_HISTOGRAM_BOOLEAN("InertialSensor.AccelerometerAndroidAvailable", 258 UMA_HISTOGRAM_BOOLEAN("InertialSensor.AccelerometerAndroidAvailable",
258 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] > 0); 259 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION] > 0);
259 UMA_HISTOGRAM_BOOLEAN( 260 UMA_HISTOGRAM_BOOLEAN(
260 "InertialSensor.AccelerometerIncGravityAndroidAvailable", 261 "InertialSensor.AccelerometerIncGravityAndroidAvailable",
261 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY] 262 received_motion_data_[RECEIVED_MOTION_DATA_ACCELERATION_INCL_GRAVITY]
262 > 0); 263 > 0);
263 UMA_HISTOGRAM_BOOLEAN("InertialSensor.GyroscopeAndroidAvailable", 264 UMA_HISTOGRAM_BOOLEAN("InertialSensor.GyroscopeAndroidAvailable",
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 { 317 {
317 base::AutoLock autolock(orientation_buffer_lock_); 318 base::AutoLock autolock(orientation_buffer_lock_);
318 if (device_orientation_buffer_) { 319 if (device_orientation_buffer_) {
319 SetOrientationBufferReadyStatus(false); 320 SetOrientationBufferReadyStatus(false);
320 device_orientation_buffer_ = NULL; 321 device_orientation_buffer_ = NULL;
321 } 322 }
322 } 323 }
323 } 324 }
324 325
325 } // namespace content 326 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698