Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / device_sensors / sensor_manager_chromeos.h
blob74c4acecbc7f119c5e649fdc03024ea3cfc2e40b
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_
6 #define CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_
8 #include "base/macros.h"
9 #include "base/threading/thread_checker.h"
10 #include "chromeos/accelerometer/accelerometer_reader.h"
11 #include "chromeos/accelerometer/accelerometer_types.h"
12 #include "content/common/content_export.h"
13 #include "content/common/device_sensors/device_motion_hardware_buffer.h"
14 #include "content/common/device_sensors/device_orientation_hardware_buffer.h"
16 namespace content {
18 // Observes Chrome OS accelerometer sensors, and provides updated device
19 // orientation information.
20 class CONTENT_EXPORT SensorManagerChromeOS
21 : public chromeos::AccelerometerReader::Observer {
22 public:
23 SensorManagerChromeOS();
24 ~SensorManagerChromeOS() override;
26 // Begins monitoring of motion events, the shared memory of |buffer| will be
27 // updated upon subsequent events.
28 void StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer);
30 // Stops monitoring motion events. Returns true if there is an active
31 // |motion_buffer_| and fetching stops. Otherwise returns false.
32 bool StopFetchingDeviceMotionData();
34 // Begins monitoring of orientation events, the shared memory of |buffer| will
35 // be updated upon subsequent events.
36 void StartFetchingDeviceOrientationData(
37 DeviceOrientationHardwareBuffer* buffer);
39 // Stops monitoring orientation events. Returns true if there is an active
40 // |orientation_buffer_| and fetching stops. Otherwise returns false.
41 bool StopFetchingDeviceOrientationData();
43 // chromeos::AccelerometerReader::Observer:
44 void OnAccelerometerUpdated(
45 scoped_refptr<const chromeos::AccelerometerUpdate> update) override;
47 protected:
48 // Begins/ends the observation of accelerometer events.
49 virtual void StartObservingAccelerometer();
50 virtual void StopObservingAccelerometer();
52 private:
53 // Updates |motion_buffer_| or |orientation_buffer_| accordingly.
54 void GenerateMotionEvent(double x, double y, double z);
55 void GenerateOrientationEvent(double x, double y, double z);
57 // Shared memory to update.
58 DeviceMotionHardwareBuffer* motion_buffer_;
59 DeviceOrientationHardwareBuffer* orientation_buffer_;
61 // Verify all work is done on the same thread.
62 base::ThreadChecker thread_checker_;
64 DISALLOW_COPY_AND_ASSIGN(SensorManagerChromeOS);
67 } // namespace content
69 #endif // CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_