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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/device_sensors/sensor_manager_chromeos.h
diff --git a/content/browser/device_sensors/sensor_manager_chromeos.h b/content/browser/device_sensors/sensor_manager_chromeos.h
new file mode 100644
index 0000000000000000000000000000000000000000..36e27819bcc9d89eba7fdad21caf0005d7d6fc7f
--- /dev/null
+++ b/content/browser/device_sensors/sensor_manager_chromeos.h
@@ -0,0 +1,66 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_
+#define CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/synchronization/lock.h"
+#include "content/common/content_export.h"
+#include "content/common/device_sensors/device_orientation_hardware_buffer.h"
+
+template <typename T>
+struct DefaultSingletonTraits;
+
+namespace content {
+
+class SensorManagerChromeOSTest;
+
+// Notifies Chrome OS sensors to start and stop observing accelerometer sensors.
+// Provides a callback, which interprets accelerometer data for
+// Device Orientation events.
+class CONTENT_EXPORT SensorManagerChromeOS
+ : public base::RefCountedThreadSafe<SensorManagerChromeOS> {
+ public:
+ // Retrieves the singleton instance.
+ static SensorManagerChromeOS* GetInstance();
+
+ // Begins monitoring of orientation events, the shared memory of |buffer| will
+ // be updated upon subsequent events.
+ bool StartFetchingDeviceOrientationData(
+ DeviceOrientationHardwareBuffer* buffer);
+
+ // Stops monitoring orientation events.
+ void StopFetchingDeviceOrientationData();
+
+ protected:
+ virtual ~SensorManagerChromeOS();
+
+ private:
+ friend class base::RefCountedThreadSafe<SensorManagerChromeOS>;
+ friend class SensorManagerChromeOSTest;
+ friend struct DefaultSingletonTraits<SensorManagerChromeOS>;
+
+ // Shared memory to to update.
+ DeviceOrientationHardwareBuffer* orientation_buffer_;
+
+ // Synchronize orientation_buffer_ across threads.
+ base::Lock orientation_buffer_lock_;
+
+ // Thread safe tracking of callback for Chrome OS sensors.
+ scoped_refptr<SensorManagerChromeOS> callback_ref_;
+
+ SensorManagerChromeOS();
+
+ // Callback that receives accelerometer events. These events are interpreted
+ // into orientation events.
+ void OnAccelerationIncludingGravity(double x, double y, double z);
+
+ DISALLOW_COPY_AND_ASSIGN(SensorManagerChromeOS);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_

Powered by Google App Engine
This is Rietveld 408576698