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

Side by Side Diff: content/browser/device_sensors/sensor_manager_chromeos.h

Issue 934843002: Implement DeviceMotionEvent API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 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"
10 #include "chromeos/accelerometer/accelerometer_reader.h" 9 #include "chromeos/accelerometer/accelerometer_reader.h"
11 #include "chromeos/accelerometer/accelerometer_types.h" 10 #include "chromeos/accelerometer/accelerometer_types.h"
12 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "content/common/device_sensors/device_motion_hardware_buffer.h"
13 #include "content/common/device_sensors/device_orientation_hardware_buffer.h" 13 #include "content/common/device_sensors/device_orientation_hardware_buffer.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 // Observes Chrome OS accelerometer sensors, and provides updated device 17 // Observes Chrome OS accelerometer sensors, and provides updated device
18 // orientation information. 18 // orientation information.
19 class CONTENT_EXPORT SensorManagerChromeOS 19 class CONTENT_EXPORT SensorManagerChromeOS
20 : public chromeos::AccelerometerReader::Observer { 20 : public chromeos::AccelerometerReader::Observer {
21 public: 21 public:
22 SensorManagerChromeOS(); 22 SensorManagerChromeOS();
23 ~SensorManagerChromeOS() override; 23 ~SensorManagerChromeOS() override;
24 24
25 // Begins monitoring of motion events, the shared memory of |buffer| will be
26 // updated upon subsequent events.
27 bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer);
28
29 // Stops monitoring motion events. Returns true if there is an active
30 // |motion_buffer_| and fetching stops. Otherwise returns false.
31 bool StopFetchingDeviceMotionData();
32
25 // Begins monitoring of orientation events, the shared memory of |buffer| will 33 // Begins monitoring of orientation events, the shared memory of |buffer| will
26 // be updated upon subsequent events. 34 // be updated upon subsequent events.
27 bool StartFetchingDeviceOrientationData( 35 bool StartFetchingDeviceOrientationData(
28 DeviceOrientationHardwareBuffer* buffer); 36 DeviceOrientationHardwareBuffer* buffer);
29 37
30 // Stops monitoring orientation events. Returns true if there is an active 38 // Stops monitoring orientation events. Returns true if there is an active
31 // |orientation_buffer_| and fetching stops. Otherwise returns false. 39 // |orientation_buffer_| and fetching stops. Otherwise returns false.
32 bool StopFetchingDeviceOrientationData(); 40 bool StopFetchingDeviceOrientationData();
33 41
34 // chromeos::AccelerometerReader::Observer: 42 // chromeos::AccelerometerReader::Observer:
35 void OnAccelerometerUpdated( 43 void OnAccelerometerUpdated(
36 const chromeos::AccelerometerUpdate& update) override; 44 scoped_refptr<const chromeos::AccelerometerUpdate> update) override;
37 45
38 protected: 46 protected:
39 // Begins/ends the observation of accelerometer events. 47 // Begins/ends the observation of accelerometer events.
40 virtual void StartObservingAccelerometer(); 48 virtual void StartObservingAccelerometer();
41 virtual void StopObservingAccelerometer(); 49 virtual void StopObservingAccelerometer();
42 50
43 private: 51 private:
52 // Updates |motion_buffer_| or |orientation_buffer_| accordingly.
53 void GenerateMotionEvent(double x, double y, double z);
54 void GenerateOrientationEvent(double x, double y, double z);
55
44 // Shared memory to update. 56 // Shared memory to update.
57 DeviceMotionHardwareBuffer* motion_buffer_;
45 DeviceOrientationHardwareBuffer* orientation_buffer_; 58 DeviceOrientationHardwareBuffer* orientation_buffer_;
46 59
47 // Synchronize orientation_buffer_ across threads.
48 base::Lock orientation_buffer_lock_;
49
50 DISALLOW_COPY_AND_ASSIGN(SensorManagerChromeOS); 60 DISALLOW_COPY_AND_ASSIGN(SensorManagerChromeOS);
51 }; 61 };
52 62
53 } // namespace content 63 } // namespace content
54 64
55 #endif // CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_ 65 #endif // CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698