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

Unified Diff: content/public/browser/sensor_manager.h

Issue 680383007: DeviceOrientation API on ChromeOS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Isolate Chrome OS changes 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/public/browser/sensor_manager.h
diff --git a/content/public/browser/sensor_manager.h b/content/public/browser/sensor_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..aec4f622ceca0e4a6281b5f7e0fa81a85982a96d
--- /dev/null
+++ b/content/public/browser/sensor_manager.h
@@ -0,0 +1,59 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
timvolodine 2014/11/07 03:27:39 is there any chance we can put it in content/brows
jonross 2014/11/07 19:59:37 I'm going to go with the Callback suggestion. con
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_BROWSER_SENSOR_MANAGER_H_
+#define CONTENT_PUBLIC_BROWSER_SENSOR_MANAGER_H_
+
+#include "base/macros.h"
+#include "base/synchronization/lock.h"
+#include "content/common/content_export.h"
+#include "content/common/device_sensors/device_orientation_hardware_buffer.h"
+#include "ui/gfx/geometry/vector3d_f.h"
+
+template <typename T>
+struct DefaultSingletonTraits;
+
+namespace content {
+
+// For platforms with a push API for accelerometer sensors. Received data is
+// placed in a shared memory buffer, which is read by the renderer process.
+class CONTENT_EXPORT SensorManager {
timvolodine 2014/11/07 03:27:39 this is chrome OS specific right? so probably shou
+ public:
+ // Returns the SensorManager singleton
+ static SensorManager* GetInstance();
+
+ // Push sensor notifications to shared memory.
+ void OnAccelerationIncludingGravity(double x, double y, double z);
+
+ // Set the shared memory buffer for orientation events. Accelerometer events
+ // will begin being processed.
+ void StartFetchingDeviceOrientationData(
+ DeviceOrientationHardwareBuffer* buffer);
+
+ // Stop processing accelerometer events for orientation.
+ void StopFetchingDeviceOrientationData();
+
+ private:
+ friend class SensorManagerTest;
+ friend struct DefaultSingletonTraits<SensorManager>;
+
+ // Shared memory buffers, not owned.
+ DeviceOrientationHardwareBuffer* orientation_buffer_;
+
+ // Synchronize orientation_buffer_ across threads.
+ base::Lock orientation_buffer_lock_;
+
+ SensorManager();
+ virtual ~SensorManager();
+
+ DeviceOrientationHardwareBuffer* GetOrientationBufferForTest() {
+ return orientation_buffer_;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(SensorManager);
+};
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_BROWSER_SENSOR_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698