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

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

Issue 680383007: DeviceOrientation API on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_
6 #define CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_
7
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/synchronization/lock.h"
11 #include "content/common/content_export.h"
12 #include "content/common/device_sensors/device_orientation_hardware_buffer.h"
13 #include "content/public/browser/sensor_manager_delegate_chromeos.h"
14
15 template <typename T>
16 struct DefaultSingletonTraits;
17
18 namespace content {
19
20 class SensorManagerChromeOSTest;
21 class SensorManagerDelegateChromeOS;
22
23 // Notifies Chrome OS sensors to start and stop observing accelerometer sensors.
24 // Provides a callback, which interprets accelerometer data for
25 // Device Orientation events.
26 class CONTENT_EXPORT SensorManagerChromeOS {
27 public:
28 // Retrieves the singleton instance.
29 // TODO(jonross): Consider removing this singleton once crbug.com/431865 has
30 // been addressed.
31 static SensorManagerChromeOS* GetInstance();
32
33 // Sets the delegate which observes accelerometer events.
34 void SetDelegate(SensorManagerDelegateChromeOS* delegate);
35
36 // Begins monitoring of orientation events, the shared memory of |buffer| will
37 // be updated upon subsequent events.
38 bool StartFetchingDeviceOrientationData(
39 DeviceOrientationHardwareBuffer* buffer);
40
41 // Stops monitoring orientation events.
42 void StopFetchingDeviceOrientationData();
43
44 protected:
45 virtual ~SensorManagerChromeOS();
46
47 private:
48 friend class SensorManagerChromeOSTest;
49 friend struct DefaultSingletonTraits<SensorManagerChromeOS>;
50
51 SensorManagerChromeOS();
52
53 // Callback that receives accelerometer events. These events are interpreted
54 // into orientation events.
55 void OnAccelerationIncludingGravity(double x, double y, double z);
56
57 OrientationDataCallback callback_;
58
59 // Shared memory to to update.
60 DeviceOrientationHardwareBuffer* orientation_buffer_;
61
62 // Synchronize orientation_buffer_ across threads.
63 base::Lock orientation_buffer_lock_;
64
65 // Platform delegate that receives actual accelerometer updates, and provides
66 // them via a callback. Owned by ash::Shell, however
67 // content::SensorManagerChromeOS is destructed first upon shutdown.
68 // TODO(jonross): Mirror device/battery/battery_status_manager_chromeos.cc for
69 // exposing accelerometer data to content::SensorManagerChromeOS. Will be
70 // possible after addressing crbug.com/431865
71 SensorManagerDelegateChromeOS* delegate_;
72
73 DISALLOW_COPY_AND_ASSIGN(SensorManagerChromeOS);
74 };
75
76 } // namespace content
77
78 #endif // CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698