2 Copyright (C) 2014 Samsung Electronics
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #ifndef DATA_FETCHER_IMPL_TIZEN_H_
21 #define DATA_FETCHER_IMPL_TIZEN_H_
23 #ifndef TIZEN_LEGACY_V_2_2_1
24 #include <sensor/sensor.h>
29 #include "base/memory/scoped_ptr.h"
30 #include "base/synchronization/lock.h"
31 #include "content/browser/device_sensors/inertial_sensor_consts.h"
32 #include "content/common/device_sensors/device_motion_hardware_buffer.h"
33 #include "content/common/device_sensors/device_orientation_hardware_buffer.h"
35 template<typename T> struct DefaultSingletonTraits;
39 class DataFetcherImplTizen {
41 static DataFetcherImplTizen* GetInstance();
43 // Shared memory related methods.
44 bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer);
45 void StopFetchingDeviceMotionData();
47 bool StartFetchingDeviceOrientationData(
48 DeviceOrientationHardwareBuffer* buffer);
49 void StopFetchingDeviceOrientationData();
51 virtual bool Start(ConsumerType);
52 virtual void Stop(ConsumerType);
55 DataFetcherImplTizen();
56 virtual ~DataFetcherImplTizen();
57 static void onOrientationChanged(unsigned long long timestamp,
58 sensor_data_accuracy_e, float azimuth,
59 float pitch, float roll, void* userData);
60 static void onAccelerationChanged(unsigned long long timestamp,
61 sensor_data_accuracy_e, float x, float y,
62 float z, void* userData);
65 friend struct DefaultSingletonTraits<DataFetcherImplTizen>;
67 void SetOrientationBufferReadyStatus(bool ready);
69 DeviceMotionHardwareBuffer* device_motion_buffer_;
70 DeviceOrientationHardwareBuffer* device_orientation_buffer_;
71 blink::WebDeviceMotionData last_motion_data_;
72 bool has_last_motion_data_;
73 unsigned long long last_motion_timestamp_;
74 bool is_orientation_buffer_ready_;
76 base::Lock motion_buffer_lock_;
77 base::Lock orientation_buffer_lock_;
81 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplTizen);
84 } // namespace content
86 #endif // DATA_FETCHER_IMPL_TIZEN_H_