1 // Copyright (c) 2013 Intel Corporation. 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.
5 #ifndef XWALK_TIZEN_MOBILE_SENSOR_SENSOR_PROVIDER_H_
6 #define XWALK_TIZEN_MOBILE_SENSOR_SENSOR_PROVIDER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/display.h"
15 class SensorProvider {
19 virtual ~Observer() {}
21 virtual void OnRotationChanged(gfx::Display::Rotation r) {}
22 virtual void OnOrientationChanged(float alpha, float beta, float gamma) {}
23 virtual void OnAccelerationChanged(float raw_x, float raw_y, float raw_z,
24 float x, float y, float z) {}
25 virtual void OnRotationRateChanged(float alpha, float beta, float gamma) {}
28 static SensorProvider* GetInstance();
30 virtual ~SensorProvider();
32 virtual void AddObserver(Observer* observer);
33 virtual void RemoveObserver(Observer* observer);
35 virtual gfx::Display::Rotation GetCurrentRotation() const {
36 return last_rotation_;
42 virtual bool Initialize() = 0;
43 virtual void Finish() {}
45 virtual void OnRotationChanged(gfx::Display::Rotation rotation);
46 virtual void OnOrientationChanged(float alpha, float beta, float gamma);
47 virtual void OnAccelerationChanged(float raw_x, float raw_y, float raw_z,
48 float x, float y, float z);
49 virtual void OnRotationRateChanged(float alpha, float beta, float gamma);
51 std::set<Observer*> observers_;
52 gfx::Display::Rotation last_rotation_;
55 static scoped_ptr<SensorProvider> instance_;
57 DISALLOW_COPY_AND_ASSIGN(SensorProvider);
62 #endif // XWALK_TIZEN_MOBILE_SENSOR_SENSOR_PROVIDER_H_