[M47_2526] Chromium upversion to m47_2526 branch
[platform/framework/web/chromium-efl.git] / tizen_src / chromium_impl / content / browser / device_sensors / data_fetcher_impl_tizen.h
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.
4
5 #ifndef DATA_FETCHER_IMPL_TIZEN_H_
6 #define DATA_FETCHER_IMPL_TIZEN_H_
7
8 #include <sensor/sensor.h>
9
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"
15
16 namespace base {
17 template<typename T> struct DefaultSingletonTraits;
18 }
19
20 namespace content {
21
22 class DataFetcherImplTizen {
23  public:
24   static DataFetcherImplTizen* GetInstance();
25
26   // Shared memory related methods.
27   bool StartFetchingDeviceMotionData(DeviceMotionHardwareBuffer* buffer);
28   void StopFetchingDeviceMotionData();
29
30   bool StartFetchingDeviceOrientationData(
31       DeviceOrientationHardwareBuffer* buffer);
32   void StopFetchingDeviceOrientationData();
33
34   virtual bool Start(ConsumerType);
35   virtual void Stop(ConsumerType);
36
37  protected:
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);
42
43  private:
44   friend struct base::DefaultSingletonTraits<DataFetcherImplTizen>;
45
46   void SetOrientationBufferReadyStatus(bool ready);
47
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_;
54
55   base::Lock motion_buffer_lock_;
56   base::Lock orientation_buffer_lock_;
57
58   DISALLOW_COPY_AND_ASSIGN(DataFetcherImplTizen);
59 };
60
61 } // namespace content
62
63 #endif  // DATA_FETCHER_IMPL_TIZEN_H_