1 // Copyright 2014 Samsung Electronics. 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 DATA_FETCHER_IMPL_TIZEN_H_
6 #define DATA_FETCHER_IMPL_TIZEN_H_
8 #include <sensor/sensor.h>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/synchronization/lock.h"
12 #include "content/browser/device_sensors/inertial_sensor_consts.h"
13 #include "content/common/device_sensors/device_motion_hardware_buffer.h"
14 #include "content/common/device_sensors/device_orientation_hardware_buffer.h"
17 template<typename T> struct DefaultSingletonTraits;
22 class DataFetcherImplTizen {
24 static DataFetcherImplTizen* GetInstance();
26 // Shared memory related methods.
27 bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer);
28 void StopFetchingDeviceMotionData();
30 bool StartFetchingDeviceOrientationData(
31 DeviceOrientationHardwareBuffer* buffer);
32 void StopFetchingDeviceOrientationData();
34 virtual bool Start(ConsumerType);
35 virtual void Stop(ConsumerType);
38 DataFetcherImplTizen();
39 virtual ~DataFetcherImplTizen();
40 static void onOrientationChanged(sensor_h sensor, sensor_event_s *event, void* userData);
41 static void onAccelerationChanged(sensor_h sensor, sensor_event_s *event, void* userData);
44 friend struct base::DefaultSingletonTraits<DataFetcherImplTizen>;
46 void SetOrientationBufferReadyStatus(bool ready);
48 DeviceMotionHardwareBuffer* device_motion_buffer_;
49 DeviceOrientationHardwareBuffer* device_orientation_buffer_;
50 blink::WebDeviceMotionData last_motion_data_;
51 bool has_last_motion_data_;
52 unsigned long long last_motion_timestamp_;
53 bool is_orientation_buffer_ready_;
55 base::Lock motion_buffer_lock_;
56 base::Lock orientation_buffer_lock_;
58 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplTizen);
61 } // namespace content
63 #endif // DATA_FETCHER_IMPL_TIZEN_H_