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_
25 #include "base/memory/scoped_ptr.h"
26 #include "base/synchronization/lock.h"
27 #include "content/browser/device_sensors/inertial_sensor_consts.h"
28 #include "content/common/device_sensors/device_motion_hardware_buffer.h"
29 #include "content/common/device_sensors/device_orientation_hardware_buffer.h"
31 template<typename T> struct DefaultSingletonTraits;
35 class DataFetcherImplTizen {
37 static DataFetcherImplTizen* GetInstance();
39 // Shared memory related methods.
40 bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer);
41 void StopFetchingDeviceMotionData();
43 bool StartFetchingDeviceOrientationData(
44 DeviceOrientationHardwareBuffer* buffer);
45 void StopFetchingDeviceOrientationData();
47 virtual bool Start(ConsumerType);
48 virtual void Stop(ConsumerType);
51 DataFetcherImplTizen();
52 virtual ~DataFetcherImplTizen();
53 static void onOrientationChanged(unsigned long long timestamp,
54 sensor_data_accuracy_e, float azimuth,
55 float pitch, float roll, void* userData);
56 static void onAccelerationChanged(unsigned long long timestamp,
57 sensor_data_accuracy_e, float x, float y,
58 float z, void* userData);
61 friend struct DefaultSingletonTraits<DataFetcherImplTizen>;
63 void SetOrientationBufferReadyStatus(bool ready);
65 DeviceMotionHardwareBuffer* device_motion_buffer_;
66 DeviceOrientationHardwareBuffer* device_orientation_buffer_;
67 blink::WebDeviceMotionData last_motion_data_;
68 bool has_last_motion_data_;
69 unsigned long long last_motion_timestamp_;
70 bool is_orientation_buffer_ready_;
72 base::Lock motion_buffer_lock_;
73 base::Lock orientation_buffer_lock_;
77 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplTizen);
80 } // namespace content
82 #endif // DATA_FETCHER_IMPL_TIZEN_H_