| 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..6d4369b1d9faf722c50392ed0c5abfbf8887235f
|
| --- /dev/null
|
| +++ b/content/browser/device_sensors/sensor_manager_chromeos.h
|
| @@ -0,0 +1,78 @@
|
| +// 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/callback.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 "content/public/browser/sensor_manager_delegate_chromeos.h"
|
| +
|
| +template <typename T>
|
| +struct DefaultSingletonTraits;
|
| +
|
| +namespace content {
|
| +
|
| +class SensorManagerChromeOSTest;
|
| +class SensorManagerDelegateChromeOS;
|
| +
|
| +// 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:
|
| + // Retrieves the singleton instance.
|
| + // TODO(jonross): Consider removing this singleton once crbug.com/431865 has
|
| + // been addressed.
|
| + static SensorManagerChromeOS* GetInstance();
|
| +
|
| + // Sets the delegate which observes accelerometer events.
|
| + void SetDelegate(SensorManagerDelegateChromeOS* delegate);
|
| +
|
| + // 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 SensorManagerChromeOSTest;
|
| + friend struct DefaultSingletonTraits<SensorManagerChromeOS>;
|
| +
|
| + SensorManagerChromeOS();
|
| +
|
| + // Callback that receives accelerometer events. These events are interpreted
|
| + // into orientation events.
|
| + void OnAccelerationIncludingGravity(double x, double y, double z);
|
| +
|
| + OrientationDataCallback callback_;
|
| +
|
| + // Shared memory to to update.
|
| + DeviceOrientationHardwareBuffer* orientation_buffer_;
|
| +
|
| + // Synchronize orientation_buffer_ across threads.
|
| + base::Lock orientation_buffer_lock_;
|
| +
|
| + // Platform delegate that receives actual accelerometer updates, and provides
|
| + // them via a callback. Owned by ash::Shell, however
|
| + // content::SensorManagerChromeOS is destructed first upon shutdown.
|
| + // TODO(jonross): Mirror device/battery/battery_status_manager_chromeos.cc for
|
| + // exposing accelerometer data to content::SensorManagerChromeOS. Will be
|
| + // possible after addressing crbug.com/431865
|
| + SensorManagerDelegateChromeOS* delegate_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SensorManagerChromeOS);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_DEVICE_SENSORS_SENSOR_MANAGER_CHROMEOS_H_
|
|
|