Chromium Code Reviews| Index: content/browser/device_orientation/data_fetcher_impl_win.h |
| diff --git a/content/browser/device_orientation/data_fetcher_impl_win.h b/content/browser/device_orientation/data_fetcher_impl_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d08d84bd7b3bd28b0ce410a964c7a694e93244b8 |
| --- /dev/null |
| +++ b/content/browser/device_orientation/data_fetcher_impl_win.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_ |
| +#define CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_ |
| + |
| +#include <SensorsApi.h> |
|
Peter Beverloo
2013/04/09 15:34:15
Is SensorsApi.h available in anything pre-Windows
sail
2013/04/09 15:36:53
We build against the Windows8 SDK.
Linking is OK s
|
| + |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/synchronization/lock.h" |
| +#include "base/win/scoped_comptr.h" |
| +#include "content/browser/device_orientation/data_fetcher.h" |
| +#include "content/browser/device_orientation/device_data.h" |
| + |
| +namespace content { |
| + |
| +class Orientation; |
| + |
| +// Windows implementation of DeviceOrientation API. |
| +// The SensorEventSink is installed to Windows sensor thread to listen for |
| +// sensor's data. Upon each notification, DataFetcherImplWin buffers the data. |
| +// Then Chrome sensor polling thread pulls the buffered data via GetDeviceData. |
| +// The Inclinometer 3D sensor (SENSOR_TYPE_INCLINOMETER_3D) is used to get the |
| +// orientation data. |
| + |
| +class DataFetcherImplWin : public DataFetcher { |
| + public: |
| + // Factory function. We'll listen for events for the lifetime of this object. |
|
sail
2013/04/09 14:59:14
Shouldn't use "we" in comments.
nhu
2013/04/09 18:13:16
Done.
|
| + // Returns NULL on error. |
| + static DataFetcher* Create(); |
| + |
| + // Implement DataFetcher. |
| + virtual const DeviceData* GetDeviceData(DeviceData::Type type) OVERRIDE; |
| + |
| + virtual ~DataFetcherImplWin(); |
| + |
| + private: |
| + class SensorEventSink; |
| + friend SensorEventSink; |
| + |
| + DataFetcherImplWin(); |
| + bool Init(); |
| + void OnOrientationData(bool can_provide_alpha, double alpha, |
| + bool can_provide_beta, double beta, |
| + bool can_provide_gamma, double gamma); |
| + const Orientation* GetOrientation(); |
| + |
| + base::win::ScopedComPtr<ISensor> sensor_; |
| + |
| + // The data buffer, written by OnOrientationData, read by GetDeviceData. |
| + base::Lock last_orientation_lock_; |
| + scoped_refptr<Orientation> last_orientation_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_DEVICE_ORIENTATION_DATA_FETCHER_IMPL_WIN_H_ |
| + |