Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_ | 5 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_ |
| 6 #define CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_ | 6 #define CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "chromeos/accelerometer/accelerometer_reader.h" | 10 #include "chromeos/accelerometer/accelerometer_reader.h" |
| 11 #include "chromeos/accelerometer/accelerometer_types.h" | 11 #include "chromeos/accelerometer/accelerometer_types.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "content/common/device_sensors/device_motion_hardware_buffer.h" | |
| 13 #include "content/common/device_sensors/device_orientation_hardware_buffer.h" | 14 #include "content/common/device_sensors/device_orientation_hardware_buffer.h" |
| 15 #include "ui/gfx/geometry/vector3d_f.h" | |
| 14 | 16 |
| 15 namespace content { | 17 namespace content { |
| 16 | 18 |
| 17 // Observes Chrome OS accelerometer sensors, and provides updated device | 19 // Observes Chrome OS accelerometer sensors, and provides updated device |
| 18 // orientation information. | 20 // orientation information. |
| 19 class CONTENT_EXPORT SensorManagerChromeOS | 21 class CONTENT_EXPORT SensorManagerChromeOS |
| 20 : public chromeos::AccelerometerReader::Observer { | 22 : public chromeos::AccelerometerReader::Observer { |
| 21 public: | 23 public: |
| 22 SensorManagerChromeOS(); | 24 SensorManagerChromeOS(); |
| 23 ~SensorManagerChromeOS() override; | 25 ~SensorManagerChromeOS() override; |
| 24 | 26 |
| 27 // Begins monitoring of motion events, the shared memory of |buffer| will be | |
| 28 // updated upon subsequent events. | |
| 29 bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer); | |
| 30 | |
| 31 // Stops monitoring motion events. Returns true if there is an active | |
| 32 // |motion_buffer_| and fetching stops. Otherwise returns false. | |
| 33 bool StopFetchingDeviceMotionData(); | |
| 34 | |
| 25 // Begins monitoring of orientation events, the shared memory of |buffer| will | 35 // Begins monitoring of orientation events, the shared memory of |buffer| will |
| 26 // be updated upon subsequent events. | 36 // be updated upon subsequent events. |
| 27 bool StartFetchingDeviceOrientationData( | 37 bool StartFetchingDeviceOrientationData( |
| 28 DeviceOrientationHardwareBuffer* buffer); | 38 DeviceOrientationHardwareBuffer* buffer); |
| 29 | 39 |
| 30 // Stops monitoring orientation events. Returns true if there is an active | 40 // Stops monitoring orientation events. Returns true if there is an active |
| 31 // |orientation_buffer_| and fetching stops. Otherwise returns false. | 41 // |orientation_buffer_| and fetching stops. Otherwise returns false. |
| 32 bool StopFetchingDeviceOrientationData(); | 42 bool StopFetchingDeviceOrientationData(); |
| 33 | 43 |
| 34 // chromeos::AccelerometerReader::Observer: | 44 // chromeos::AccelerometerReader::Observer: |
| 35 void OnAccelerometerUpdated( | 45 void OnAccelerometerUpdated( |
| 36 const chromeos::AccelerometerUpdate& update) override; | 46 const chromeos::AccelerometerUpdate& update) override; |
| 37 | 47 |
| 38 protected: | 48 protected: |
| 39 // Begins/ends the observation of accelerometer events. | 49 // Begins/ends the observation of accelerometer events. |
| 40 virtual void StartObservingAccelerometer(); | 50 virtual void StartObservingAccelerometer(); |
| 41 virtual void StopObservingAccelerometer(); | 51 virtual void StopObservingAccelerometer(); |
| 42 | 52 |
| 43 private: | 53 private: |
| 54 // Process accelerometer data and update according buffers. | |
|
flackr
2015/02/18 22:34:09
Comment is a bit confusing, Perhaps "Updates |moti
jonross
2015/02/25 00:09:56
Done.
| |
| 55 void GenerateMotionEvent(double x, double y, double z); | |
| 56 void GenerateOrientationEvent(double x, double y, double z); | |
| 57 | |
| 44 // Shared memory to update. | 58 // Shared memory to update. |
| 59 DeviceMotionHardwareBuffer* motion_buffer_; | |
| 45 DeviceOrientationHardwareBuffer* orientation_buffer_; | 60 DeviceOrientationHardwareBuffer* orientation_buffer_; |
| 46 | 61 |
| 47 // Synchronize orientation_buffer_ across threads. | 62 // Synchronize orientation_buffer_ across threads. |
|
flackr
2015/02/18 22:34:09
nit: Two comments or convert into a single comment
jonross
2015/02/25 00:09:56
StartFetchingDeviceMotionData is called from the I
| |
| 63 base::Lock motion_buffer_lock_; | |
| 48 base::Lock orientation_buffer_lock_; | 64 base::Lock orientation_buffer_lock_; |
| 49 | 65 |
| 66 // The current component of accelerometer data associated to gravity. | |
| 67 gfx::Vector3dF gravity_; | |
| 68 | |
| 50 DISALLOW_COPY_AND_ASSIGN(SensorManagerChromeOS); | 69 DISALLOW_COPY_AND_ASSIGN(SensorManagerChromeOS); |
| 51 }; | 70 }; |
| 52 | 71 |
| 53 } // namespace content | 72 } // namespace content |
| 54 | 73 |
| 55 #endif // CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_ | 74 #endif // CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_ |
| OLD | NEW |