Re-enable index-basics-workers test to see if still times
[chromium-blink-merge.git] / content / browser / device_orientation / data_fetcher_impl_win.h
blob9a065066a31f0d5a9e81b2a63f846d51acd8b49c
1 // Copyright (c) 2013 The Chromium Authors. 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 CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_
6 #define CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_
8 #include <SensorsApi.h>
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/synchronization/lock.h"
13 #include "base/win/scoped_comptr.h"
14 #include "content/browser/device_orientation/data_fetcher.h"
15 #include "content/browser/device_orientation/device_data.h"
17 namespace content {
19 class Orientation;
21 // Windows implementation of DeviceOrientation API.
22 // The SensorEventSink is installed to Windows sensor thread to listen for
23 // sensor's data. Upon each notification, DataFetcherImplWin buffers the data.
24 // Then Chrome sensor polling thread pulls the buffered data via GetDeviceData.
25 // The Inclinometer 3D sensor (SENSOR_TYPE_INCLINOMETER_3D) is used to get the
26 // orientation data.
28 class DataFetcherImplWin : public DataFetcher {
29 public:
30 virtual ~DataFetcherImplWin();
32 // Factory function. It returns NULL on error.
33 // The created object listens for events for the whole lifetime.
34 static DataFetcher* Create();
36 // Implement DataFetcher.
37 virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE;
39 private:
40 class SensorEventSink;
41 friend SensorEventSink;
43 DataFetcherImplWin();
44 bool Initialize();
45 void OnOrientationData(Orientation* orientation);
46 const Orientation* GetOrientation();
48 base::win::ScopedComPtr<ISensor> sensor_;
50 // Value returned by GetDeviceData.
51 scoped_refptr<Orientation> current_orientation_;
53 // The 1-element buffer follows DataFetcherImplAndroid implementation.
54 // It is written by OnOrientationData and read by GetDeviceData.
55 base::Lock next_orientation_lock_;
56 scoped_refptr<Orientation> next_orientation_;
58 DISALLOW_COPY_AND_ASSIGN(DataFetcherImplWin);
61 } // namespace content
63 #endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_