Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/DeviceSensors.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/DeviceSensors.java b/content/public/android/java/src/org/chromium/content/browser/DeviceSensors.java |
| index 376b954213bc7b6760c2cbbfdeb3d4abb9ceb945..2dfbb727f5ab6b15df693f61a363e333e329c64e 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/DeviceSensors.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/DeviceSensors.java |
| @@ -92,27 +92,27 @@ class DeviceSensors implements SensorEventListener { |
| * for events, the old callback is unregistered first. |
| * |
| * @param nativePtr Value to pass to nativeGotOrientation() for each event. |
| - * @param rateInMilliseconds Requested callback rate in milliseconds. The |
| + * @param rateInMicroseconds Requested callback rate in microseconds. The |
| * actual rate may be higher. Unwanted events should be ignored. |
| * @param eventType Type of event to listen to, can be either DEVICE_ORIENTATION or |
| * DEVICE_MOTION or DEVICE_LIGHT. |
| * @return True on success. |
| */ |
| @CalledByNative |
| - public boolean start(long nativePtr, int eventType, int rateInMilliseconds) { |
| + public boolean start(long nativePtr, int eventType, int rateInMicroseconds) { |
|
timvolodine
2014/09/26 13:09:16
long, also below
|
| boolean success = false; |
| synchronized (mNativePtrLock) { |
| switch (eventType) { |
| case DEVICE_ORIENTATION: |
| - success = registerSensors(DEVICE_ORIENTATION_SENSORS, rateInMilliseconds, |
| + success = registerSensors(DEVICE_ORIENTATION_SENSORS, rateInMicroseconds, |
| true); |
| break; |
| case DEVICE_MOTION: |
| // note: device motion spec does not require all sensors to be available |
| - success = registerSensors(DEVICE_MOTION_SENSORS, rateInMilliseconds, false); |
| + success = registerSensors(DEVICE_MOTION_SENSORS, rateInMicroseconds, false); |
| break; |
| case DEVICE_LIGHT: |
| - success = registerSensors(DEVICE_LIGHT_SENSORS, rateInMilliseconds, true); |
| + success = registerSensors(DEVICE_LIGHT_SENSORS, rateInMicroseconds, true); |
| break; |
| default: |
| Log.e(TAG, "Unknown event type: " + eventType); |
| @@ -377,19 +377,19 @@ class DeviceSensors implements SensorEventListener { |
| /** |
| * @param sensorTypes List of sensors to activate. |
| - * @param rateInMilliseconds Intended delay (in milliseconds) between sensor readings. |
| + * @param rateInMicroseconds Intended delay (in microseconds) between sensor readings. |
| * @param failOnMissingSensor If true the method returns true only if all sensors could be |
| * activated. When false the method return true if at least one |
| * sensor in sensorTypes could be activated. |
| */ |
| - private boolean registerSensors(Set<Integer> sensorTypes, int rateInMilliseconds, |
| + private boolean registerSensors(Set<Integer> sensorTypes, int rateInMicroseconds, |
| boolean failOnMissingSensor) { |
| Set<Integer> sensorsToActivate = new HashSet<Integer>(sensorTypes); |
| sensorsToActivate.removeAll(mActiveSensors); |
| boolean success = false; |
| for (Integer sensorType : sensorsToActivate) { |
| - boolean result = registerForSensorType(sensorType, rateInMilliseconds); |
| + boolean result = registerForSensorType(sensorType, rateInMicroseconds); |
| if (!result && failOnMissingSensor) { |
| // restore the previous state upon failure |
| unregisterSensors(sensorsToActivate); |
| @@ -412,12 +412,11 @@ class DeviceSensors implements SensorEventListener { |
| } |
| } |
| - private boolean registerForSensorType(int type, int rateInMilliseconds) { |
| + private boolean registerForSensorType(int type, int rateInMicroseconds) { |
| SensorManagerProxy sensorManager = getSensorManagerProxy(); |
| if (sensorManager == null) { |
| return false; |
| } |
| - final int rateInMicroseconds = 1000 * rateInMilliseconds; |
| return sensorManager.registerListener(this, type, rateInMicroseconds, getHandler()); |
| } |