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

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: Remove implementation details from content/public/browser Created 6 years, 1 month 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/macros.h"
9 #include "base/memory/ref_counted.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
14 template <typename T>
15 struct DefaultSingletonTraits;
16
17 namespace content {
18
19 class SensorManagerChromeOSTest;
20
21 // Notifies Chrome OS sensors to start and stop observing accelerometer sensors.
22 // Provides a callback, which interprets accelerometer data for
23 // Device Orientation events.
24 class CONTENT_EXPORT SensorManagerChromeOS
25 : public base::RefCountedThreadSafe<SensorManagerChromeOS> {
26 public:
27 // Retrieves the singleton instance.
28 static SensorManagerChromeOS* GetInstance();
29
30 // Begins monitoring of orientation events, the shared memory of |buffer| will
31 // be updated upon subsequent events.
32 bool StartFetchingDeviceOrientationData(
33 DeviceOrientationHardwareBuffer* buffer);
34
35 // Stops monitoring orientation events.
36 void StopFetchingDeviceOrientationData();
37
38 protected:
39 virtual ~SensorManagerChromeOS();
40
41 private:
42 friend class base::RefCountedThreadSafe<SensorManagerChromeOS>;
43 friend class SensorManagerChromeOSTest;
44 friend struct DefaultSingletonTraits<SensorManagerChromeOS>;
45
46 // Shared memory to to update.
47 DeviceOrientationHardwareBuffer* orientation_buffer_;
48
49 // Synchronize orientation_buffer_ across threads.
50 base::Lock orientation_buffer_lock_;
51
52 // Thread safe tracking of callback for Chrome OS sensors.
53 scoped_refptr<SensorManagerChromeOS> callback_ref_;
54
55 SensorManagerChromeOS();
56
57 // Callback that receives accelerometer events. These events are interpreted
58 // into orientation events.
59 void OnAccelerationIncludingGravity(double x, double y, double z);
60
61 DISALLOW_COPY_AND_ASSIGN(SensorManagerChromeOS);
62 };
63
64 } // namespace content
65
66 #endif // CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698